Class GraphMLWriter<V,​E>


  • public class GraphMLWriter<V,​E>
    extends java.lang.Object
    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

      Fields 
      Modifier and Type Field Description
      protected boolean directed  
      protected java.util.Map<java.lang.String,​GraphMLMetadata<E>> edge_data  
      protected org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_desc  
      protected org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_ids  
      protected java.util.Map<java.lang.String,​GraphMLMetadata<edu.uci.ics.jung.graph.Hypergraph<V,​E>>> graph_data  
      protected org.apache.commons.collections4.Transformer<edu.uci.ics.jung.graph.Hypergraph<V,​E>,​java.lang.String> graph_desc  
      protected int nest_level  
      protected java.util.Map<java.lang.String,​GraphMLMetadata<V>> vertex_data  
      protected org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_desc  
      protected org.apache.commons.collections4.Transformer<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
      void addEdgeData​(java.lang.String id, java.lang.String description, java.lang.String default_value, org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_transformer)
      Adds a new edge data specification.
      void addGraphData​(java.lang.String id, java.lang.String description, java.lang.String default_value, org.apache.commons.collections4.Transformer<edu.uci.ics.jung.graph.Hypergraph<V,​E>,​java.lang.String> graph_transformer)
      Adds a new graph data specification.
      void addVertexData​(java.lang.String id, java.lang.String description, java.lang.String default_value, org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_transformer)
      Adds a new vertex data specification.
      protected java.lang.String format​(java.lang.String type, java.lang.String attr, java.lang.String value, java.lang.String contents)  
      void save​(edu.uci.ics.jung.graph.Hypergraph<V,​E> graph, java.io.Writer w)  
      void setEdgeData​(java.util.Map<java.lang.String,​GraphMLMetadata<E>> edge_map)
      Provides a map from data type name to edge data.
      void setEdgeDescriptions​(org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_desc)
      Provides edge descriptions.
      void setEdgeIDs​(org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_ids)
      Provides an ID that will be used to identify an edge in the output file.
      void setGraphData​(java.util.Map<java.lang.String,​GraphMLMetadata<edu.uci.ics.jung.graph.Hypergraph<V,​E>>> graph_map)
      Provides a map from data type name to graph data.
      void setGraphDescriptions​(org.apache.commons.collections4.Transformer<edu.uci.ics.jung.graph.Hypergraph<V,​E>,​java.lang.String> graph_desc)
      Provides graph descriptions.
      void setVertexData​(java.util.Map<java.lang.String,​GraphMLMetadata<V>> vertex_map)
      Provides a map from data type name to vertex data.
      void setVertexDescriptions​(org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_desc)
      Provides vertex descriptions.
      void setVertexIDs​(org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_ids)
      Provides an ID that will be used to identify a vertex in the output file.
      protected void writeEdgeData​(edu.uci.ics.jung.graph.Hypergraph<V,​E> g, java.io.Writer w)  
      protected void writeIndentedText​(java.io.BufferedWriter w, java.lang.String to_write)  
      protected void writeKeySpecification​(java.lang.String key, java.lang.String type, GraphMLMetadata<?> ds, java.io.BufferedWriter bw)  
      protected void writeVertexData​(edu.uci.ics.jung.graph.Hypergraph<V,​E> graph, java.io.BufferedWriter w)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • vertex_ids

        protected org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_ids
      • edge_ids

        protected org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_ids
      • graph_data

        protected java.util.Map<java.lang.String,​GraphMLMetadata<edu.uci.ics.jung.graph.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 org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_desc
      • edge_desc

        protected org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_desc
      • graph_desc

        protected org.apache.commons.collections4.Transformer<edu.uci.ics.jung.graph.Hypergraph<V,​E>,​java.lang.String> graph_desc
      • directed

        protected boolean directed
      • nest_level

        protected int nest_level
    • Constructor Detail

      • GraphMLWriter

        public GraphMLWriter()
    • Method Detail

      • save

        public void save​(edu.uci.ics.jung.graph.Hypergraph<V,​E> graph,
                         java.io.Writer w)
                  throws java.io.IOException
        Parameters:
        graph -
        w -
        Throws:
        java.io.IOException
      • 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​(edu.uci.ics.jung.graph.Hypergraph<V,​E> graph,
                                       java.io.BufferedWriter w)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • writeEdgeData

        protected void writeEdgeData​(edu.uci.ics.jung.graph.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​(org.apache.commons.collections4.Transformer<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 of toString (and thus not guaranteed to be unique).
        Parameters:
        vertex_ids -
      • setEdgeIDs

        public void setEdgeIDs​(org.apache.commons.collections4.Transformer<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 -
      • setGraphData

        public void setGraphData​(java.util.Map<java.lang.String,​GraphMLMetadata<edu.uci.ics.jung.graph.Hypergraph<V,​E>>> graph_map)
        Provides a 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.
      • setEdgeData

        public void setEdgeData​(java.util.Map<java.lang.String,​GraphMLMetadata<E>> edge_map)
        Provides a 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,
                                 org.apache.commons.collections4.Transformer<edu.uci.ics.jung.graph.Hypergraph<V,​E>,​java.lang.String> graph_transformer)
        Adds a new graph data specification.
      • addVertexData

        public void addVertexData​(java.lang.String id,
                                  java.lang.String description,
                                  java.lang.String default_value,
                                  org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_transformer)
        Adds a new vertex data specification.
      • addEdgeData

        public void addEdgeData​(java.lang.String id,
                                java.lang.String description,
                                java.lang.String default_value,
                                org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_transformer)
        Adds a new edge data specification.
      • setVertexDescriptions

        public void setVertexDescriptions​(org.apache.commons.collections4.Transformer<V,​java.lang.String> vertex_desc)
        Provides vertex descriptions.
      • setEdgeDescriptions

        public void setEdgeDescriptions​(org.apache.commons.collections4.Transformer<E,​java.lang.String> edge_desc)
        Provides edge descriptions.
      • setGraphDescriptions

        public void setGraphDescriptions​(org.apache.commons.collections4.Transformer<edu.uci.ics.jung.graph.Hypergraph<V,​E>,​java.lang.String> graph_desc)
        Provides graph descriptions.