Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
1,293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. void divideandconquer(int current, int total)
  2. {
  3.  
  4. if(total == 1)return;
  5.  
  6. dfs(current, -1);
  7.  
  8. int newcenter = findcenter(current, -1, total);
  9.  
  10. delete[center] = 1;
  11.  
  12.  
  13. // Add the conditions needed to be checked with the current center
  14.  
  15. int sum = 0, nextinline = -1;
  16.  
  17. for(int i=0;i<(int)adjacency_list[center].size();i++)
  18. {
  19. int next = adjacency_list[center][i];
  20.  
  21. if(delete[next])continue;
  22.  
  23. if(size[next] < size[center])
  24. {
  25. divide_conquer(next, size[next] + 1);
  26. sum += size[next] + 1;
  27. }
  28. else
  29. nextinline = next;
  30. }
  31.  
  32. if(nextline != -1)
  33. divide_conquer(nextinline, total - sum - 1);
  34. return ;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement