Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Solve(const vector<vector<int>>& graph, int curr, int parent, int depth,
- vector<bool>& visited, vector<int>& min_depth_can_reach, vector<Edge>& res) {
- visited[curr] = true;
- min_depth_can_reach[curr] = depth;
- for (auto adj : graph[curr]) {
- if (adj == parent) continue;
- if (!visited[adj])
- Solve(graph, adj, curr, depth + 1, visited, min_depth_can_reach, res);
- min_depth_can_reach[curr] = min(min_depth_can_reach[curr], min_depth_can_reach[adj]);
- if (min_depth_can_reach[adj] > depth) // bridge found
- res.push_back(Edge(curr, adj));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement