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

java.lang.Object
ubic.basecode.dataStructure.graph.AbstractGraph<R,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 Details

    • 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 Details

    • 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:
    • 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:
    • 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>