GraphDiameter
✖
GraphDiameter
Details and Options

- The following options can be given:
-
EdgeWeight Automatic weight for each edge Method Automatic method to use - With the default setting EdgeWeight->Automatic, the edge weight of an edge is taken to be the EdgeWeight of the graph g if available; otherwise, it is 1.
- Possible Method settings include "Dijkstra", "FloydWarshall", "Johnson", and "PseudoDiameter".
- GraphDiameter works with undirected graphs, directed graphs, weighted graphs, multigraphs, and mixed graphs.

Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (7)Survey of the scope of standard use cases
GraphDiameter works with undirected graphs:

https://wolfram.com/xid/05fvxus4fq-dy6dt4


https://wolfram.com/xid/05fvxus4fq-c4jban


https://wolfram.com/xid/05fvxus4fq-dc7o48


https://wolfram.com/xid/05fvxus4fq-uvnf7h


https://wolfram.com/xid/05fvxus4fq-5geyu

Use rules to specify the graph:

https://wolfram.com/xid/05fvxus4fq-bndh30

GraphDiameter works with large graphs:

https://wolfram.com/xid/05fvxus4fq-cddhqp

https://wolfram.com/xid/05fvxus4fq-l2vea2

Applications (2)Sample problems that can be solved with this function
Illustrate the diameter in two Petersen graphs:

https://wolfram.com/xid/05fvxus4fq-hf6au8

https://wolfram.com/xid/05fvxus4fq-begywe

For a CompleteGraph, the diameter is 1:

https://wolfram.com/xid/05fvxus4fq-199oob

For a PathGraph of size , the diameter is
:

https://wolfram.com/xid/05fvxus4fq-nan2hv

For a CycleGraph of size , the diameter is
:

https://wolfram.com/xid/05fvxus4fq-xdcrj5

For a WheelGraph of size 5 or more, the diameter is 2:

https://wolfram.com/xid/05fvxus4fq-3nsp14

A WheelGraph of size 4 is a complete graph, so the diameter is 1:

https://wolfram.com/xid/05fvxus4fq-xyoniq

For a GridGraph of size {m,n}, the diameter is :

https://wolfram.com/xid/05fvxus4fq-85xu8b

For a CompleteKaryTree tree of depth , the diameter is
:

https://wolfram.com/xid/05fvxus4fq-bwecfz

Find the largest number of steps separating two people at a family gathering network:

https://wolfram.com/xid/05fvxus4fq-hc7ipt


https://wolfram.com/xid/05fvxus4fq-d8i6l7

Properties & Relations (3)Properties of the function, and connections to other functions
For a connected graph, the diameter can be computed by VertexEccentricity:

https://wolfram.com/xid/05fvxus4fq-b74jc


https://wolfram.com/xid/05fvxus4fq-p1igzl


https://wolfram.com/xid/05fvxus4fq-gihody

If a simple graph has diameter greater than 3, then its complement has diameter less than 3:

https://wolfram.com/xid/05fvxus4fq-l8baf


https://wolfram.com/xid/05fvxus4fq-42x2y


https://wolfram.com/xid/05fvxus4fq-pa5v

The graph diameter is unchanged when reversing every edge:

https://wolfram.com/xid/05fvxus4fq-6m9vb

https://wolfram.com/xid/05fvxus4fq-elsv0u


https://wolfram.com/xid/05fvxus4fq-cbztik

Wolfram Research (2010), GraphDiameter, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDiameter.html (updated 2015).
Text
Wolfram Research (2010), GraphDiameter, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDiameter.html (updated 2015).
Wolfram Research (2010), GraphDiameter, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphDiameter.html (updated 2015).
CMS
Wolfram Language. 2010. "GraphDiameter." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphDiameter.html.
Wolfram Language. 2010. "GraphDiameter." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphDiameter.html.
APA
Wolfram Language. (2010). GraphDiameter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphDiameter.html
Wolfram Language. (2010). GraphDiameter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphDiameter.html
BibTeX
@misc{reference.wolfram_2025_graphdiameter, author="Wolfram Research", title="{GraphDiameter}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphDiameter.html}", note=[Accessed: 19-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_graphdiameter, organization={Wolfram Research}, title={GraphDiameter}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphDiameter.html}, note=[Accessed: 19-June-2025
]}