net.walend.digraph.path
Class AbstractListCEPath

java.lang.Object
  |
  +--net.walend.digraph.path.AbstractListCEPath
All Implemented Interfaces:
CEDigraph, CEPath, Digraph, HasState, Path, java.io.Serializable
Direct Known Subclasses:
ListCEPath, MutableListCEPath

public abstract class AbstractListCEPath
extends java.lang.Object
implements CEPath, java.io.Serializable

This abstract class implements the CEPath interface using a List of nodes and a List of Edges. It implements all the methods in MutableCEPath as protected, for easy subclassing. By default, it uses ArrayLists, but one constructor allows you to supply the Lists.

Since:
20010922
Author:
David Walend dfw1@cornell.edu
See Also:
Serialized Form

Nested Class Summary
private  class AbstractListCEPath.EdgeCountToken
           
protected  class AbstractListCEPath.ListEdgeIterator
           
 
Field Summary
private static int DEFAULTCAPACITY
           
private  CEDigraph digraph
           
private  java.util.List edges
           
private  int modCount
           
private  java.util.List nodes
           
 
Fields inherited from interface net.walend.digraph.CEDigraph
EMPTY
 
Constructor Summary
protected AbstractListCEPath(CEDigraph digraph, java.util.List nodeList, java.util.List edgeList)
          Creates a new path on digraph that has only node in it, using nodeList and edgeList.
protected AbstractListCEPath(CEDigraph digraph, java.lang.Object node)
          Creates a new path on digraph that has only node in it with DEFAULTCAPACITY of 7.
protected AbstractListCEPath(CEDigraph digraph, java.lang.Object node, int nodeCapacity)
          Creates a new path on digraph that has only node in it, with a capacity nodeCapacity.
protected AbstractListCEPath(CEDigraph digraph, java.lang.Object node, java.util.List nodeList, java.util.List edgeList)
          Creates a new path on digraph that has only node in it, using nodeList and edgeList.
protected AbstractListCEPath(CEPath path)
          Create a new path that is a copy of path.
protected AbstractListCEPath(CEPath path, java.util.List nodeList, java.util.List edgeList)
          Create a new path that is a copy of path, using nodeList and edgeList.
 
Method Summary
protected  void addToHead(java.lang.Object node, java.lang.Object edge)
          Adds a node and edge to the beginning of the path.
protected  void addToTail(java.lang.Object edge, java.lang.Object node)
          Adds an edge and node to the end of the path.
private  void checkIndices(int startNodeIndex, int endNodeIndex)
           
private  void checkSubpathIndices(int startNodeIndex, int endNodeIndex, java.lang.Object startNode, java.lang.Object endNode)
           
protected  void checkValid()
          Throw an InvalidPathException if anything is wrong.
