Tutorials › Graph Theory (Undergraduate) › Alternating Paths and Cycles

Bipartite Graphs and Konig's Theorem · Tutorial 260 of 799

Alternating Paths and Cycles

Learn to read alternating edge patterns and determine what they imply—and do not imply—about path endpoints and cycles.

Intermediate 9 min read

What You'll Learn

  • Define alternating paths and alternating cycles relative to a fixed matching.
  • Determine which edge types can occur first and last on an alternating path.
  • Relate path length parity to the numbers of matching and nonmatching edges.
  • Identify what endpoint edge patterns imply about saturation.
  • Explain why an alternating cycle must have even length.
  • Avoid inferring endpoint status from a nonmatching path edge alone.

Alternation Relative to a Matching

A matching records a set of edges with no shared endpoints. Once a matching is fixed, each edge of the graph has one of two statuses: it belongs to the matching, or it does not. A path or cycle is alternating when those statuses switch at every consecutive pair of its edges. This makes the edge pattern itself meaningful: its length and its first and last edges constrain what can happen at its ends.

Definition: Let \(G=(V,E)\) be a finite simple graph, and let \(M\subseteq E\) be a matching. An alternating path with respect to \(M\) is a path \(v_0v_1\cdots v_\ell\) of positive length such that, for each \(i=1,\ldots,\ell-1\), exactly one of \(v_{i-1}v_i\) and \(v_iv_{i+1}\) belongs to \(M\). An alternating cycle with respect to \(M\) is a cycle whose edges alternate between belonging and not belonging to \(M\), including where the last edge meets the first.

A path has no repeated vertices; a cycle has no repeated vertices other than its starting and ending vertex. The length of either is its number of edges. A path consisting of one vertex has length zero and no edges, so it has no edge pattern to classify; throughout, an alternating path means one of positive length. Since \(M\) is a matching, no two consecutive edges of any path or cycle can both belong to \(M\). Alternation adds the other requirement: no two consecutive edges can both lie outside \(M\).

A vertex is saturated by \(M\) if it is incident with an edge of \(M\), and unsaturated or exposed if it is not. These terms refer to all of \(M\), not just to the edges used by a particular path. In particular, a path endpoint can be incident with a nonmatching path edge and still be saturated by a matching edge that is not on the path.

Edge Patterns and Path Length

Write the edges of an alternating path in order as \(e_1,e_2,\ldots,e_\ell\). Once the status of \(e_1\) is specified, every later status is determined: \(e_i\) belongs to \(M\) exactly when \(e_{i+1}\) does not, for each \(i<\ell\). Thus the pattern switches at every step.

Proposition: An alternating path of even length has equally many edges in \(M\) and outside \(M\), and its first and last edges have different statuses. An alternating path of odd length has one more edge of the type that appears first than of the other type, and its first and last edges have the same status.

Proof. Suppose first that the path has even length \(\ell=2k\), where \(k\ge1\). Its positions \(1,2,\ldots,2k\) can be grouped into the \(k\) consecutive pairs \((1,2),(3,4),\ldots,(2k-1,2k)\). In each pair, one edge belongs to \(M\) and one does not, so there are \(k\) edges of each type. Since the statuses switch at every step and there are an even number of edges, the status at position \(2k\) differs from the status at position \(1\). Now suppose \(\ell=2k+1\), where \(k\ge0\). The first \(2k\) positions form \(k\) consecutive pairs, each containing one edge of each type, and the last edge has the same status as the first because \(2k\) switches return to the starting status. Therefore the starting type occurs \(k+1\) times and the other type occurs \(k\) times. This also covers \(\ell=1\), when \(k=0\). \(\square\)

The length-parity rule gives a quick way to check a proposed pattern. For example, a path of length four cannot have both its first and last edges in \(M\): four alternating edges have two of each type and different statuses at the two ends. A path of length three has either the pattern \(M,\ E\setminus M,\ M\), or the pattern \(E\setminus M,\ M,\ E\setminus M\).

There is an important limitation: the first or last edge of a path is only the edge used by the path at that endpoint. If that edge is in \(M\), the endpoint is certainly saturated. If the path edge is outside \(M\), the endpoint may be saturated by a different edge. This distinction is necessary when translating an edge pattern into a statement about vertices.

Endpoint rule: If an endpoint's path edge belongs to \(M\), that endpoint is saturated. If an endpoint's path edge does not belong to \(M\), its saturation status is not determined by the path edge alone. In particular, if both endpoints are unsaturated, neither end edge can belong to \(M\); hence an alternating path between two unsaturated endpoints has odd length and has the pattern \(E\setminus M,\ M,\ldots,M,\ E\setminus M\).

Proof. An endpoint is incident with exactly one edge of the path. If that edge belongs to \(M\), it is an incident matching edge, which is precisely what it means for the endpoint to be saturated. If both endpoints are unsaturated, each has no incident edge in \(M\), so the first and last path edges are outside \(M\). Alternation then forces the statuses to start and end outside \(M\). By the proposition, an alternating path with the same status at both ends has odd length. \(\square\)

Alternating Cycles

Proposition: Every alternating cycle has even length and contains equally many edges in \(M\) and outside \(M\).

Proof. List the cycle's edges in their cyclic order as \(e_1,e_2,\ldots,e_\ell\), where \(\ell\ge3\). Alternation requires consecutive edges to have different statuses, including \(e_\ell\) and \(e_1\). Starting from the status of \(e_1\), each step switches the status. After \(\ell\) switches, the status must return to that of \(e_1\), because the next comparison is between \(e_\ell\) and \(e_1\). An odd number of switches would give the opposite status, so \(\ell\) is even. With \(\ell=2k\), the cyclic sequence has \(k\) edges of each type: starting at any edge, the statuses alternate \(k\) times through each type. \(\square\)

