Package edu.uci.ics.jung.io
Class GraphMLWriter<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.io.GraphMLWriter<V,E>
-
public class GraphMLWriter<V,E> extends java.lang.ObjectWrites 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
Fields Modifier and Type Field Description protected booleandirectedprotected java.util.Map<java.lang.String,GraphMLMetadata<E>>edge_dataprotected com.google.common.base.Function<? super E,java.lang.String>edge_descprotected com.google.common.base.Function<? super E,java.lang.String>edge_idsprotected java.util.Map<java.lang.String,GraphMLMetadata<Hypergraph<V,E>>>graph_dataprotected com.google.common.base.Function<? super Hypergraph<V,E>,java.lang.String>graph_descprotected intnest_levelprotected java.util.Map<java.lang.String,GraphMLMetadata<V>>vertex_dataprotected com.google.common.base.Function<? super V,java.lang.String>vertex_descprotected com.google.common.base.Function<? super V,java.lang.String>vertex_ids
-
Constructor Summary
Constructors Constructor Description GraphMLWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEdgeData(java.lang.String id, java.lang.String description, java.lang.String default_value, com.google.common.base.Function<E,java.lang.String> edge_transformer)Adds a new edge data specification.voidaddGraphData(java.lang.String id, java.lang.String description, java.lang.String default_value, com.google.common.base.Function<Hypergraph<V,E>,java.lang.String> graph_transformer)Adds a new graph data specification.voidaddVertexData(java.lang.String id, java.lang.String description, java.lang.String default_value, com.google.common.base.Function<V,java.lang.String> vertex_transformer)Adds a new vertex data specification.protected java.lang.Stringformat(java.lang.String type, java.lang.String attr, java.lang.String value, java.lang.String contents)voidsave(Hypergraph<V,E> graph, java.io.Writer w)Writesgraphout usingw.voidsetEdgeData(java.util.Map<java.lang.String,GraphMLMetadata<E>> edge_map)Provides a map from data type name to edge data.voidsetEdgeDescriptions(com.google.common.base.Function<E,java.lang.String> edge_desc)Provides edge descriptions.voidsetEdgeIDs(com.google.common.base.Function<E,java.lang.String> edge_ids)Provides an ID that will be used to identify an edge in the output file.voidsetGraphData(java.util.Map<java.lang.String,GraphMLMetadata<Hypergraph<V,E>>> graph_map)Provides a map from data type name to graph data.voidsetGraphDescriptions(com.google.common.base.Function<Hypergraph<V,E>,java.lang.String> graph_desc)Provides graph descriptions.voidsetVertexData(java.util.Map<java.lang.String,GraphMLMetadata<V>> vertex_map)Provides a map from data type name to vertex data.voidsetVertexDescriptions(com.google.common.base.Function<V,java.lang.String> vertex_desc)Provides vertex descriptions.voidsetVertexIDs(com.google.common.base.Function<V,java.lang.String> vertex_ids)Provides an ID that will be used to identify a vertex in the output file.protected voidwriteEdgeData(Hypergraph<V,E> g, java.io.Writer w)protected voidwriteIndentedText(java.io.BufferedWriter w, java.lang.String to_write)protected voidwriteKeySpecification(java.lang.String key, java.lang.String type, GraphMLMetadata<?> ds, java.io.BufferedWriter bw)protected voidwriteVertexData(Hypergraph<V,E> graph, java.io.BufferedWriter w)
-
-
-
Field Detail
-
vertex_ids
protected com.google.common.base.Function<? super V,java.lang.String> vertex_ids
-
edge_ids
protected com.google.common.base.Function<? super E,java.lang.String> edge_ids
-
graph_data
protected java.util.Map<java.lang.String,GraphMLMetadata<Hypergraph<V,E>>> graph_data
-
vertex_data
protected java.util.Map<java.lang.String,GraphMLMetadata<V>> vertex_data
-
edge_data
protected java.util.Map<java.lang.String,GraphMLMetadata<E>> edge_data
-
vertex_desc
protected com.google.common.base.Function<? super V,java.lang.String> vertex_desc
-
edge_desc
protected com.google.common.base.Function<? super E,java.lang.String> edge_desc
-
graph_desc
protected com.google.common.base.Function<? super Hypergraph<V,E>,java.lang.String> graph_desc
-
directed
protected boolean directed
-
nest_level
protected int nest_level
-
-
Method Detail
-
save
public void save(Hypergraph<V,E> graph, java.io.Writer w) throws java.io.IOException
Writesgraphout usingw.- Parameters:
graph- the graph to write outw- the writer instance to which the graph data will be written out- Throws:
java.io.IOException- if writing the graph fails
-
writeIndentedText
protected void writeIndentedText(java.io.BufferedWriter w, java.lang.String to_write) throws java.io.IOException- Throws:
java.io.IOException
-
writeVertexData
protected void writeVertexData(Hypergraph<V,E> graph, java.io.BufferedWriter w) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEdgeData
protected void writeEdgeData(Hypergraph<V,E> g, java.io.Writer w) throws java.io.IOException
- Throws:
java.io.IOException
-
writeKeySpecification
protected void writeKeySpecification(java.lang.String key, java.lang.String type, GraphMLMetadata<?> ds, java.io.BufferedWriter bw) throws java.io.IOException- Throws:
java.io.IOException
-
format
protected java.lang.String format(java.lang.String type, java.lang.String attr, java.lang.String value, java.lang.String contents)
-
setVertexIDs
public void setVertexIDs(com.google.common.base.Function<V,java.lang.String> vertex_ids)
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
public void setEdgeIDs(com.google.common.base.Function<E,java.lang.String> edge_ids)
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
public void setGraphData(java.util.Map<java.lang.String,GraphMLMetadata<Hypergraph<V,E>>> graph_map)
Provides a map from data type name to graph data.- Parameters:
graph_map- map from data type name to graph data
-
setVertexData
public void setVertexData(java.util.Map<java.lang.String,GraphMLMetadata<V>> vertex_map)
Provides a map from data type name to vertex data.- Parameters:
vertex_map- map from data type name to vertex data
-
setEdgeData
public void setEdgeData(java.util.Map<java.lang.String,GraphMLMetadata<E>> edge_map)
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(java.lang.String id, java.lang.String description, java.lang.String default_value, com.google.common.base.Function<Hypergraph<V,E>,java.lang.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(java.lang.String id, java.lang.String description, java.lang.String default_value, com.google.common.base.Function<V,java.lang.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(java.lang.String id, java.lang.String description, java.lang.String default_value, com.google.common.base.Function<E,java.lang.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
public void setVertexDescriptions(com.google.common.base.Function<V,java.lang.String> vertex_desc)
Provides vertex descriptions.- Parameters:
vertex_desc- a mapping from vertices to their descriptions
-
setEdgeDescriptions
public void setEdgeDescriptions(com.google.common.base.Function<E,java.lang.String> edge_desc)
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>,java.lang.String> graph_desc)
Provides graph descriptions.- Parameters:
graph_desc- a mapping from graphs to their descriptions
-
-