Graph Diameter Calculator

max shortest path

CalculatorsFreeNo Signup
4.5(634 reviews)
All Tools

Loading tool...

About Graph Diameter Calculator

A graph diameter calculator finding diam(G) = max{d(u,v)} over all vertex pairs. Uses BFS for unweighted graphs. diam(K_n)=1, diam(P_n)=n-1, diam(C_n)=⌊n/2⌋. Infinite for disconnected graphs. Client-side.

Graph Diameter Calculator Features

  • diam(G)
  • All-pairs distances
  • Common graphs
  • Eccentricity max
  • Radius compare
Graph diameter diam(G) = max d(u,v): the longest shortest-path distance. Measures how 'spread out' a graph is. diam(K_n)=1, diam(path P_n)=n-1, diam(cycle C_n)=⌊n/2⌋. For disconnected G: diam=∞.

How to Use

Select graph:

  • Diameter: Max distance
  • Pair: Diametral pair
  • Compare: To radius

Bounds

rad(G) ≤ diam(G) ≤ 2·rad(G). For trees: diam = longest path. For regular graphs: diam ≤ ⌊log n / log(d-1)⌋ approximately. Small-world networks have diam ∝ log n.

Applications

Network design (worst-case communication delay), social networks (six degrees of separation = diameter ≈ 6), protein interaction networks, transportation (longest necessary trip). Small diameter = efficient network.

Step-by-Step Instructions

  1. 1Select graph.
  2. 2Compute diameter.
  3. 3Find diametral pair.
  4. 4Compare to radius.
  5. 5Check bounds.

Graph Diameter Calculator — Frequently Asked Questions

How is diameter computed?+

For unweighted: BFS from each vertex, track max distance. O(n·(n+m)). For weighted: Floyd-Warshall O(n³) or n×Dijkstra O(n·m·log n). For sparse graphs, BFS is preferred.

What's a diametral pair?+

Vertices u,v achieving d(u,v)=diam(G). There can be multiple such pairs. In a path P_n, the diametral pair is the two endpoints. In a cycle C_n, every pair of antipodal vertices.

What about disconnected graphs?+

If G is disconnected, diam(G)=∞ (some pairs have no path). We typically report diameter per connected component, or say the effective diameter is the maximum over components.

Share this tool: