All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bitplan.rythm.graphvizTree.rythm Maven / Gradle / Ivy

The newest version!
@// Rythm template
@import com.bitplan.simplegraph.core.SimpleNode
@import org.apache.tinkerpop.gremlin.structure.Edge
@import org.apache.tinkerpop.gremlin.structure.Vertex
@import java.text.SimpleDateFormat
@import java.util.Date
@args() {
  SimpleNode start,
  String edge,
  String property,
  String idProperty,
  String urlPrefix,
  String graphname,
  String rankdir;
}
@// display a vertice in a graph in graphviz with an URL link based on the given urlprefix
@def verticeLine(Vertex vertex, String property,String idProperty,String urlprefix) {
@{
   String label=vertex.property(property).value().toString();
   String id=vertex.property(idProperty).value().toString();
   String url=urlprefix+id;
}"@id" [ label="@label" URL="@url"]
}
@// display an edge in a graph in graphviz
@def edgeLine(Edge edge, String idProperty) {
@{
  String in=(String) edge.inVertex().property(idProperty).value();
  String out=(String) edge.outVertex().property(idProperty).value();
  String label=edge.label();
}"@out" -> "@in" [ label="@label"]
}

@// prepare an Edge and vertice list from the given starting point since
@// the lambda approach is not so easily applied directly
@{
  List vertices=new ArrayList();
  start.g().V().has(idProperty).forEachRemaining(vertex -> {
    vertices.add(vertex);
  });
  List edges=new ArrayList();
  start.g().E().hasLabel(edge).forEachRemaining(edge->{
    	edges.add(edge);
  });
}
@{
 SimpleDateFormat isoDateFormat = new SimpleDateFormat(
      "yyyy-MM-dd HH:mm:ss");
 String now=isoDateFormat.format(new Date());
}


  digraph @graphname @("{")
    rankdir="@rankdir";
  @for(Vertex vertex:vertices) {
    @verticeLine(vertex,property,idProperty,urlPrefix)
  }
  @for(Edge edge:edges) {
    @edgeLine(edge,idProperty)
  }
  @("}")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy