Class EdgeBasedTarjanSCC
java.lang.Object
com.graphhopper.routing.subnetwork.EdgeBasedTarjanSCC
Edge-based version of Tarjan's algorithm to find strongly connected components on a directed graph. Compared
to the more traditional node-based version that traverses the nodes of the graph this version works directly with
the edges. This way its possible to take into account possible turn restrictions.
The algorithm is of course very similar to the node-based version and it might be possible to reuse some code between the two, but especially the version with an explicit stack needs different 'state' information and loops required some special treatment as well (this was written when base graph could still have loops!).
- Author:
- easbar
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
createEdgeKey
(EdgeIteratorState edgeState, boolean reverse) findComponents
(Graph graph, EdgeBasedTarjanSCC.EdgeTransitionFilter edgeTransitionFilter, boolean excludeSingleEdgeComponents) Runs Tarjan's algorithm using an explicit stack.findComponentsForStartEdges
(Graph graph, EdgeBasedTarjanSCC.EdgeTransitionFilter edgeTransitionFilter, com.carrotsearch.hppc.IntContainer edges) LikefindComponents(Graph, EdgeTransitionFilter, boolean)
, but the search only starts at the given edges.findComponentsRecursive
(Graph graph, EdgeBasedTarjanSCC.EdgeTransitionFilter edgeTransitionFilter, boolean excludeSingleEdgeComponents) Runs Tarjan's algorithm in a recursive way.
-
Method Details
-
findComponents
public static EdgeBasedTarjanSCC.ConnectedComponents findComponents(Graph graph, EdgeBasedTarjanSCC.EdgeTransitionFilter edgeTransitionFilter, boolean excludeSingleEdgeComponents) Runs Tarjan's algorithm using an explicit stack.- Parameters:
edgeTransitionFilter
- Only edge transitions accepted by this filter will be considered when we explore the graph. If a turn is not accepted the corresponding path will be ignored (edges that are only connected by a path with such a turn will not be considered to belong to the same component)excludeSingleEdgeComponents
- if set to true components that only contain a single edge will not be returned when callingfindComponents(com.graphhopper.storage.Graph, com.graphhopper.routing.subnetwork.EdgeBasedTarjanSCC.EdgeTransitionFilter, boolean)
orfindComponentsRecursive()
, which can be useful to save some memory.
-
findComponentsForStartEdges
public static EdgeBasedTarjanSCC.ConnectedComponents findComponentsForStartEdges(Graph graph, EdgeBasedTarjanSCC.EdgeTransitionFilter edgeTransitionFilter, com.carrotsearch.hppc.IntContainer edges) LikefindComponents(Graph, EdgeTransitionFilter, boolean)
, but the search only starts at the given edges. This does not mean the search cannot expand to other edges, but this can be controlled by the edgeTransitionFilter. This method does not return single edge components (the excludeSingleEdgeComponents option is set to true). -
findComponentsRecursive
public static EdgeBasedTarjanSCC.ConnectedComponents findComponentsRecursive(Graph graph, EdgeBasedTarjanSCC.EdgeTransitionFilter edgeTransitionFilter, boolean excludeSingleEdgeComponents) Runs Tarjan's algorithm in a recursive way. Doing it like this requires a large stack size for large graphs, which can be set like `-Xss1024M`. Usually the version using an explicit stack (findComponents()
) should be preferred. However, this recursive implementation is easier to understand. -
createEdgeKey
-