common
Class DefaultDGraph

java.lang.Object
  extended by common.AbstractDGraph
      extended by common.DefaultDGraph
All Implemented Interfaces:
DGraph, java.lang.Cloneable

public class DefaultDGraph
extends AbstractDGraph
implements java.lang.Cloneable

Default implementation of the DGraph interface. Represents both the parent set and the child set for each node (even though this is redundant) so both kinds of sets can be accessed quickly.


Field Summary
 
Fields inherited from interface common.DGraph
EMPTY_GRAPH
 
Constructor Summary
DefaultDGraph()
          Creates a new, empty graph.
 
Method Summary
 void addEdge(java.lang.Object parent, java.lang.Object child)
          Throws an UnsupportedOperationException.
 boolean addNode(java.lang.Object v)
          Throws an UnsupportedOperationException.
 java.lang.Object clone()
           
 java.util.Set getChildren(java.lang.Object v)
          Returns an unmodifiable set consisting of the given object's children, or null if the object is not in the graph.
 java.util.Set getParents(java.lang.Object v)
          Returns an unmodifiable set consisting of the given object's parents, or null if the object is not in the graph.
 java.util.Set nodes()
          Returns an unmodifiable set consisting of the nodes in this graph.
 void removeEdge(java.lang.Object parent, java.lang.Object child)
          Throws an UnsupportedOperationException.
 boolean removeNode(java.lang.Object v)
          Throws an UnsupportedOperationException.
 void setParents(java.lang.Object v, java.util.Set newParents)
          Implements setParents in terms of addEdge and removeEdge.
 
Methods inherited from class common.AbstractDGraph
getAncestors, getDescendants, getRoots, print
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDGraph

public DefaultDGraph()
Creates a new, empty graph.

Method Detail

nodes

public java.util.Set nodes()
Returns an unmodifiable set consisting of the nodes in this graph.

Specified by:
nodes in interface DGraph

addNode

public boolean addNode(java.lang.Object v)
Description copied from class: AbstractDGraph
Throws an UnsupportedOperationException.

Specified by:
addNode in interface DGraph
Overrides:
addNode in class AbstractDGraph
Returns:
true if the node was actually added; false if it was already in the graph

removeNode

public boolean removeNode(java.lang.Object v)
Description copied from class: AbstractDGraph
Throws an UnsupportedOperationException.

Specified by:
removeNode in interface DGraph
Overrides:
removeNode in class AbstractDGraph
Returns:
true if the node was actually removed; false if it was not in the graph

addEdge

public void addEdge(java.lang.Object parent,
                    java.lang.Object child)
Description copied from class: AbstractDGraph
Throws an UnsupportedOperationException.

Specified by:
addEdge in interface DGraph
Overrides:
addEdge in class AbstractDGraph

removeEdge

public void removeEdge(java.lang.Object parent,
                       java.lang.Object child)
Description copied from class: AbstractDGraph
Throws an UnsupportedOperationException.

Specified by:
removeEdge in interface DGraph
Overrides:
removeEdge in class AbstractDGraph

getParents

public java.util.Set getParents(java.lang.Object v)
Description copied from interface: DGraph
Returns an unmodifiable set consisting of the given object's parents, or null if the object is not in the graph.

Specified by:
getParents in interface DGraph

setParents

public void setParents(java.lang.Object v,
                       java.util.Set newParents)
Description copied from class: AbstractDGraph
Implements setParents in terms of addEdge and removeEdge.

Specified by:
setParents in interface DGraph
Overrides:
setParents in class AbstractDGraph

getChildren

public java.util.Set getChildren(java.lang.Object v)
Description copied from interface: DGraph
Returns an unmodifiable set consisting of the given object's children, or null if the object is not in the graph.

Specified by:
getChildren in interface DGraph

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object