Advertisement
Guest User

Untitled

a guest
Aug 24th, 2012
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. void dfs(int x) {
  2.     vis[x] = 1;
  3.     nivel[x] = menor[x] = cont++;
  4.     int sons = 0;
  5.     REP(i, graph[x].size()) {
  6.         if(vis[graph[x][i]] == 0) {
  7.             sons += 1;
  8.             pai[graph[x][i]] = x;
  9.             dfs(graph[x][i]);
  10.             if(menor[graph[x][i]] < menor[x]) menor[x] = menor[graph[x][i]];
  11.             if(menor[graph[x][i]] == nivel[graph[x][i]]) {
  12.                bridges += 1
  13.             }
  14.         } else if(vis[graph[x][i]] == 1 && pai[x] != graph[x][i]) {
  15.             if(nivel[graph[x][i]] < menor[x]) menor[x] = nivel[graph[x][i]];
  16.         }
  17.     }
  18.     vis[x] = 2;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement