Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. void Solve(const vector<vector<int>>& graph, int curr, int parent, int depth,
  2.                     vector<bool>& visited, vector<int>& min_depth_can_reach, vector<Edge>& res) {
  3.     visited[curr] = true;
  4.     min_depth_can_reach[curr] = depth;
  5.  
  6.     for (auto adj : graph[curr]) {
  7.         if (adj == parent) continue;
  8.         if (!visited[adj])
  9.             Solve(graph, adj, curr, depth + 1, visited, min_depth_can_reach, res);
  10.  
  11.         min_depth_can_reach[curr] = min(min_depth_can_reach[curr], min_depth_can_reach[adj]);
  12.  
  13.         if (min_depth_can_reach[adj] > depth) // bridge found
  14.             res.push_back(Edge(curr, adj));
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement