Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSE 373
23wi
website
Commits
449c4c68
Commit
449c4c68
authored
2 years ago
by
Kevin Lin
✨
Browse files
Options
Downloads
Patches
Plain Diff
lessons: Rename 'bestKnownWeight' -> 'oldWeight'
parent
c74ae9c8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#528734
passed with stages
in 46 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lessons/graphs.md
+2
-2
2 additions, 2 deletions
lessons/graphs.md
with
2 additions
and
2 deletions
lessons/graphs.md
+
2
−
2
View file @
449c4c68
...
...
@@ -413,11 +413,11 @@ public class PrimMST<V> implements MSTSolver<V> {
for
(
Edge
<
V
>
edge
:
graph
.
neighbors
(
from
))
{
V
to
=
edge
.
to
;
double
bestKnown
Weight
=
distTo
.
getOrDefault
(
to
,
Double
.
POSITIVE_INFINITY
);
double
old
Weight
=
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
<
bestKnown
Weight
)
{
if
(!
visited
.
contains
(
to
)
&&
edge
.
weight
<
old
Weight
)
{
edgeTo
.
put
(
to
,
edge
);
// Diff 1. Store the edge weight rather than distance from start.
distTo
.
put
(
to
,
edge
.
weight
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment