Classic Algorithm Solutions: Step-by-Step Examples
1) DIJKSTRA (SSSP) — STEP TABLE (PAST-PAPER INSTANCE A)
Given edges: a→b(2), a→c(7), a→e(10), b→d(2), c→d(1), c→g(2), d→f(2), e→g(1), f→g(2). Source = a.
Rule: Pick unsettled vertex with minimum dist; relax outgoing edges.
Vertices: a b c d e f g
Init:
Dist = 0 2 7 ∞ 10 ∞ ∞
S = ∅
Step 1: Pick a (min=0), S={a}
Relax from a: already set b=2, c=7, e=10
Dist = 0 2 7 ∞ 10 ∞ ∞
Step 2: Pick b (min=2), S={a,b}
Relax b→d: dist(d) = dist(b)+2 = 2+2 = 4
Dist = 0 2 7 4 10 ∞ ∞
Step 3: Pick d (min=4), S={a,b,d}
Relax d→f: dist(f) = 4+2 = 6
Dist = 0 2 7 4 10 6 ∞
Step 4: Pick f (min=6), S={a,b,d,f}
Relax f→g: dist(g) = 6+2 = 8
Dist... Continue reading "Classic Algorithm Solutions: Step-by-Step Examples" »
English with a size of 5.78 KB