public class AdjMatrixEdgeWeightedDigraph extends Object
AdjMatrixEdgeWeightedDigraph
class represents a edgeweighted
digraph of vertices named 0 through V  1, where each
directed edge is of type DirectedEdge
and has a realvalued weight.
It supports the following two primary operations: add a directed edge
to the digraph and iterate over all of edges incident from a given vertex.
It also provides
methods for returning the number of vertices V and the number
of edges E. Parallel edges are disallowed; selfloops are permitted.
This implementation uses an adjacencymatrix representation. All operations take constant time (in the worst case) except iterating over the edges incident from a given vertex, which takes time proportional to V.
For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
Constructor and Description 

AdjMatrixEdgeWeightedDigraph(int V)
Initializes an empty edgeweighted digraph with
V vertices and 0 edges. 
AdjMatrixEdgeWeightedDigraph(int V,
int E)
Initializes a random edgeweighted digraph with
V vertices and E edges. 
Modifier and Type  Method and Description 

void 
addEdge(DirectedEdge e)
Adds the directed edge
e to the edgeweighted digraph (if there
is not already an edge with the same endpoints). 
Iterable<DirectedEdge> 
adj(int v)
Returns the directed edges incident from vertex
v . 
int 
E()
Returns the number of edges in the edgeweighted digraph.

static void 
main(String[] args)
Unit tests the
AdjMatrixEdgeWeightedDigraph data type. 
String 
toString()
Returns a string representation of the edgeweighted digraph.

int 
V()
Returns the number of vertices in the edgeweighted digraph.

public AdjMatrixEdgeWeightedDigraph(int V)
V
vertices and 0 edges.V
 the number of verticesIllegalArgumentException
 if V < 0
public AdjMatrixEdgeWeightedDigraph(int V, int E)
V
vertices and E edges.V
 the number of verticesE
 the number of edgesIllegalArgumentException
 if V < 0
IllegalArgumentException
 if E < 0
public int V()
public int E()
public void addEdge(DirectedEdge e)
e
to the edgeweighted digraph (if there
is not already an edge with the same endpoints).e
 the edgepublic Iterable<DirectedEdge> adj(int v)
v
.v
 the vertexv
as an IterableIllegalArgumentException
 unless 0 <= v < V
public String toString()
public static void main(String[] args)
AdjMatrixEdgeWeightedDigraph
data type.args
 the commandline arguments