Skip to content

Instantly share code, notes, and snippets.

@eternnoir
Created March 9, 2017 02:54
Show Gist options
  • Save eternnoir/00308e322deca0096ce3c265b730f9bc to your computer and use it in GitHub Desktop.
Save eternnoir/00308e322deca0096ce3c265b730f9bc to your computer and use it in GitHub Desktop.
private void draw()
{
Graphviz gv = new Graphviz(); //Graphviz Object.
Graph graph = new Graph("g1", GraphType.DIGRAPH); //Create New Gpaph.
graph.addAttributes(new Attribute("rankdir","LR")); //Add some attribute.
Node n1 = new Node("N1"); //Create Node Object.
n1.addAttributes(new Attribute("label","\" Node1 \"")); //Add attribute
Node n2 = new Node("N2");
Node n3 = new Node("N3");
graph.addNode(n1); //Add node to graph.
graph.addNode(n2);
graph.addNode(n3);
graph.addEdge(new Edge(n1, n2)); //Add edge
graph.addEdge(new Edge(n2, n3));
graph.addEdge(new Edge(n3,n1));
String type = "png";
File out = new File(tmpPath+"/outEX1."+ type); //Output File.
this.writeGraphToFile( gv.getGraphByteArray(graph, type, "100"), out );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment