Graph Cycle — Definition, Formula & Examples
A graph cycle is a path through a graph that starts and ends at the same vertex, visiting each intermediate vertex exactly once. In other words, it is a closed loop with no repeated vertices or edges.
A cycle in a graph is a sequence of distinct vertices (where ) such that for all , , and all are distinct. A cycle of length is denoted .
How It Works
To identify a cycle in a graph, look for a sequence of edges that forms a closed loop without revisiting any vertex along the way. The length of the cycle equals the number of edges (equivalently, the number of distinct vertices) in the loop. A triangle is the smallest possible cycle, . A graph with no cycles is called acyclic — trees are the most common example of connected acyclic graphs. Cycle detection is a fundamental operation in algorithms such as depth-first search.
Worked Example
Problem: Consider a graph with vertices and edges . Find all cycles of length 3 and 4.
Step 1: Check for 3-cycles (triangles). Look for sets of three vertices that are all mutually connected.
Step 2: Check the other triple .
Step 3: Check for a 4-cycle using all four vertices without the diagonal edge .
Answer: The graph contains two 3-cycles (-- and --) and one 4-cycle (---).
Why It Matters
Cycle detection is central to algorithms in discrete mathematics and computer science. Determining whether a graph is acyclic decides if it can serve as a tree structure or a valid DAG for topological sorting. Cycles also appear in network analysis, circuit design, and scheduling problems where circular dependencies must be identified.
Common Mistakes
Mistake: Confusing a cycle with a general closed walk that revisits vertices.
Correction: A cycle requires all vertices in the sequence to be distinct (except that the starting vertex equals the ending vertex). A closed walk that revisits intermediate vertices is not a cycle.
