Skip to content

Commit c9241cd

Browse files
committed
Make generic Tarjan's algorithm publically available
This enables outside users to find SCCs, not just count them as previously.
1 parent 64d5dd2 commit c9241cd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/util/graph.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class grapht
253253
std::vector<node_indext> &subgraph_nr);
254254

255255
// return value: number of SCCs
256-
std::size_t SCCs(std::vector<node_indext> &subgraph_nr);
256+
std::size_t SCCs(std::vector<node_indext> &subgraph_nr) const;
257257

258258
bool is_dag() const
259259
{
@@ -290,7 +290,7 @@ class grapht
290290
}
291291
};
292292

293-
void tarjan(class tarjant &t, node_indext v);
293+
void tarjan(class tarjant &t, node_indext v) const;
294294

295295
void shortest_path(
296296
node_indext src,
@@ -515,7 +515,7 @@ std::size_t grapht<N>::connected_subgraphs(
515515
}
516516

517517
template<class N>
518-
void grapht<N>::tarjan(tarjant &t, node_indext v)
518+
void grapht<N>::tarjan(tarjant &t, node_indext v) const
519519
{
520520
t.scc_stack.push(v);
521521
t.in_scc[v]=true;
@@ -559,7 +559,7 @@ void grapht<N>::tarjan(tarjant &t, node_indext v)
559559
}
560560

561561
template<class N>
562-
std::size_t grapht<N>::SCCs(std::vector<node_indext> &subgraph_nr)
562+
std::size_t grapht<N>::SCCs(std::vector<node_indext> &subgraph_nr) const
563563
{
564564
tarjant t(nodes.size(), subgraph_nr);
565565

0 commit comments

Comments
 (0)