Macaulay2 » Documentation
Packages » Graphs :: diameter(Graph)
next | previous | forward | backward | up | index | toc

diameter(Graph) -- 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 this method: