- java.lang.Object
-
- org.jgrapht.nio.BaseExporter<V,E>
-
- org.jgrapht.nio.gml.GmlExporter<V,E>
-
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
GraphExporter<V,E>
public class GmlExporter<V,E> extends BaseExporter<V,E> implements GraphExporter<V,E>
Exports a graph into a GML file (Graph Modeling Language).For a description of the format see https://github.com/GunterMueller/UNI_PASSAU_FMI_Graph_Drawing/blob/master/GML/gml-technical-report.pdf.
The behavior of the exporter such as whether to print vertex labels, edge labels, and/or edge weights can be adjusted using the
setParametermethod. When exporting labels, the exporter escapes them as Java strings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGmlExporter.ParameterParameters that affect the behavior of theGmlExporterexporter.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCREATORprivate static java.lang.StringDELIMprivate static java.util.Set<java.lang.String>FORBIDDEN_EDGE_CUSTOM_ATTRIBUTE_KEYSprivate static java.util.Set<java.lang.String>FORBIDDEN_VERTEX_CUSTOM_ATTRIBUTE_KEYSprivate static java.lang.StringLABEL_ATTRIBUTE_KEYprivate java.util.Set<GmlExporter.Parameter>parametersprivate static java.lang.StringTAB1private static java.lang.StringTAB2private static java.lang.StringVERSIONprivate static java.lang.StringWEIGHT_ATTRIBUTE_KEY-
Fields inherited from class org.jgrapht.nio.BaseExporter
edgeAttributeProvider, edgeIdProvider, graphAttributeProvider, graphIdProvider, vertexAttributeProvider, vertexIdProvider
-
-
Constructor Summary
Constructors Constructor Description GmlExporter()Creates a new GmlExporter object with integer id providers for the vertex identifiers.GmlExporter(java.util.function.Function<V,java.lang.String> vertexIdProvider)Constructs a new GmlExporter object with the given id providers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidexportAttribute(java.io.PrintWriter out, java.lang.String key, Attribute attribute)private voidexportEdges(java.io.PrintWriter out, Graph<V,E> g)voidexportGraph(Graph<V,E> g, java.io.Writer writer)Exports an graph into a plain text GML format.private voidexportHeader(java.io.PrintWriter out)private voidexportVertices(java.io.PrintWriter out, Graph<V,E> g)booleanisParameter(GmlExporter.Parameter p)Return if a particular parameter of the exporter is enabledprivate java.lang.Stringquoted(java.lang.String s)voidsetParameter(GmlExporter.Parameter p, boolean value)Set the value of a parameter of the exporter-
Methods inherited from class org.jgrapht.nio.BaseExporter
getEdgeAttribute, getEdgeAttributeProvider, getEdgeAttributes, getEdgeId, getEdgeIdProvider, getGraphAttribute, getGraphAttributeProvider, getGraphId, getGraphIdProvider, getVertexAttribute, getVertexAttributeProvider, getVertexAttributes, getVertexId, getVertexIdProvider, setEdgeAttributeProvider, setEdgeIdProvider, setGraphAttributeProvider, setGraphIdProvider, setVertexAttributeProvider, setVertexIdProvider
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.nio.GraphExporter
exportGraph, exportGraph
-
-
-
-
Field Detail
-
CREATOR
private static final java.lang.String CREATOR
- See Also:
- Constant Field Values
-
VERSION
private static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
DELIM
private static final java.lang.String DELIM
- See Also:
- Constant Field Values
-
TAB1
private static final java.lang.String TAB1
- See Also:
- Constant Field Values
-
TAB2
private static final java.lang.String TAB2
- See Also:
- Constant Field Values
-
LABEL_ATTRIBUTE_KEY
private static final java.lang.String LABEL_ATTRIBUTE_KEY
- See Also:
- Constant Field Values
-
WEIGHT_ATTRIBUTE_KEY
private static final java.lang.String WEIGHT_ATTRIBUTE_KEY
- See Also:
- Constant Field Values
-
FORBIDDEN_VERTEX_CUSTOM_ATTRIBUTE_KEYS
private static final java.util.Set<java.lang.String> FORBIDDEN_VERTEX_CUSTOM_ATTRIBUTE_KEYS
-
FORBIDDEN_EDGE_CUSTOM_ATTRIBUTE_KEYS
private static final java.util.Set<java.lang.String> FORBIDDEN_EDGE_CUSTOM_ATTRIBUTE_KEYS
-
parameters
private final java.util.Set<GmlExporter.Parameter> parameters
-
-
Constructor Detail
-
GmlExporter
public GmlExporter()
Creates a new GmlExporter object with integer id providers for the vertex identifiers.
-
GmlExporter
public GmlExporter(java.util.function.Function<V,java.lang.String> vertexIdProvider)
Constructs a new GmlExporter object with the given id providers.- Parameters:
vertexIdProvider- for generating vertex IDs. Must not be null.
-
-
Method Detail
-
exportGraph
public void exportGraph(Graph<V,E> g, java.io.Writer writer)
Exports an graph into a plain text GML format.- Specified by:
exportGraphin interfaceGraphExporter<V,E>- Parameters:
writer- the writerg- the graph
-
isParameter
public boolean isParameter(GmlExporter.Parameter p)
Return if a particular parameter of the exporter is enabled- Parameters:
p- the parameter- Returns:
trueif the parameter is set,falseotherwise
-
setParameter
public void setParameter(GmlExporter.Parameter p, boolean value)
Set the value of a parameter of the exporter- Parameters:
p- the parametervalue- the value to set
-
quoted
private java.lang.String quoted(java.lang.String s)
-
exportHeader
private void exportHeader(java.io.PrintWriter out)
-
exportAttribute
private void exportAttribute(java.io.PrintWriter out, java.lang.String key, Attribute attribute)
-
-