Graphs: | see below |
---|---|
Properties: | components, color, discover time, root vertex |
Complexity: | O(V + E) |
(1) template <typename Graph, typename ComponentMap, typename RootMap, typename ColorMap, typename DiscoverTime> typename property_traits<ComponentMap>::value_type strong_components(Graph& g, ComponentMap comp, RootMap root, ColorMap color, DiscoverTime d) (2) template <typename Graph, typename ComponentMap, typename RootMap, typename ColorMap, typename DiscoverTime, typename DFSVisitor> typename property_traits<ComponentMap>::value_type strong_components(Graph& g, ComponentMap comp, RootMap root, ColorMap color, DiscoverTime discover_time, DFSVisitor v)
The strong_components() functions compute the strongly connected components of a directed graph using Tarjan's algorithm based on DFS [41].
The output of the algorithm is recorded in the component property map comp, which will contain numbers giving the component ID assigned to each vertex. The number of components is the return value of the function.
The algorithm requires the use of several property maps: color, discover time, and root vertex. There are two versions of this algorithm to accommodate whether or not you wish to extend the algorithm with a DFSVisitor.
boost/graph/strong_components.hpp
A strongly connected component of a directed graph G=(V,E) is a maximal set of vertices U which is in V such that for every pair of vertices u and v in U, we have both a path from u to v and path from v to u. That is to say that u and v are reachable from each other.
The time complexity for the strongly connected components algorithm is O(V + E).
See examples/strong_components.cpp.
Copyright © 2000 | Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) |