How Many Unicycles in a Wheel?
Time limit1sMemory limit512 MB
Count the number of spanning unicycles (spanning trees plus one edge forming a single cycle) in a wheel graph of size m, output modulo 100007.
- Level
Medium7 of 10
- Topics
- Combinatorics, Graph, Math, Dynamic programming
- Solved
- No attempts yet
Problem
A wheel graph of size is a cycle of vertices, each of which is connected to a center vertex. Examples of wheel graphs of size 4, 5, 6, and 8 are shown below.

A spanning unicycle in a graph is a spanning tree in with one additional edge added to form a single cycle. Each of the examples below is a spanning unicycle in a wheel graph of size 5.

Write a program to compute the number of different unicycles in a wheel graph of size . Recall that two subgraphs and of a graph are different if there is at least one edge of that is in and not in , or an edge in which is not in .
Input
Input consists of a single line that contains a decimal integer (), which is the size of the wheel graph to find the number of unicycles of.
Output
The single output line consists of the count of unicycles modulo for the input size .