Class DOTExporter<V,E>
java.lang.Object
org.jgrapht.nio.BaseExporter<V,E>
org.jgrapht.nio.dot.DOTExporter<V,E>
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
GraphExporter<V,E>
Exports a graph into a DOT file.
For a description of the format see http://en.wikipedia.org/wiki/DOT_language.
The user can adjust the behavior using the various providers.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault graph id used by the exporter.private static final StringFields inherited from class BaseExporter
edgeAttributeProvider, edgeIdProvider, graphAttributeProvider, graphIdProvider, vertexAttributeProvider, vertexIdProvider -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new DOTExporter object with an integer id provider.DOTExporter(Function<V, String> vertexIdProvider) Constructs a new DOTExporter object with the given id provider. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringcomputeConnector(Graph<V, E> graph) Compute the connectorprivate StringcomputeFooter(Graph<V, E> graph) Compute the footerprivate StringcomputeGraphId(Graph<V, E> graph) Get the id of the graph.private StringcomputeHeader(Graph<V, E> graph) Compute the headerprivate static StringescapeDoubleQuotes(String labelName) voidexportGraph(Graph<V, E> g, Writer writer) Exports a graph into a plain text file in DOT format.private StringgetVertexID(V v) Return a valid vertex ID (with respect to the .dot language definition as described in http://www.graphviz.org/doc/info/lang.htmlprivate voidrenderAttribute(PrintWriter out, String attrName, Attribute attribute) private voidrenderAttributes(PrintWriter out, Map<String, Attribute> attributes) Methods inherited from class BaseExporter
getEdgeAttribute, getEdgeAttributeProvider, getEdgeAttributes, getEdgeId, getEdgeIdProvider, getGraphAttribute, getGraphAttributeProvider, getGraphId, getGraphIdProvider, getVertexAttribute, getVertexAttributeProvider, getVertexAttributes, getVertexId, getVertexIdProvider, setEdgeAttributeProvider, setEdgeIdProvider, setGraphAttributeProvider, setGraphIdProvider, setVertexAttributeProvider, setVertexIdProviderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GraphExporter
exportGraph, exportGraph
-
Field Details
-
DEFAULT_GRAPH_ID
-
INDENT
- See Also:
-
validatedIds
-
-
Constructor Details
-
DOTExporter
public DOTExporter()Constructs a new DOTExporter object with an integer id provider. -
DOTExporter
-
-
Method Details
-
exportGraph
Exports a graph into a plain text file in DOT format.- Specified by:
exportGraphin interfaceGraphExporter<V,E> - Parameters:
g- the graph to be exportedwriter- the writer to which the graph to be exported
-
computeHeader
-
computeConnector
-
computeGraphId
-
renderAttributes
-
renderAttribute
-
escapeDoubleQuotes
-
getVertexID
Return a valid vertex ID (with respect to the .dot language definition as described in http://www.graphviz.org/doc/info/lang.htmlQuoted from above mentioned source: An ID is valid if it meets one of the following criteria:
- any string of alphabetic characters, underscores or digits, not beginning with a digit;
- a number [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? );
- any double-quoted string ("...") possibly containing escaped quotes (\");
- an HTML string (invalid input: '<'...>).
- Throws:
ExportException- if the givenvertexIDProviderdidn't generate a valid vertex ID.
-