Walks, Trails, Paths and Cycles
A walk is a sequence with each the edge ; its length is the number of edges. A trail is a walk that repeats no edge; a path is a walk that repeats no vertex (so it repeats no edge either). A walk is closed if ; a closed path whose only repeat is , of length at least , is a cycle. The pentagon-with-chord pictured below, call it , has vertices and edges.
Walk, trail and path nest inside one another — every path is a trail and every trail is a walk — because each extra adjective forbids one more kind of repetition. The distinction matters because the theorems ahead are each about a specific one of these: a shortest walk between two vertices is automatically a path, since a repeated vertex could always be cut out to shorten it, so "distance" between vertices is really a statement about paths; Euler's theorem (Topic 6) asks for a trail using every edge once; and Menger's theorem below is about counting paths, not walks.
In , follow . The edges used are — but is the same edge as , used a second time. So this closed walk of length is not a trail (and, since and each occur twice, not a path either).
Follow . The five edges used, , are all different from each other, so this is a trail. But the vertex appears twice, as the third and the sixth stop, so it is not a path: the walk passes through on its way to , then returns to before finally stopping.
A -cycle needs four distinct vertices joined in a closed loop. Try : the edges , , , are all present in — the chord is exactly what makes this possible — and no vertex repeats before closing back to . So is a -cycle.
The walk has length and ends at , but it visits twice. Delete everything between the two visits to — the detour — and what is left is , a path of length from to , and in fact the shortest one, since and are not adjacent. This is why a shortest walk between two vertices is always a path: a repeated vertex always hides a shortcut.
Length counts edges, not stops. The walk has stops but length , and even that overcounts the distinct vertices visited: only appear, with twice. It is also neither a trail nor a path, since the edge is used twice (once in each direction) and repeats.
What is in — a walk, a trail, a path, or a cycle?
Show the answerHide the answer
The five edges used, , are all distinct, so it is a trail; the only repeated vertex is , which is also the start and the end, so it is in fact a closed path — a cycle, of length .
Connected Components
Vertices and are connected if some walk joins them. This is an equivalence relation on ("Why It Works" proves it), and its equivalence classes are the connected components of ; itself is connected exactly when it has one component.
Reflexivity needs only the trivial length- walk from a vertex to itself; symmetry comes from walking a path backwards; transitivity from joining two walks end to end. Because it is an equivalence relation, the components partition with no overlaps and no vertex left out — even an isolated vertex, with no edges at all, is its own component of size . Listing the components, or testing whether two vertices share one, is exactly what breadth-first search computes (Topic 5).
Let consist of three pieces glued by nothing at all: the pentagon-with-chord from the last section (connected internally by its edges), a separate triangle on (edges ), and a single vertex with no edges whatsoever. No edge joins any of the three groups, so has exactly components, of sizes , and — and accounts for every one of its vertices.
has vertices and edges — the same count a connected graph on vertices could have — yet it is not connected. Each new edge can join at most two different components into one, reducing the component count by at most ; starting from components, reaching needs at least new edges, and is enough (for instance and ). So edges suffice, and no fewer will do.
Is there a walk from to in ? Every edge of lies entirely inside one of the three listed vertex sets, , , , so a walk starting at can never reach a vertex outside — in particular never . Contrast this with and , joined directly by the edge : they are connected, and in fact adjacent.
It is tempting to think enough edges guarantee a connected graph. has edges on vertices, more than the a tree on vertices would need (Topic 4), and is still disconnected. Edges only help if they cross between pieces; piling edges inside one piece, like the chord , does nothing for the pieces left out.
Add the single edge to . How many components does the result have, and what are their sizes?
Show the answerHide the answer
merges the -vertex piece and the -vertex piece into one -vertex component; is untouched. So there are components, of sizes and .
Counting Walks with Matrix Powers
If is the adjacency matrix of (Topic 1), with rows and columns indexed by , then for every the entry equals the number of walks of length from to . In particular the diagonal entries count closed walks at .
The reason is the same one that makes matrix multiplication the right operation at all: sums, over every neighbor of , the walks of length from to followed by the one edge — exactly the walks of length that end at by way of . "Why It Works" turns this into an induction on . The payoff is that a question about paths through a whole graph becomes ordinary arithmetic, and it is this fact that makes the adjacency matrix (introduced for its own sake in Topic 1) earn its keep.
The graph on with edges is two triangles, and , sharing the edge — sometimes called a diamond. In the vertex order its adjacency matrix is
Row of comes from , summed over 's neighbors . For : — the walks and , matching the common neighbors of and . The full matrix is
and its diagonal, , is exactly the degree sequence: a closed walk of length at is "step out an edge, step straight back," and there are choices of which edge.
In a simple graph, a closed walk of length can never repeat a vertex (two equal vertices among would force a loop or a repeated edge within a single step), so every closed length- walk is a genuine triangle, traversed from one of its vertices in one of directions — walks per triangle. So the number of triangles is . Computing gives diagonal , so , and the diamond has triangles — exactly and , as expected.
. Check this by listing every length- walk from to : starting gives , , ; starting gives and ( is not a walk, since is not an edge). That is walks in all, matching the matrix entry.
is not a count of anything but the edges, doubled: it equals by the handshake lemma (Topic 1), since every edge contributes exactly one there-and-back walk from each of its two ends. There are zero genuine -vertex cycles in a simple graph, so unlike , the trace of never counts cycles.
Without recomputing, find .
Show the answerHide the answer
Swapping and fixing is an automorphism of the diamond, since and have the same neighbors, . So .
Cut Vertices and Bridges
A vertex of a connected graph is a cut vertex if — delete and every edge at — is disconnected. An edge is a bridge if is disconnected. Both are single points of failure: removing one breaks the whole graph into pieces.
A connected graph with no cut vertex and no bridge has some redundancy built in: between any two vertices there is more than one way around, made precise by Menger's theorem below. Cut vertices and bridges are where that redundancy runs out. Topic 5's depth-first search finds every one of them in a single pass, by tracking how far back up the search tree each vertex can still reach.
Let be the graph on with edges — two triangles joined by a bridge, with a pendant hanging off the second. Test each vertex by deleting it and checking what is left connected: deleting , or leaves the rest joined through the other triangle edges, so none of these is a cut vertex. Deleting splits off from ; deleting splits from ; deleting splits off alone. So the cut vertices are . The same test on edges shows only and disconnect when removed — every other edge sits inside one of the two triangles, which stays connected without any one of its edges — so the bridges are and .
The bridge has two ends, but only one, , is a cut vertex. has degree , and deleting a degree- vertex can never disconnect what remains, since nothing else depended on reaching through it. In general, an endpoint of a bridge fails to be a cut vertex exactly when it is a leaf — compare and , the two ends of the other bridge , both of degree and both cut vertices.
In the "bowtie" graph on with two triangles, and , sharing only the vertex , every edge lies inside a triangle, so there is no bridge at all. Yet is a cut vertex: deleting it separates from . So a cut vertex need not be the endpoint of any bridge.
Assuming every bridge endpoint is a cut vertex. is an endpoint of the bridge but, as a leaf, removing it changes nothing about the rest of ; it is , the other end, that is the cut vertex.
Find the cut vertices and bridges of the path (edges ).
Show the answerHide the answer
A path has no alternate route around any vertex or edge, so every internal vertex is a cut vertex, , and every one of its edges is a bridge. (Topic 4 proves this holds for every edge and every non-leaf vertex of any tree.)
Connectivity and Menger's Theorem
The vertex connectivity is the smallest number of vertices whose removal disconnects (or leaves a single vertex); the edge connectivity is the smallest number of edges whose removal disconnects . Menger's theorem: for non-adjacent , the maximum number of pairwise internally-disjoint paths equals the minimum number of vertices, other than , whose removal separates them.
Connectivity turns the previous section's yes/no questions — is there a cut vertex? — into a number: exactly when is connected and has a cut vertex, and when is already disconnected. Menger's theorem is the deep fact underneath: having many disjoint routes between two vertices (a "max", hard to rule out) and having no small cut between them (a "min", easy to check one candidate at a time) turn out to be the exact same quantity. The same min-max phenomenon returns as max-flow–min-cut once edges carry capacities (Topic 10).
For the graph of the last section, : removing the single cut vertex (or , or ) disconnects it, removing the single bridge (or ) disconnects it too, and no removal of vertices or edges can disconnect a connected graph — so is the smallest number that works, for vertices and for edges alike.
Label the -cycle . Deleting any single vertex leaves a path on the other vertices, still connected, so . Deleting the two opposite vertices and leaves only the edges and , splitting from — so , and together . The same two numbers work for edges: deleting one edge leaves a connected path, but deleting the two opposite edges and splits from , so as well.
The two arcs of the cycle give two paths from to sharing no internal vertex: and . On the other side, removing the two vertices and leaves with no edges at all, since its only neighbors were and , while stay joined by — so separates from , and no single vertex can, since that would force . Both the maximum number of disjoint paths and the minimum separating set have size , exactly as Menger's theorem predicts.
In the complete graph , every two vertices are already adjacent, so by convention ; for that is . Between any two vertices, say and , there are pairwise internally-disjoint paths: the edge itself, and , through the other two vertices — using all vertices and giving exactly independent routes.
It is tempting to assume , the minimum degree, since removing the neighbors of a minimum-degree vertex always disconnects it, giving in general. But the inequality can be strict: join two triangles and by a single bridge . Every vertex has degree or , so , yet deleting the one cut vertex (or ) disconnects the graph, so .
Find and for the star (one hub joined to leaves, no other edges).
Show the answerHide the answer
Every leaf has degree , so , and both connectivities are squeezed down to it: removing the hub disconnects all leaves from one another, and removing any single edge isolates that one leaf. So .
Why It Works
Write when some walk joins to . Reflexivity: the length- walk consisting of just joins to itself, so . Symmetry: if is a walk from to , then reading it backwards, , is a walk from to , since each joins the same two vertices regardless of the direction it is read — so . Transitivity: if a walk joins to and another joins to , following the first to and then immediately the second gives a single walk from to , so . Being reflexive, symmetric and transitive, is an equivalence relation, and the equivalence classes of any equivalence relation partition the underlying set with no overlaps and nothing left out — so the connected components partition .
Induct on . Base case : , which is if is an edge and otherwise — exactly the number of walks of length from to . Inductive step: suppose, for every vertex , that counts the walks of length from to . A walk of length from to is exactly a walk of length from to some neighbor of , followed by the edge ; every length- walk from to arises this way for exactly one , namely its second-to-last vertex. So the number of length- walks from to is , since is exactly when and otherwise — and that sum is by the definition of matrix multiplication. By induction the claim holds for every .
Let be an edge of a connected graph . If lies on a cycle , then is a path avoiding , so any walk that uses can be rerouted around it using in its place; every pair of vertices joined by a walk in is still joined by one in , so deleting changes nothing about connectivity and is not a bridge. Conversely, if is not a bridge, then has the same components as , so in particular and , the two endpoints of , are still joined by some path in . Since lies in it does not use , so together with the edge is a closed walk through and with no repeated vertex except the shared start and end — a cycle containing . So lies on a cycle if and only if it is not a bridge.
Suppose are pairwise internally-disjoint paths, and is any set of vertices, excluding and , whose removal leaves no path. Each has both endpoints outside (since ); if had no internal vertex in , it would survive intact in , contradicting that separates from . So every contributes at least one internal vertex to , and since the paths are pairwise internally disjoint, these contributed vertices are all different from each other. Hence . This holds for every separating set , in particular for a smallest one, so the minimum separator size is at least — and since was the size of an arbitrary family of pairwise internally-disjoint paths, the minimum separator size is at least the maximum number of such paths. The reverse inequality, that a separator this small is always achievable by that many disjoint paths, is the genuinely hard half of Menger's theorem.