Distance (graph theory)
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. Notice that there may be more than one shortest path between two vertices. 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 between two vertices and is defined as the length of a shortest path from to consisting of arcs, provided at least one such path exists. Notice that, in contrast with the case of undirected graphs, does not necessarily coincide with , and it might be the case that one is defined while the other is not.
A metric space defined over a set of points in terms of distances in a graph defined over the set is called a graph metric. The vertex set (of an undirected graph) and the distance function form a metric space, if and only if the graph is connected.
The diameter of a graph is the maximum eccentricity of any vertex in the graph. That is, it is the greatest distance between any pair of vertices or, alternatively, . To find the diameter of a graph, first find the shortest path between each pair of vertices. The greatest length of any of these paths is the diameter of the graph.
A pseudo-peripheral vertex has the property that for any vertex , if is as far away from as possible, then is as far away from as possible. Formally, a vertex u is pseudo-peripheral, if for each vertex v with holds .
Algorithm for finding pseudo-peripheral vertices
Often peripheral sparse matrix algorithms need a starting vertex with a high eccentricity. A peripheral vertex would be perfect, but is often hard to calculate. In most circumstances a pseudo-peripheral vertex can be used. A pseudo-peripheral vertex can easily be found with the following algorithm:
- Choose a vertex .
- Among all the vertices that are as far from as possible, let be one with minimal degree.
- If then set and repeat with step 2, else is a pseudo-peripheral vertex.
- Distance matrix
- Resistance distance
- Degree diameter problem for graphs and digraphs
- Metric graph