When considering the shortest paths between two vertices (distance), the diameter of the graph is the number of edges in the longest of those distances. Therefore, to find the diameter of a graph, you need to start by finding the shortest path between each pair of vertices. The longest length of
one of these paths is the diameter of the graph.
one of these paths is the diameter of the graph.