ObjectEdge
public class 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 |
|---|
public Edge(int v,
int w,
double weight)
| Method Detail |
|---|
public double weight()
public int either()
public int other(int vertex)
public int compareTo(Edge that)
compareTo in interface Comparable<Edge>public String toString()
toString in class Objectpublic static void main(String[] args)