In
graph theory
In mathematics, graph theory is the study of ''graphs'', which are mathematical structures used to model pairwise relations between objects. A graph in this context is made up of '' vertices'' (also called ''nodes'' or ''points'') which are conne ...
, a path in a
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 ...
is a finite or infinite
sequence
In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is calle ...
of
edges which joins a sequence of
vertices which, by most definitions, are all distinct (and since the vertices are distinct, so are the edges). A directed path (sometimes called dipath
[Graph Structure Theory: Proceedings of the AMS-IMS-SIAM Joint Summer Research Conference on Graph Minors, Held June 22 to July 5, 1991]
p.205
/ref>) in a directed graph
In mathematics, and more specifically in graph theory, a directed graph (or digraph) is a graph that is made up of a set of vertices connected by directed edges, often called arcs.
Definition
In formal terms, a directed graph is an ordered pa ...
is a finite or infinite sequence of edges which joins a sequence of distinct vertices, but with the added restriction that the edges be all directed in the same direction.
Paths are fundamental concepts of graph theory, described in the introductory sections of most graph theory texts. See e.g. Bondy and Murty (1976), Gibbons (1985), or Diestel (2005). Korte et al. (1990) cover more advanced algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algorithms are used as specificat ...
ic topics concerning paths in graphs.
Definitions
Walk, trail, and path
* A walk is a finite or infinite sequence
In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is calle ...
of edges which joins a sequence of vertices.
: Let be a graph. A finite walk is a sequence of edges for which there is a sequence of vertices such that ''ϕ''(''e''''i'') = for . is the ''vertex sequence'' of the walk. The walk is ''closed'' if ''v''1 = ''v''''n'', and it is ''open'' otherwise. An infinite walk is a sequence of edges of the same type described here, but with no first or last vertex, and a semi-infinite walk (or ray) has a first vertex but no last vertex.
* A trail is a walk in which all edges are distinct.
* A path is a trail in which all vertices (and therefore also all edges) are distinct.
If is a finite walk with vertex sequence then ''w'' is said to be a ''walk from'' ''v''1 ''to'' ''v''''n''. Similarly for a trail or a path. If there is a finite walk between two ''distinct'' vertices then there is also a finite trail and a finite path between them.
Some authors do not require that all vertices of a path be distinct and instead use the term simple path to refer to such a path where all vertices are distinct.
A weighted graph
This is a glossary of graph theory. Graph theory is the study of graphs, systems of nodes or vertices connected in pairs by lines or edges.
Symbols
A
B
...
associates a value (''weight'') with every edge in the graph. The ''weight of a walk'' (or trail or path) in a weighted graph is the sum of the weights of the traversed edges. Sometimes the words ''cost'' or ''length'' are used instead of weight.
Directed walk, directed trail, and directed path
* A directed walk is a finite or infinite sequence
In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is calle ...
of edges directed in the same direction which joins a sequence of vertices.
: Let be a directed graph. A finite directed walk is a sequence of edges for which there is a sequence of vertices such that for . is the ''vertex sequence'' of the directed walk. The directed walk is ''closed'' if ''v''1 = ''v''''n'', and it is ''open'' otherwise. An infinite directed walk is a sequence of edges of the same type described here, but with no first or last vertex, and a semi-infinite directed walk (or ray) has a first vertex but no last vertex.
* A directed trail is a directed walk in which all edges are distinct.
* A directed path is a directed trail in which all vertices are distinct.
If is a finite directed walk with vertex sequence then ''w'' is said to be a ''walk from'' ''v''1 ''to'' ''v''''n''. Similarly for a directed trail or a path. If there is a finite directed walk between two ''distinct'' vertices then there is also a finite directed trail and a finite directed path between them.
Some authors do not require that all vertices of a directed path be distinct and instead use the term simple directed path to refer to such a directed path.
A weighted directed graph associates a value (''weight'') with every edge in the directed graph. The ''weight of a directed walk'' (or trail or path) in a weighted directed graph is the sum of the weights of the traversed edges. Sometimes the words ''cost'' or ''length'' are used instead of weight.
Examples
* A graph is 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 ...
if there are paths containing each pair of vertices.
* A directed graph is strongly connected
In the mathematical theory of directed graphs, a graph is said to be strongly connected if every vertex is reachable from every other vertex. The strongly connected components of an arbitrary directed graph form a partition into subgraphs that ...
if there are oppositely oriented directed paths containing each pair of vertices.
* A path such that no graph edges connect two nonconsecutive path vertices is called an induced path
In the mathematical area of graph theory, an induced path in an undirected graph is a path that is an induced subgraph of . That is, it is a sequence of vertices in such that each two adjacent vertices in the sequence are connected by an edg ...
.
* A path that includes every vertex of the graph without repeats is known as a Hamiltonian path
In the mathematical field of graph theory, a Hamiltonian path (or traceable path) is a path in an undirected or directed graph that visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a cycle that visits each vertex ...
.
* Two paths are ''vertex-independent'' (alternatively, ''internally vertex-disjoint'') if they do not have any internal vertex in common. Similarly, two paths are ''edge-independent'' (or ''edge-disjoint'') if they do not have any internal edge in common. Two internally vertex-disjoint paths are edge-disjoint, but the converse is not necessarily true.
* The distance
Distance is a numerical or occasionally qualitative measurement of how far apart objects or points are. In physics or everyday usage, distance may refer to a physical length or an estimation based on other criteria (e.g. "two counties over"). ...
between two vertices in a graph is the length of a shortest path between them, if one exists, and otherwise the distance is infinity.
* The diameter of a connected graph is the largest distance (defined above) between pairs of vertices of the graph.
Finding paths
Several algorithms exist to find shortest and longest paths in graphs, with the important distinction that the former problem is computationally much easier than the latter.
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 ...
produces a list of shortest paths from a source vertex to every other vertex in directed and undirected graphs with non-negative edge weights (or no edge weights), whilst the 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 is ...
can be applied to directed graphs with negative edge weights. The Floyd–Warshall algorithm
In computer science, the Floyd–Warshall algorithm (also known as Floyd's algorithm, the Roy–Warshall algorithm, the Roy–Floyd algorithm, or the WFI algorithm) is an algorithm for finding shortest paths in a directed weighted graph with p ...
can be used to find the shortest paths between all pairs of vertices in weighted directed graphs.
See also
* Glossary of graph theory
This is a glossary of graph theory. Graph theory is the study of graphs, systems of nodes or vertices connected in pairs by lines or edges.
Symbols
A
B
...
* Path graph
In the mathematical field of graph theory, a path graph or linear graph is a graph whose vertices can be listed in the order such that the edges are where . Equivalently, a path with at least two vertices is connected and has two termina ...
* Polygonal chain
In geometry, a polygonal chain is a connected series of line segments. More formally, a polygonal chain is a curve specified by a sequence of points (A_1, A_2, \dots, A_n) called its vertices. The curve itself consists of the line segments co ...
* Shortest path problem
* Longest path problem
In graph theory and theoretical computer science, the longest path problem is the problem of finding a simple path of maximum length in a given graph. A path is called ''simple'' if it does not have any repeated vertices; the length of a path ma ...
* 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 ...
* 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 is ...
* Floyd–Warshall algorithm
In computer science, the Floyd–Warshall algorithm (also known as Floyd's algorithm, the Roy–Warshall algorithm, the Roy–Floyd algorithm, or the WFI algorithm) is an algorithm for finding shortest paths in a directed weighted graph with p ...
* Self-avoiding walk
In mathematics, a self-avoiding walk (SAW) is a sequence of moves on a lattice (a lattice path) that does not visit the same point more than once. This is a special case of the graph theoretical notion of a path. A self-avoiding polygon (SAP) ...
*Shortest-path graph
In mathematics and geographic information science, a shortest-path graph is an undirected graph defined from a set of points in the Euclidean plane. The shortest-path graph is proposed with the idea of inferring edges between a point set such t ...
References
*
*
*
*
*
{{Authority control
Graph theory objects
Graph connectivity