Weighted Graph
Each edge carries a cost; the setting for shortest paths and spanning trees.
Unsettled vertices with a known distance: 0 at 0. The smallest is 0, so settle it: 0 is final, because every other route into 0 would pass through something at least as far and edges never shorten a path.
What you will see
Edge labels with weights; thicker or longer edges for larger weights where helpful.
Cost
| add edge | O(1) |
|---|---|
| edge weight | O(deg) |
| Space | O(V + E) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.
Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.
Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.
Before this
Taught by the same lesson
Shortest Paths covers these too, in the same run.