public class Digraph extends java.lang.Object
For additional documentation, see Section 4.2 of Algorithms, 4th Edition, by Robert Sedgewick and Kevin Wayne.
Constructor and Description |
---|
Digraph(Digraph G)
Copy constructor.
|
Digraph(In in)
Create a digraph from input stream.
|
Digraph(int V)
Create an empty digraph with V vertices.
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(int v,
int w)
Add the directed edge v->w to the digraph.
|
java.lang.Iterable<java.lang.Integer> |
adj(int v)
Return the list of vertices pointed to from vertex v as an Iterable.
|
int |
E()
Return the number of edges in the digraph.
|
static void |
main(java.lang.String[] args)
Test client.
|
Digraph |
reverse()
Return the reverse of the digraph.
|
java.lang.String |
toString()
Return a string representation of the digraph.
|
int |
V()
Return the number of vertices in the digraph.
|
public Digraph(int V)
java.lang.IllegalArgumentException
- if V < 0public Digraph(In in)
public Digraph(Digraph G)
public int V()
public int E()
public void addEdge(int v, int w)
java.lang.IndexOutOfBoundsException
- unless both 0 <= v < V and 0 <= w < Vpublic java.lang.Iterable<java.lang.Integer> adj(int v)
java.lang.IndexOutOfBoundsException
- unless 0 <= v < Vpublic Digraph reverse()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)