Package dsa
Class DiEdge
- java.lang.Object
-
- dsa.DiEdge
-
class DiEdge extends Object
An immutable data type to represent a weighted edge in an directed graph.
-
-
Constructor Summary
Constructors Constructor Description DiEdge(int v, int w, double weight)
Constructs a directed edge from vertexv
to vertexw
of the givenweight
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
from()
Returns the tail vertex of this directed edge.static void
main(String[] args)
Unit tests the data type.int
to()
Returns the head vertex of this directed edge.String
toString()
Returns a string representation of this directed edge.double
weight()
Returns the weight of this directed edge.
-
-
-
Method Detail
-
from
public int from()
Returns the tail vertex of this directed edge.- Returns:
- the tail vertex of this directed edge.
-
to
public int to()
Returns the head vertex of this directed edge.- Returns:
- the head vertex of this directed edge.
-
weight
public double weight()
Returns the weight of this directed edge.- Returns:
- the weight of this directed edge
-
toString
public String toString()
Returns a string representation of this directed edge.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-