In
mathematics
Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
and
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, a shortest-path tree rooted at a
vertex
Vertex, vertices or vertexes may refer to:
Science and technology Mathematics and computer science
*Vertex (geometry), a point where two or more curves, lines, or edges meet
* Vertex (computer graphics), a data structure that describes the positio ...
''v'' of a
connected
Connected may refer to:
Film and television
* ''Connected'' (2008 film), a Hong Kong remake of the American movie ''Cellular''
* '' Connected: An Autoblogography About Love, Death & Technology'', a 2011 documentary film
* ''Connected'' (2015 TV ...
,
undirected
In discrete mathematics, and more specifically in graph theory, a graph is a structure amounting to a set of objects in which some pairs of the objects are in some sense "related". The objects correspond to mathematical abstractions called '' v ...
graph
Graph may refer to:
Mathematics
*Graph (discrete mathematics), a structure made of vertices and edges
**Graph theory, the study of such graphs and their properties
*Graph (topology), a topological space resembling a graph in the sense of discre ...
''G'' is a
spanning tree ''T'' of ''G'', such that the path distance from root ''v'' to any other vertex ''u'' in ''T'' is the
shortest path
In graph theory, the shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized.
The problem of finding the shortest path between ...
distance from ''v'' to ''u'' in ''G''.
In connected graphs where shortest paths are well-defined (i.e. where there are no negative-length cycles), we may construct a shortest-path tree using the following algorithm:
# Compute dist(''u''), the shortest-path distance from root ''v'' to vertex ''u'' in ''G'' using
Dijkstra's algorithm
Dijkstra's algorithm ( ) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and published three years ...
or
Bellman–Ford algorithm
The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph.
It is slower than Dijkstra's algorithm for the same problem, but more versatile, as it i ...
.
# For all non-root vertices ''u'', we can assign to ''u'' a parent vertex ''p
u'' such that ''p''
''u'' is connected to ''u'', and that dist(''p''
''u'') + edge_dist(''p''
''u'',''u'') = dist(''u''). In case multiple choices for ''p
u'' exist, choose ''p''
''u'' for which there exists a shortest path from ''v'' to ''p''
''u'' with as few edges as possible; this tie-breaking rule is needed to prevent loops when there exist zero-length cycles.
# Construct the shortest-path tree using the edges between each node and its parent.
The above algorithm guarantees the existence of shortest-path trees. Like
minimum spanning tree
A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. T ...
s, shortest-path trees in general are not unique.
In graphs for which all edge weights are equal, shortest path trees coincide with
breadth-first search
Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next de ...
trees.
In graphs that have negative cycles, the set of shortest simple paths from ''v'' to all other vertices do not necessarily form a tree.
For simple connected graphs, shortest-path trees can be used
to suggest a non-linear relationship between two network
centrality measures,
closeness and
degree
Degree may refer to:
As a unit of measurement
* Degree (angle), a unit of angle measurement
** Degree of geographical latitude
** Degree of geographical longitude
* Degree symbol (°), a notation used in science, engineering, and mathematics
...
. By assuming that the branches of the shortest-path trees are statistically similar for any root node in one network, one may show that the size of the branches depend only on the number of branches connected to the root vertex, i.e. to the degree of the root node. From this one deduces that the inverse of closeness, a length scale associated with each vertex, varies approximately linearly with the logarithm of degree. The relationship is not exact but it captures a correlation between closeness and degree in large number of networks constructed from real data
and this success suggests that shortest-path trees can be a useful approximation in network analysis.
See also
*
Shortest path problem
References
References
Spanning tree
{{combin-stub