Why does adding one extra link to a tree-shaped overlay create exactly one cycle?
answer
- the endpoints already had a route
- closing the unique path
- every new cycle must use the new link
- one path to complete it with
- fundamental cycle of the added link
basics
~20 sThe new link's endpoints already had exactly one path between them, and the link closes it into a cycle. Any cycle in the result must use the new link, and only one path completes it.
solid answer
~50 sCall the tree `T` and the new link `uv`. Because `T` is a tree, `u` and `v` are joined by exactly one path `P`. Adding `uv` closes `P` into a cycle, so at least one appears. For the upper half: any cycle in `T + uv` must use `uv`, because `T` on its own is acyclic; and a cycle that uses `uv` consists of `uv` plus a path from `u` to `v` inside `T`, of which there is exactly one. So exactly one cycle exists, and it is the **fundamental cycle** of that link. This is the maximally-acyclic characterization of a tree: a tree is acyclic, but so tightly so that *any* new link between two of its nodes creates a cycle immediately. Note the "exactly one" is specific to adding a single link — a second added link can push the distinct-cycle count to three.
go deeper
Remember the picture: the two ends of the new link already had one route between them, and the new link closes that route into a loop. One link, one loop.
Argue both halves — at least one cycle because a path existed, at most one because any cycle must use the new link and the path completing it is unique. Then say why the count does not simply double.
Connect it to behaviour you would see: the loop duplicates delivery for the nodes on it, so a flood that needed no termination rule suddenly needs one, and the loop's length tells you how much of the cluster is involved.
This is the exact price of leaving tree-ness. Decide deliberately whether the redundancy an extra link buys is worth the duplicate-suppression machinery it forces into every participant.
## The claim and the two halves of its argument Start with a tree `T` on `n` nodes and `n-1` links, and add one link `uv` between two nodes that are not already joined by a link. The result `T + uv` has `n` links, and the claim is that it contains **exactly one cycle**. Like most "exactly" claims, the argument has a lower half and an upper half: 1. **At least one cycle exists.** `T` is connected, so `u` and `v` are joined by a path `P`. Appending `uv` to `P` gives a closed route that repeats no link and no node other than its start: a cycle. 2. **At most one cycle exists.** Any cycle in `T + uv` must use the link `uv`, since removing `uv` leaves `T`, which is acyclic. A cycle through `uv` is exactly `uv` plus a path from `u` to `v` that avoids `uv` — that is, a path inside `T`. A tree has exactly one such path, so there is exactly one such cycle. The cycle produced this way is called the **fundamental cycle** of `uv` with respect to `T`. Its length is one more than the number of links on the tree path between `u` and `v`, which is why a link added between two nearby nodes creates a short loop and one added between two far-apart nodes creates a long one. ## The characterization it belongs to This is the mirror image of another tree property, and the pair is worth stating together: | Direction | Statement | What the tree sits on | |---|---|---| | Remove a link | The graph splits into exactly two parts | minimally connected | | Add a link | Exactly one cycle appears | maximally acyclic | A tree is exactly the boundary between the two regimes: it has no slack to lose and no room to gain. Either of these statements, taken with connectivity or acyclicity respectively, is a valid definition of a tree — they sit beside "connected and acyclic", "connected with `n-1` links" and "exactly one path between every pair". ## Adding more than one link The "exactly one" figure does not simply multiply. Two quantities are easy to confuse: - **Independent cycles** — the dimension of the graph's cycle space — is `E - V + 1` for a connected graph, so a tree plus `k` extra links has exactly `k` independent cycles, one fundamental cycle per added link. - **Distinct cycles** — how many closed routes you could actually trace — can be larger. With two added links whose fundamental cycles share at least one link, the two cycles combine into a third: drop the shared links and the outer boundary is a cycle of its own. So two added links give **two** distinct cycles when their fundamental cycles are link-disjoint, and **three** when they overlap. With `k` added links the distinct-cycle count sits between `k` and `2^k - 1`, which is why "one link, one cycle" is a statement about the first link and not a rate. ## Why an overlay designer cares Take a broadcast overlay wired as a tree over a cluster. A message flooded from any node reaches every other node exactly once, because the route to each is unique. Now add one link, for whatever reason — a helpful shortcut, an operator repairing something, two nodes discovering each other: - A message entering the fundamental cycle travels both ways around it, so every node on that cycle receives it **twice**, and the flood no longer terminates on structure alone. - The overlay therefore needs a termination rule it did not need before: a seen-set, a message identifier, or a hop limit. That cost appears at the first extra link, not gradually. - The nodes *outside* the cycle are unaffected in delivery count — they still sit on a tree hanging off it. The duplication is local to the loop, which is why the length of the fundamental cycle, not just its existence, tells you how much of the cluster is affected. ## The traps The first trap is symmetry: people say "two cycles, one in each direction". Direction is not a property of a cycle in an undirected graph; clockwise and anticlockwise trace the same link set and are the same cycle. The second is assuming the added link must join two distant nodes to matter — a link between two nodes that are already neighbours-of-a-neighbour creates a three-link cycle, which is still a cycle and still duplicates. The third is extrapolating the count, which the section above corrects.
- How long is the cycle that the added link creates?One more than the number of links on the tree path between the added link's endpoints. Joining two nodes that share a neighbour gives a three-link cycle; joining the two ends of a long chain gives a cycle spanning the whole chain. So the same single link can create a loop touching three nodes or nearly all of them, depending on where its endpoints sat.
- If a graph has n nodes and n links and is connected, how many independent cycles does it have?Exactly one, since the number of independent cycles in a connected graph is links minus nodes plus one, here `n - n + 1 = 1`. Structurally it is a single cycle with trees hanging off its nodes. Removing any one link on that cycle returns a tree; removing a link off the cycle splits the graph.
- Why is 'exactly one cycle' not what you get from two added links?Each added link contributes one independent cycle, so two give two independent cycles — but distinct traceable cycles can number three if the two fundamental cycles share at least one link, because their non-shared parts form a third closed route. Independent count and distinct count are different measures and only coincide when the fundamental cycles are link-disjoint.
saying these in an interview costs you the question
- Says two cycles appear, one per direction around the loop
- Thinks the new link creates no cycle if the endpoints were far apart
- Claims each added link adds one distinct cycle forever
- Believes a cycle can exist in the result without using the new link
- Assumes a short three-node loop does not count as a cycle