# Distance (graph theory)

## Length of shortest path between two nodes of a graph / From Wikipedia, the free encyclopedia

#### Dear Wikiwand AI, let's keep it short by simply answering these key questions:

Can you list the top facts and stats about Graph diameter?

Summarize this article for a 10 year old

In the mathematical field of graph theory, the **distance** between two vertices in a graph is the number of edges in a shortest path (also called a **graph geodesic**) connecting them. This is also known as the **geodesic distance** or **shortest-path distance**.^{[1]} Notice that there may be more than one shortest path between two vertices.^{[2]} If there is no path connecting the two vertices, i.e., if they belong to different connected components, then conventionally the distance is defined as infinite.

In the case of a directed graph the distance *d*(*u*,*v*) between two vertices u and v is defined as the length of a shortest directed path from u to v consisting of arcs, provided at least one such path exists.^{[3]} Notice that, in contrast with the case of undirected graphs, *d*(*u*,*v*) does not necessarily coincide with *d*(*v*,*u*)—so it is just a quasi-metric, and it might be the case that one is defined while the other is not.