next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Graphs :: diameter

diameter -- Computes the diameter of a graph

Synopsis

Description

The diameter of a graph is the maximum of the distances between all the vertexSet of G. If the graph is not connected, the diameter is infinity.

i1 : G = graph({{1,2},{2,3},{3,4}},EntryMode=>"edges");
i2 : d = diameter G

o2 = 3
i3 : G = graph({1,2,3,4},{{2,3},{3,4}});
i4 : d = diameter G

o4 = infinity

o4 : InfiniteNumber

See also

Ways to use diameter :

For the programmer

The object diameter is a method function.