public class DirectedEdge extends Object
EdgeWeightedDigraph. Each edge consists of two integers
(naming the two vertices) and a real-value weight. The data type
provides methods for accessing the two endpoints of the directed edge and
the weight.
For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
| Constructor and Description |
|---|
DirectedEdge(int v,
int w,
double weight)
Initializes a directed edge from vertex v to vertex w with
the given weight.
|
| Modifier and Type | Method and Description |
|---|---|
int |
from()
Returns the tail vertex of the directed edge.
|
static void |
main(String[] args)
Unit tests the DirectedEdge data type.
|
int |
to()
Returns the head vertex of the directed edge.
|
String |
toString()
Returns a string representation of the directed edge.
|
double |
weight()
Returns the weight of the directed edge.
|
public DirectedEdge(int v,
int w,
double weight)
v - the tail vertexw - the head vertexweight - the weight of the directed edgeIndexOutOfBoundsException - if either v or w
is a negative integerIllegalArgumentException - if weight is NaNpublic int from()
public int to()
public double weight()
public String toString()
public static void main(String[] args)
Copyright © 2014. All Rights Reserved.