common
Class ParentUpdateDGraph

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

public class ParentUpdateDGraph
extends AbstractDGraph
implements java.lang.Cloneable

Directed graph that is backed by an underlying DGraph, but represents changes to the set of nodes and to the parent sets of some existing nodes (and thus to the child sets of some nodes as well).


Field Summary
 
Fields inherited from interface common.DGraph
EMPTY_GRAPH
 
Constructor Summary
ParentUpdateDGraph(DGraph underlying)
          Creates a new ParentUpdateDGraph that represents no changes to the given underlying graph.
 
Method Summary
 void addEdge(java.lang.Object parent, java.lang.Object child)
          Throws an UnsupportedOperationException.
 boolean addNode(java.lang.Object v)
          Adds the given node to the graph with an empty parent set.
 void changeUnderlying()
          Changes the underlying graph so it is equal to this graph.
 void clearChanges()
           
 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 getNewlyBarrenNodes()
          Returns the set of nodes that are barren in this graph but are not barren nodes in the underlying 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)
          Removes the given node from the graph, along with all incident edges.
 void setParents(java.lang.Object v, java.util.Set newParents)
          Changes the parent set of the given node to equal the given set.
 
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

ParentUpdateDGraph

public ParentUpdateDGraph(DGraph underlying)
Creates a new ParentUpdateDGraph that represents no changes to the given underlying graph.

Method Detail

nodes

public java.util.Set nodes()
Description copied from interface: DGraph
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)
Adds the given node to the graph with an empty parent set. Does nothing if the node is already in the graph. If a node is removed and then added again, it gets an empty parent set (and an empty child set, since no node has this removed node as a parent anymore).

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)
Removes the given node from the graph, along with all incident edges.

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)
Changes the parent set of the given node to equal the given set. If any elements of newParents were not in the graph, this method adds them as nodes.

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

getNewlyBarrenNodes

public java.util.Set getNewlyBarrenNodes()
Returns the set of nodes that are barren in this graph but are not barren nodes in the underlying graph. A barren node is one with no children.


changeUnderlying

public void changeUnderlying()
Changes the underlying graph so it is equal to this graph.


clearChanges

public void clearChanges()

clone

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