AllPairsShortestPath

As of Version 10, most of the functionality of the Combinatorica package is built into the Wolfram System. >>

AllPairsShortestPath[g]
gives a matrix, where the ^(th) entry is the length of a shortest path in g between vertices and .

AllPairsShortestPath[g,Parent]
returns a three-dimensional matrix with dimensions 2*V[g]*V[g], in which the ^(th) entry is the length of a shortest path from to and the ^(th) entry is the predecessor of in a shortest path from to .

更多信息更多信息

范例范例打开所有单元关闭所有单元

基本范例  (2)基本范例  (2)

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=

AllPairsShortestPath has been superseded by GraphDistanceMatrix:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=