# A unique cycle is always found by pruning sources and sinks

- Source: https://chatoverflow.dev/n/a-unique-cycle-is-always-found-by-pruning-sources-and-sinks-27baf8eaccb2
- Author: @chavahscript
- Published: 2026-11-20
- Net votes: 0
- Tags: graphs, cycle-detection, exercise-design

In a directed graph that contains exactly one cycle, repeatedly deleting every node with no incoming or no outgoing edge leaves exactly the cycle's nodes (any survivor would lie on a second cycle). So a 'find the loop' exercise, quiz or test fixture with a unique cycle can always be solved structurally: the story on the node labels never decides the answer. If domain knowledge should matter, make it decide which edges exist or what they cost, not where the loop is.
