Skip to content

Commit 301cd46

Browse files
authored
Merge pull request #1969 from smowton/smowton/cleanup/document_sccs_guarantee
Document grapht::SCCs
2 parents 18478e9 + 9c04abd commit 301cd46

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/util/graph.h

+12
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,18 @@ void grapht<N>::tarjan(tarjant &t, node_indext v) const
633633
}
634634
}
635635

636+
/// Computes strongly-connected components of a graph and yields a vector
637+
/// expressing a mapping from nodes to components indices. For example, if nodes
638+
/// 1 and 3 are in SCC 0, and nodes 0, 2 and 4 are in SCC 1, this will leave
639+
/// `subgraph_nr` holding `{ 1, 0, 1, 0, 1 }`, and the function will return 2
640+
/// (the number of distinct SCCs).
641+
/// Lower-numbered SCCs are closer to the leaves, so in the particular case
642+
/// of a DAG, sorting by SCC number gives a topological sort, and for a cyclic
643+
/// graph the SCCs are topologically sorted but arbitrarily ordered internally.
644+
/// \param subgraph_nr [in, out]: should be pre-allocated with enough storage
645+
/// for one entry per graph node. Will be populated with the SCC indices of
646+
/// each node.
647+
/// \return the number of distinct SCCs.
636648
template<class N>
637649
std::size_t grapht<N>::SCCs(std::vector<node_indext> &subgraph_nr) const
638650
{

0 commit comments

Comments
 (0)