12 std::vector<std::vector<int>>
graph;
13 std::vector<int> in_time, out_time;
15 std::vector<std::vector<int>> bridge;
16 std::vector<bool> visited;
17 void dfs(
int current_node,
int parent) {
18 visited.at(current_node) =
true;
19 in_time[current_node] = out_time[current_node] = timer++;
20 for (
auto& itr :
graph[current_node]) {
25 dfs(itr, current_node);
26 if (out_time[itr] > in_time[current_node]) {
27 bridge.push_back({itr, current_node});
30 out_time[current_node] =
31 std::min(out_time[current_node], out_time[itr]);
36 std::vector<std::vector<int>> search_bridges(
37 int n,
const std::vector<std::vector<int>>& connections) {
41 visited.assign(n,
false);
42 out_time.assign(n, 0);
43 for (
auto& itr : connections) {
44 graph.at(itr[0]).push_back(itr[1]);
45 graph.at(itr[1]).push_back(itr[0]);