The detour matrix ,
sometimes also called the maximum path matrix or maximal topological distances matrix,
of a graph is a symmetric matrix whose
th entry is the length of the longest path from vertex
to vertex
, or
if there is no such path (Harary 1994, p. 203). The
most common convention (and that adopted here) is to take
.
There is no efficient method for finding the entries of a detour matrix (Harary 1994, p. 203), but the detour matrix can be computed by finding the set of all spanning trees for a given graph, finding their distance
matrices, and setting ,
where the maximum is taken over all spanning trees.
For a graph with vertex count , a detour matrix element of
corresponds to a Hamiltonian
path between vertices
and
. A graph having a detour matrix whose off-diagonal elements
are all equal to
is therefore Hamilton-connected. Similarly,
a bipartite graph whose elements
are maximal for all
and
corresponding to different elements of the vertex bipartition
is Hamilton-laceable.
Precomputed detour matrices for many named graphs are available in the Wolfram Language as GraphData[graph, "DetourMatrix"].