distanceMatrix -- Computes the distance matrix of a digraph

Synopsis

• Usage:
M = distanceMatrix(G)
• Inputs:
• G, an instance of the type Digraph,
• Outputs:
• M, , the distance matrix of G

Description

The distance matrix is the matrix where entry M_(i,j) corresponds to the distance between vertex indexed i and vertex indexed j in the specified graph. If the distance between two vertexSet is infinite (i.e. the vertexSet are not connected) the matrix lists the distance as -1.

 i1 : G = graph({{1,2},{2,3},{3,4}},EntryMode=>"edges"); i2 : d = distanceMatrix G o2 = | 0 1 2 3 | | 1 0 1 2 | | 2 1 0 1 | | 3 2 1 0 | 4 4 o2 : Matrix ZZ <--- ZZ i3 : G = digraph({1,2,3,4},{{2,3},{3,4}},EntryMode=>"edges"); i4 : d = distanceMatrix G o4 = | 0 -1 -1 -1 | | -1 0 1 2 | | -1 -1 0 1 | | -1 -1 -1 0 | 4 4 o4 : Matrix ZZ <--- ZZ

• diameter(Graph) -- Computes the diameter of a graph
• distance -- Computes the distance between two vertexSet in a graph

Ways to use distanceMatrix :

• "distanceMatrix(Digraph)"

For the programmer

The object distanceMatrix is .