protected  void chopList(java.util.List victim, int fromIndex, int toIndex)
           
 boolean containsCEDigraph(CEDigraph digraph)
          Returns true if digraph is a subgraph of this CEDigraph.
 boolean containsEdge(java.lang.Object fromNode, java.lang.Object toNode)
          Returns true if the digraph contains any edge from fromNode to toNode
 boolean containsEdge(java.lang.Object fromNode, java.lang.Object toNode, java.lang.Object edge)
          Returns true if edge links fromNode to toNode
 boolean containsNode(java.lang.Object node)
           
 boolean containsNodes(java.util.Set nodes)
           
 int countInboundEdges(java.lang.Object node)
          This implementation takes linear time.
 int countOutboundEdges(java.lang.Object node)
          This implementation takes linear time.
 int edgeCount()
          This method is wildly inefficient.
 EdgeIterator edgeIterator()
          edgeIterator()'s remove() method throws an UnsupportedOperationException.
 EdgeNodeIterator edgeNodeIterator()
          Returns an iterator that iterates across pairs of nodes that make edges.
 java.lang.Object getEdge(java.lang.Object fromNode, java.lang.Object toNode)
          Returns null if no edge links fromNode to toNode.
 java.lang.Object getEdgeAtIndex(int index)
           
 java.util.List getEdgeList()
          Returns an immutable list of the edges.
 Bag getEdges()
           
 java.util.Set getFromNodes(java.lang.Object node)
          Returns the set of nodes that can reach this node by crossing one edge.
 java.lang.Object getHead()
           
 Bag getInboundEdges(java.lang.Object node)
          This implementation takes linear time.
 int getIndexOfEdge(java.lang.Object edge)
           
 int getIndexOfNode(java.lang.Object node)
           
 int getLastIndexOfEdge(java.lang.Object edge)
           
 int getLastIndexOfNode(java.lang.Object node)
           
 java.lang.Object getNodeAtIndex(int index)
           
 java.util.List getNodeList()
          Returns an immutable list of the nodes.
 java.util.Set getNodes()
           
 Bag getOutboundEdges(java.lang.Object node)
          This implementation takes linear time.
 java.lang.Class getPrincipleInterface()
          Returns the class's principle interface for state comparisons.
 CEPath getSubpath(int startNodeIndex, int endNodeIndex)
          Returns a new path, between startNodeIndex and endNodeIndex, inclusive.
 CEPath getSubpathFirst(java.lang.Object startNode, java.lang.Object endNode)
          Returns a new path, between the first occurence of startNode and the first occurence of endNode, inclusive.
 CEPath getSubpathFirstToLast(java.lang.Object startNode, java.lang.Object endNode)
          Returns a new path, between the first occurence of startNode and the last occurence of endNode, inclusive.
 CEPath getSubpathLast(java.lang.Object startNode, java.lang.Object endNode)
          Returns a new path, between the last occurence of startNode and the last occurence of endNode, inclusive.
 CEPath getSubpathLastToFirst(java.lang.Object startNode, java.lang.Object endNode)
          Returns a new path, between the last occurence of startNode and the first occurence of endNode, inclusive.
 CEDigraph getSupergraph()
          Returns the supergraph.
 java.lang.Object getTail()
           
 java.util.Set getToNodes(java.lang.Object node)
          Returns the set of nodes that can be reached from this node by crossing one edge.
protected  void graftToHead(CEPath path)
          Adds a path to the beginning of this path.
protected  void graftToTail(CEPath path)
          Adds a path to the end of this path.
 CEDigraph intersectWithCEDigraph(CEDigraph digraph)
          Returns a new digraph that is the intersection of this with digraph.
 boolean isEdgeFree()
          Returns true if this CEDigraph has no edges.
 boolean isEmpty()
           
 int nodeCount()
          This method is not terribly efficient.
 java.util.Iterator nodeIterator()
          nodeIterator()'s remove() method throws an UnsupportedOperationException.
 int pathEdgeCount()
          Returns the number of edges in the path, including repeats.
 EdgeIterator pathEdgeIterator()
          Implementations should explicitly state how they interpret nodeIterator()'s remove method.
 EdgeNodeIterator pathEdgeNodeIterator()
          Iterate through the edges in path order.
 int pathNodeCount()
          Returns the number of nodes in the path, including repeates.
 java.util.Iterator pathNodeIterator()
          Implementations should explicitly state how they interpret nodeIterator()'s remove method.
protected  CEPath pruneHead(int index)
          Removes from the head to the edge at index.
protected  CEPath pruneHeadFromFirst(java.lang.Object node)
          Removes from the head to the first occurance of node.
protected  CEPath pruneHeadFromLast(java.lang.Object node)
          Removes from the head to the last occurance of node.
protected  CEPath pruneTail(int index)
          Removes from the edge at index to the tail.
protected  CEPath pruneTailFromFirst(java.lang.Object node)
          Removes from the first occurance of node to the tail.
protected  CEPath pruneTailFromLast(java.lang.Object node)
          Removes from the last occurance of node to the tail.
