Games played by moving a token or pieces on a graph. Some are solved by matching theory or a structural characterization in polynomial time; close relatives are PSPACE-complete.
| Game | Rule | Answer | Complexity |
|---|---|---|---|
| undirected vertex geography | a token starts on (visited); players alternately move it to an unvisited neighbour; who cannot move loses | the first player wins iff every maximum matching covers ( in Gallai–Edmonds) | |
| undirected edge geography | the same, but edges may not be reused | PSPACE-complete (Fraenkel, Scheinerman and Ullman, 1993) | |
| directed vertex / edge geography | on a digraph | PSPACE-complete (Schaefer 1978; Lichtenstein and Sipser 1980 for planar) | |
| tokens moving on a DAG, sum of several tokens | move one token along an arc | XOR of Grundy values of the token positions | : Sprague–Grundy |
| tokens on a graph with cycles | generalized Sprague–Grundy / retrograde | Loopy Games | |
| cops and robber (one cop, both may stay; the cop wins by landing on the robber) | the cop wins iff the graph is dismantlable (Nowakowski–Winkler, Quilliot, 1983) | ||
| Shannon switching game (Short claims edges to connect ; Cut deletes edges) | Short, moving second, wins iff some subgraph containing has two edge-disjoint spanning trees (Lehman, 1964) | matroid union: Matroid Intersection | |
| Hex, Chomp | strategy stealing | Chomp and Hex |
Undirected vertex geography
The Gallai–Edmonds decomposition splits the vertices into (missed by some maximum matching), and (the rest); Blossom and gallaiEdmonds are in General Matching, with their proofs.
// Uses Blossom and gallaiEdmonds from the General Matching note. Token on s, s already visited.
bool geographyFirstWins(int n, const vector<pair<int, int>>& edges, int s) {
Blossom B(n);
for (auto [u, v] : edges) B.addEdge(u, v);
B.run();
return gallaiEdmonds(B)[s] != 0; // first player wins iff s is covered by every maximum matching
}Proof: the first player wins iff every maximum matching covers s
If every maximum matching covers : fix a maximum matching . The first player always moves along : first to , and after the opponent moves to , to . This is always possible. is unvisited, because visited vertices come in -pairs (each first-player move completes a pair) and itself was unvisited. And is matched: otherwise the path played so far alternates, starting with a matched edge at and ending at the unmatched , and flipping it gives a maximum matching that misses . So the first player always has a move and wins (the game is finite).
If some maximum matching misses : the second player answers every move to with . Each the first player reaches is matched, otherwise the play would be an -augmenting path ( and both free), contradicting maximality; and is unvisited by the same pairing argument. So the second player always has a move and wins. Hence the first player wins iff . Checked against exhaustive game search on random graphs with up to 10 vertices.
Cops and robber
The cop chooses a start vertex, then the robber; then they alternate, the cop first, each moving along an edge or staying put. The cop wins by occupying the robber’s vertex. A vertex is a corner if some has (closed neighbourhoods); a graph is dismantlable if corners can be deleted one by one down to a single vertex.
bool copWin(const vector<vector<int>>& adj) { // connected graph; greedy dismantling, O(n^3) bitsets
int n = sz(adj); vector<bitset<512>> N(n); vector<char> alive(n, 1);
for (int v = 0; v < n; v++) { N[v][v] = 1; for (int u : adj[v]) N[v][u] = 1; }
for (int left = n; left > 1; left--) {
int corner = -1;
for (int r = 0; r < n && corner < 0; r++) if (alive[r])
for (int w = 0; w < n; w++) if (w != r && alive[w] && (N[r] & ~N[w]).none()) { corner = r; break; }
if (corner < 0) return false;
alive[corner] = 0;
for (int v = 0; v < n; v++) N[v][corner] = 0;
}
return true;
}Proof: cop-win iff dismantlable, and the greedy order does not matter
Retractions. If is a corner dominated by , the map fixing every vertex except sends edges to edges or to a single vertex (), so a legal move in maps to a legal move (or a stay) in .
Dismantlable cop-win. Induction on . Delete the first corner ; is cop-win. The cop plays the winning strategy of against the shadow , whose moves are legal in ; eventually the cop stands on the shadow. If the robber is not on , it is caught. If it is on , the cop is on , and every robber move stays in : the cop catches it next turn.
Cop-win a corner exists, and deleting any corner keeps the graph cop-win. If some vertex is adjacent to all others, every other vertex is a corner. Otherwise let the robber delay capture as long as possible; consider its last move, from with the cop on : every robber option (all of ) lies in , since the cop captures next turn, so is a corner. For any corner of a cop-win , is cop-win: the cop plays the -strategy (against a robber who never uses ) but stands on ; when the -cop lands on the robber at , the image is too. Hence a cop-win graph is dismantled by deleting corners in any order, which is why the greedy loop is correct, and a graph where the loop gets stuck is robber-win. Checked against retrograde analysis of the game (states: cop, robber, player to move) on random connected graphs with up to 7 vertices.
Related notes
- General Matching (Blossom, Gallai–Edmonds)
- Loopy Games (retrograde analysis)
- Complexity Theory (PSPACE-completeness of games)