Class Edge

Object
  extended by Edge
All Implemented Interfaces:
Comparable<Edge>

public class Edge
extends Object
implements Comparable<Edge>

The Edge class represents a weighted edge in an undirected graph.

For additional documentation, see Section 4.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.


Constructor Summary
Edge(int v, int w, double weight)
          Create an edge between v and w with given weight.
 
Method Summary
 int compareTo(Edge that)
          Compare edges by weight.
 int either()
          Return either endpoint of this edge.
static void main(String[] args)
          Test client.
 int other(int vertex)
          Return the endpoint of this edge that is different from the given vertex (unless a self-loop).
 String toString()
          Return a string representation of this edge.
 double weight()
          Return the weight of this edge.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Edge

public Edge(int v,
            int w,
            double weight)
Create an edge between v and w with given weight.

Method Detail

weight

public double weight()
Return the weight of this edge.


either

public int either()
Return either endpoint of this edge.


other

public int other(int vertex)
Return the endpoint of this edge that is different from the given vertex (unless a self-loop).


compareTo

public int compareTo(Edge that)
Compare edges by weight.

Specified by:
compareTo in interface Comparable<Edge>

toString

public String toString()
Return a string representation of this edge.

Overrides:
toString in class Object

main

public static void main(String[] args)
Test client.