net.walend.digraph.path
Class AbstractDelegateDigraphOfCEPaths.DigraphCEPath

java.lang.Object
  |
  +--net.walend.digraph.path.AbstractDelegateDigraphOfCEPaths.DigraphCEPath
All Implemented Interfaces:
CEDigraph, CEPath, Digraph, HasState, Path
Direct Known Subclasses:
AbstractShortestCEPaths.DigraphMeasuredCEPath, CEPathsFromShortestDistances.DigraphMeasuredCEPath
Enclosing class:
AbstractDelegateDigraphOfCEPaths

protected static class AbstractDelegateDigraphOfCEPaths.DigraphCEPath
extends java.lang.Object
implements CEPath


Nested Class Summary
protected  class AbstractDelegateDigraphOfCEPaths.DigraphCEPath.PathEdgeIterator
           
private  class AbstractDelegateDigraphOfCEPaths.DigraphCEPath.PathNodeIterator
           
 
Field Summary
private  AbstractDelegateDigraphOfCEPaths container
           
private  AbstractDelegateDigraphOfCEPaths.Edge edge
           
private  java.lang.Object head
           
private  java.lang.Object tail
           
 
Fields inherited from interface net.walend.digraph.CEDigraph
EMPTY
 
Constructor Summary
AbstractDelegateDigraphOfCEPaths.DigraphCEPath(java.lang.Object head, AbstractDelegateDigraphOfCEPaths.Edge edge, java.lang.Object tail, AbstractDelegateDigraphOfCEPaths container)
           
 
Method Summary
private  void checkEdge(java.lang.Object edge)
           
private  void checkEdgeIndex(int index)
           
private  void checkIndices(int startNodeIndex, int endNodeIndex)
           
private  void checkNode(java.lang.Object node)
           
private  void checkNodeIndex(int index)
           
 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)
           
 int countOutboundEdges(java.lang.Object node)
           
 int edgeCount()
           
 EdgeIterator edgeIterator()
           
 EdgeNodeIterator edgeNodeIterator()
          Returns an iterator that iterates across pairs of nodes that make edges.
 boolean equals(java.lang.Object object)
           
protected  AbstractDelegateDigraphOfCEPaths getContainer()
           
 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)
          Returns the empty set if node has no inbound edges.
 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 getNeck()
           
 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)
          Returns the empty set if node has no outbound edges.
 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.
private  CEPath getSubpath(java.lang.Object startNode, java.lang.Object endNode)
           
 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 base.
 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.
 int hashCode()
           
 CEDigraph intersectWithCEDigraph(CEDigraph digraph)
          Returns a new digraph that is the intersection of this with digraph.
 boolean isEdgeFree()
          Returns true if this Digraph has no edges.
 boolean isEmpty()
           
 int nodeCount()
           
 java.util.Iterator nodeIterator()
          Implementations should explicitly state how they interpret nodeIterator()'s remove method.
 int pathEdgeCount()
          Returns the number of edges in the path, including repeates.
 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.
 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.
 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, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

edge

private AbstractDelegateDigraphOfCEPaths.Edge edge

head

private java.lang.Object head

tail

private java.lang.Object tail

container

private AbstractDelegateDigraphOfCEPaths container
Constructor Detail

AbstractDelegateDigraphOfCEPaths.DigraphCEPath

public AbstractDelegateDigraphOfCEPaths.DigraphCEPath(java.lang.Object head,
                                                      AbstractDelegateDigraphOfCEPaths.Edge edge,
                                                      java.lang.Object tail,
                                                      AbstractDelegateDigraphOfCEPaths container)
Method Detail

getContainer

protected AbstractDelegateDigraphOfCEPaths getContainer()

getNeck

public java.lang.Object getNeck()

getSupergraph

public CEDigraph getSupergraph()
Returns the base.

Specified by:
getSupergraph in interface CEPath

checkEdge

private void checkEdge(java.lang.Object edge)

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

checkEdgeIndex

private void checkEdgeIndex(int index)

getEdgeAtIndex

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

getEdgeList

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

Specified by:
getEdgeList in interface CEPath

checkNodeIndex

private void checkNodeIndex(int index)

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

getSubpath

private CEPath getSubpath(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.

pathEdgeIterator

public EdgeIterator pathEdgeIterator()
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

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

valid

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

Specified by:
valid in interface Path

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 repeates.

Specified by:
pathEdgeCount in interface Path

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

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

getNodeList

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

Specified by:
getNodeList in interface Path

pathNodeIterator

public java.util.Iterator pathNodeIterator()
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

pathEdgeNodeIterator

public EdgeNodeIterator pathEdgeNodeIterator()
Iterate through the edges in path order.

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

Specified by:
pathEdgeNodeIterator in interface Path

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.

getEdges

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

checkNode

private void checkNode(java.lang.Object node)
                throws NodeMissingException
NodeMissingException

getInboundEdges

public Bag getInboundEdges(java.lang.Object node)
                    throws NodeMissingException
Returns the empty set if node has no inbound edges.

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
Returns the empty set if node has no outbound edges.

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.

edgeIterator

public EdgeIterator edgeIterator()
Specified by:
edgeIterator in interface CEDigraph

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

nodeCount

public int nodeCount()
Specified by:
nodeCount in interface Digraph

edgeCount

public int edgeCount()
Specified by:
edgeCount in interface Digraph

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.

countInboundEdges

public int countInboundEdges(java.lang.Object node)
                      throws NodeMissingException
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
Specified by:
countOutboundEdges in interface Digraph
Throws:
NodeMissingException - if node is not in 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.

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.

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

nodeIterator

public java.util.Iterator nodeIterator()
Implementations should explicitly state how they interpret nodeIterator()'s remove method. It should either throw an UnsupportedOperationException or cause a hidden side effects of removing edges.

Specified by:
nodeIterator in interface Digraph

edgeNodeIterator

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

Specified by:
edgeNodeIterator in interface Digraph

getNodes

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

isEdgeFree

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

Specified by:
isEdgeFree in interface Digraph

containsNodes

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

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

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright (c) 2001, 2002, David Walend