There are several categories of weights:
In addition, there are 2 basic flavors of the algorithms
Here is a table of the algorithms which are used.
|
|
|
| ||||
|
|
|
| ||||
|
|
|
|
A ring is defined by R = (S,Å,Ä,0,1) where S is a set, Ä,Å:S2® S are binary operations. 0 is the identity element of Å and 1 the identity element of Ä. Rings also obey the following rules:
A semiring must satisfy every requirement except for the last.
Given any ring a matrix ring, Rn×n = (Sn×n,Ån×n,Än×n,0n×n,1n×n) can be defined. 0n×n is the 0 matrix and 1n×n is the identity matrix. The addition operator is defined elementwise and the multiplication operator is defined as: An×nÄn×nBn×n = Åk = 1n(AikÄBkj) .
Consider the min,+ ring above. Construct an n×n ring from it. Assign the weights,
Aij =
|
|
| |||
|
|
| |||
|
|
|
To compute all pairs shortest paths, calculate An-1 .
The simplest way to calculate this is by multiply A together n-1 times which has cost O(n4) . This can be cut to O(n3log(n)) by doing the multiplications in a more clever order.