Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int k = 0; k < n * (n - 1); k++) {
- int first = queue[0];
- int second = queue[1];
- if (graph[first][second] == 0) {
- int j = 2;
- while (j < n - 1 && (graph[first][queue[j]] == 0 || graph[second][queue[j + 1]] == 0)) {
- j += 1;
- }
- if (j == n - 1) {
- j = 2;
- while (j < n && graph[first][queue[j]] == 0) {
- j += 1;
- }
- }
- reverse(queue.begin() + 1, queue.begin() + j + 1);
- }
- queue.pop_front();
- queue.push_back(first);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement