In graph theory, the diameter of a connected undirected graph is the farthest distance between any two of its vertices. That is, it is the diameter of a set for the set of vertices of the graph, and for the shortest-path distance in the graph. Diameter may be considered either for weighted or for unweighted graphs. Researchers have studied the problem of computing the diameter, both in arbitrary graphs and in special classes of graphs.
The diameter of a disconnected graph may be defined to be infinite, or undefined.
The degree diameter problem seeks tight relations between the diameter, number of vertices, and degree of a graph. One way of formulating it is to ask for the largest graph with given bounds on its degree and diameter. For any fixed degree, this maximum size is exponential in the diameter, with the base of the exponent depending on the degree.
The girth of a graph, the length of its shortest cycle, can be at most
2k+1
k
2k+1
Small-world networks are a class of graphs with low diameter, modeling the real-world phenomenon of six degrees of separation in social networks.
The diameter of a graph can be computed by using a shortest path algorithm to compute shortest paths between all pairs of vertices, and then taking the maximum of the distances that it computes. For instance, in a graph with positive edge weights, this can be done by repeatedly using Dijkstra's algorithm, once for each possible starting vertex. In a graph with
n
m
O(mn+n2logn)
In an unweighted-graph, Dijkstra's algorithm may be replaced by breadth-first search, giving time
O(mn)
n x n
O(n2.37)
O(n2-\varepsilon)
\varepsilon>0
It is possible to approximate the diameter of a weighted graph to within an approximation ratio of 3/2, in time
\tildeO(min(m3/2,mn2/3)
\tildeO
The diameter can be computed in linear time for interval graphs, and in near-linear time for graphs of bounded treewidth. In median graphs, the diameter can be found in the subquadratic time bound
\tildeO(n1.6456)