java.lang.Object
org.jhotdraw8.graph.io.GraphvizWriter
Writes a graph into a graphviz "dot" file.
Writes the following productions. Does not write subgraphs!
graph : digrap [ ID ] '{' stmt_list '}'
stmt_list : [ stmt [ ';' ] stmt_list ]
stmt : node_stmt
| edge_stmt
| attr_stmt
| ID '=' ID
| subgraph
attr_stmt : (graph | node | edge) attr_list
attr_list : '[' [ a_list ] ']' [ attr_list ]
a_list : ID '=' ID [ (';' | ',') ] [ a_list ]
edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
edgeRHS : edgeop (node_id | subgraph) [ edgeRHS ]
node_stmt : node_id [ attr_list ] * node_id : ID [ port ]
port : ':' ID [ ':' compass_pt ] * | ':' compass_pt
subgraph : [ subgraph [ ID ] ] '{' stmt_list '}'
compass_pt : (n | ne | e | se | s | sw | w | nw | c | _)
edgeop : -> | --
References:
- Graphviz. DOT Language.
- graphviz.org
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V,A> void write(@NonNull Appendable w, @NonNull DirectedGraph<V, A> graph) Dumps a directed graph into a String which can be rendered with the graphviz "dot" tool.<V,A> void write(@NonNull Appendable w, @NonNull DirectedGraph<V, A> graph, @NonNull Function<V, String> vertexToString) Dumps a directed graph into a String which can be rendered with the graphviz "dot" tool.<V,A> void write(@NonNull Appendable w, @NonNull DirectedGraph<V, A> graph, @NonNull Function<V, String> vertexToString, @Nullable Function<V, String> vertexAttributes, @Nullable Function<A, String> arrowAttributes, @Nullable String graphId) Dumps a directed graph into a String which can be rendered with the graphviz "dot" tool.<V,A> String write(@NonNull DirectedGraph<V, A> graph) Dumps the graph graph into a String which can be rendered with the graphviz "dot" tool.<V,A> String write(@NonNull DirectedGraph<V, A> graph, @NonNull Function<V, String> vertexToString, @NonNull Function<V, String> vertexAttributes, @NonNull Function<A, String> arrowAttributes) Dumps a directed graph into a String which can be rendered with the graphviz "dot" tool.
-
Constructor Details
-
GraphvizWriter
public GraphvizWriter()Creates a new instance.
-
-
Method Details
-
write
public <V,A> void write(@NonNull Appendable w, @NonNull DirectedGraph<V, A> graph) throws IOExceptionDumps a directed graph into a String which can be rendered with the graphviz "dot" tool.- Type Parameters:
V- the vertex data typeA- the arrow data type- Parameters:
w- the writergraph- the graph- Throws:
IOException- if writing fails
-
write
public <V,A> void write(@NonNull Appendable w, @NonNull DirectedGraph<V, A> graph, @NonNull Function<V, throws IOExceptionString> vertexToString) Dumps a directed graph into a String which can be rendered with the graphviz "dot" tool.- Type Parameters:
V- the vertex data typeA- the arrow data type- Parameters:
w- the writergraph- the graphvertexToString- a function that converts a vertex to a String for use as vertex name- Throws:
IOException- if writing fails
-
write
public <V,A> String write(@NonNull DirectedGraph<V, A> graph, @NonNull Function<V, String> vertexToString, @NonNull Function<V, String> vertexAttributes, @NonNull Function<A, String> arrowAttributes) Dumps a directed graph into a String which can be rendered with the graphviz "dot" tool.- Type Parameters:
V- the vertex data typeA- the arrow data type- Parameters:
graph- the graphvertexToString- a function that converts a vertex to a String for use as vertex namevertexAttributes- a function that converts a vertex to a String for use as vertex attributesarrowAttributes- a function that converts an arrow to a String for use as arrow attributes- Returns:
- the "dot" string
-
write
public <V,A> void write(@NonNull Appendable w, @NonNull DirectedGraph<V, A> graph, @NonNull Function<V, throws IOExceptionString> vertexToString, @Nullable Function<V, String> vertexAttributes, @Nullable Function<A, String> arrowAttributes, @Nullable String graphId) Dumps a directed graph into a String which can be rendered with the graphviz "dot" tool.- Type Parameters:
V- the vertex data typeA- the arrow data type- Parameters:
w- the writergraph- the graphvertexToString- a function that converts a vertex to a String for use as vertex namevertexAttributes- a function that converts a vertex to a String for use as vertex attributesarrowAttributes- a function that converts an arrow to a String for use as arrow attributesgraphId- the id of the graph- Throws:
IOException- if writing fails
-
write
Dumps the graph graph into a String which can be rendered with the graphviz "dot" tool.- Type Parameters:
V- the vertex data typeA- the arrow data type- Parameters:
graph- the graph to be dumped- Returns:
- the dump
-