com.mhhe.clrs2e
Class Prim.PrimInfo

java.lang.Object
  |
  +--com.mhhe.clrs2e.Prim.PrimInfo
All Implemented Interfaces:
java.lang.Comparable, DynamicSetElement
Enclosing class:
Prim

private static class Prim.PrimInfo
extends java.lang.Object
implements DynamicSetElement

Inner class to maintain the Vertex object, key, parent, and handle into the priority queue for each vertex.


Nested Class Summary
 
Nested classes inherited from class com.mhhe.clrs2e.DynamicSetElement
DynamicSetElement.Helper
 
Field Summary
 java.lang.Object handle
          A handle to the vertex's information in the priority queue, or null if the vertex is not in the priority queue.
 java.lang.Double key
          Vertex's key, representing the weight of the lightest edge between this vertex and some vertex known to be in the minimum spanning tree.
 com.mhhe.clrs2e.Vertex pi
          The current parent for this vertex.
 com.mhhe.clrs2e.Vertex theVertex
          The vertex.
 
Constructor Summary
Prim.PrimInfo(com.mhhe.clrs2e.Vertex v, com.mhhe.clrs2e.MinPriorityQueue q)
          Sets the instance variables so that there is no known edge between this vertex and any vertex in the minimum spanning tree (i.e., the key is infinity), and inserts this object into the min-priority queue.
 
Method Summary
 int compareTo(java.lang.Object e)
          Compares this object's key to that of another PrimInfo object.
 java.lang.Comparable getKey()
          Returns the value of the key.
 void setKey(java.lang.Comparable key)
          Sets the key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theVertex

public com.mhhe.clrs2e.Vertex theVertex
The vertex.


key

public java.lang.Double key
Vertex's key, representing the weight of the lightest edge between this vertex and some vertex known to be in the minimum spanning tree.


pi

public com.mhhe.clrs2e.Vertex pi
The current parent for this vertex.


handle

public java.lang.Object handle
A handle to the vertex's information in the priority queue, or null if the vertex is not in the priority queue.

Constructor Detail

Prim.PrimInfo

public Prim.PrimInfo(com.mhhe.clrs2e.Vertex v,
                     com.mhhe.clrs2e.MinPriorityQueue q)
Sets the instance variables so that there is no known edge between this vertex and any vertex in the minimum spanning tree (i.e., the key is infinity), and inserts this object into the min-priority queue.

Parameters:
v - The vertex.
q - The min-priority queue.
Method Detail

setKey

public void setKey(java.lang.Comparable key)
Sets the key.

Specified by:
setKey in interface DynamicSetElement
Parameters:
key - The new key value.

getKey

public java.lang.Comparable getKey()
Returns the value of the key.

Specified by:
getKey in interface DynamicSetElement

compareTo

public int compareTo(java.lang.Object e)
Compares this object's key to that of another PrimInfo object.

Specified by:
compareTo in interface DynamicSetElement
Parameters:
e - The other PrimInfo object.
Returns:
A negative integer if the key of this object's vertex is less; 0 if the keys are equal; a positive integer if the key of this object's vertex is greater.