Class AbstractGraph<R extends GraphNode<K,​V>,​K,​V>

  • All Implemented Interfaces:
    Graph<R,​K,​V>
    Direct Known Subclasses:
    DirectedGraph

    public abstract class AbstractGraph<R extends GraphNode<K,​V>,​K,​V>
    extends Object
    implements Graph<R,​K,​V>
    Author:
    Paul Pavlidis
    • Constructor Detail

      • AbstractGraph

        public AbstractGraph()
      • AbstractGraph

        public AbstractGraph​(Set<R> nodes)
        Create a new graph from a set of nodes. This allows us to easily make subtrees.
        Parameters:
        nodes - Set of AbstractGraphNodes.
    • Method Detail

      • addNode

        public abstract void addNode​(K key,
                                     V value)
        Specified by:
        addNode in interface Graph<R extends GraphNode<K,​V>,​K,​V>
      • addNode

        public abstract void addNode​(R node)
        Parameters:
        node - GraphNode
      • containsKey

        public abstract boolean containsKey​(K key)
        Specified by:
        containsKey in interface Graph<R extends GraphNode<K,​V>,​K,​V>
        Parameters:
        key - Object
        Returns:
        true if the graph contains an item referenced by key, false otherwise.
      • get

        public R get​(K key)
        Retrieve a node by key. To get the contents of a node use getNodeContents(key)
        Specified by:
        get in interface Graph<R extends GraphNode<K,​V>,​K,​V>
        Parameters:
        key - Object
        Returns:
        AbstractGraphNode referenced by the key.
        See Also:
        getNodeContents(Object)
      • getItems

        public abstract Map<K,​R> getItems()
        Returns:
        Map
      • getNodeContents

        public V getNodeContents​(K key)
        Retrieve the contents of a node by key.
        Specified by:
        getNodeContents in interface Graph<R extends GraphNode<K,​V>,​K,​V>
        Parameters:
        key - Object
        Returns:
        The object contained by a node, not the node itself.
        See Also:
        get(K)
      • unmarkAll

        public void unmarkAll()
        Reset the 'visited' marks of the graph to false.
        Specified by:
        unmarkAll in interface Graph<R extends GraphNode<K,​V>,​K,​V>