Skip to content
Snippets Groups Projects
Commit 449c4c68 authored by Kevin Lin's avatar Kevin Lin
Browse files

lessons: Rename 'bestKnownWeight' -> 'oldWeight'

parent c74ae9c8
No related branches found
No related tags found
No related merge requests found
Pipeline #528734 passed with stages
in 46 seconds
......@@ -413,11 +413,11 @@ public class PrimMST<V> implements MSTSolver<V> {
for (Edge<V> edge : graph.neighbors(from)) {
V to = edge.to;
double bestKnownWeight = distTo.getOrDefault(to, Double.POSITIVE_INFINITY);
double oldWeight = distTo.getOrDefault(to, Double.POSITIVE_INFINITY);
// Diff 3. Check that we haven't added the vertex to the MST already...
// AND this edge is better than the previous best edge to this vertex
// (infinity if this vertex has not been encountered before).
if (!visited.contains(to) && edge.weight < bestKnownWeight) {
if (!visited.contains(to) && edge.weight < oldWeight) {
edgeTo.put(to, edge);
// Diff 1. Store the edge weight rather than distance from start.
distTo.put(to, edge.weight);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment