https://github.com/teverett/dot4j
A Java library for GraphViz DOT which enables both read and write of DOT files
https://github.com/teverett/dot4j
dot graphviz java
Last synced: about 1 year ago
JSON representation
A Java library for GraphViz DOT which enables both read and write of DOT files
- Host: GitHub
- URL: https://github.com/teverett/dot4j
- Owner: teverett
- License: bsd-3-clause
- Created: 2020-11-01T14:57:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-01T05:06:04.000Z (over 1 year ago)
- Last Synced: 2025-04-11T05:52:46.197Z (about 1 year ago)
- Topics: dot, graphviz, java
- Language: Java
- Homepage:
- Size: 176 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# DOT4J
A Java library for reading and writing [GraphViz](https://en.wikipedia.org/wiki/Graphviz) [DOT](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) files.
The DOT grammar is from [here](https://github.com/teverett/grammars-v4/tree/master/dot)
A formal description of DOT is available at [graphviz.org](https://graphviz.org/doc/info/lang.html)
# License
kGraphML is licensed under the 3-Clause BSD license.
# Maven Coordinates
```
com.khubla.dot4j
dot4j
1.2.0
jar
```
# Usage
Reading and writing of DOT files is done via [DOTMarshaller](https://github.com/teverett/dot4j/blob/master/src/main/java/com/khubla/dot4j/DOTMarshaller.java)
## Reading DOT
`Graph g = DOTMarshaller.importGraph(inputStream);`
## Writing DOT
```
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;
}
```