1

xd[x]parent[x]
s0-
ainf-
binf-
cinf-
dinf-

Visit s

xd[x]parent[x]
s0-
a4s
b8s
c7s
dinf-

Visit a

xd[x]parent[x]
s0-
a4s
b8s
c7s
d12a

Visit c

xd[x]parent[x]
s0-
a4s
b8s
c7s
d11c

Visit b

xd[x]parent[x]
s0-
a2b
b8s
c7s
d11c

Visit d

xd[x]parent[x]
s0-
a2b
b8s
c7s
d11c

Shortest path computed is 11 via s,c,d.

  1. [..]
  2. We can do a topological sort before running Dijkstra’s (no negative cycle) Or we can re-add nodes into the priority queue whenever we handle a negative edge
  3. Exponential running time

2

Create a list L, keep removing ‘roots’ until graph is empty.

a->b, a->c, b->d

  • Remove a
  • Remove b
  • Remove c
  • Remove d

Therefore, a,b,c,d.

3

s,b,f,h,a,e,g,c,k,d

4

s,b,a,k,h,c,d,e,f,g

5

Q = (s) Visit s

xd[x]parent[x]
s0-
u-2s
vinf-
x5s
yinf-

Q = (u,x) Visit u

xd[x]parent[x]
s0-
u-2s
v-1u
x4u
yinf-

Q = (x,v) Visit x

xd[x]parent[x]
s0-
u-2s
v-1u
x4u
y6x

Q = (v,y) Visit v

xd[x]parent[x]
s0-
u-2s
v-1u
x-6v
y3v

Q = (y,x) Visit y

xd[x]parent[x]
s0-
u-2s
v-1u
x-6v
y3v

Q = (x) Visit x

xd[x]parent[x]
s0-
u-3s
v-1u
x-6v
y3v

Q = (y) Visit y

xd[x]parent[x]
s0-
u-3s
v-1u
x-6v
y-4x

Q = ()