|
5 | 5 | //! vector<vector<int>> adj(n); |
6 | 6 | //! vector<pii> edges(m); |
7 | 7 | //! UF uf(n); |
| 8 | +//! vector<bool> seen(n); |
8 | 9 | //! 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) { |
10 | 19 | //! // nodes[0] <=> nodes[1] is a bridge |
11 | | -//! // (if no multiple edges) |
12 | | -//! // if multiple edges, then join them too in uf |
13 | 20 | //! return; |
14 | 21 | //! } |
15 | 22 | //! for (int v : nodes) uf.join(v, nodes[0]); |
|
23 | 30 | //! } |
24 | 31 | //! } |
25 | 32 | //! |
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; |
29 | 35 | //! 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 | +//! } |
36 | 41 | //! }); |
37 | 42 | //! @endcode |
38 | 43 | //! callback not called on components with a single node |
|
0 commit comments