Advanced maths

Graph cop number calculator with a winning pursuit strategy

Compute the minimum number of cops needed to guarantee capture of a visible robber on a small graph and return winning game-state information.

Your numbers

One edge per row, zero-based endpoint indices. Enter none for an edgeless graph where the method permits one.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Compute the minimum number of cops needed to guarantee capture of a visible robber on a small graph and return winning game-state information.

THE FORMULACop-turn state wins if some legal cop move reaches a winning state; robber-turn state wins if every legal robber move reaches a winning state.

A worked example

A single cop wins on the default four-vertex path. Starting at vertex 0, the cop moves toward the visible robber; the robber cannot pass the cop, and the available interval eventually ends at vertex 3. Thus c(P₄)=1.

Good to know

Connected simple undirected graphs with at most 7 vertices. Visible ordinary cops-and-robber game: cops choose starts first, robber then chooses; cops move first; every player may stay or move one edge. Complete bounded retrograde analysis, capped strategy output; no invisible or fast robber interpretation.

Guarantee capture against every legal response

The cop number is the smallest number of cooperating cops that can force capture of one robber on a graph. Both sides know every location. After the cops select starting vertices, the robber selects a starting vertex, and the cops move first. A guarantee means success against every legal robber strategy, rather than success against a sampled or careless opponent.

A move lets each player stay in place or traverse one edge. Capture occurs when a cop and the robber share a vertex. Several cops can occupy the same vertex. These conventions matter: allowing a fast robber, hiding its location or changing the order of play defines a different pursuit game and can change the required number.

One visible cop can force capture on the default four-vertex path0123CopRobberOn a path the robber cannot pass the pursuing cop
Scroll across to see the full diagram.
One visible cop can force capture on the default four-vertex path.

Compare this with the Graph burning number calculator with a burning sequence. Solve the alternating visible robber/cops pursuit game, not irreversible spread or domination of a static vertex set.

Enter a connected unweighted graph

Use zero-based endpoints for a connected simple graph with at most seven vertices. Loops and repeated edges are rejected, and each endpoint must be in range. Staying is permitted by the game rules even though the input graph has no explicit self-loops. Edge length in a drawing does not change the one-edge movement budget.

Connectivity is required for this bounded calculator’s convention. A disconnected graph introduces a separate issue of covering components before the robber chooses its start. The page does not silently select one connected component or aggregate component answers. Enter the intended connected arena, not just the edges visible in a cropped drawing.

A game state includes whose turn it is

A state contains all cop positions, the robber position and the side about to move. The same positions can have different strategic status on a cop turn and a robber turn. Capture states are winning terminal states. The algorithm propagates this known result backward through legal moves until no more states can be classified as forced wins.

On a cop turn, one winning successor is enough because the cops choose their move. On a robber turn, every legal successor must be winning for the cops because the robber chooses the response. Replacing that universal condition with an average or one favorable move would calculate a cooperative or random opponent, not the worst-case cop number.

Check starting positions after solving the states

For a fixed cop count, a cop starting configuration succeeds only if every robber starting choice is winning for the cops with the cops to move first. The solver searches configurations under that condition. If one cop configuration works, it provides a strategy witness; otherwise the next cop count is considered after the complete smaller-count analysis.

The minimum is certified only when every smaller count has been ruled out under the same rules. A winning-state table may be capped for presentation without capping the underlying classification silently. When the computation itself exceeds its resource limit, the result is unresolved rather than a guess based on a few simulated games.

See why one cop wins on the default path

The default arena is a path with vertices zero, one, two and three in order. A cop starting at zero can move toward the visible robber. Once the cop advances, the robber cannot cross its occupied vertex without capture. The segment in which the robber can safely remain is progressively shortened toward the far endpoint.

Eventually the robber reaches the endpoint and cannot keep a gap forever; staying is not an escape from a pursuing cop on a finite path. At least one cop is necessary on a nonempty arena, and the one-cop strategy supplies the upper bound, so the cop number is one. This reasoning is different from measuring the path’s diameter alone.

Read a strategy as contingent moves

A strategy table describes what the cops should do from particular states, including the robber’s current location. It is not one fixed route that works without observing the opponent. Different legal robber moves can lead to different suggested cop moves. The returned initial placement and selected winning transitions should therefore be read with the state identifiers attached.

A forced-capture rank or move bound belongs to the solver’s turn-count convention. Counting individual player moves, full rounds or simultaneous team moves can produce different numbers even for the same winning strategy. The page’s primary answer is the minimum cop count; additional state diagnostics do not change that objective into a shortest expected pursuit problem.

Keep other graph-search concepts separate

A graph’s treewidth, burning number or zero-forcing number describes another process with different rules. Those quantities may be related by theory, but they cannot replace a completed game-state solve here. Similarly, one successful manual chase does not prove that the robber lacks a perpetual evasion strategy from another response.

Use the tool for exact small-arena visible pursuit under its stated rules. It does not predict real-world policing, communications delays, player speeds or hidden movement. The small vertex cap supports complete adversarial analysis instead of providing an attractive simulation that is mistakenly described as a certified cop number.

A few questions, answered

Can a player stay still?

Yes. Staying is a legal move for every cop and for the robber.

Who chooses starting positions first?

The cops choose first, then the robber chooses after seeing their positions; the cops move first.

Does one successful chase prove the answer?

No. The cops need a strategy that wins against every legal robber response.

Does this cover an invisible robber?

No. Every player’s location is visible throughout this game.

Find your calculator

Start typing to explore the library.