A Java library for reading and writing GraphViz DOT files.
The DOT grammar is from here
A formal description of DOT is available at graphviz.org
kGraphML is licensed under the 3-Clause BSD license.
<groupId>com.khubla.dot4j</groupId>
<artifactId>dot4j</artifactId>
<version>1.2.0</version>
<packaging>jar</packaging>
Reading and writing of DOT files is done via DOTMarshaller
Graph g = DOTMarshaller.importGraph(inputStream);
Graph g = new Graph(false, GraphType.digraph, "mygraph");
Node n1 = new Node("n1");
g.addNode(n1);
Node n2 = new Node("node2");
g.addNode(n2);
Edge theEdge = new Edge("n1", "node2");
g.addEdge(theEdge);
DOTMarshaller.exportGraph(g, baos);
Creates:
digraph mygraph {
node2;
n1;
n1 -> node2;
}