d = diameter G
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