protected  java.lang.Object removeHead()
          Removes the head node from the path.
protected  java.lang.Object removeTail()
          Removes the tail node from the path.
 boolean sameCEDigraphAs(CEDigraph digraph)
          Returns true if digraph is the same as this, and all their contents have the same state.
 boolean sameCEPathAs(CEPath path)
          Returns true if path is the same path as this, on the same digraph.
 boolean sameStateAs(HasState victim)
          If two HasStates have the same internal state, return true.
protected  CEPath splice(CEPath path, int startNodeIndex, int endNodeIndex)
          Splices in path between the startNodeIndex and endNodeIndex.
protected  CEPath spliceFirst(CEPath path)
          Splices in path between the first occurence of path's head and the first occurence of path's tail.
protected  CEPath spliceFirstToLast(CEPath path)
          Splices in path between the first occurence of path's head and the last occurence of path's tail.
protected  CEPath spliceLast(CEPath path)
          Splices in path between the last occurence of path's head and the last occurence of path's tail.
protected  CEPath spliceLastToFirst(CEPath path)
          Splices in path between the last occurence of path's head and the first occurence of path's tail.
 java.lang.String toString()
           
 CEDigraph unionCEDigraph(CEDigraph digraph)
          Returns a new digraph that is the union of this with digraph.
 boolean valid()
          Returns true if this path is still a subgraph of its supergraph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULTCAPACITY

private static final int DEFAULTCAPACITY
See Also:
Constant Field Values

nodes

private java.util.List nodes

edges

private java.util.List edges

modCount

private transient volatile int modCount

digraph

private CEDigraph digraph
Constructor Detail

AbstractListCEPath

protected AbstractListCEPath(CEPath path)
Create a new path that is a copy of path.

Throws:
InvalidPathException - if the path is not valid.

AbstractListCEPath

protected AbstractListCEPath(CEPath path,
                             java.util.List nodeList,
                             java.util.List edgeList)
Create a new path that is a copy of path, using nodeList and edgeList. This constructor clear()s both lists before using them.

Throws:
InvalidPathException - if the path is not valid.

AbstractListCEPath

protected AbstractListCEPath(CEDigraph digraph,
                             java.lang.Object node)
Creates a new path on digraph that has only node in it with DEFAULTCAPACITY of 7.

