Documentation of 'edu.uci.ics.jung.io.GraphMLReader' Java class
GraphMLReader
edu.uci.ics.jung.io

Class GraphMLReader<G extends Hypergraph<V,E>,V,E>

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler


    public class GraphMLReader<G extends Hypergraph<V,E>,V,E>
    extends org.xml.sax.helpers.DefaultHandler
    Reads in data from a GraphML-formatted file and generates graphs based on that data. Currently supports the following parts of the GraphML specification:
    • graphs and hypergraphs
    • directed and undirected edges
    • graph, vertex, edge data
    • graph, vertex, edge descriptions and data descriptions
    • vertex and edge IDs
    Each of these is exposed via appropriate get methods. Does not currently support nested graphs or ports.

    Note that the user is responsible for supplying a graph Factory that can support the edge types in the supplied GraphML file. If the graph generated by the Factory is not compatible (for example: if the graph does not accept directed edges, and the GraphML file contains a directed edge) then the results are graph-implementation-dependent.

    See Also:
    "http://graphml.graphdrawing.org/specification.html"
    • Constructor Summary

      Constructors 
      Constructor and Description
      GraphMLReader()
      Creates a GraphMLReader instance that assigns the vertex and edge id strings to be the vertex and edge objects, as well as their IDs.
      GraphMLReader(com.google.common.base.Supplier<V> vertex_factory, com.google.common.base.Supplier<E> edge_factory)
      Creates a GraphMLReader instance with the specified vertex and edge factories.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void characters(char[] ch, int start, int length) 
      void endElement(java.lang.String uri, java.lang.String name, java.lang.String qName) 
      java.util.Map<E,java.lang.String> getEdgeDescriptions() 
      com.google.common.collect.BiMap<E,java.lang.String> getEdgeIDs()
      Returns a bidirectional map relating edges and IDs.
      java.util.Map<java.lang.String,GraphMLMetadata<E>> getEdgeMetadata() 
      java.util.Map<G,java.lang.String> getGraphDescriptions() 
      java.util.Map<java.lang.String,GraphMLMetadata<G>> getGraphMetadata() 
      java.util.Map<V,java.lang.String> getVertexDescriptions() 
      com.google.common.collect.BiMap<V,java.lang.String> getVertexIDs() 
      java.util.Map<java.lang.String,GraphMLMetadata<V>> getVertexMetadata() 
      void load(java.io.Reader reader, G g)
      Populates the specified graph with the data parsed from the reader.
      void load(java.lang.String filename, G g)
      Populates the specified graph with the data parsed from the specified file.
      java.util.List<G> loadMultiple(java.io.Reader reader, com.google.common.base.Supplier<G> graph_factory)
      Returns a list of the graphs parsed from the specified reader, as created by the specified Supplier.
      java.util.List<G> loadMultiple(java.lang.String filename, com.google.common.base.Supplier<G> graph_factory)
      Returns a list of the graphs parsed from the specified file, as created by the specified Supplier.
      void startElement(java.lang.String uri, java.lang.String name, java.lang.String qName, org.xml.sax.Attributes atts) 
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GraphMLReader

        public GraphMLReader(com.google.common.base.Supplier<V> vertex_factory,
                             com.google.common.base.Supplier<E> edge_factory)
                      throws javax.xml.parsers.ParserConfigurationException,
                             org.xml.sax.SAXException
        Creates a GraphMLReader instance with the specified vertex and edge factories.
        Parameters:
        vertex_factory - the vertex supplier to use to create vertex objects
        edge_factory - the edge supplier to use to create edge objects
        Throws:
        javax.xml.parsers.ParserConfigurationException - if a SAX parser cannot be constructed
        org.xml.sax.SAXException - if the SAX parser factory cannot be constructed
      • GraphMLReader

        public GraphMLReader()
                      throws javax.xml.parsers.ParserConfigurationException,
                             org.xml.sax.SAXException
        Creates a GraphMLReader instance that assigns the vertex and edge id strings to be the vertex and edge objects, as well as their IDs. Note that this requires that (a) each edge have a valid ID, which is not normally a requirement for edges in GraphML, and (b) that the vertex and edge types be assignment-compatible with String.
        Throws:
        javax.xml.parsers.ParserConfigurationException - if a SAX parser cannot be constructed
        org.xml.sax.SAXException - if the SAX parser factory cannot be constructed
    • Method Detail

      • loadMultiple

        public java.util.List<G> loadMultiple(java.io.Reader reader,
                                              com.google.common.base.Supplier<G> graph_factory)
                                       throws java.io.IOException
        Returns a list of the graphs parsed from the specified reader, as created by the specified Supplier.
        Parameters:
        reader - the source of the graph data in GraphML format
        graph_factory - used to build graph instances
        Returns:
        the graphs parsed from the specified reader
        Throws:
        java.io.IOException - if an error is encountered while parsing the graph
      • loadMultiple

        public java.util.List<G> loadMultiple(java.lang.String filename,
                                              com.google.common.base.Supplier<G> graph_factory)
                                       throws java.io.IOException
        Returns a list of the graphs parsed from the specified file, as created by the specified Supplier.
        Parameters:
        filename - the source of the graph data in GraphML format
        graph_factory - used to build graph instances
        Returns:
        the graphs parsed from the specified file
        Throws:
        java.io.IOException - if an error is encountered while parsing the graph
      • load

        public void load(java.io.Reader reader,
                         G g)
                  throws java.io.IOException
        Populates the specified graph with the data parsed from the reader.
        Parameters:
        reader - the source of the graph data in GraphML format
        g - the graph instance to populate
        Throws:
        java.io.IOException - if an error is encountered while parsing the graph
      • load

        public void load(java.lang.String filename,
                         G g)
                  throws java.io.IOException
        Populates the specified graph with the data parsed from the specified file.
        Parameters:
        filename - the source of the graph data in GraphML format
        g - the graph instance to populate
        Throws:
        java.io.IOException - if an error is encountered while parsing the graph
      • startElement

        public void startElement(java.lang.String uri,
                                 java.lang.String name,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes atts)
                          throws org.xml.sax.SAXNotSupportedException
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXNotSupportedException
      • characters

        public void characters(char[] ch,
                               int start,
                               int length)
                        throws org.xml.sax.SAXNotSupportedException
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXNotSupportedException
      • endElement

        public void endElement(java.lang.String uri,
                               java.lang.String name,
                               java.lang.String qName)
                        throws org.xml.sax.SAXNotSupportedException
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXNotSupportedException
      • getVertexIDs

        public com.google.common.collect.BiMap<V,java.lang.String> getVertexIDs()
        Returns:
        a bidirectional map relating vertices and IDs.
      • getEdgeIDs

        public com.google.common.collect.BiMap<E,java.lang.String> getEdgeIDs()
        Returns a bidirectional map relating edges and IDs. This is not guaranteed to always be populated (edge IDs are not required in GraphML files.
        Returns:
        a bidirectional map relating edges and IDs.
      • getGraphMetadata

        public java.util.Map<java.lang.String,GraphMLMetadata<G>> getGraphMetadata()
        Returns:
        a map from graph type name to type metadata
      • getVertexMetadata

        public java.util.Map<java.lang.String,GraphMLMetadata<V>> getVertexMetadata()
        Returns:
        a map from vertex type name to type metadata
      • getEdgeMetadata

        public java.util.Map<java.lang.String,GraphMLMetadata<E>> getEdgeMetadata()
        Returns:
        a map from edge type name to type metadata
      • getGraphDescriptions

        public java.util.Map<G,java.lang.String> getGraphDescriptions()
        Returns:
        a map from graphs to graph descriptions
      • getVertexDescriptions

        public java.util.Map<V,java.lang.String> getVertexDescriptions()
        Returns:
        a map from vertices to vertex descriptions
      • getEdgeDescriptions

        public java.util.Map<E,java.lang.String> getEdgeDescriptions()
        Returns:
        a map from edges to edge descriptions

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.