Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1.  
  2. for (int k = 0; k < n * (n - 1); k++) {
  3. int first = queue[0];
  4. int second = queue[1];
  5. if (graph[first][second] == 0) {
  6. int j = 2;
  7. while (j < n - 1 && (graph[first][queue[j]] == 0 || graph[second][queue[j + 1]] == 0)) {
  8. j += 1;
  9. }
  10. if (j == n - 1) {
  11. j = 2;
  12. while (j < n && graph[first][queue[j]] == 0) {
  13. j += 1;
  14. }
  15. }
  16. reverse(queue.begin() + 1, queue.begin() + j + 1);
  17. }
  18. queue.pop_front();
  19. queue.push_back(first);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement