public class Edge extends java.lang.Object implements java.lang.Comparable<Edge>
For additional documentation, see Section 4.3 of Algorithms, 4th Edition, by Robert Sedgewick and Kevin Wayne.
Constructor and Description |
---|
Edge(int v,
int w,
double weight)
Create an edge between v and w with given weight.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Edge that)
Compare edges by weight.
|
int |
either()
Return either endpoint of this edge.
|
static void |
main(java.lang.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).
|
java.lang.String |
toString()
Return a string representation of this edge.
|
double |
weight()
Return the weight of this edge.
|
public Edge(int v, int w, double weight)
public double weight()
public int either()
public int other(int vertex)
public int compareTo(Edge that)
compareTo
in interface java.lang.Comparable<Edge>
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)