A cycle is a path in a graph that begins and ends at the same node. In other words, the cycle does not visit any node more than once and returns to its starting node; more technically, the subgraph formed by the cycle is such that each node has degree 2.

In the graph below, the edges connecting nodes 2, 3, 4, and 5 form a cycle, as do the edges connecting nodes 1, 2, and 5. Furthermore, $1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 5$ is a cycle, but $1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 5 \rightarrow 2 \rightarrow 1$ because the second collection of edges does not form a well-defined path: node 2 is visited twice.


For cycles in directed graphs, see directed cycle.