ObjectDigraph
public class Digraph
The Digraph class represents an directed graph of vertices named 0 through V-1. It supports the following operations: add an edge to the graph, iterate over all of the neighbors incident to a vertex. Parallel edges and self-loops are permitted.
For additional documentation, see Section 4.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
| Constructor Summary | |
|---|---|
Digraph(Digraph G)
Copy constructor. |
|
Digraph(In in)
Create a digraph from input stream. |
|
Digraph(int V)
Create an empty digraph with V vertices. |
|
| Method Summary | |
|---|---|
void |
addEdge(int v,
int w)
Add the directed edge v-w to the digraph. |
Iterable<Integer> |
adj(int v)
Return the list of neighbors of vertex v as in Iterable. |
int |
E()
Return the number of edges in the digraph. |
static void |
main(String[] args)
Test client. |
Digraph |
reverse()
Return the reverse of the digraph. |
String |
toString()
Return a string representation of the digraph. |
int |
V()
Return the number of vertices in the digraph. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Digraph(int V)
public Digraph(In in)
public Digraph(Digraph G)
| Method Detail |
|---|
public int V()
public int E()
public void addEdge(int v,
int w)
public Iterable<Integer> adj(int v)
public Digraph reverse()
public String toString()
toString in class Objectpublic static void main(String[] args)