diff options
Diffstat (limited to 'graphs-algo/task1.cpp')
| -rw-r--r-- | graphs-algo/task1.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/graphs-algo/task1.cpp b/graphs-algo/task1.cpp index cd96c72..d6d2a83 100644 --- a/graphs-algo/task1.cpp +++ b/graphs-algo/task1.cpp @@ -2,6 +2,7 @@ #include<vector> #include<algorithm> #include<iomanip> +#include<stdio.h> using namespace std; @@ -74,6 +75,7 @@ graph dijkstra(graph g, int n) v = p; } } + if (v == -1) continue; u[s][v] = 1; // Производим релаксации @@ -103,6 +105,11 @@ vector<int> backtrack(graph paths, int start, int end) { path.push_back(cur); cur = paths[start][cur]; + if (cur == -1) + { + path.clear(); + return path; + } } path.push_back(start); reverse(path.begin(), path.end()); |