Throws:
InvalidPathException - if the path is not valid (because the node isn't in the supergraph).

AbstractListCEPath

protected AbstractListCEPath(CEDigraph digraph,
                             java.lang.Object node,
                             int nodeCapacity)
Creates a new path on digraph that has only node in it, with a capacity nodeCapacity.

Throws:
InvalidPathException - if the path is not valid (because the node isn't in the supergraph).

AbstractListCEPath

protected AbstractListCEPath(CEDigraph digraph,
                             java.lang.Object node,
                             java.util.List nodeList,
                             java.util.List edgeList)
Creates a new path on digraph that has only node in it, using nodeList and edgeList. This constructor clear()s both lists before using them.

Throws:
InvalidPathException - if the path is not valid (because the node isn't in the supergraph).

AbstractListCEPath

protected AbstractListCEPath(CEDigraph digraph,
                             java.util.List nodeList,
                             java.util.List edgeList)
Creates a new path on digraph that has only node in it, using nodeList and edgeList. This constructor uses nodeList as the list of nodes, and edgeList as the list of edges.

Throws:
InvalidPathException - if the path is not valid (because the node isn't in the supergraph).
Method Detail

checkValid

protected void checkValid()
Throw an InvalidPathException if anything is wrong.


nodeCount

public int nodeCount()
This method is not terribly efficient. It puts the nodes into a Set, then returns that Set's size.

Specified by:
nodeCount in interface Digraph

edgeCount

public int edgeCount()
This method is wildly inefficient. It scans the edges, and creates objects to stuff in a Set, then gets the size of the set.

Specified by:
edgeCount in interface Digraph

pathNodeCount

public int pathNodeCount()
Returns the number of nodes in the path, including repeates.

Specified by:
pathNodeCount in interface Path

pathEdgeCount

public int pathEdgeCount()
Returns the number of edges in the path, including repeats.

Specified by:
pathEdgeCount in interface Path

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Digraph

containsNode

public boolean containsNode(java.lang.Object node)
Specified by:
containsNode in interface Digraph

containsEdge

public boolean containsEdge(java.lang.Object fromNode,
                            java.lang.Object toNode)
                     throws NodeMissingException
Returns true if the digraph contains any edge from fromNode to toNode

Specified by:
containsEdge in interface Digraph
Throws:
NodeMissingException - if either node is missing from the digraph.

containsEdge

public boolean containsEdge(java.lang.Object fromNode,
                            java.lang.Object toNode,
                            java.lang.Object edge)
                     throws NodeMissingException
Returns true if edge links fromNode to toNode

Specified by:
containsEdge in interface CEDigraph
Throws:
NodeMissingException - if either node is missing from the digraph.

countInboundEdges

public int countInboundEdges(java.lang.Object node)
                      throws NodeMissingException
This implementation takes linear time. If you know the path is acyclic, override it to be constant time.

Specified by:
countInboundEdges in interface Digraph
Throws:
NodeMissingException - if node is not in the digraph.

countOutboundEdges

public int countOutboundEdges(java.lang.Object node)
                       throws NodeMissingException
This implementation takes linear time. If you know the path is acyclic, override it to be constant time.

Specified by:
countOutboundEdges in interface Digraph
Throws:
NodeMissingException - if node is not in the digraph.

getInboundEdges

public Bag getInboundEdges(java.lang.Object node)
                    throws NodeMissingException
This implementation takes linear time. If you know the path is acyclic, override it to be constant time.

Specified by:
getInboundEdges in interface CEDigraph
Throws:
NodeMissingException - if node is not in the digraph.

getOutboundEdges

public Bag getOutboundEdges(java.lang.Object node)
                     throws NodeMissingException
This implementation takes linear time. If you know the path is acyclic, override it to be constant time.

Specified by:
getOutboundEdges in interface CEDigraph
Throws:
NodeMissingException - if node is not in the digraph.

getEdge

public java.lang.Object getEdge(java.lang.Object fromNode,
                                java.lang.Object toNode)
                         throws NodeMissingException
Returns null if no edge links fromNode to toNode.

Specified by:
getEdge in interface CEDigraph
Throws:
NodeMissingException - if either node is missing from the digraph.

getFromNodes

public java.util.Set getFromNodes(java.lang.Object node)
                           throws NodeMissingException
Returns the set of nodes that can reach this node by crossing one edge.

If you know this path is acyclic, override this method with one that takes constant time.

Specified by:
getFromNodes in interface Digraph
Throws:
NodeMissingException - if node is not in the digraph.

getToNodes

public java.util.Set getToNodes(java.lang.Object node)
                         throws NodeMissingException
Returns the set of nodes that can be reached from this node by crossing one edge.

If you know this path is acyclic, override this method with one that takes constant time.

Specified by:
getToNodes in interface Digraph
Throws:
NodeMissingException - if node is not in the digraph.

nodeIterator

public java.util.Iterator nodeIterator()
nodeIterator()'s remove() method throws an UnsupportedOperationException.

Specified by:
nodeIterator in interface Digraph

pathNodeIterator

public java.util.Iterator pathNodeIterator()
Description copied from interface: Path
Implementations should explicitly state how they interpret nodeIterator()'s remove method. It should either throw an UnsupportedOperationException or cause a hidden side effect of removing edges.

The Iterator should start at the beginning of the path and iterate to the end.

Specified by:
pathNodeIterator in interface Path

edgeIterator

public EdgeIterator edgeIterator()
edgeIterator()'s remove() method throws an UnsupportedOperationException.

Specified by:
edgeIterator in interface CEDigraph

pathEdgeIterator

public EdgeIterator pathEdgeIterator()
Description copied from interface: CEPath
Implementations should explicitly state how they interpret nodeIterator()'s remove method. It should either throw an UnsupportedOperationException or cause a hidden side effect of removing edges. I'm not sure what those side effects should be.

The Iterator should start at the beginning of the path and iterate to the end.

Specified by:
pathEdgeIterator in interface CEPath

edgeNodeIterator

public EdgeNodeIterator edgeNodeIterator()
Returns an iterator that iterates across pairs of nodes that make edges.

Specified by:
edgeNodeIterator in interface Digraph

pathEdgeNodeIterator

public EdgeNodeIterator pathEdgeNodeIterator()
Description copied from interface: Path
Iterate through the edges in path order.

If Path is immutable, edgeIterator()'s remove() method throws an UnsupportedOperationException.

Specified by:
pathEdgeNodeIterator in interface Path

getNodes

public java.util.Set getNodes()
Specified by:
getNodes in interface Digraph

getEdges

public Bag getEdges()
Specified by:
getEdges in interface CEDigraph

isEdgeFree

public boolean isEdgeFree()
Returns true if this CEDigraph has no edges.

Specified by:
isEdgeFree in interface Digraph

containsNodes

public boolean containsNodes(java.util.Set nodes)
Specified by:
containsNodes in interface Digraph

containsCEDigraph

public boolean containsCEDigraph(CEDigraph digraph)
Returns true if digraph is a subgraph of this CEDigraph.

Specified by:
containsCEDigraph in interface CEDigraph

sameCEDigraphAs

public boolean sameCEDigraphAs(CEDigraph digraph)
Returns true if digraph is the same as this, and all their contents have the same state.

Specified by:
sameCEDigraphAs in interface CEDigraph

intersectWithCEDigraph

public CEDigraph intersectWithCEDigraph(CEDigraph digraph)
Returns a new digraph that is the intersection of this with digraph. Implementations should generally return the same implementation of CEDigraph as they have themselves.

Specified by:
intersectWithCEDigraph in interface CEDigraph

unionCEDigraph

public CEDigraph unionCEDigraph(CEDigraph digraph)
Returns a new digraph that is the union of this with digraph. Implementations should generally return the same implementation of CEDigraph as they are themselves. If the digraphs contain conflicting edges, then (unless you have a better rule) let digraph's edge win out.

Specified by:
unionCEDigraph in interface CEDigraph

getPrincipleInterface

public java.lang.Class getPrincipleInterface()
Description copied from interface: HasState
Returns the class's principle interface for state comparisons. If two objects have different principle interfaces, they never have the same state.

Specified by:
getPrincipleInterface in interface HasState

sameStateAs

public boolean sameStateAs(HasState victim)
Description copied from interface: HasState
If two HasStates have the same internal state, return true.

For objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.

Specified by:
sameStateAs in interface HasState

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

valid

public boolean valid()
Returns true if this path is still a subgraph of its supergraph

Specified by:
valid in interface Path

getSupergraph

public CEDigraph getSupergraph()
Returns the supergraph. Unlike most methods, this does not copy the supergraph into an immutable object.

Specified by:
getSupergraph in interface CEPath

getHead

public java.lang.Object getHead()
Specified by:
getHead in interface Path

getTail

public java.lang.Object getTail()
Specified by:
getTail in interface Path

getNodeAtIndex

public java.lang.Object getNodeAtIndex(int index)
Specified by:
getNodeAtIndex in interface Path

getEdgeAtIndex

public java.lang.Object getEdgeAtIndex(int index)
Specified by:
getEdgeAtIndex in interface CEPath

getIndexOfNode

public int getIndexOfNode(java.lang.Object node)
Specified by:
getIndexOfNode in interface Path

getLastIndexOfNode

public int getLastIndexOfNode(java.lang.Object node)
Specified by:
getLastIndexOfNode in interface Path

getIndexOfEdge

public int getIndexOfEdge(java.lang.Object edge)
Specified by:
getIndexOfEdge in interface CEPath

getLastIndexOfEdge

public int getLastIndexOfEdge(java.lang.Object edge)
Specified by:
getLastIndexOfEdge in interface CEPath

getNodeList

public java.util.List getNodeList()
Returns an immutable list of the nodes.

Specified by:
getNodeList in interface Path

getEdgeList

public java.util.List getEdgeList()
Returns an immutable list of the edges.

Specified by:
getEdgeList in interface CEPath

checkIndices

private void checkIndices(int startNodeIndex,
                          int endNodeIndex)
                   throws InvalidSpliceException
InvalidSpliceException

getSubpath

public CEPath getSubpath(int startNodeIndex,
                         int endNodeIndex)
                  throws InvalidSpliceException
Returns a new path, between startNodeIndex and endNodeIndex, inclusive.

Specified by:
getSubpath in interface CEPath
InvalidSpliceException

checkSubpathIndices

private void checkSubpathIndices(int startNodeIndex,
                                 int endNodeIndex,
                                 java.lang.Object startNode,
                                 java.lang.Object endNode)
                          throws NodeMissingException,
                                 InvalidSpliceException
NodeMissingException
InvalidSpliceException

getSubpathFirst

public CEPath getSubpathFirst(java.lang.Object startNode,
                              java.lang.Object endNode)
                       throws NodeMissingException,
                              InvalidSpliceException
Returns a new path, between the first occurence of startNode and the first occurence of endNode, inclusive.

Specified by:
getSubpathFirst in interface CEPath
Throws:
NodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.

getSubpathLast

public CEPath getSubpathLast(java.lang.Object startNode,
                             java.lang.Object endNode)
                      throws NodeMissingException,
                             InvalidSpliceException
Returns a new path, between the last occurence of startNode and the last occurence of endNode, inclusive.

Specified by:
getSubpathLast in interface CEPath
Throws:
NodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.

getSubpathFirstToLast

public CEPath getSubpathFirstToLast(java.lang.Object startNode,
                                    java.lang.Object endNode)
                             throws NodeMissingException,
                                    InvalidSpliceException
Returns a new path, between the first occurence of startNode and the last occurence of endNode, inclusive.

Specified by:
getSubpathFirstToLast in interface CEPath
Throws:
NodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.

getSubpathLastToFirst

public CEPath getSubpathLastToFirst(java.lang.Object startNode,
                                    java.lang.Object endNode)
                             throws NodeMissingException,
                                    InvalidSpliceException
Returns a new path, between the last occurence of startNode and the first occurence of endNode, inclusive.

Specified by:
getSubpathLastToFirst in interface CEPath
Throws:
NodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.

sameCEPathAs

public boolean sameCEPathAs(CEPath path)
Returns true if path is the same path as this, on the same digraph. So if two paths are on different supergraphs, they may be the same digraph, but not the same path.

Specified by:
sameCEPathAs in interface CEPath

addToTail

protected void addToTail(java.lang.Object edge,
                         java.lang.Object node)
                  throws EdgeMissingException,
                         NodeMissingException
Adds an edge and node to the end of the path.

returns true if the operation is successful, false if the path is unchanged.

Throws:
EdgeMissingException - if the edge is not in the digraph between the tail node and node.
NodeMissingException - if the node is not in the digraph.

addToHead

protected void addToHead(java.lang.Object node,
                         java.lang.Object edge)
                  throws EdgeMissingException,
                         NodeMissingException
Adds a node and edge to the beginning of the path.

returns true if the operation is successful, false if the path is unchanged.

Throws:
EdgeMissingException - if the edge is not in the digraph between the tail node and node.
NodeMissingException - if the node is not in the digraph.

graftToTail

protected void graftToTail(CEPath path)
                    throws EdgeMissingException,
                           NodeMissingException,
                           InvalidSpliceException
Adds a path to the end of this path.

Throws:
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not this' tail node.

graftToHead

protected void graftToHead(CEPath path)
                    throws EdgeMissingException,
                           NodeMissingException,
                           InvalidSpliceException
Adds a path to the beginning of this path.

Throws:
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's tail node is not this' head node.

removeHead

protected java.lang.Object removeHead()
                               throws LastNodeException
Removes the head node from the path.

returns the orphaned edge.

LastNodeException

removeTail

protected java.lang.Object removeTail()
                               throws LastNodeException
Removes the tail node from the path.

returns the orphaned edge.

LastNodeException

chopList

protected void chopList(java.util.List victim,
                        int fromIndex,
                        int toIndex)

pruneTail

protected CEPath pruneTail(int index)
Removes from the edge at index to the tail.

Returns:
the path from the node at index to the tail.

pruneHead

protected CEPath pruneHead(int index)
Removes from the head to the edge at index.

Returns:
the path from the head to the node at index.

pruneTailFromFirst

protected CEPath pruneTailFromFirst(java.lang.Object node)
                             throws NodeMissingException
Removes from the first occurance of node to the tail.

Returns:
a path from the first occurance of node to the tail.
Throws:
NodeMissingException - if the node is not in the digraph.

pruneTailFromLast

protected CEPath pruneTailFromLast(java.lang.Object node)
                            throws NodeMissingException
Removes from the last occurance of node to the tail.

Returns:
a path from the last occurance of node to the tail.
Throws:
NodeMissingException - if the node is not in the digraph.

pruneHeadFromFirst

protected CEPath pruneHeadFromFirst(java.lang.Object node)
                             throws NodeMissingException
Removes from the head to the first occurance of node.

Returns:
a path from the head to the first occurance of node.
Throws:
NodeMissingException - if the node is not in the digraph.

pruneHeadFromLast

protected CEPath pruneHeadFromLast(java.lang.Object node)
                            throws NodeMissingException
Removes from the head to the last occurance of node.

Returns:
a path from the head to the last occurance of node.
Throws:
NodeMissingException - if the node is not in the digraph.

splice

protected CEPath splice(CEPath path,
                        int startNodeIndex,
                        int endNodeIndex)
                 throws EdgeMissingException,
                        NodeMissingException,
                        InvalidSpliceException
Splices in path between the startNodeIndex and endNodeIndex.

Returns:
the orphaned path

Throws:
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.

spliceFirst

protected CEPath spliceFirst(CEPath path)
                      throws EdgeMissingException,
                             NodeMissingException,
                             InvalidSpliceException
Splices in path between the first occurence of path's head and the first occurence of path's tail.

Returns:
the orphaned path

Throws:
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.

spliceLast

protected CEPath spliceLast(CEPath path)
                     throws EdgeMissingException,
                            NodeMissingException,
                            InvalidSpliceException
Splices in path between the last occurence of path's head and the last occurence of path's tail.

Returns:
the orphaned path

Throws:
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.

spliceFirstToLast

protected CEPath spliceFirstToLast(CEPath path)
                            throws EdgeMissingException,
                                   NodeMissingException,
                                   InvalidSpliceException
Splices in path between the first occurence of path's head and the last occurence of path's tail.

Returns:
the orphaned path

Throws:
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.

spliceLastToFirst

protected CEPath spliceLastToFirst(CEPath path)
                            throws EdgeMissingException,
                                   NodeMissingException,
                                   InvalidSpliceException
Splices in path between the last occurence of path's head and the first occurence of path's tail.

Returns:
the orphaned path

Throws:
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.


Copyright (c) 2001, 2002, David Walend