[
next
] [
prev
] [
prev-tail
] [
tail
] [
up
]
12.6
All Pairs Shortest Paths (Floyd-Warshall)
c(i,j,k): cost of going from node
i
to node
j
with only
{
1
,
...
,k
}
available as intermediate nodes.
FOR k=1 TO n
FOR i=1 TO n
FOR j=1 TO n
c(i,j,k) = min( c(i,j,k-1),
c(i,k,k-1)+c(k,j,k-1)
)
k
=
Ø
a
b
c
d
e
f
a
1
7
5
b
7
3
c
1
2
d
8
e
4
f
k
=
{
a
}
a
b
c
d
e
f
a
1
7
5
b
7,b-a-c
,b-a-d
3,b-a-e
,b-a-f
c
,c-a-d
1,c-a-e
2,c-a-f
d
8,d-a-e
,d-a-f
e
4,e-a-f
f
k
=
{
a,b
}
k
=
{
a,b,c
}
k
=
{
a,b,c,d
}
k
=
{
a,b,c,d,e
}
k
=
{
a,b,c,d,e,f
}
[
next
] [
prev
] [
prev-tail
] [
front
] [
up
]