public class TarjanSCC extends Object
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
| Modifier and Type | Class and Description |
|---|---|
static class |
TarjanSCC.ConnectedComponents |
| Modifier and Type | Method and Description |
|---|---|
static TarjanSCC.ConnectedComponents |
findComponents(Graph graph,
EdgeFilter edgeFilter,
boolean excludeSingleNodeComponents)
Runs Tarjan's algorithm using an explicit stack.
|
static TarjanSCC.ConnectedComponents |
findComponentsRecursive(Graph graph,
EdgeFilter edgeFilter,
boolean excludeSingleNodeComponents)
Runs Tarjan's algorithm in a recursive way.
|
public static TarjanSCC.ConnectedComponents findComponents(Graph graph, EdgeFilter edgeFilter, boolean excludeSingleNodeComponents)
excludeSingleNodeComponents - if set to true components that only contain a single node will not be
returned when calling findComponents(com.graphhopper.storage.Graph, com.graphhopper.routing.util.EdgeFilter, boolean) or findComponentsRecursive(),
which can be useful to save some memory.public static TarjanSCC.ConnectedComponents findComponentsRecursive(Graph graph, EdgeFilter edgeFilter, boolean excludeSingleNodeComponents)
findComponents()) should be
preferred. However, this recursive implementation is easier to understand.Copyright © 2012–2022. All rights reserved.