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
ConstructorDescriptionEdge
(int v, int w, double weight) Create an edge between v and w with given weight. -
Method Summary
Modifier and TypeMethodDescriptionint
Compare edges by weight.int
either()
Return either endpoint of this edge.static void
Test client.int
other
(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.double
weight()
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:
compareTo
in interfaceComparable<Edge>
-
toString
Return a string representation of this edge. -
main
Test client.
-