java.lang.Object
org.jgrapht.nio.BaseExporter<V,E>
org.jgrapht.nio.gexf.GEXFExporter<V,E>
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
GraphExporter<V,E>
Exports a graph as GEXF (Graph Exchange XML Format).
For a description of the format see https://gephi.org/gexf/format/schema.html. A nice primer for the format is located at https://gephi.org/gexf/1.2draft/gexf-12draft-primer.pdf.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDenotes the category of a GEXF-Attribute.private classstatic enumParameters that affect the behavior of the exporter. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate Stringprivate Stringprivate static final Stringprivate final Set<GEXFExporter.Parameter> private Map<String, GEXFExporter<V, E>.AttributeDetails> private Map<String, GEXFExporter<V, E>.AttributeDetails> private intprivate intprivate static final Stringprivate static final StringFields inherited from class org.jgrapht.nio.BaseExporter
edgeAttributeProvider, edgeIdProvider, graphAttributeProvider, graphIdProvider, vertexAttributeProvider, vertexIdProvider -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new exporter with integer id providers for the vertices and the edges.Constructs a new exporter. -
Method Summary
Modifier and TypeMethodDescriptionvoidexportGraph(Graph<V, E> g, Writer writer) Exports a graph in GraphML format.Get the creator for the meta field.Get the description for the meta field.Get the keywords for the meta field.booleanReturn if a particular parameter of the exporter is enabledvoidregisterAttribute(String name, GEXFExporter.AttributeCategory category, GEXFAttributeType type) Register a GEXF AttributevoidregisterAttribute(String name, GEXFExporter.AttributeCategory category, GEXFAttributeType type, String defaultValue) Register a GEXF AttributevoidregisterAttribute(String name, GEXFExporter.AttributeCategory category, GEXFAttributeType type, String defaultValue, String options) Register a GEXF AttributevoidsetCreator(String creator) Set the creator for the meta field.voidsetDescription(String description) Set the description for the meta field.voidsetKeywords(String keywords) Set the keywords for the meta field.voidsetParameter(GEXFExporter.Parameter p, boolean value) Set the value of a parameter of the exportervoidunregisterAttribute(String name, GEXFExporter.AttributeCategory category) Unregister a GraphML-Attributeprivate voidwriteAttribute(TransformerHandler handler, String name, GEXFExporter<V, E>.AttributeDetails details) private voidwriteAttributeValue(TransformerHandler handler, String key, String value) private voidwriteEdgeAttributes(TransformerHandler handler) private voidwriteEdgeAttributeValues(TransformerHandler handler, E e) private voidwriteEdges(TransformerHandler handler, Graph<V, E> g) private voidwriteFooter(TransformerHandler handler) private voidwriteGraphEnd(TransformerHandler handler) private voidwriteGraphStart(TransformerHandler handler, Graph<V, E> g) private voidwriteHeader(TransformerHandler handler) private voidwriteMeta(TransformerHandler handler) private voidwriteVertexAttributes(TransformerHandler handler) private voidwriteVertexAttributeValues(TransformerHandler handler, V v) private voidwriteVertices(TransformerHandler handler, Graph<V, E> g) 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, setVertexIdProviderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jgrapht.nio.GraphExporter
exportGraph, exportGraph
-
Field Details
-
LABEL_ATTRIBUTE_NAME
- See Also:
-
WEIGHT_ATTRIBUTE_NAME
- See Also:
-
TYPE_ATTRIBUTE_NAME
- See Also:
-
VERTEX_RESERVED_ATTRIBUTES
-
EDGE_RESERVED_ATTRIBUTES
-
totalVertexAttributes
private int totalVertexAttributes -
registeredVertexAttributes
-
totalEdgeAttributes
private int totalEdgeAttributes -
registeredEdgeAttributes
-
parameters
-
creator
-
keywords
-
description
-
-
Constructor Details
-
GEXFExporter
public GEXFExporter()Constructs a new exporter with integer id providers for the vertices and the edges. -
GEXFExporter
Constructs a new exporter.- Parameters:
vertexIdProvider- for generating vertex identifiers. Must not be null.edgeIdProvider- for generating edge identifiers. Must not be null.
-
-
Method Details
-
isParameter
Return if a particular parameter of the exporter is enabled- Parameters:
p- the parameter- Returns:
trueif the parameter is set,falseotherwise
-
setParameter
Set the value of a parameter of the exporter- Parameters:
p- the parametervalue- the value to set
-
registerAttribute
public void registerAttribute(String name, GEXFExporter.AttributeCategory category, GEXFAttributeType type) Register a GEXF Attribute- Parameters:
name- the attribute namecategory- the attribute categorytype- the attribute type
-
registerAttribute
public void registerAttribute(String name, GEXFExporter.AttributeCategory category, GEXFAttributeType type, String defaultValue) Register a GEXF Attribute- Parameters:
name- the attribute namecategory- the attribute categorytype- the attribute typedefaultValue- default value
-
registerAttribute
public void registerAttribute(String name, GEXFExporter.AttributeCategory category, GEXFAttributeType type, String defaultValue, String options) Register a GEXF Attribute- Parameters:
name- the attribute namecategory- the attribute categorytype- the attribute typedefaultValue- default valueoptions- the possible options
-
unregisterAttribute
Unregister a GraphML-Attribute- Parameters:
name- the attribute namecategory- the attribute category
-
getCreator
Get the creator for the meta field.- Returns:
- the creator for the meta field
-
setCreator
Set the creator for the meta field.- Parameters:
creator- the creator for the meta field
-
getKeywords
Get the keywords for the meta field.- Returns:
- the keywords for the meta field
-
setKeywords
Set the keywords for the meta field.- Parameters:
keywords- the keywords for the meta field
-
getDescription
Get the description for the meta field.- Returns:
- the description for the meta field
-
setDescription
Set the description for the meta field.- Parameters:
description- the description for the meta field
-
exportGraph
Exports a graph in GraphML format.- Specified by:
exportGraphin interfaceGraphExporter<V,E> - Parameters:
g- the graphwriter- the writer to export the graph- Throws:
ExportException- in case any error occurs during export
-
writeHeader
- Throws:
SAXException
-
writeMeta
- Throws:
SAXException
-
writeGraphStart
- Throws:
SAXException
-
writeGraphEnd
- Throws:
SAXException
-
writeVertexAttributes
- Throws:
SAXException
-
writeEdgeAttributes
- Throws:
SAXException
-
writeAttribute
private void writeAttribute(TransformerHandler handler, String name, GEXFExporter<V, E>.AttributeDetails details) throws SAXException- Throws:
SAXException
-
writeVertexAttributeValues
- Throws:
SAXException
-
writeEdgeAttributeValues
- Throws:
SAXException
-
writeAttributeValue
private void writeAttributeValue(TransformerHandler handler, String key, String value) throws SAXException - Throws:
SAXException
-
writeVertices
- Throws:
SAXException
-
writeEdges
- Throws:
SAXException
-