com.mhhe.clrs2e
Class Kruskal.WeightedEdge

java.lang.Object
  |
  +--com.mhhe.clrs2e.Kruskal.WeightedEdge
All Implemented Interfaces:
java.lang.Comparable
Enclosing class:
Kruskal

private static class Kruskal.WeightedEdge
extends java.lang.Object
implements java.lang.Comparable

Inner class for weighted edges so that the edges can be sorted and considered in nondecreasing order by weight.


Field Summary
 com.mhhe.clrs2e.Vertex u
          A vertex on which this edge is incident.
 com.mhhe.clrs2e.Vertex v
          Another vertex on which this edge is incident.
 double w
          The weight of the edge.
 
Constructor Summary
Kruskal.WeightedEdge(com.mhhe.clrs2e.Vertex a, com.mhhe.clrs2e.Vertex b, double weight)
          Stores the vertices and edge weight into the instance variables.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares the weight of this WeightedEdge to that of another.
 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

u

public com.mhhe.clrs2e.Vertex u
A vertex on which this edge is incident.


v

public com.mhhe.clrs2e.Vertex v
Another vertex on which this edge is incident.


w

public double w
The weight of the edge.

Constructor Detail

Kruskal.WeightedEdge

public Kruskal.WeightedEdge(com.mhhe.clrs2e.Vertex a,
                            com.mhhe.clrs2e.Vertex b,
                            double weight)
Stores the vertices and edge weight into the instance variables.

Parameters:
a - One vertex on which this edge is incident.
b - Another vertex on which this edge is incident.
weight - The weight of the edge.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares the weight of this WeightedEdge to that of another.

Specified by:
compareTo in interface java.lang.Comparable
Returns:
A negative integer if this object's weight vertex is less; 0 if the weights are equal; a positive integer if this object's weight is greater.

toString

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

Overrides:
toString in class java.lang.Object