Class MultidirectedMultiGraph

  • All Implemented Interfaces:
    edu.uci.ics.jung.graph.Graph, edu.uci.ics.jung.graph.Hypergraph, java.io.Serializable

    public class MultidirectedMultiGraph
    extends edu.uci.ics.jung.graph.SparseGraph
    implements edu.uci.ics.jung.graph.Graph, java.io.Serializable
    Implementation of an Graph that can be used as a simple or a multi graph with directed and undirected edges.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int INCIDENT
      Indicates incident (undirected) edges in the map
      protected static int INCOMING
      Indicates incoming edges in the map
      protected java.util.Map mdirected_edges
      Map of directed edges to incident vertex sets
      protected java.util.Map mundirected_edges
      Map of undirected edges to incident vertex sets
      protected java.util.Map mvertex_maps
      Map of vertices to adjacency maps of vertices to {incoming, outgoing, incident} edges
      protected static int OUTGOING
      Indicates outgoing edges in the map
      • Fields inherited from class edu.uci.ics.jung.graph.SparseGraph

        directed_edges, undirected_edges, vertex_maps
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addEdge​(java.lang.Object edge, edu.uci.ics.jung.graph.util.Pair endpoints)
      Adds a directed edge to the graph.
      boolean addEdge​(java.lang.Object edge, edu.uci.ics.jung.graph.util.Pair endpoints, edu.uci.ics.jung.graph.util.EdgeType edgeType)
      Adds a edge to the graph with a specific edge type.
      boolean addEdge​(java.lang.Object e, java.lang.Object v1, java.lang.Object v2)
      Adds a directed edge to the graph.
      boolean addEdge​(java.lang.Object e, java.lang.Object v1, java.lang.Object v2, edu.uci.ics.jung.graph.util.EdgeType edgeType)
      Adds a edge to the graph with a specific edge type.
      boolean addVertex​(java.lang.Object vertex)
      Adds a vertex to the graph.
      boolean containsEdge​(java.lang.Object edge)
      Returns true if the graph contains the edge.
      boolean containsVertex​(java.lang.Object vertex)
      Returns true if the graph contains the vertex.
      static edu.uci.ics.jung.graph.Graph create()
      Returns a new MultidirectedMultiGraph.
      int degree​(java.lang.Object vertex)
      Returns the degree (number of incident edges) of a vertex.
      java.lang.Object findEdge​(java.lang.Object v1, java.lang.Object v2)
      Returns the first edge between the two vertices.
      java.util.Collection findEdgeSet​(java.lang.Object v1, java.lang.Object v2)
      Returns a collection of edges between the two vertices.
      java.lang.Object getDest​(java.lang.Object directed_edge)
      Returns the destination of a directed edge.
      int getEdgeCount()  
      java.util.Collection getEdges()
      Returns all edges of the graph.
      java.util.Collection getEdges​(edu.uci.ics.jung.graph.util.EdgeType edgeType)
      Returns the edges for a given edge type.
      edu.uci.ics.jung.graph.util.EdgeType getEdgeType​(java.lang.Object edge)
      Returns the edge type of en edge.
      edu.uci.ics.jung.graph.util.Pair getEndpoints​(java.lang.Object edge)
      Returns the endpoints of the edge.
      static org.apache.commons.collections15.Factory getFactory()
      Returns the factory for the graph.
      protected java.util.Collection getIncident_internal​(java.lang.Object vertex)
      Returns the incident edges of the vertex
      java.util.Collection getIncidentEdges​(java.lang.Object vertex)
      Returns the incident edges of the vertex.
      protected java.util.Collection getIncoming_internal​(java.lang.Object vertex)
      Returns the incoming edges of the vertex
      java.util.Collection getInEdges​(java.lang.Object vertex)
      Returns the incoming edges of the vertex.
      java.util.Collection getNeighbors​(java.lang.Object vertex)
      Returns the neighbor vertices of a given vertex.
      java.util.Collection getOutEdges​(java.lang.Object vertex)
      Returns the outgoing edges of the vertex.
      protected java.util.Collection getOutgoing_internal​(java.lang.Object vertex)
      Returns the outgoing edges of the vertex
      java.util.Collection getPredecessors​(java.lang.Object vertex)
      Returns the vertices that have an outgoing edge to the given vertex.
      java.lang.Object getSource​(java.lang.Object directed_edge)
      Returns the source of a directed edge.
      java.util.Collection getSuccessors​(java.lang.Object vertex)
      Returns the vertices that have an incoming edge from the given vertex.
      int getVertexCount()  
      java.util.Collection getVertices()
      Returns all vertices of the graph.
      boolean isDest​(java.lang.Object vertex, java.lang.Object edge)
      Returns true if the vertex is the destination of the edge.
      boolean isSource​(java.lang.Object vertex, java.lang.Object edge)
      Returns true if the vertex is the source of the edge.
      boolean removeEdge​(java.lang.Object edge)
      Removes a edge from the graph.
      boolean removeVertex​(java.lang.Object vertex)
      Removes a vertex from the graph.
      • Methods inherited from class edu.uci.ics.jung.graph.SparseGraph

        getDefaultEdgeType, getEdgeCount
      • Methods inherited from class edu.uci.ics.jung.graph.AbstractGraph

        addEdge, addEdge, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface edu.uci.ics.jung.graph.Graph

        getOpposite, getPredecessorCount, getSuccessorCount, inDegree, isPredecessor, isSuccessor, outDegree
      • Methods inherited from interface edu.uci.ics.jung.graph.Hypergraph

        addEdge, addEdge, getDefaultEdgeType, getEdgeCount, getIncidentCount, getIncidentVertices, getNeighborCount, isIncident, isNeighbor
    • Field Detail

      • INCOMING

        protected static final int INCOMING
        Indicates incoming edges in the map
        See Also:
        Constant Field Values
      • OUTGOING

        protected static final int OUTGOING
        Indicates outgoing edges in the map
        See Also:
        Constant Field Values
      • INCIDENT

        protected static final int INCIDENT
        Indicates incident (undirected) edges in the map
        See Also:
        Constant Field Values
      • mvertex_maps

        protected java.util.Map mvertex_maps
        Map of vertices to adjacency maps of vertices to {incoming, outgoing, incident} edges
      • mdirected_edges

        protected java.util.Map mdirected_edges
        Map of directed edges to incident vertex sets
      • mundirected_edges

        protected java.util.Map mundirected_edges
        Map of undirected edges to incident vertex sets
    • Constructor Detail

      • MultidirectedMultiGraph

        public MultidirectedMultiGraph()
        Creates a new graph.
    • Method Detail

      • getFactory

        public static org.apache.commons.collections15.Factory getFactory()
        Returns the factory for the graph.
        Returns:
        The Factory for the graph..
      • create

        public static edu.uci.ics.jung.graph.Graph create()
        Returns a new MultidirectedMultiGraph.
        Returns:
        The MultidirectedMultiGraph.
      • addEdge

        public boolean addEdge​(java.lang.Object edge,
                               edu.uci.ics.jung.graph.util.Pair endpoints)
        Adds a directed edge to the graph.
        Overrides:
        addEdge in class edu.uci.ics.jung.graph.AbstractGraph
        Parameters:
        edge - The edge.
        endpoints - The endpoints.
        Returns:
        true if success.
      • addEdge

        public boolean addEdge​(java.lang.Object edge,
                               edu.uci.ics.jung.graph.util.Pair endpoints,
                               edu.uci.ics.jung.graph.util.EdgeType edgeType)
        Adds a edge to the graph with a specific edge type.
        Overrides:
        addEdge in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        edge - The edge.
        endpoints - The endpoints.
        edgeType - The edge type.
        Returns:
        true if success.
      • addEdge

        public boolean addEdge​(java.lang.Object e,
                               java.lang.Object v1,
                               java.lang.Object v2)
        Adds a directed edge to the graph.
        Specified by:
        addEdge in interface edu.uci.ics.jung.graph.Graph
        Overrides:
        addEdge in class edu.uci.ics.jung.graph.AbstractGraph
        Parameters:
        edge - The edge.
        v1 - The first vertex.
        v2 - The second vertex.
        Returns:
        true if success.
      • addEdge

        public boolean addEdge​(java.lang.Object e,
                               java.lang.Object v1,
                               java.lang.Object v2,
                               edu.uci.ics.jung.graph.util.EdgeType edgeType)
        Adds a edge to the graph with a specific edge type.
        Specified by:
        addEdge in interface edu.uci.ics.jung.graph.Graph
        Overrides:
        addEdge in class edu.uci.ics.jung.graph.AbstractGraph
        Parameters:
        edge - The edge.
        v1 - The first vertex.
        v2 - The second vertex..
        edgeType - The edge type.
        Returns:
        true if success.
      • findEdge

        public java.lang.Object findEdge​(java.lang.Object v1,
                                         java.lang.Object v2)
        Returns the first edge between the two vertices.
        Specified by:
        findEdge in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        findEdge in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        v1 - The first vertex.
        v2 - The second vertex.
        Returns:
        The edge or null if there is no incident edge between the vertices.
      • findEdgeSet

        public java.util.Collection findEdgeSet​(java.lang.Object v1,
                                                java.lang.Object v2)
        Returns a collection of edges between the two vertices.
        Specified by:
        findEdgeSet in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        findEdgeSet in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        v1 - The first vertex.
        v2 - The second vertex.
        Returns:
        The collection of edges or null if there is no incident edge between the vertices.
      • getInEdges

        public java.util.Collection getInEdges​(java.lang.Object vertex)
        Returns the incoming edges of the vertex.
        Specified by:
        getInEdges in interface edu.uci.ics.jung.graph.Graph
        Specified by:
        getInEdges in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getInEdges in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertx
        Returns:
        The collection of edges.
      • getOutEdges

        public java.util.Collection getOutEdges​(java.lang.Object vertex)
        Returns the outgoing edges of the vertex.
        Specified by:
        getOutEdges in interface edu.uci.ics.jung.graph.Graph
        Specified by:
        getOutEdges in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getOutEdges in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertx
        Returns:
        The collection of edges.
      • getPredecessors

        public java.util.Collection getPredecessors​(java.lang.Object vertex)
        Returns the vertices that have an outgoing edge to the given vertex.
        Specified by:
        getPredecessors in interface edu.uci.ics.jung.graph.Graph
        Specified by:
        getPredecessors in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getPredecessors in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        Returns:
        The collection of vertices.
      • getSuccessors

        public java.util.Collection getSuccessors​(java.lang.Object vertex)
        Returns the vertices that have an incoming edge from the given vertex.
        Specified by:
        getSuccessors in interface edu.uci.ics.jung.graph.Graph
        Specified by:
        getSuccessors in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getSuccessors in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        Returns:
        The collection of vertices.
      • getEdges

        public java.util.Collection getEdges​(edu.uci.ics.jung.graph.util.EdgeType edgeType)
        Returns the edges for a given edge type.
        Specified by:
        getEdges in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getEdges in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        edgeType - The edge tzpe.
        Returns:
        The collection of edges.
      • getEndpoints

        public edu.uci.ics.jung.graph.util.Pair getEndpoints​(java.lang.Object edge)
        Returns the endpoints of the edge.
        Specified by:
        getEndpoints in interface edu.uci.ics.jung.graph.Graph
        Overrides:
        getEndpoints in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        edge - The edge.
        Returns:
        The endpoints.
      • getEdgeType

        public edu.uci.ics.jung.graph.util.EdgeType getEdgeType​(java.lang.Object edge)
        Returns the edge type of en edge.
        Specified by:
        getEdgeType in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getEdgeType in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        edge - The edge.
        Returns:
        The edge type.
      • getSource

        public java.lang.Object getSource​(java.lang.Object directed_edge)
        Returns the source of a directed edge.
        Specified by:
        getSource in interface edu.uci.ics.jung.graph.Graph
        Specified by:
        getSource in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getSource in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        directed_edge - The edge.
        Returns:
        The vertex.
      • getDest

        public java.lang.Object getDest​(java.lang.Object directed_edge)
        Returns the destination of a directed edge.
        Specified by:
        getDest in interface edu.uci.ics.jung.graph.Graph
        Specified by:
        getDest in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getDest in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        directed_edge - The edge.
        Returns:
        The vertex.
      • isSource

        public boolean isSource​(java.lang.Object vertex,
                                java.lang.Object edge)
        Returns true if the vertex is the source of the edge.
        Specified by:
        isSource in interface edu.uci.ics.jung.graph.Graph
        Overrides:
        isSource in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        edge - The edge.
        Returns:
        true if the vertex is the source.
      • isDest

        public boolean isDest​(java.lang.Object vertex,
                              java.lang.Object edge)
        Returns true if the vertex is the destination of the edge.
        Specified by:
        isDest in interface edu.uci.ics.jung.graph.Graph
        Overrides:
        isDest in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        edge - The edge.
        Returns:
        true if the vertex is the destination.
      • getEdges

        public java.util.Collection getEdges()
        Returns all edges of the graph.
        Specified by:
        getEdges in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getEdges in class edu.uci.ics.jung.graph.SparseGraph
        Returns:
        The collection of edges.
      • getVertices

        public java.util.Collection getVertices()
        Returns all vertices of the graph.
        Specified by:
        getVertices in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getVertices in class edu.uci.ics.jung.graph.SparseGraph
        Returns:
        The collection of vertices.
      • containsVertex

        public boolean containsVertex​(java.lang.Object vertex)
        Returns true if the graph contains the vertex.
        Specified by:
        containsVertex in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        containsVertex in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        Returns:
        true if the vertex is in the graph.
      • containsEdge

        public boolean containsEdge​(java.lang.Object edge)
        Returns true if the graph contains the edge.
        Specified by:
        containsEdge in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        containsEdge in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        edge - The edge.
        Returns:
        true if the edge is in the graph.
      • getEdgeCount

        public int getEdgeCount()
        Specified by:
        getEdgeCount in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getEdgeCount in class edu.uci.ics.jung.graph.SparseGraph
        Returns:
        The edge count.
      • getVertexCount

        public int getVertexCount()
        Specified by:
        getVertexCount in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getVertexCount in class edu.uci.ics.jung.graph.SparseGraph
        Returns:
        The vertex count.
      • getNeighbors

        public java.util.Collection getNeighbors​(java.lang.Object vertex)
        Returns the neighbor vertices of a given vertex.
        Specified by:
        getNeighbors in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getNeighbors in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        Returns:
        The collection of neighbors.
      • degree

        public int degree​(java.lang.Object vertex)
        Returns the degree (number of incident edges) of a vertex.
        Specified by:
        degree in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        degree in class edu.uci.ics.jung.graph.AbstractGraph
        Parameters:
        vertex - The vertex.
        Returns:
        The degree.
      • getIncidentEdges

        public java.util.Collection getIncidentEdges​(java.lang.Object vertex)
        Returns the incident edges of the vertex.
        Specified by:
        getIncidentEdges in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        getIncidentEdges in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        Returns:
        The collection of edges.
      • addVertex

        public boolean addVertex​(java.lang.Object vertex)
        Adds a vertex to the graph.
        Specified by:
        addVertex in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        addVertex in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        Returns:
        true if success.
      • removeVertex

        public boolean removeVertex​(java.lang.Object vertex)
        Removes a vertex from the graph.
        Specified by:
        removeVertex in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        removeVertex in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        vertex - The vertex.
        Returns:
        true if success
      • removeEdge

        public boolean removeEdge​(java.lang.Object edge)
        Removes a edge from the graph.
        Specified by:
        removeEdge in interface edu.uci.ics.jung.graph.Hypergraph
        Overrides:
        removeEdge in class edu.uci.ics.jung.graph.SparseGraph
        Parameters:
        edge - The edge.
        Returns:
        true if success
      • getIncoming_internal

        protected java.util.Collection getIncoming_internal​(java.lang.Object vertex)
        Returns the incoming edges of the vertex
        Parameters:
        vertex - The vertex.
        Returns:
        The collection of edges.
      • getIncident_internal

        protected java.util.Collection getIncident_internal​(java.lang.Object vertex)
        Returns the incident edges of the vertex
        Parameters:
        vertex - The vertex.
        Returns:
        The collection of edges.
      • getOutgoing_internal

        protected java.util.Collection getOutgoing_internal​(java.lang.Object vertex)
        Returns the outgoing edges of the vertex
        Parameters:
        vertex - The vertex.
        Returns:
        The collection of edges.