Skip to content

Commit ec84b7f

Browse files
committed
nits to example init
1 parent c59af51 commit ec84b7f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

library/graphs/bridges_cuts/bcc_callback.hpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
//! vector<vector<int>> adj(n);
66
//! vector<pii> edges(m);
77
//! UF uf(n);
8+
//! vector<bool> seen(n);
89
//! bcc_callback(adj, [&](const vi& nodes) {
9-
//! if (sz(nodes) == 2) {
10+
//! int count_edges = 0;
11+
//! rep (i, 0, sz(nodes) - 1) {
12+
//! seen[nodes[i]] = 1;
13+
//! for (int v : adj[nodes[i]]) if (!seen[v]) {
14+
//! // edge nodes[i] <=> v is in current BCC
15+
//! count_edges++;
16+
//! }
17+
//! }
18+
//! if (count_edges == 1) {
1019
//! // nodes[0] <=> nodes[1] is a bridge
11-
//! // (if no multiple edges)
12-
//! // if multiple edges, then join them too in uf
1320
//! return;
1421
//! }
1522
//! for (int v : nodes) uf.join(v, nodes[0]);
@@ -23,16 +30,14 @@
2330
//! }
2431
//! }
2532
//!
26-
//! vector<basic_string<int>> adj(n);
27-
//! vector<basic_string<array<int, 2>>> adj_edge_ids(n);
28-
//! vector<bool> seen(m);
33+
//! vector<basic_string<int>> adj(n), block_vertex_tree(2 * n);
34+
//! int bcc_id = n;
2935
//! bcc_callback(adj, [&](const vi& nodes) {
30-
//! rep (i, 0, sz(nodes) - 1)
31-
//! for (auto [v, e_id] : adj_edge_ids[nodes[i]])
32-
//! if (!seen[e_id]) {
33-
//! seen[e_id] = 1;
34-
//! // this edge is in the current BCC
35-
//! }
36+
//! for (int v : nodes) {
37+
//! block_vertex_tree[v] += bcc_id;
38+
//! block_vertex_tree[bcc_id] += v;
39+
//! bcc_id++;
40+
//! }
3641
//! });
3742
//! @endcode
3843
//! callback not called on components with a single node

0 commit comments

Comments
 (0)