This preview shows page 1. Sign up to view the full content.
Unformatted text preview: – Nodes are pathnodes in your map – Labels are the distances between connecDng nodes (or other speciﬁc cost informaDon) • G=(V, E) in which each arc v → w has a non
negaDve cost C[v,w]. • Find, for each ordered pair (v,w) the smallest length of any path from v to w. UC Santa Cruz Computer Science – Game Design All Pairs Shortest Path (APSP) Floyd’s Algorithm • Assume the verDces in V are numbered 1,...,n. • Use an n X n matrix in which to compute the lengths of the shortest paths. UC Santa Cruz Computer Science – Game Design All Pairs Shortest Path (APSP) Floyd’s Algorithm • Set A[i,j] = C[i,j] for all i not equal to j. • If there is no arc from i to j, then assume C[i,j] = ∞. • Each diagonal element is set to 0. UC Santa Cruz Computer Science – Game Design All Pairs Shortest Path (APSP) Floyd’s Algorithm • Make n iteraDons over the matrix • On the kth iteraDon, A[i,j] will have for its value the smallest length of any path from i to j that doesn’t pass through a vertex numbered higher than k. UC Santa Cruz Computer Science – Game Design All Pairs Shortest Path (APSP) Floyd’s Algorithm • On the kth iteraDon, use the following formula to compute A Ak
1[i,j] • A[i,j] = min { Ak
1[i,k] + Ak
1[k,j] UC Santa Cruz Computer Science – Game Design All Pairs Shortest Path (APSP) Floyd’s Algorithm • On the kth iteraDon, use the following formula to compute A The cost of going from i Ak
1[i,j] to j without going through • A[i,j] = min { k or any higher node Ak
1[i,k] + Ak
1[k,j] UC Santa Cruz Computer Science – Game Design All Pairs Shortest Path (APSP) Floyd’s Algorithm • On the kth iteraDon, use the following formula to compute A The cost of going from i Ak
1[i,j] to k, then k to j, without • A[i,j] = min { going through any node higher than k....
View
Full
Document
This note was uploaded on 11/10/2010 for the course CMPS 101 taught by Professor Tantalo,p during the Fall '08 term at UCSC.
 Fall '08
 Tantalo,P

Click to edit the document details