This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

GraphDiameter

GraphDiameter[g]
gives the maximum eccentricity of the vertices in the graph g.
Give the graph diameter for a complete graph:
Give the graph diameter for a complete graph:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
GraphDiameter works with undirected graphs:
Directed graphs:
Weighted graphs:
Large graphs:
People at a family gathering:
Use Subsets to create edges between all members of the family:
The resulting social graph:
Find the largest number of steps separating two people at the gathering:
For a connected graph, the diameter can be computed by VertexEccentricity:
If a simple graph has diameter greater than 3, then its complement has diameter less than 3:
The graph diameter is unchanged when reversing every edge:
The graph radius does change:
Illustrate the diameter in two Petersen graphs:
For a CompleteGraph, the diameter is 1:
For a PathGraph of size , the diameter is :
For a CycleGraph of size , the diameter is :
For a WheelGraph of size 5 or more, the diameter is 2:
A WheelGraph of size 4 is a complete graph, so the diameter is 1:
For a GridGraph of size , the diameter is :
For a CompleteKaryTree tree of depth , the diameter is :
New in 8