In an alternating cycle, every vertex is incident with exactly one cycle edge in \(M\) and one cycle edge outside \(M\). The first statement follows by examining the two cycle edges meeting at that vertex: alternation requires opposite statuses. This describes the edges of the cycle; it does not say that the cycle contains every matching edge incident with its vertices in the whole graph.

Worked Examples

Worked Example: An Even-Length Alternating Path

Let \(G=(V,E)\) have \(V=\{1,2,3,4,5,6\}\) and \(E=\{12,23,34,45,56,61\}\). Fix the matching \(M=\{23,45\}\). Consider the path \(P=1,2,3,4,5\).

Its successive edges are \(12,23,34,45\). Their statuses are, in order, outside \(M\), in \(M\), outside \(M\), in \(M\). Each pair of consecutive edges has opposite statuses, so \(P\) is alternating. Its length is \(4\), and the count is two edges in \(M\) (\(23,45\)) and two outside \(M\) (\(12,34\)). Its first edge \(12\) is outside \(M\), while its last edge \(45\) is in \(M\), as required for even length.

The matching edges are disjoint: \(23\) has endpoints \(2,3\), and \(45\) has endpoints \(4,5\), so they share no endpoint. Vertex \(1\) is unsaturated, while vertex \(5\) is saturated by \(45\). The example illustrates that an even alternating path has opposite end-edge statuses; it does not, by itself, make both endpoints unsaturated.

Check: Reading the path backward gives \(5,4,3,2,1\), with statuses \(M,\ E\setminus M,\ M,\ E\setminus M\). It is still alternating, and its end-edge statuses are again different. The path has \(4=2+2\) edges, matching the equal-count rule.

Worked Example: A Nonmatching End Edge at a Saturated Vertex

Let \(G=(V,E)\) have \(V=\{1,2,3,4,5\}\) and \(E=\{12,23,34,45\}\). Fix \(M=\{23,45\}\), and consider the path \(P=1,2,3,4\).

The successive edge statuses are: \(12\notin M\), \(23\in M\), and \(34\notin M\). Therefore \(P\) is alternating, of length \(3\), with the pattern \(E\setminus M,\ M,\ E\setminus M\). It has two edges outside \(M\) and one edge in \(M\); the starting type occurs one more time, as the odd-length rule predicts.

Vertex \(1\) is unsaturated because neither of its incident edges belongs to \(M\). Vertex \(4\), however, is saturated: although the path's last edge \(34\) is not in \(M\), the edge \(45\) is in \(M\) and is incident with \(4\). Thus the two end edges are both outside \(M\), but the endpoint statuses are different.

Check: The edges of \(M\) are \(23\) and \(45\), which have no common endpoint, so \(M\) is a matching. Among the three path edges, exactly \(23\) belongs to \(M\), giving one matching edge and two nonmatching edges, consistent with the displayed pattern.

Worked Example: An Alternating Cycle

Let \(G=(V,E)\) have \(V=\{1,2,3,4,5,6\}\) and \(E=\{12,23,34,45,56,61\}\), and fix \(M=\{12,34,56\}\). Consider the cycle \(1,2,3,4,5,6,1\).

In cyclic order, its edges are \(12,23,34,45,56,61\). Their statuses are \(M,\ E\setminus M,\ M,\ E\setminus M,\ M,\ E\setminus M\). The last edge \(61\) is outside \(M\), while the first edge \(12\) is in \(M\), so alternation holds also where the cycle closes. The cycle has length \(6\), with three edges in \(M\) and three outside \(M\).

The set \(M\) is a matching because its edges \(12,34,56\) have disjoint endpoint sets \(\{1,2\}\), \(\{3,4\}\), and \(\{5,6\}\). At each vertex, one of its two cycle edges is in \(M\) and the other is outside \(M\). For instance, at vertex \(1\), edge \(12\) is in \(M\) and edge \(61\) is not.

Check: The listed cycle has six edges, and counting the statuses directly gives three matching edges, \(12,34,56\), and three nonmatching edges, \(23,45,61\). The counts agree, and its length is even, as the proposition requires.

Common Pitfall: Confusing Edge Status with Endpoint Status

A nonmatching path edge does not prove that its endpoint is unsaturated. In the second example, the incorrect calculation would be: “The last edge \(34\notin M\), so vertex \(4\) is unsaturated.” That conclusion examines only the path edge and ignores the rest of the matching. The correction is to inspect all edges of \(M\) incident with the endpoint: \(45\in M\) and \(45\) is incident with \(4\), so \(4\) is saturated.

The converse implication is safe: if an end edge of the path belongs to \(M\), the endpoint is saturated. But if the end edge is outside \(M\), the endpoint may be either saturated or unsaturated. Keep the two questions separate: first determine the path's edge pattern; then check the endpoint's incident matching edges in the whole graph.

Alternation is also distinct from the bipartition of a bipartite graph. A bipartition classifies vertices, while a matching classifies edges as selected or not selected. A path may alternate between the two vertex parts and independently alternate between matching and nonmatching edges; the two patterns describe different features.

Check Your Understanding

Use the definitions and parity rules above. When deciding whether a vertex is saturated, inspect all matching edges incident with it, not only the path edges.

  1. An alternating path has length \(7\) and its first edge belongs to \(M\). How many of its edges belong to \(M\), and what is the status of its last edge?
  2. Can a cycle of length \(5\) be alternating with respect to a matching? Explain using the cyclic closing condition.
  3. Give a reason why an endpoint whose path edge belongs to \(M\) must be saturated.
  4. In the second worked example, which edge saturates vertex \(4\), even though the path edge at that endpoint is outside \(M\)?
  5. Can an alternating path of even length have both end edges outside \(M\)? Justify your answer from the edge pattern.