Professional Documents
Culture Documents
Chapter 6
Network Model
Shortest-Route Algorithms
1. Dijkstra’s algorithm
2. Floyd’s algorithm
Floyd’s algorithm
The algorithm represents an n-node network as a (n x n)
square matrix.
dij is the distance from node i to node j, which is finite if
i is linked directly to j, and infinite otherwise.
The idea of Floyd’s algorithm is that if dik + dkj < dij it is
optimal to replace the direct route from i j with the
indirect route i k j. This is called triple operation.
Example 6.3-5
For the network in Figure, find the shortest routes
between every two nodes. The distances
(in miles) are given on the arcs. Arc (3, 5) is
directional—no traffic is allowed from node 5 to
node 3. All the other arcs allow two-way traffic.
D0
n\n 1 2 3 4 5
1 — 3 10
2 3 — 5
3 — 6 15
4 5 6 — 4
5 4 —
Iteration 0
Define the starting
distance matrix D0
and node sequence
matrix S0 (all
diagonal elements
are blocked).
General rules (Step k)
Set k = 1. Define row k and column k as pivot row
and pivot column. Apply the triple operation to each
element dij in Dk - 1, for all i and j. If the condition
dik + dkj < dij, (i ≠ k, j ≠ k, and i ≠ j)
is satisfied, make the following changes: