net.walend.measured
Class CEPathsFromShortestDistances
java.lang.Object
|
+--net.walend.digraph.path.AbstractDelegateDigraphOfCEPaths
|
+--net.walend.measured.CEPathsFromShortestDistances
- All Implemented Interfaces:
- CEDigraph, Digraph, DigraphOfCEPaths, HasState, IndexedCEDigraph, IndexedDigraph, java.io.Serializable, ShortestCEDistances, ShortestCEPaths
- public class CEPathsFromShortestDistances
- extends AbstractDelegateDigraphOfCEPaths
- implements ShortestCEPaths, java.io.Serializable
CEPathsFromShortestDistances wraps a ShortestCEDistances object to provide a full ShortestCEPaths interface.
- Author:
- David Walend dfw1@cornell.edu
- See Also:
- Serialized Form
Method Summary |
boolean |
containsEdge(int fromIndex,
int toIndex)
|
protected ShortestCEDistances |
getDistances()
|
java.lang.Object |
getEdge(int fromIndex,
int toIndex)
|
int |
getLength(int from,
int to)
|
int |
getLength(java.lang.Object fromNode,
java.lang.Object toNode)
|
CEPath |
getPath(int fromIndex,
int toIndex)
|
CEPath |
getPath(java.lang.Object fromNode,
java.lang.Object toNode)
|
CEPathMeter |
getPathMeter()
Return the path meter used to evaluate these shortest paths. |
java.lang.Class |
getPrincipleInterface()
Returns the class's principle interface for state comparisons. |
MeasuredCEPath |
getShortestPath(int fromIndex,
int toIndex)
|
MeasuredCEPath |
getShortestPath(java.lang.Object fromNode,
java.lang.Object toNode)
|
void |
recalculate()
If the digraph is not valid, rediscover the shortest paths. |
protected int |
safeLength(int from,
int to)
|
boolean |
sameStateAs(HasState victim)
If two HasStates have the same internal state, return true. |
boolean |
somewhatValidLengths()
Checks to make sure all the two node paths have lengths equal to or less than the lengths predicted by the path meter. |
java.lang.String |
toString()
|
boolean |
valid()
Checks to make sure all the nodes and edges in the path still exist in the base digraph, and that none of the edge lengths have changed. |
boolean |
validLengths()
Checks to make sure all the two node paths have lengths equal to or less than the lengths predicted by the path meter. |
Methods inherited from class net.walend.digraph.path.AbstractDelegateDigraphOfCEPaths |
addEdge, clearEdges, containsCEDigraph, containsEdge, containsEdge, containsEdge, containsNode, containsNode, containsNodes, countInboundEdges, countInboundEdges, countOutboundEdges, countOutboundEdges, edgeCount, edgeIterator, edgeNodeIterator, getBase, getDelegate, getEdge, getEdges, getFromIndices, getFromNodes, getFromNodes, getInboundEdges, getInboundEdges, getNode, getNodeIndex, getNodes, getOutboundEdges, getOutboundEdges, getToIndices, getToNodes, getToNodes, indexedEdgeIterator, indexedEdgeNodeIterator, indexedNodeIterator, initWithNodesFrom, intersectWithCEDigraph, isEdgeFree, isEmpty, nodeCapacity, nodeCount, nodeIndices, nodeIterator, sameCEDigraphAs, unionCEDigraph |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.walend.digraph.IndexedDigraph |
containsNode, countInboundEdges, countOutboundEdges, getFromIndices, getFromNodes, getNode, getNodeIndex, getToIndices, getToNodes, indexedEdgeNodeIterator, indexedNodeIterator, nodeCapacity, nodeIndices |
Methods inherited from interface net.walend.digraph.Digraph |
containsEdge, containsNode, containsNodes, countInboundEdges, countOutboundEdges, edgeCount, edgeNodeIterator, getFromNodes, getNodes, getToNodes, isEdgeFree, isEmpty, nodeCount, nodeIterator |
shortestDistances
private ShortestCEDistances shortestDistances
tieBreaker
private TieBreaker tieBreaker
CEPathsFromShortestDistances
public CEPathsFromShortestDistances(ShortestCEDistances shortestDistances,
IndexedMutableCEDigraph delegate,
TieBreaker tieBreaker)
getDistances
protected ShortestCEDistances getDistances()
containsEdge
public boolean containsEdge(int fromIndex,
int toIndex)
- Specified by:
containsEdge
in interface IndexedDigraph
- Overrides:
containsEdge
in class AbstractDelegateDigraphOfCEPaths
getEdge
public java.lang.Object getEdge(int fromIndex,
int toIndex)
- Specified by:
getEdge
in interface IndexedCEDigraph
- Overrides:
getEdge
in class AbstractDelegateDigraphOfCEPaths
getPath
public CEPath getPath(java.lang.Object fromNode,
java.lang.Object toNode)
throws NodeMissingException
- Specified by:
getPath
in interface DigraphOfCEPaths
- Overrides:
getPath
in class AbstractDelegateDigraphOfCEPaths
NodeMissingException
getPath
public CEPath getPath(int fromIndex,
int toIndex)
- Specified by:
getPath
in interface DigraphOfCEPaths
- Overrides:
getPath
in class AbstractDelegateDigraphOfCEPaths
valid
public boolean valid()
- Checks to make sure all the nodes and edges in the path still exist in the base digraph, and that none of the edge lengths have changed.
- Specified by:
valid
in interface DigraphOfCEPaths
- Overrides:
valid
in class AbstractDelegateDigraphOfCEPaths
validLengths
public boolean validLengths()
- Checks to make sure all the two node paths have lengths equal to or less than the lengths predicted by the path meter. If a length is less than the path meter's prediction, makes sure that the path has more than two nodes.
WARNING: this method builds the Path for all shortest paths in the digraph and checks if they're valid. It logs a warning about this. Fix your code st/ it knows when the underlying digraph changes and recalculates the paths, or use somewhatValidLengths() instead.
- Specified by:
validLengths
in interface ShortestCEPaths
somewhatValidLengths
public boolean somewhatValidLengths()
- Checks to make sure all the two node paths have lengths equal to or less than the lengths predicted by the path meter. If a length is less than the path meter's prediction, makes sure that the path has more than two nodes.
WARNING: this method only returns true if a direct path between nodes is shorter than the measured path.
recalculate
public void recalculate()
throws CENegativeWeightCycleException
- If the digraph is not valid, rediscover the shortest paths.
- Specified by:
recalculate
in interface ShortestCEDistances
CENegativeWeightCycleException
getPathMeter
public CEPathMeter getPathMeter()
- Return the path meter used to evaluate these shortest paths.
- Specified by:
getPathMeter
in interface ShortestCEDistances
getShortestPath
public MeasuredCEPath getShortestPath(java.lang.Object fromNode,
java.lang.Object toNode)
throws NodeMissingException
- Specified by:
getShortestPath
in interface ShortestCEPaths
NodeMissingException
getShortestPath
public MeasuredCEPath getShortestPath(int fromIndex,
int toIndex)
- Specified by:
getShortestPath
in interface ShortestCEPaths
getLength
public int getLength(int from,
int to)
- Specified by:
getLength
in interface ShortestCEDistances
safeLength
protected final int safeLength(int from,
int to)
getLength
public int getLength(java.lang.Object fromNode,
java.lang.Object toNode)
throws NodeMissingException
- Specified by:
getLength
in interface ShortestCEDistances
NodeMissingException
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
- Overrides:
getPrincipleInterface
in class AbstractDelegateDigraphOfCEPaths
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
- Overrides:
sameStateAs
in class AbstractDelegateDigraphOfCEPaths
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
Copyright (c) 2001, 2002, David Walend