Package edu.uci.ics.jung.io
Class GraphMLWriter<V,E>
java.lang.Object
edu.uci.ics.jung.io.GraphMLWriter<V,E>
Writes graphs out in GraphML format.
Current known issues:
- Only supports one graph per output file.
- Does not indent lines for text-format readability.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected Map
<String, GraphMLMetadata<E>> protected Map
<String, GraphMLMetadata<Hypergraph<V, E>>> protected com.google.common.base.Function
<? super Hypergraph<V, E>, String> protected int
protected Map
<String, GraphMLMetadata<V>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEdgeData
(String id, String description, String default_value, com.google.common.base.Function<E, String> edge_transformer) Adds a new edge data specification.void
addGraphData
(String id, String description, String default_value, com.google.common.base.Function<Hypergraph<V, E>, String> graph_transformer) Adds a new graph data specification.void
addVertexData
(String id, String description, String default_value, com.google.common.base.Function<V, String> vertex_transformer) Adds a new vertex data specification.protected String
void
save
(Hypergraph<V, E> graph, Writer w) Writesgraph
out usingw
.void
setEdgeData
(Map<String, GraphMLMetadata<E>> edge_map) Provides a map from data type name to edge data.void
setEdgeDescriptions
(com.google.common.base.Function<E, String> edge_desc) Provides edge descriptions.void
setEdgeIDs
(com.google.common.base.Function<E, String> edge_ids) Provides an ID that will be used to identify an edge in the output file.void
setGraphData
(Map<String, GraphMLMetadata<Hypergraph<V, E>>> graph_map) Provides a map from data type name to graph data.void
setGraphDescriptions
(com.google.common.base.Function<Hypergraph<V, E>, String> graph_desc) Provides graph descriptions.void
setVertexData
(Map<String, GraphMLMetadata<V>> vertex_map) Provides a map from data type name to vertex data.void
setVertexDescriptions
(com.google.common.base.Function<V, String> vertex_desc) Provides vertex descriptions.void
setVertexIDs
(com.google.common.base.Function<V, String> vertex_ids) Provides an ID that will be used to identify a vertex in the output file.protected void
writeEdgeData
(Hypergraph<V, E> g, Writer w) protected void
writeIndentedText
(BufferedWriter w, String to_write) protected void
writeKeySpecification
(String key, String type, GraphMLMetadata<?> ds, BufferedWriter bw) protected void
writeVertexData
(Hypergraph<V, E> graph, BufferedWriter w)
-
Field Details
-
vertex_ids
-
edge_ids
-
graph_data
-
vertex_data
-
edge_data
-
vertex_desc
-
edge_desc
-
graph_desc
-
directed
protected boolean directed -
nest_level
protected int nest_level
-
-
Constructor Details
-
GraphMLWriter
public GraphMLWriter()
-
-
Method Details
-
save
Writesgraph
out usingw
.- Parameters:
graph
- the graph to write outw
- the writer instance to which the graph data will be written out- Throws:
IOException
- if writing the graph fails
-
writeIndentedText
- Throws:
IOException
-
writeVertexData
- Throws:
IOException
-
writeEdgeData
- Throws:
IOException
-
writeKeySpecification
protected void writeKeySpecification(String key, String type, GraphMLMetadata<?> ds, BufferedWriter bw) throws IOException - Throws:
IOException
-
format
-
setVertexIDs
Provides an ID that will be used to identify a vertex in the output file. If the vertex IDs are not set, the ID for each vertex will default to the output oftoString
(and thus not guaranteed to be unique).- Parameters:
vertex_ids
- a mapping from vertex to ID
-
setEdgeIDs
Provides an ID that will be used to identify an edge in the output file. If any edge ID is missing, no ID will be written out for the corresponding edge.- Parameters:
edge_ids
- a mapping from edge to ID
-
setGraphData
Provides a map from data type name to graph data.- Parameters:
graph_map
- map from data type name to graph data
-
setVertexData
Provides a map from data type name to vertex data.- Parameters:
vertex_map
- map from data type name to vertex data
-
setEdgeData
Provides a map from data type name to edge data.- Parameters:
edge_map
- map from data type name to edge data
-
addGraphData
public void addGraphData(String id, String description, String default_value, com.google.common.base.Function<Hypergraph<V, E>, String> graph_transformer) Adds a new graph data specification.- Parameters:
id
- the ID of the data to adddescription
- a description of the data to adddefault_value
- a default value for the data typegraph_transformer
- a mapping from graphs to their string representations
-
addVertexData
public void addVertexData(String id, String description, String default_value, com.google.common.base.Function<V, String> vertex_transformer) Adds a new vertex data specification.- Parameters:
id
- the ID of the data to adddescription
- a description of the data to adddefault_value
- a default value for the data typevertex_transformer
- a mapping from vertices to their string representations
-
addEdgeData
public void addEdgeData(String id, String description, String default_value, com.google.common.base.Function<E, String> edge_transformer) Adds a new edge data specification.- Parameters:
id
- the ID of the data to adddescription
- a description of the data to adddefault_value
- a default value for the data typeedge_transformer
- a mapping from edges to their string representations
-
setVertexDescriptions
Provides vertex descriptions.- Parameters:
vertex_desc
- a mapping from vertices to their descriptions
-
setEdgeDescriptions
Provides edge descriptions.- Parameters:
edge_desc
- a mapping from edges to their descriptions
-
setGraphDescriptions
public void setGraphDescriptions(com.google.common.base.Function<Hypergraph<V, E>, String> graph_desc) Provides graph descriptions.- Parameters:
graph_desc
- a mapping from graphs to their descriptions
-