Class AdjacencyListsGraph<V extends Vertex,​E extends Edge<V>>

  • Type Parameters:
    V - vertex type
    E - edge type
    All Implemented Interfaces:
    Graph<V,​E>
    Direct Known Subclasses:
    DefaultTopologyGraph

    public class AdjacencyListsGraph<V extends Vertex,​E extends Edge<V>>
    extends java.lang.Object
    implements Graph<V,​E>
    Immutable graph implemented using adjacency lists.
    • Constructor Summary

      Constructors 
      Constructor Description
      AdjacencyListsGraph​(java.util.Set<V> vertexes, java.util.Set<E> edges)
      Creates a graph comprising of the specified vertexes and edges.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.util.Set<E> getEdges()
      Returns the set of edges comprising the graph.
      java.util.Set<E> getEdgesFrom​(V src)
      Returns all edges leading out from the specified source vertex.
      java.util.Set<E> getEdgesTo​(V dst)
      Returns all edges leading towards the specified destination vertex.
      java.util.Set<V> getVertexes()
      Returns the set of vertexes comprising the graph.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AdjacencyListsGraph

        public AdjacencyListsGraph​(java.util.Set<V> vertexes,
                                   java.util.Set<E> edges)
        Creates a graph comprising of the specified vertexes and edges.
        Parameters:
        vertexes - set of graph vertexes
        edges - set of graph edges
    • Method Detail

      • getVertexes

        public java.util.Set<V> getVertexes()
        Description copied from interface: Graph
        Returns the set of vertexes comprising the graph.
        Specified by:
        getVertexes in interface Graph<V extends Vertex,​E extends Edge<V>>
        Returns:
        set of vertexes
      • getEdges

        public java.util.Set<E> getEdges()
        Description copied from interface: Graph
        Returns the set of edges comprising the graph.
        Specified by:
        getEdges in interface Graph<V extends Vertex,​E extends Edge<V>>
        Returns:
        set of edges
      • getEdgesFrom

        public java.util.Set<E> getEdgesFrom​(V src)
        Description copied from interface: Graph
        Returns all edges leading out from the specified source vertex.
        Specified by:
        getEdgesFrom in interface Graph<V extends Vertex,​E extends Edge<V>>
        Parameters:
        src - source vertex
        Returns:
        set of egress edges; empty if no such edges
      • getEdgesTo

        public java.util.Set<E> getEdgesTo​(V dst)
        Description copied from interface: Graph
        Returns all edges leading towards the specified destination vertex.
        Specified by:
        getEdgesTo in interface Graph<V extends Vertex,​E extends Edge<V>>
        Parameters:
        dst - destination vertex
        Returns:
        set of ingress vertexes; empty if no such edges
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object