com.mhhe.clrs2e
Class ShortestPathInfo

java.lang.Object
  |
  +--com.mhhe.clrs2e.ShortestPathInfo
Direct Known Subclasses:
Dijkstra.DijkstraInfo

public class ShortestPathInfo
extends java.lang.Object

Class for information determined about a vertex during a shortest-path algorithm.


Field Summary
private  double d
          The current shortest-path estimate for this vertex.
private  com.mhhe.clrs2e.Vertex pi
          The current predecessor (parent) for this vertex.
 
Constructor Summary
ShortestPathInfo()
          Initializes the shortest-path estimate to infinity and the predecessor to null.
 
Method Summary
 double getEstimate()
          Returns the shortest-path estimate.
 com.mhhe.clrs2e.Vertex getPredecessor()
          Returns the predecessor.
 boolean relax(com.mhhe.clrs2e.Vertex u, double du, double w)
          Relaxes an edge entering this vertex, say v, based on the Relax procedure on page 586 of Introduction to Algorithms, Second edition.
 void setEstimate(double newEstimate)
          Sets the shortest-path estimate.
 void setPredecessor(com.mhhe.clrs2e.Vertex v)
          Sets the predecessor.
 java.lang.String toString()
          Returns the String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

d

private double d
The current shortest-path estimate for this vertex.


pi

private com.mhhe.clrs2e.Vertex pi
The current predecessor (parent) for this vertex.

Constructor Detail

ShortestPathInfo

public ShortestPathInfo()
Initializes the shortest-path estimate to infinity and the predecessor to null.

Method Detail

setEstimate

public void setEstimate(double newEstimate)
Sets the shortest-path estimate.

Parameters:
newEstimate - The new shortest-path estimate.

getEstimate

public double getEstimate()
Returns the shortest-path estimate.


setPredecessor

public void setPredecessor(com.mhhe.clrs2e.Vertex v)
Sets the predecessor.

Parameters:
v - The new predecessor.

getPredecessor

public com.mhhe.clrs2e.Vertex getPredecessor()
Returns the predecessor.


relax

public boolean relax(com.mhhe.clrs2e.Vertex u,
                     double du,
                     double w)
Relaxes an edge entering this vertex, say v, based on the Relax procedure on page 586 of Introduction to Algorithms, Second edition.

Parameters:
u - Vertex that the edge leaves.
du - u's shortest-path estimate.
w - The weight of the edge (u,v).
Returns:
true if the shortest-path estimate for v changes, false if the shortest-path estimate remains unchanged.

toString

public java.lang.String toString()
Returns the String representation of this object.

Overrides:
toString in class java.lang.Object