Skip to content

Commit 4f6c501

Browse files
committed
Document grapht::SCCs
The security product was relying on the SCC ordering this function produces, so we thought we ought to document our expectation that SCCs were topologically ordered.
1 parent 0b17511 commit 4f6c501

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/util/graph.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,17 @@ void grapht<N>::tarjan(tarjant &t, node_indext v) const
601601
}
602602
}
603603

604+
/// Populate a vector giving an SCC index for each node. For example, if nodes
605+
/// 1 and 3 are in SCC 0, and nodes 0, 2 and 4 are in SCC 1, this will leave
606+
/// `subgraph_nr` holding `{ 1, 0, 1, 0, 1 }`, and the function will return 2
607+
/// (the number of distinct SCCs).
608+
/// Lower-numbered SCCs are closer to the leaves, so in the particular case
609+
/// of a DAG, sorting by SCC number gives a topological sort, and for a cyclic
610+
/// graph the SCCs are topologically sorted but arbitrarily ordered internally.
611+
/// \param subgraph_nr [in, out]: should be pre-allocated with enough storage
612+
/// for one entry per graph node. Will be populated with the SCC indices of
613+
/// each node.
614+
/// \return the number of distinct SCCs.
604615
template<class N>
605616
std::size_t grapht<N>::SCCs(std::vector<node_indext> &subgraph_nr) const
606617
{

0 commit comments

Comments
 (0)