Class TarjanSCC

java.lang.Object
com.graphhopper.routing.subnetwork.TarjanSCC

public class TarjanSCC extends Object
Tarjan's algorithm to find strongly connected components of a directed graph. Two nodes belong to the same connected component iff they are reachable from each other. Reachability from A to B is not necessarily equal to reachability from B to A because the graph is directed.

This class offers two ways to run the algorithm: Either using (function call) recursion findComponentsRecursive() or recursion using an explicit stack findComponents(). The first one is easier to implement and understand and the second one allows running the algorithm also on large graphs without having to deal with JVM stack size limits.

Tarjan's algorithm is explained for example here: - http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm - http://www.timl.id.au/?p=327 - http://homepages.ecs.vuw.ac.nz/~djp/files/P05.pdf

Author:
easbar