daily pastebin goal
0%
SHARE
TWEET

nth tree rooting

keverman Jan 16th, 2018 37 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int rootTree(int src, int u, int *root, std::vector<int> *edges)
  2. {
  3.     visited[u] = true;
  4.    
  5.     if(edges[u].size() > 1 || u == src)
  6.     {
  7.         for(unsigned int i = 0; i < edges[u].size(); i++)
  8.             if(!visited[edges[u][i]])
  9.                 root[u] += rootTree(src, edges[u][i], root, edges);
  10.     }
  11.    
  12.     return (root[u] += 1);
  13. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top