|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.mhhe.clrs2e.SingleSourceShortestPaths
Abstract class for computing single-source shortest paths. Defines methods for algorithms in Chapter 24 of Introduction to Algorithms, Second edition.
| Field Summary | |
protected com.mhhe.clrs2e.WeightedAdjacencyListGraph |
g
The graph for which we are computing single-source shortest paths. |
protected boolean |
noNegWeightCycle
true if no negative-weight cycles were detected,
false if a negative-weight cycle was detected. |
private com.mhhe.clrs2e.ShortestPathInfo[] |
spInfo
The result of running a single-source shortest-paths algorithm. |
| Constructor Summary | |
protected |
SingleSourceShortestPaths(com.mhhe.clrs2e.WeightedAdjacencyListGraph theGraph)
Sets up the instance variables, including allocation of the spInfo array but not allocation of the
ShortestPathInfo objects referenced by the array. |
| Method Summary | |
abstract void |
computeShortestPaths(com.mhhe.clrs2e.Vertex s)
Computes single-source shortest paths from a given source vertex, filling in weights and predecessors in the spInfo array. |
com.mhhe.clrs2e.ShortestPathInfo |
getShortestPathInfo(int v)
Returns a reference to the ShortestPathInfo object
for a given vertex. |
com.mhhe.clrs2e.ShortestPathInfo |
getShortestPathInfo(com.mhhe.clrs2e.Vertex v)
Returns a reference to the ShortestPathInfo object
for a given vertex. |
boolean |
hasNoNegativeWeightCycle()
After running computeShortestPaths, returns
true if no negative-weight cycles were detected,
false if a negative-weight cycle was detected. |
void |
initializeSingleSource(com.mhhe.clrs2e.Vertex s)
Initializes a single-source shortest-paths algorithm. |
protected com.mhhe.clrs2e.ShortestPathInfo |
newShortestPathInfo()
Returns a new ShortestPathInfo object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected com.mhhe.clrs2e.WeightedAdjacencyListGraph g
protected boolean noNegWeightCycle
true if no negative-weight cycles were detected,
false if a negative-weight cycle was detected.
private com.mhhe.clrs2e.ShortestPathInfo[] spInfo
ShortestPathInfo class.
| Constructor Detail |
protected SingleSourceShortestPaths(com.mhhe.clrs2e.WeightedAdjacencyListGraph theGraph)
spInfo array but not allocation of the
ShortestPathInfo objects referenced by the array.
(That's initializeSingleSource(com.mhhe.clrs2e.Vertex)'s job.)
theGraph - The graph for which we are computing
single-source shortest paths.| Method Detail |
public abstract void computeShortestPaths(com.mhhe.clrs2e.Vertex s)
spInfo array.
s - The source vertex.public void initializeSingleSource(com.mhhe.clrs2e.Vertex s)
s - The source vertex.protected com.mhhe.clrs2e.ShortestPathInfo newShortestPathInfo()
ShortestPathInfo object. This
method may be overridden in subclasses.
public boolean hasNoNegativeWeightCycle()
computeShortestPaths, returns
true if no negative-weight cycles were detected,
false if a negative-weight cycle was detected.
public com.mhhe.clrs2e.ShortestPathInfo getShortestPathInfo(com.mhhe.clrs2e.Vertex v)
ShortestPathInfo object
for a given vertex.
v - The vertex for which the corresponding
ShortestPathInfo is returned.public com.mhhe.clrs2e.ShortestPathInfo getShortestPathInfo(int v)
ShortestPathInfo object
for a given vertex.
v - The index of the vertex for which the corresponding
ShortestPathInfo is returned.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||