Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b8788bd

Browse files
Update kth_shortest_path_between_nodes_graph.cpp
1 parent 42b63b9 commit b8788bd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎src/kth_shortest_path_between_nodes_graph.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Usage : getCost O((V + E) lg(V) * k)
44
* Source: https://github.com/dragonslayerx
55
*/
6-
7-
int getCost(graph &G, int s, int t, int k) {
6+
constint INF = 1e9;
7+
int getCost(vector< vector< pair<int,int> > > &G, int s, int t, int k) {
88
int n = G.size();
99
int dist[MAX], count[MAX];
1010
for (int i = 0; i < n; i++) {
@@ -19,15 +19,15 @@ int getCost(graph &G, int s, int t, int k) {
1919
int w = node.first;
2020
Q.pop();
2121
if ((dist[u] == INF) or (w > dist[u])) { // remove equal paths
22-
count[u]++;
23-
dist[u] = w;
22+
count[u]++;
23+
dist[u] = w;
2424
}
2525
if (count[u] <= k) {
26-
for (int i = 0; i < G[u].size(); i++) {
27-
int v = G[u][i].first;
28-
int w = G[u][i].second;
29-
Q.push(make_pair(dist[u] + w, v));
30-
}
26+
for (int i = 0; i < G[u].size(); i++) {
27+
int v = G[u][i].first;
28+
int w = G[u][i].second;
29+
Q.push(make_pair(dist[u] + w, v));
30+
}
3131
}
3232
}
3333
return dist[t];

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /