ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
StrongComponents.h File Reference

The strongly connected components of an oriented graph by one visit in depth, beyond the book, whose visits and components by the algorithm of Kosaraju are in Visit.h [see Visit.h, which includes this header]: More...

#include "ADS/Contract.h"
#include "ADS/graph/Graph.h"
#include "ADS/graph/Visit.h"
#include <algorithm>
#include <cstddef>
#include <utility>
#include <vector>
#include "ADS/graph/impl/StrongComponents.tpp"

Go to the source code of this file.

Namespaces

namespace  ADS

Functions

template<Graph G>
std::vector< int > ADS::sccTarjan (const G &g)
 the strongly connected components of scc() by one visit in depth, with no transposed graph, numbered as there
template<Graph G>
std::vector< int > ADS::sccPearce (const G &g)
 the strongly connected components of sccTarjan() with one integer and one bit per node in place of three integers, numbered as scc() does

Detailed description

The strongly connected components of an oriented graph by one visit in depth, beyond the book, whose visits and components by the algorithm of Kosaraju are in Visit.h [see Visit.h, which includes this header]:

  • sccTarjan() and sccPearce(), the components of scc() by one visit in depth and no transposed graph (beyond the book): the algorithm of Tarjan keeps the order of discovery and the lowest one reachable through the tree and one more edge of each node, and pops a component off a stack when its first node finishes with the two equal; the variant of Pearce keeps one integer per node instead of three, the two numbers sharing a place and the closed components taking numbers that count down from n - 1 above those in use, and one bit per node. Both number the components as scc() does, in a topological order of the graph of the components.

The visits in depth keep their recursion on an explicit stack, as those of Visit.h. The contracts [see Contract.h]: at the level of the audits each node has a component and the numbers of the components are a topological order of their graph. The functions are defined in StrongComponents.tpp.

See also
R. E. Tarjan, Depth-first search and linear graph algorithms, SIAM Journal on Computing 1(2), 146-160, 1972, doi:10.1137/0201010
D. J. Pearce, A space-efficient algorithm for finding strongly connected components, Information Processing Letters 116(1), 47-52, 2016, doi:10.1016/j.ipl.2015.08.010
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa