public class DirectedEdge extends Object
DirectedEdge
class represents a weighted edge in an
EdgeWeightedDigraph
. Each edge consists of two integers
(naming the two vertices) and a realvalue 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
to vertex w
with
the given weight
.v
 the tail vertexw
 the head vertexweight
 the weight of the directed edgeIllegalArgumentException
 if either v
or w
is a negative integerIllegalArgumentException
 if weight
is NaN
public int from()
public int to()
public double weight()
public String toString()
public static void main(String[] args)
DirectedEdge
data type.args
 the commandline arguments