GraphDistance

As of Version 10, all the functionality of the GraphUtilities package is built into the Wolfram System. >>


gives the distance from vertex i to vertex j in the graph g.

Details and OptionsDetails and Options

  • GraphDistance functionality is now available in the built-in Wolfram Language function GraphDistance.
  • To use , you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
  • returns the graph distance from one vertex to another. Infinity is returned if no path exists from i to j. By default every edge is assumed to have an edge weight of 1.
  • The following option can be used:
  • WeightedFalsespecifies whether edge weight is to be used in calculating distance

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

In[1]:=
Click for copyable input

This defines a simple directed graph:

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

This calculates the distance from vertex 1 to vertex 5:

In[4]:=
Click for copyable input
Out[4]=

This function has been superseded by GraphDistance in the Wolfram System:

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