Skip to content

Commit 18e780e

Browse files
lrvideckisweb-flow
andauthored
Doc nit (#140)
* nit at docs * [auto-verifier] verify commit 053684f * different style of handling multiple edges for bridges --------- Co-authored-by: GitHub <noreply@github.com>
1 parent 8396676 commit 18e780e

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

.verify-helper/timestamps.remote.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
"tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600",
5151
"tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600",
5252
"tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600",
53-
"tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp": "2025-06-23 20:06:38 -0600",
54-
"tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_two_edge_cc.test.cpp": "2025-06-23 20:06:38 -0600",
55-
"tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 20:06:38 -0600",
56-
"tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp": "2025-06-23 20:06:38 -0600",
53+
"tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp": "2025-06-23 20:30:30 -0600",
54+
"tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_two_edge_cc.test.cpp": "2025-06-23 20:30:30 -0600",
55+
"tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 20:30:30 -0600",
56+
"tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp": "2025-06-23 20:30:30 -0600",
5757
"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2025-02-10 23:30:47 -0700",
5858
"tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-12-14 19:50:29 -0600",
5959
"tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-12-14 19:50:29 -0600",

library/graphs/bridges_cuts/bcc_callback.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
//! vector<pii> edges(m);
77
//! UF uf(n);
88
//! bcc_callback(adj, [&](const vi& nodes) {
9-
//! if (sz(nodes) == 2)
10-
//! return; // is bridge assuming no multiple edges
9+
//! if (sz(nodes) == 2) {
10+
//! // nodes[0] <=> nodes[1] is a bridge
11+
//! // (if no multiple edges)
12+
//! // if multiple edges, then join them too in uf
13+
//! return;
14+
//! }
1115
//! for (int v : nodes) uf.join(v, nodes[0]);
1216
//! });
1317
//! vector<basic_string<int>> bridge_tree(n);

tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,25 @@ int main() {
88
int n, m;
99
cin >> n >> m;
1010
vector<basic_string<int>> adj(n);
11-
vector<basic_string<array<int, 2>>> adj_e_id(n);
12-
for (int i = 0; i < n; i++) {
13-
adj[i] += i;
14-
adj_e_id[i] += {i, i};
15-
}
11+
for (int i = 0; i < n; i++) adj[i] += i;
12+
vector<array<int, 2>> edges(m);
1613
for (int i = 0; i < m; i++) {
1714
int u, v;
1815
cin >> u >> v;
1916
adj[u] += v;
2017
adj[v] += u;
21-
adj_e_id[u] += {v, n + i};
22-
adj_e_id[v] += {u, n + i};
18+
if (u > v) swap(u, v);
19+
edges[i] = {u, v};
2320
}
2421
UF uf(n);
25-
vector<bool> seen(n + m);
22+
ranges::sort(edges);
23+
for (int i = 1; i < m; i++)
24+
if (edges[i - 1] == edges[i])
25+
uf.join(edges[i][0], edges[i][1]);
2626
bcc_callback(adj, [&](const vi& nodes) {
2727
assert(sz(nodes) >= 2);
28-
int cnt_edges = 0;
29-
rep(i, 0, sz(nodes) - 1) for (auto [v, e_id] :
30-
adj_e_id[nodes[i]]) if (!seen[e_id] &&
31-
v != nodes[i]) {
32-
seen[e_id] = 1;
33-
cnt_edges++;
34-
}
35-
if (cnt_edges >= 2)
36-
for (int v : nodes) uf.join(v, nodes[0]);
28+
if (sz(nodes) == 2) return;
29+
for (int v : nodes) uf.join(v, nodes[0]);
3730
});
3831
vector<basic_string<int>> two_edge_ccs(n);
3932
rep(i, 0, n) two_edge_ccs[uf.find(i)] += i;

0 commit comments

Comments
 (0)