Lably
Skip to content

Distance (graph theory)

Length of shortest path between two nodes of a graph

  • 6 min read
  • 5 chapters

Related on Lably

Through Mathematics, Graph (discrete mathematics) and Directed graph

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. 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.

Computational Representation

In graph theory, distances between nodes can be represented computationally by using a distance matrix (also called the all-pairs shortest-path matrix). This is the square matrix (D=(dij)), where each entry (dij) indicates the length of a shortest path between the two vertices (vi) and (vj).

Distance matrices have several applications, which include telecommunications and chemistry. In chemical graph theory, multiple topological indices that characterize molecular structure were able to be derived from the distance matrix.

Beyond exact matrix representations, graph distances can also be represented using metric embeddings. This approach maps the vertices of a graph to points in a geometric space (such as Euclidean space) in a way that preserves the graph distances as closely as possible.

Directed Graph Distance

In a directed graph, edges have an assigned direction, meaning travel between vertices is not necessarily bidirectional. As a result, the distance from u to v may differ from the distance from v to u. This makes directed graph distance a quasi-metric rather than a true metric.

Formally, for vertices u and v in a directed graph G, it is not guaranteed that d(u,v)=d(v,u), and d(u,v) may be undefined if no directed path from u to v exists.

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Topics in mathematics