public class TransitiveClosure extends Object
This implementation runs depth-first search from each vertex. The constructor takes time proportional to V(V + E) (in the worst case) and uses space proportional to V2, where V is the number of vertices and E is the number of edges.
For additional documentation, see Section 4.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
| Constructor and Description |
|---|
TransitiveClosure(Digraph G)
Computes the transitive closure of the digraph G.
|
public TransitiveClosure(Digraph G)
G - the digraphpublic boolean reachable(int v,
int w)
v - the source vertexw - the target vertexpublic static void main(String[] args)
Copyright © 2014. All Rights Reserved.