PseudoDiameter
PseudoDiameter[g]
give the pseudo-diameter of the undirected graph g, and the two vertices that achieve this diameter.
Details and Options
- PseudoDiameter functionality is now available in the built-in Wolfram Language function GraphDiameter.
- To use PseudoDiameter, you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
- A graph geodesic is a shortest path between two vertices of a graph. The graph diameter is the longest possible length of all graph geodesics of the graph. PseudoDiameter finds an approximate graph diameter. It works by starting from a vertex u, and finds a vertex v that is farthest away from u. This process is repeated by treating v as the new starting vertex, and ends when the graph distance no longer increases. A vertex from the last level set that has the smallest degree is chosen as the final starting vertex u, and a traversal is done to see if the graph distance can be increased. This graph distance is taken to be the pseudo-diameter.
- If the graph is disconnected, then the diameter and vertices for each connected component are returned.
- The following option can be given:
-
Aggressive False whether to make extra effort in finding the optimal graph diameter
Examples
open allclose allBasic Examples (2)Summary of the most common use cases

https://wolfram.com/xid/0d5mo6uj1ucvq-dafuas
The pseudo-diameter of the graph of a square is 2:

https://wolfram.com/xid/0d5mo6uj1ucvq-rvz

https://wolfram.com/xid/0d5mo6uj1ucvq-ov9

PseudoDiameter has been superseded by GraphDiameter:

https://wolfram.com/xid/0d5mo6uj1ucvq-hi209b

https://wolfram.com/xid/0d5mo6uj1ucvq-4bylv

Scope (1)Survey of the scope of standard use cases

https://wolfram.com/xid/0d5mo6uj1ucvq-btf9gn
A graph with disconnected components:

https://wolfram.com/xid/0d5mo6uj1ucvq-pj6

PseudoDiameter returns a list with pseudo-diameters and vertices for each component:

https://wolfram.com/xid/0d5mo6uj1ucvq-l2r

Wolfram Research (2007), PseudoDiameter, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html.
Text
Wolfram Research (2007), PseudoDiameter, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html.
Wolfram Research (2007), PseudoDiameter, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html.
CMS
Wolfram Language. 2007. "PseudoDiameter." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html.
Wolfram Language. 2007. "PseudoDiameter." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html.
APA
Wolfram Language. (2007). PseudoDiameter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html
Wolfram Language. (2007). PseudoDiameter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html
BibTeX
@misc{reference.wolfram_2025_pseudodiameter, author="Wolfram Research", title="{PseudoDiameter}", year="2007", howpublished="\url{https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html}", note=[Accessed: 02-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_pseudodiameter, organization={Wolfram Research}, title={PseudoDiameter}, year={2007}, url={https://reference.wolfram.com/language/GraphUtilities/ref/PseudoDiameter.html}, note=[Accessed: 02-April-2025
]}