Ingraph theory, apath in agraph is a finite or infinitesequence ofedges which joins a sequence ofvertices which, by most definitions, are all distinct (and since the vertices are distinct, so are the edges). Adirected path (sometimes calleddipath[1]) in adirected graph 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.
LetG = (V,E,Φ) be a graph. A finite walk is a sequence of edges(e1,e2, ...,en − 1) for which there is a sequence of vertices(v1,v2, ...,vn) such thatΦ(ei) = {vi,vi + 1} fori = 1, 2, ...,n − 1.(v1,v2, ...,vn) is thevertex sequence of the walk. The walk isclosed ifv1 =vn, and it isopen 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 (orray) has a first vertex but no last vertex.
Atrail is a walk in which all edges are distinct.[2]
Apath is a trail in which all vertices (and therefore also all edges) are distinct.[2]
Ifw = (e1,e2, ...,en − 1) is a finite walk with vertex sequence(v1,v2, ...,vn) thenw is said to be awalk fromv1tovn. Similarly for a trail or a path. If there is a finite walk between twodistinct 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 termsimple path to refer to such a path where all vertices are distinct.
Aweighted graph associates a value (weight) with every edge in the graph. Theweight of a walk (or trail or path) in a weighted graph is the sum of the weights of the traversed edges. Sometimes the wordscost orlength are used instead of weight.
Adirected walk is a finite or infinitesequence ofedges directed in the same direction which joins a sequence ofvertices.[2]
LetG = (V,E,Φ) be a directed graph. A finite directed walk is a sequence of edges(e1,e2, ...,en − 1) for which there is a sequence of vertices(v1,v2, ...,vn) such thatΦ(ei) = (vi,vi + 1) fori = 1, 2, ...,n − 1.(v1,v2, ...,vn) is thevertex sequence of the directed walk. The directed walk isclosed ifv1 =vn, and it isopen 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 (orray) has a first vertex but no last vertex.
Adirected trail is a directed walk in which all edges are distinct.[2]
Adirected path is a directed trail in which all vertices are distinct.[2]
Ifw = (e1,e2, ...,en − 1) is a finite directed walk with vertex sequence(v1,v2, ...,vn) thenw is said to be awalk fromv1tovn. Similarly for a directed trail or a path. If there is a finite directed walk between twodistinct vertices then there is also a finite directed trail and a finite directed path between them.
A "simple directed path" is a path where all vertices are distinct.
Aweighted directed graph associates a value (weight) with every edge in the directed graph. Theweight 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 wordscost orlength are used instead of weight.
A graph isconnected if there are paths containing each pair of vertices.
A directed graph isstrongly connected 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 aninduced path.
A path that includes every vertex of the graph without repeats is known as aHamiltonian path.
Two paths arevertex-independent (alternatively,internally disjoint orinternally vertex-disjoint) if they do not have any internal vertex or edge in common. Similarly, two paths areedge-independent (oredge-disjoint) if they do not have any edge in common. Two internally disjoint paths are edge-disjoint, but the converse is not necessarily true.
Thedistance 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.
Several algorithms exist to findshortest andlongest paths in graphs, with the important distinction that the former problem is computationally much easier than the latter.
Dijkstra's algorithm 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 theBellman–Ford algorithm can be applied to directed graphs with negative edge weights. TheFloyd–Warshall algorithm can be used to find the shortest paths between all pairs of vertices in weighted directed graphs.
McCuaig, William (1992)."Intercyclic Digraphs". In Robertson, Neil; Seymour, Paul (eds.).Graph Structure Theory. AMS–IMS–SIAM Joint Summer Research Conference on Graph Minors, Seattle, June 22 – July 5, 1991. American Mathematical Society. p. 205.