Distance matrix is a by matrix that stores the total distance taken to travel from one node to the other.
Stores distance not weight. If unreachable, distance is infinity.
Notation
Distance matrix is commonly notated as .
Example
a | b | c | d | |
---|---|---|---|---|
a | 0 | 10 | 3 | 4 |
b | 2 | 0 | 5 | 6 |
c | 7 | 7 | 0 | 1 |
d | 6 | 16 | 9 | 0 |