Walks, Paths, and Cycles
How many fundamentally different ways can you move through a graph? This simple question turns out to organize an enormous amount of graph theory. A traveler moving along edges from vertex to vertex might repeat streets, revisit intersections, or do neither. Each restriction produces a different combinatorial object with its own name and theory. Distinguishing walks, trails, paths, and cycles is not pedantic bookkeeping. It is the vocabulary that later lets us state precise theorems. These cover connectivity, Eulerian circuits, and Hamiltonian cycles, all without ambiguity. The big picture is a hierarchy of increasingly restrictive notions of "movement" through a graph. A walk is the most permissive: any sequence of adjacent vertices. There is no restriction at all on repetition. A trail forbids reusing edges. A path forbids reusing vertices, which automatically forbids reusing edges as well. Circuits and cycles are the closed versions of trails and paths. They are walks that return to their starting point. Each restriction rules out a class of pathological behavior. Examples include infinite backtracking, retracing the same street, or looping around a block twice. Each is exactly the right notion for a different theorem later on. Why does this matter? Many of the deepest classical theorems in graph theory concern precisely these objects. They ask which of these objects exist. Euler's theorem on the bridges of Königsberg is one example. It states the existence of a closed trail using every edge exactly once. The Traveling Salesman Problem and Hamiltonian cycle theory are about paths and cycles. These use every vertex exactly once. Connectivity itself is defined in terms of the existence of paths between vertices. None of these statements can even be phrased correctly. This is true without the careful distinctions this article establishes. This article gives the formal definitions. It proves the basic structural facts relating walks, trails, and paths. Most importantly: every walk between distinct vertices contains a path between them. It also works through nontrivial examples that expose common points of confusion. These particularly concern edge-repetition versus vertex-repetition. Also covered is the special handling of closed walks.
- A walk is a vertex-edge sequence with no repetition restrictions; a trail is a walk with no repeated edges; a path is a walk with no repeated vertices.
- Closed versions get their own names: a closed walk that is a trail is a circuit; a closed walk that is a path (except for the shared start/end) is a cycle.
- Every walk between two distinct vertices contains a path between the same two vertices — this is the key structural theorem of the article.
- Path ⟹ trail ⟹ walk, and these implications are strict: trails need not be paths, and walks need not be trails.
- Length is measured in edges traversed (with multiplicity for walks/trails), not in vertices visited.
- Key idea: restricting how much repetition is allowed in a walk produces a strict hierarchy of objects, and the passage from "some walk exists" to "a path exists" is a genuine theorem, not a definition.
Where this lives today
The walk/trail/path/cycle hierarchy is the load-bearing vocabulary of essentially all of algorithmic graph theory. Breadth-first and depth-first search algorithms are, at their core, procedures for finding shortest paths and detecting cycles efficiently, relying on exactly the extraction principle proved above to guarantee that reachability (a walk exists) is equivalent to the existence of a path. In network routing and telecommunications, finding a path (not merely a walk) between two nodes is essential to avoid wasted bandwidth from revisiting the same link. In cryptography and coding theory, cycle structure in graphs underlies constructions of expander graphs and error-correcting codes. In chemistry and bioinformatics, Eulerian trails (from Eulerian Graphs and Circuits) model DNA sequencing via the reconstruction of genome fragments, while Hamiltonian cycles (from Hamiltonian Graphs) model the Traveling Salesman Problem central to logistics and operations research. In pure mathematics, the notion of connectivity — whether a path exists between every pair of vertices — is the entry point to the theory of Connectivity and Components, which itself underlies network reliability theory and the structure theory of graphs more broadly.
Ask the tutor: Can you show step-by-step how the excision algorithm turns a specific messy closed walk into an Eulerian circuit or a simple cycle?
Let be a graph (loops and multiple edges allowed unless stated otherwise). A walk of length in is a sequence
where , , and each is an edge joining and . The vertices and are the endpoints; is the start and is the end. If is simple, the walk may be written unambiguously as just the vertex sequence , since each consecutive pair determines a unique edge.
- The walk is closed if , and open otherwise.
- A trail is a walk in which no edge is repeated: for all .
- A path is a walk in which no vertex is repeated: for all (in particular , so a path is automatically open, unless ).
- A circuit is a closed trail: a closed walk with no repeated edges.
- A cycle (of length in a simple graph, allowing loops/multi-edges) is a closed walk in which are pairwise distinct and no edge is repeated.
The length of a walk, trail, path, circuit, or cycle is the number of edges traversed (counted with multiplicity for walks and trails). A walk of length is the trivial walk consisting of a single vertex and is considered both a (trivial) trail and a (trivial) path.
Intuition
Picture a graph as a map of intersections (vertices) joined by roads (edges). A walk is what happens if you drive with no memory at all: you might drive down the same road five times, and pass through the same intersection over and over, perhaps even doing a small back-and-forth (which is only possible if the graph has parallel edges or you retrace a single edge, i.e., an edge traversed and then immediately traversed back to ). A trail is a walk taken by someone who refuses to drive down any road twice — but who might still pass through the same intersection more than once, arriving from a different direction each time and leaving on a road not yet used. A path is the walk of someone with a much stronger constraint: never revisit any intersection at all, which forces every road used to be used only once as well. The closed variants matter because "returning home" is qualitatively different from "ending up somewhere new." A circuit is a round trip using no road twice (but possibly passing through some intersections more than once along the way, always excepting the shared start/end vertex which is visited exactly at the beginning and the end). A cycle is the cleanest round trip of all: it revisits no intersection at all except that the very last stop coincides with the very first. The picture below shows a single small graph together with a walk that repeats an edge, a trail in the same graph that reuses a vertex but not an edge, and a path that repeats nothing.
The extraction principle
The single most important structural fact tying these definitions together is that repetition can always be removed: if you can get from to at all by any walk, however wasteful, you can get from to by a path. This is the content of the theorem below, and it is what makes "connectivity" (defined via paths) equivalent to "reachability" (naturally phrased via walks).
Let be a graph and let be distinct vertices. If there exists a walk in from to , then there exists a path in from to .
We use strong induction on the length of the walk, together with an extremal (minimal-length) argument to make the inductive step constructive and non-circular.
Base case (). A walk of length from to is a single edge joining and . Since , the sequence has no repeated vertex, so it is itself a path from to of length .
Inductive step. Let and suppose the claim holds for every pair of distinct vertices joined by a walk of length strictly less than (strong induction hypothesis). Let
be a walk of length with , , . Case 1: has no repeated vertex. Then is already a path from to by definition, and we are done. Case 2: has a repeated vertex. Then there exist indices with . Choose such a pair with minimal among all repeated-vertex pairs (this minimum exists because the set of positive integers arising this way is a nonempty finite set of positive integers, so it has a least element). Form the shortened sequence
obtained by deleting the sub-walk from to and identifying . Since consecutive vertices in are still joined by the corresponding original edges, is a walk from to of length (strictly shorter, since ). We claim has no repeated vertex, i.e. is already a path, which will let us finish without even needing the full strength of the inductive hypothesis — but to keep the induction airtight in general, we argue as follows. Suppose toward contradiction has a repeated vertex, say for some indices of corresponding to indices of not both lying in (since we already removed the repeat at ) and with, translating back to indices in the original walk , a gap smaller than , OR a gap equal in a different location. More carefully: any repeated pair in corresponds to a repeated pair of vertices in at two indices (after the natural relabeling) with , because is a sub-sequence of obtained by excising an interval, and any two surviving positions are strictly closer together in "original index gap" than positions that had the excised interval strictly between them, and positions entirely before or entirely after keep their original gaps which by minimality of cannot be repeats with gap smaller than unless the gap is not smaller — contradicting minimality of chosen among all repeated pairs of . Hence no such repeat can occur, and has no repeated vertex. Therefore is itself a path from to (of length since forces at least one edge). This establishes the claim for length , completing the induction. By strong induction, for every , every walk of length from to (distinct vertices) yields a path from to . Since any walk between distinct vertices has length at least , the theorem follows.
∎Let be vertices of joined by at least one walk. Then: 1. There is a trail from to (immediate, since every path is a trail). 2. A walk of minimum length among all – walks is automatically a path.
Part (1) follows immediately from Path Extraction, since the path produced is in particular a trail (no repeated vertices implies no repeated edges: if edge with , both being simple edges joining and , then in a simple graph this would force as vertex sets, and combined with the walk structure this produces a repeated vertex, contradicting the path property; in a multigraph the same edge cannot be traversed via two different vertex pairs at all, so repetition of vertex indices used by the very same edge object already violates the path condition directly at those endpoints). For part (2): let be a walk from to of minimum length among all - walks. If had a repeated vertex, the excision argument in the proof of Path Extraction would produce a strictly shorter – walk with , contradicting minimality of . Hence has no repeated vertex, i.e., is a path.
∎Worked examples
Example 1 (Distinguishing all three notions in one non-symmetric graph). Let have vertex set and edge set
(so is a 5-cycle ––––– with one extra chord ). Consider the sequence
Check adjacency: are all edges of (note and are the same edges listed differently, which is fine — edges are unordered pairs). So is a walk of length .
- Is a trail? Its edges in order are . As a multiset these are — all six are distinct edges of (recall ), so no edge repeats. Hence is a trail. Since it starts and ends at the same vertex , it is in fact a circuit, and since it uses every edge of exactly once, it is an Eulerian circuit (a notion developed further in Eulerian Graphs and Circuits).
- Is a path? No: the vertex appears at position and again at position . So is a circuit but not a cycle in the strict sense (a cycle would require no interior vertex repetition at all, only start = end).
- Extract a path from to using as raw material. The sub-walk of from to is — this has a repeated vertex ( at positions and ). Apply the excision from the proof: delete the segment strictly between the two occurrences of , i.e. delete "" and merge, giving . Check: and are edges of , and are pairwise distinct. So is a path from to of length , exactly as the extraction theorem guarantees, and indeed it is even a shortest – walk (length 2, since and are not adjacent... wait, they are adjacent via edge ! Let's recheck: , so the walk of length exists and is shorter). This shows the extracted path need not be a shortest path — extraction guarantees a path, not the shortest one. The genuinely shortest – walk is (length 1), which by the corollary is automatically a path (trivially, one edge, two distinct vertices).
This example illustrates a common subtlety: path-extraction from an arbitrary walk gives some path, not necessarily a minimum-length one, unless the input walk was already minimum-length.
Example 2 (A walk that is not a trail, and locating the cycle inside it). Let have vertices and edges (a 4-cycle). Consider
Check adjacency: — all valid edges of . So is a walk of length from to .
- Edges used, with multiplicity: appears at positions and ; appears at positions and . Two edges are each used twice. Hence is not a trail (edges repeat), and consequently not a path either (trails are necessary for paths, since path trail).
- Vertices repeat too: vertex at positions ; vertex at positions ; vertex at positions .
- Extract a path from to via the proof's algorithm: find a repeated-vertex pair with minimal index gap. The repeated pairs are with gap , with gap , and with gap . All gaps are ; take the first found, . Excise the interior, giving (deleting the middle "" between the two 's and relabeling). Check: this is exactly the walk , using edges , with all vertices distinct — a valid path of length from to .
- Independently, notice itself contains the cycle (its first four steps) as a genuine closed sub-walk with distinct interior vertices — a nice illustration that a "messy" walk can contain a clean cycle as a substructure even though the walk as a whole is not one.
Why each hypothesis is needed
The theorem Path Extraction requires . If we instead ask whether every closed walk (where ) of length must contain a cycle through , the natural-sounding strengthening is false in general when the walk's length is not large enough or when the walk is allowed to be a trivial back-and-forth. Concretely, let have vertices and a single edge (so ). Consider the closed walk
of length : it starts and ends at , using the edge twice (once each direction). This is a walk, and even a closed walk, but it is not a circuit (the edge is repeated) and it contains no cycle at all through , because has no cycle whatsoever (a cycle needs length in a simple graph, and has only one edge). The extraction theorem, as stated, only promises a path between distinct endpoints — it says nothing about closed walks producing cycles, precisely because the endpoint-distinctness hypothesis is what drives the excision argument (a repeated vertex pair with itself as one of the two endpoints, e.g. trivially, does not yield a nontrivial cycle when the "walk between the repeat" is too short or when the graph structurally has no cycles at all, such as in a tree — see Connectivity and Components for why trees have unique paths and no cycles). This shows the theorem's scope is exactly the open-walk, distinct-endpoint setting; the closed-walk analogue (that a closed walk of length that is not null-homotopically trivial contains a genuine cycle) requires extra hypotheses (e.g. the closed walk must not simply retrace an edge back and forth, and more careful bookkeeping is needed, which belongs to the theory in Eulerian Graphs and Circuits rather than to this basic extraction fact).
Scope, edge cases & common traps
| Situation | What holds | Common mistake |
|---|---|---|
| Walk between distinct | Contains a path between (proved above) | Assuming the extracted path is automatically shortest |
| Closed walk () | May contain a cycle, or may not (e.g. trivial back-and-forth, or acyclic graph) | Assuming every closed walk of length yields a cycle |
| Multigraphs / parallel edges | Two parallel edges between the same pair give a cycle of length : | Forgetting that "cycle of length " is a simple-graph convention; multigraphs allow length-2 cycles |
| Loops | A loop at is sometimes counted as a cycle of length ; conventions vary by textbook | Silently assuming loops are automatically excluded |
| Trail vs. path | Every path is a trail, not conversely | Using "trail" and "path" interchangeably |
| Length convention | Length = number of edges, not number of vertices | Off-by-one errors counting vertices instead of edges |
The mathematician behind it
Origins · 1 minLeonhard Euler and how this was discovered
Euler's 1736 resolution of the Seven Bridges of Königsberg problem is the founding act of graph theory, and it is precisely a theorem about the existence of a particular kind of closed trail — what we now call a circuit using every edge exactly once. To even state Euler's theorem one needs the trail/walk distinction made in this article: Euler's insight was that the question "can I walk the city crossing each bridge exactly once" is a question about trails (no edge repeated), completely independent of how many times any given intersection (vertex) is revisited. This separation of "no repeated edges" from "no repeated vertices" is the conceptual seed from which the modern definitions of walk, trail, path, and cycle all grew, later formalized rigorously in the 19th and 20th centuries as graph theory matured into an independent field.
Is a single vertex, with no edges traversed, considered a walk?
Yes. The definition allows length : the sequence consisting of just with no edges is the trivial walk. It is vacuously a trail (no edges to repeat) and vacuously a path (only one vertex, so no repetition is possible). This convention matters for base cases in inductive proofs and for stating that every vertex is trivially "connected to itself" by a path of length , which is needed to make the connectivity relation reflexive in Connectivity and Components.
Why do cycles require length at least 3 in a simple graph, but not necessarily in a multigraph?
In a simple graph there is at most one edge between any two vertices, so returning to your starting vertex after only or edges would either repeat the same edge (length 2: go out and immediately back along the only available edge) or not be a valid distinct-edge closed walk at all. A genuine cycle needs at least vertices to form a closed loop without reusing an edge. In a multigraph, however, two parallel edges between the same pair of vertices give a valid closed trail of length with no repeated edge, which is legitimately called a -cycle by some authors (conventions vary, so always check the source's definition).
Is every trail automatically a path, since repeated edges seem like they'd force repeated vertices anyway?
No — this is one of the most important distinctions in the article. A trail forbids repeated edges but permits repeated vertices, as long as those revisits use different edges. For instance, in a graph shaped like a "bowtie" (two triangles sharing a single vertex ), the trail that goes around one triangle back to and then around the other triangle revisits exactly once in the middle, using entirely different edges each time. This is a valid trail but not a path, because the vertex appears twice.
How does path extraction relate to finding shortest paths algorithmically?
The corollary that a minimum-length walk is automatically a path is exactly the theoretical justification for why breadth-first search, which explores walks in increasing order of length, correctly finds shortest paths without needing a separate check for repeated vertices. If BFS ever produced a shortest walk with a repeated vertex, that walk could be shortened by excision, contradicting minimality — so the algorithm's output is guaranteed path-like "for free," a fact that would otherwise require separate verification.
Does the path-extraction theorem hold in directed graphs as well?
Yes, with directed walks, trails, and paths defined analogously using directed edges (arcs) respecting orientation, the same excision argument applies verbatim: if a directed walk from to () revisits a vertex, the sub-walk between the two visits can be excised, and the direction of all remaining edges is unaffected because we only delete a contiguous directed sub-walk and glue two already-compatible endpoints together. The proof techniques transfer without modification, though closed structures behave differently since "directed cycles" impose a consistent orientation constraint not present in the undirected case.
If a graph has no cycles at all (a tree or forest), what does that say about walks?
In an acyclic graph, between any two distinct vertices there is at most one path, and consequently every walk between two distinct vertices in a tree, however long and repetitive, extracts down to that unique path. This is because if two distinct paths existed between the same pair of vertices, their union would necessarily contain a cycle (a fact proved in Connectivity and Components), contradicting acyclicity. Trees are thus the extreme case where the "many possible walks, but a canonical extracted path" phenomenon of this article becomes as simple as possible: there is only one path to extract, no matter which walk you start with.