Class GraphMLImporter<V,E>
- java.lang.Object
-
- org.jgrapht.io.GraphMLImporter<V,E>
-
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
GraphImporter<V,E>
@Deprecated public class GraphMLImporter<V,E> extends Object implements GraphImporter<V,E>
Deprecated.UseGraphMLImporter
insteadImports a graph from a GraphML data source.For a description of the format see http://en.wikipedia.org/wiki/ GraphML or the GraphML Primer.
Below is small example of a graph in GraphML format.
<?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> <key id="d0" for="node" attr.name="color" attr.type="string"> <default>yellow</default> </key> <key id="d1" for="edge" attr.name="weight" attr.type="double"/> <graph id="G" edgedefault="undirected"> <node id="n0"> <data key="d0">green</data> </node> <node id="n1"/> <node id="n2"> <data key="d0">blue</data> </node> <node id="n3"> <data key="d0">red</data> </node> <node id="n4"/> <node id="n5"> <data key="d0">turquoise</data> </node> <edge id="e0" source="n0" target="n2"> <data key="d1">1.0</data> </edge> <edge id="e1" source="n0" target="n1"> <data key="d1">1.0</data> </edge> <edge id="e2" source="n1" target="n3"> <data key="d1">2.0</data> </edge> <edge id="e3" source="n3" target="n2"/> <edge id="e4" source="n2" target="n4"/> <edge id="e5" source="n3" target="n5"/> <edge id="e6" source="n5" target="n4"> <data key="d1">1.1</data> </edge> </graph> </graphml>
The importer reads the input into a graph which is provided by the user. In case the graph is weighted and the corresponding edge key with attr.name="weight" is defined, the importer also reads edge weights. Otherwise edge weights are ignored. To test whether the graph is weighted, method
Graph.getType()
can be used.GraphML-Attributes Values are read as string key-value pairs and passed on to the
VertexProvider
andEdgeProvider
respectively.The provided graph object, where the imported graph will be stored, must be able to support the features of the graph that is read. For example if the GraphML file contains self-loops then the graph provided must also support self-loops. The same for multiple edges. Moreover, the parser completely ignores the attribute "edgedefault" which denotes whether an edge is directed or not. Whether edges are directed or not depends on the underlying implementation of the user provided graph object.
The importer by default validates the input using the 1.0 GraphML Schema. The user can (not recommended) disable the validation by calling
setSchemaValidation(boolean)
.- Author:
- Dimitrios Michail
-
-
Field Summary
Fields Modifier and Type Field Description protected EdgeProvider<V,E>
edgeProvider
Deprecated.Constructs new edgesprotected ComponentUpdater<Graph<V,E>>
graphUpdater
Deprecated.Updates graph propertiesprotected VertexProvider<V>
vertexProvider
Deprecated.Constructs new verticesprotected ComponentUpdater<V>
vertexUpdater
Deprecated.Updates already constructed vertices
-
Constructor Summary
Constructors Constructor Description GraphMLImporter(VertexProvider<V> vertexProvider, EdgeProvider<V,E> edgeProvider)
Deprecated.Constructs a new importer.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description EdgeProvider<V,E>
getEdgeProvider()
Deprecated.Get the edge providerString
getEdgeWeightAttributeName()
Deprecated.Get the attribute name for edge weightsComponentUpdater<Graph<V,E>>
getGraphUpdater()
Deprecated.Get the graph updater.VertexProvider<V>
getVertexProvider()
Deprecated.Get the vertex providerComponentUpdater<V>
getVertexUpdater()
Deprecated.Get the vertex updatervoid
importGraph(Graph<V,E> graph, Reader input)
Deprecated.Import a graph.boolean
isSchemaValidation()
Deprecated.Whether the importer validates the inputvoid
setEdgeProvider(EdgeProvider<V,E> edgeProvider)
Deprecated.Set the edge provider.void
setEdgeWeightAttributeName(String edgeWeightAttributeName)
Deprecated.Set the attribute name to use for edge weights.void
setGraphUpdater(ComponentUpdater<Graph<V,E>> graphUpdater)
Deprecated.Set the graph updater.void
setSchemaValidation(boolean schemaValidation)
Deprecated.Set whether the importer should validate the inputvoid
setVertexProvider(VertexProvider<V> vertexProvider)
Deprecated.Set the vertex providervoid
setVertexUpdater(ComponentUpdater<V> vertexUpdater)
Deprecated.Set the vertex updater.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.io.GraphImporter
importGraph, importGraph
-
-
-
-
Field Detail
-
vertexProvider
protected VertexProvider<V> vertexProvider
Deprecated.Constructs new vertices
-
edgeProvider
protected EdgeProvider<V,E> edgeProvider
Deprecated.Constructs new edges
-
vertexUpdater
protected ComponentUpdater<V> vertexUpdater
Deprecated.Updates already constructed vertices
-
graphUpdater
protected ComponentUpdater<Graph<V,E>> graphUpdater
Deprecated.Updates graph properties
-
-
Constructor Detail
-
GraphMLImporter
public GraphMLImporter(VertexProvider<V> vertexProvider, EdgeProvider<V,E> edgeProvider)
Deprecated.Constructs a new importer.- Parameters:
vertexProvider
- provider for the generation of vertices. Must not be null.edgeProvider
- provider for the generation of edges. Must not be null.
-
-
Method Detail
-
getEdgeWeightAttributeName
public String getEdgeWeightAttributeName()
Deprecated.Get the attribute name for edge weights- Returns:
- the attribute name
-
setEdgeWeightAttributeName
public void setEdgeWeightAttributeName(String edgeWeightAttributeName)
Deprecated.Set the attribute name to use for edge weights.- Parameters:
edgeWeightAttributeName
- the attribute name
-
isSchemaValidation
public boolean isSchemaValidation()
Deprecated.Whether the importer validates the input- Returns:
- true if the importer validates the input
-
setSchemaValidation
public void setSchemaValidation(boolean schemaValidation)
Deprecated.Set whether the importer should validate the input- Parameters:
schemaValidation
- value for schema validation
-
importGraph
public void importGraph(Graph<V,E> graph, Reader input) throws ImportException
Deprecated.Import a graph.The provided graph must be able to support the features of the graph that is read. For example if the GraphML file contains self-loops then the graph provided must also support self-loops. The same for multiple edges.
If the provided graph is a weighted graph, the importer also reads edge weights.
GraphML-Attributes Values are read as string key-value pairs and passed on to the
VertexProvider
andEdgeProvider
respectively.- Specified by:
importGraph
in interfaceGraphImporter<V,E>
- Parameters:
graph
- the output graphinput
- the input reader- Throws:
ImportException
- in case an error occurs, such as I/O or parse error
-
getVertexProvider
public VertexProvider<V> getVertexProvider()
Deprecated.Get the vertex provider- Returns:
- the vertex provider
-
setVertexProvider
public void setVertexProvider(VertexProvider<V> vertexProvider)
Deprecated.Set the vertex provider- Parameters:
vertexProvider
- the new vertex provider. Must not be null.
-
getEdgeProvider
public EdgeProvider<V,E> getEdgeProvider()
Deprecated.Get the edge provider- Returns:
- The edge provider
-
setEdgeProvider
public void setEdgeProvider(EdgeProvider<V,E> edgeProvider)
Deprecated.Set the edge provider.- Parameters:
edgeProvider
- the new edge provider. Must not be null.
-
getVertexUpdater
public ComponentUpdater<V> getVertexUpdater()
Deprecated.Get the vertex updater- Returns:
- the vertex updater
-
setVertexUpdater
public void setVertexUpdater(ComponentUpdater<V> vertexUpdater)
Deprecated.Set the vertex updater.- Parameters:
vertexUpdater
- the new vertex updater. Must not be null.
-
getGraphUpdater
public ComponentUpdater<Graph<V,E>> getGraphUpdater()
Deprecated.Get the graph updater.- Returns:
- the graph updater
-
setGraphUpdater
public void setGraphUpdater(ComponentUpdater<Graph<V,E>> graphUpdater)
Deprecated.Set the graph updater.- Parameters:
graphUpdater
- the new graph updater. Must not be null.
-
-