Skip to content

Commit 5eca722

Browse files
committed
Rename w to edge in weighted graphs
1 parent d5a59c7 commit 5eca722

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

javascript/graph-algorithms/p634_Prim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const PrimMST = (G, r) => {
5555
const adj = u.adjacentVertices;
5656
for (let vertex in adj) {
5757
const v = G.V[vertex];
58-
const w = adj[vertex].w.weight;
58+
const w = adj[vertex].edge.weight;
5959
if((v.color === 'WHITE') && (w < v.key)) {
6060
v.pi = u;
6161
Q.decreaseKey(v, w)

javascript/graph-algorithms/p658_Dijkstra.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const dijkstra = (G, s) => {
4545
const adj = u.adjacentVertices;
4646
for (let vertex in adj) {
4747
const v = G.V[vertex];
48-
const w = adj[vertex].w.weight;
48+
const w = adj[vertex].edge.weight;
4949
relax(u, v, w);
5050
}
5151
}

javascript/utilities.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ class WeightedGraph {
129129
});
130130

131131
this.V[u.name].adjacentVertices[v.name] = {
132-
w: this.E[this.E.length - 1]
132+
edge: this.E[this.E.length - 1]
133133
};
134134
this.V[v.name].adjacentVertices[u.name] = {
135-
w: this.E[this.E.length - 1]
135+
edge: this.E[this.E.length - 1]
136136
};
137137
}
138138

@@ -149,7 +149,7 @@ class WeightedGraph {
149149
});
150150

151151
this.V[u.key].adjacentVertices[v.key] = {
152-
w: this.E[this.E.length - 1]
152+
edge: this.E[this.E.length - 1]
153153
};
154154
}
155155
}

0 commit comments

Comments
 (0)