Package org.jgrapht.ext
Class GmlExporter<V,E>
java.lang.Object
org.jgrapht.ext.GmlExporter<V,E>
Exports a graph into a GML file (Graph Modelling Language).
For a description of the format see http://www.infosun.fmi.uni-passau.de/Graphlet/GML/.
The objects associated with vertices and edges are exported as labels
using their toString() implementation. See the setPrintLabels(Integer)
method. The default behavior is to export no label
information.
- Author:
- Dimitrios Michail
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new GmlExporter object with integer name providers for the vertex and edge IDs and null providers for the vertex and edge labels.GmlExporter
(VertexNameProvider<V> vertexIDProvider, VertexNameProvider<V> vertexLabelProvider, EdgeNameProvider<E> edgeIDProvider, EdgeNameProvider<E> edgeLabelProvider) Constructs a new GmlExporter object with the given ID and label providers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
export
(Writer output, DirectedGraph<V, E> g) Exports a directed graph into a plain text file in GML format.void
export
(Writer output, UndirectedGraph<V, E> g) Exports an undirected graph into a plain text file in GML format.Get whether to export the vertex and edge labels.void
Set whether to export the vertex and edge labels.
-
Field Details
-
PRINT_NO_LABELS
Option to export no vertex or edge labels. -
PRINT_EDGE_LABELS
Option to export only the edge labels. -
PRINT_EDGE_VERTEX_LABELS
Option to export both edge and vertex labels. -
PRINT_VERTEX_LABELS
Option to export only the vertex labels.
-
-
Constructor Details
-
GmlExporter
public GmlExporter()Creates a new GmlExporter object with integer name providers for the vertex and edge IDs and null providers for the vertex and edge labels. -
GmlExporter
public GmlExporter(VertexNameProvider<V> vertexIDProvider, VertexNameProvider<V> vertexLabelProvider, EdgeNameProvider<E> edgeIDProvider, EdgeNameProvider<E> edgeLabelProvider) Constructs a new GmlExporter object with the given ID and label providers.- Parameters:
vertexIDProvider
- for generating vertex IDs. Must not be null.vertexLabelProvider
- for generating vertex labels. If null, vertex labels will be generated using the toString() method of the vertex object.edgeIDProvider
- for generating vertex IDs. Must not be null.edgeLabelProvider
- for generating edge labels. If null, edge labels will be generated using the toString() method of the edge object.
-
-
Method Details
-
export
Exports an undirected graph into a plain text file in GML format.- Parameters:
output
- the writer to which the graph to be exportedg
- the undirected graph to be exported
-
export
Exports a directed graph into a plain text file in GML format.- Parameters:
output
- the writer to which the graph to be exportedg
- the directed graph to be exported
-
setPrintLabels
Set whether to export the vertex and edge labels. The default behavior is to export no vertex or edge labels.- Parameters:
i
- What labels to export. Valid options arePRINT_NO_LABELS
,PRINT_EDGE_LABELS
,PRINT_EDGE_VERTEX_LABELS
, andPRINT_VERTEX_LABELS
.- Throws:
IllegalArgumentException
- if a non-supported value is used- See Also:
-
getPrintLabels
Get whether to export the vertex and edge labels.- Returns:
- One of the
PRINT_NO_LABELS
,PRINT_EDGE_LABELS
,PRINT_EDGE_VERTEX_LABELS
, orPRINT_VERTEX_LABELS
.
-