Class AdjacencyMap


  • public class AdjacencyMap
    extends Object
    An AdjacencyMap is used to store the contents of a graph in memory in a format which can easily be interrogated.
    • Constructor Detail

      • AdjacencyMap

        public AdjacencyMap()
    • Method Detail

      • getEdges

        public Set<Edge> getEdges​(Object source,
                                  Object destination)
        Get the entries in the AdjacencyMap which match the provided source and destination vertices.
        Parameters:
        source - the source vertex
        destination - the destination vertex
        Returns:
        the Set of edge objects relating to the specified vertices
      • putEdges

        public Set<Edge> putEdges​(Object source,
                                  Object destination,
                                  Set<Edge> set)
        Add an entry to the AdjacencyMap.
        Parameters:
        source - the source vertex
        destination - the destination vertex
        set - the Set of edge objects to associate with the specified pair of vertices.
        Returns:
        the added edge objects
      • putEdge

        public Set<Edge> putEdge​(Object source,
                                 Object destination,
                                 Edge edge)
        Add an entry to the AdjacencyMap.
        Parameters:
        source - the source vertex
        destination - the destination vertex
        edge - the edge to add
        Returns:
        the Set containing the edge objects associated with the source and destination vertices
      • getDestinations

        public Set<Object> getDestinations​(Object source)
        Given a source vertex, get all of the vertices which can be reached from that source.
        Parameters:
        source - the source vertex
        Returns:
        a Set of the destination vertices
      • getSources

        public Set<Object> getSources​(Object destination)
        Given a destination vertex, get all of the vertices which are linked to that destination.
        Parameters:
        destination - the destination vertex
        Returns:
        a Set of the source vertices
      • getAllSources

        public Set<Object> getAllSources()
        Get a Set containing all of the source vertices in this AdjacencyMap.
        Returns:
        an immutable set containing the source vertices
      • getAllDestinations

        public Set<Object> getAllDestinations()
        Get a Set containing all of the destination vertices in this AdjacencyMap.
        Returns:
        an immutable set containing the destination vertices
      • removeAllWithDestination

        public void removeAllWithDestination​(Object destination)
        Given a vertex, remove all entries in the AdjacencyMap which have this vertex as a destination.
        Parameters:
        destination - the destination vertex
      • containsSource

        public boolean containsSource​(Object source)
        Determines whether this AdjacencyMap contains the specified source vertex.
        Parameters:
        source - the source vertex to query for
        Returns:
        true if the adjacency map contains the source, otherwise false
      • containsDestination

        public boolean containsDestination​(Object destination)
        Determines whether this AdjacencyMap contains the specified destination vertex.
        Parameters:
        destination - the source vertex to query for
        Returns:
        true if the adjacency map contains the destination, otherwise false
      • toStringFull

        public String toStringFull()