In other words, the diameter of a graph is the greatest number of edges in an undirected graph or arcs in a directed graph that we can find between two distinct vertices in this graph.

### Example

The diameter of the graph below is 4. In fact, the greatest distance between the vertices A and E is given by the length of the chain A – B – C – D – E.