Package algs43
Class Edge
java.lang.Object
algs43.Edge
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionEdge(int v, int w, double weight) Create an edge between v and w with given weight. -
Method Summary
Modifier and TypeMethodDescriptionintCompare edges by weight.inteither()Return either endpoint of this edge.static voidTest client.intother(int vertex) Return the endpoint of this edge that is different from the given vertex (unless a self-loop).toString()Return a string representation of this edge.doubleweight()Return the weight of this edge.
-
Constructor Details
-
Edge
Create an edge between v and w with given weight.
-
-
Method Details
-
weight
Return the weight of this edge. -
either
Return either endpoint of this edge. -
other
Return the endpoint of this edge that is different from the given vertex (unless a self-loop). -
compareTo
Compare edges by weight.- Specified by:
compareToin interfaceComparable<Edge>
-
toString
Return a string representation of this edge. -
main
Test client.
-