Algorithm Search⌘K

Proofs: Hopcroft-Tarjan planar isomorphism algorithm

These are the human proofs of Hopcroft-Tarjan planar isomorphism algorithm, at full length.

Dart refinement decides isomorphism of 3-connected planar graphs full

This proof shows: correctness, termination.

Setting. A map MM is a connected simple graph with a rotation system. Its darts D(M)D(M) are the ordered pairs (u,v)(u, v) with uvuv an edge; σ(u,v)=(u,v′)\sigma(u, v) = (u, v') where v′v' follows vv in the rotation of uu, and α(u,v)=(v,u)\alpha(u, v) = (v, u). A map isomorphism M1→M2M_1 \to M_2 is a bijection f:D(M1)→D(M2)f : D(M_1) \to D(M_2) with fσ=σff \sigma = \sigma f and fα=αff \alpha = \alpha f. The algorithm works on the disjoint union D=D(M1)∪D(M2)D = D(M_1) \cup D(M_2), where σ\sigma and α\alpha act on each side separately. A partition PP of DD is stable when, for every block BB, both σ−1(B)\sigma^{-1}(B) and α−1(B)\alpha^{-1}(B) are unions of blocks; equivalently, darts in one block have their σ\sigma-images in one block and their α\alpha-images in one block.

Lemma 1 (refine computes the coarsest stable refinement). Given a partition PP and a queue that contains every block, or that contains enough blocks that every block of PP outside the queue is already a union of preimages as described below, REFINE stops and returns the coarsest stable partition finer than PP.

Proof. Termination: each split increases the number of blocks, which is at most ∣D∣|D|, and each loop iteration removes one queue entry, while entries are added only at splits. Never too fine: let QQ be any stable partition finer than PP. Suppose all blocks so far are unions of blocks of QQ. A split cuts a block CC into C∩τ−1(S)C \cap \tau^{-1}(S) and C∖τ−1(S)C \setminus \tau^{-1}(S) for a block SS and τ∈{σ,α}\tau \in \{\sigma, \alpha\}. Since SS is a union of QQ-blocks and QQ is stable, τ−1(S)\tau^{-1}(S) is a union of QQ-blocks, so both pieces are too. Stable at the end: this is Hopcroft's argument. Invariant: for every current block CC and τ\tau, τ−1(C)\tau^{-1}(C) is a union of blocks, or CC is in the queue, or CC is one piece of a split X=C∪C′X = C \cup C' where τ−1(X)\tau^{-1}(X) is already a union of blocks and C′C' is in the queue. In the last case τ−1(C)=τ−1(X)∖τ−1(C′)\tau^{-1}(C) = \tau^{-1}(X) \setminus \tau^{-1}(C'), and after C′C' is processed every block lies inside or outside τ−1(C′)\tau^{-1}(C'), so τ−1(C)\tau^{-1}(C) is a union of blocks. The code keeps the invariant: when a queued block splits, both pieces are queued; otherwise the smaller piece is queued and the other is covered by the third case. When the queue is empty, the invariant gives stability. □\square

Lemma 2 (invariance). Let ff be a map isomorphism M1→M2M_1 \to M_2, and let Πf\Pi_f be the partition of DD into the pairs {d,f(d)}\{d, f(d)\}, d∈D(M1)d \in D(M_1). Then Πf\Pi_f is stable, and if every block of a partition PP is a union of such pairs, so is every block of the coarsest stable refinement of PP.

Proof. σ\sigma maps the pair {d,f(d)}\{d, f(d)\} to {σ(d),σ(f(d))}={σ(d),f(σ(d))}\{\sigma(d), \sigma(f(d))\} = \{\sigma(d), f(\sigma(d))\}, another pair; the same holds for α\alpha. Since σ\sigma and α\alpha are permutations, preimages of pairs are pairs too, so Πf\Pi_f is stable. If PP is coarser than Πf\Pi_f, then Πf\Pi_f is a stable partition finer than PP, and the coarsest stable refinement of PP is coarser than every such partition, by Lemma 1. □\square

The initial blocks of L1 are unions of pairs, since ff keeps the degree of the tail (the length of the σ\sigma-cycle) and the length of the face (the σα\sigma\alpha-cycle). So after L2 every block is a union of pairs of Πf\Pi_f.

Lemma 3 (pairs give isomorphisms). If a stable partition has every block of the form {a,b}\{a, b\} with a∈D(M1)a \in D(M_1) and b∈D(M2)b \in D(M_2), then f(a)=bf(a) = b is a map isomorphism, and φ(tail(a))=tail(f(a))\varphi(\text{tail}(a)) = \text{tail}(f(a)) is a well defined graph isomorphism.

Proof. ff is a bijection. Stability says σ(a)\sigma(a) and σ(b)\sigma(b) lie in one block, which must be {σ(a),σ(b)}\{\sigma(a), \sigma(b)\} since σ\sigma keeps sides, so fσ=σff\sigma = \sigma f; the same for α\alpha. The darts with tail uu form one σ\sigma-cycle, which ff maps onto one σ\sigma-cycle, so φ\varphi is well defined and a bijection on vertices. An edge uvuv gives the dart (u,v)(u, v) and f(u,v)=(φ(u),w)f(u, v) = (\varphi(u), w) with f(v,u)=fα(u,v)=αf(u,v)=(w,φ(u))f(v, u) = f\alpha(u, v) = \alpha f(u, v) = (w, \varphi(u)), so w=φ(v)w = \varphi(v) and φ(u)φ(v)\varphi(u)\varphi(v) is an edge. □\square

Lemma 4 (one dart decides). In a connected map, σ\sigma and α\alpha generate a group that acts transitively on the darts. If a map isomorphism ff with f(x)=yf(x) = y exists, refining after the pair {x,y}\{x, y\} is individualized ends with exactly the partition Πf\Pi_f.

Proof. From (u,v)(u, v), σ\sigma reaches every dart with tail uu and α\alpha moves to a dart with tail vv; by connectivity every dart of the map is reached, so every dart of M1M_1 is w(x)w(x) and every dart of M2M_2 is w(y)w(y) for words ww in σ,α\sigma, \alpha and their inverses. In a stable partition QQ, darts in one block have their images under σ\sigma in one block, and since σ−1\sigma^{-1} is a power of σ\sigma, also their images under σ−1\sigma^{-1}; the same for α\alpha. So if {x,y}\{x, y\} is a block of QQ and cc shares a block with w(x)w(x), then w−1(c)w^{-1}(c) shares a block with xx, so w−1(c)∈{x,y}w^{-1}(c) \in \{x, y\} and c∈{w(x),w(y)}={w(x),f(w(x))}c \in \{w(x), w(y)\} = \{w(x), f(w(x))\}. Hence the result QQ of the refinement is finer than Πf\Pi_f. The starting partition is a union of pairs (the remark after Lemma 2, and {x,y}\{x, y\} is a pair), so by Lemma 2 QQ is also coarser than Πf\Pi_f. □\square

Theorem (map isomorphism). MAP-ISOMORPHISM returns a vertex bijection induced by a map isomorphism if one exists, and None otherwise.

Proof. If it returns φ\varphi, the check in L7 and Lemma 3 show that φ\varphi comes from a map isomorphism. Conversely, let ff be a map isomorphism. By Lemma 2 every block after L2 is a union of pairs {d,f(d)}\{d, f(d)\}, so each block has equally many darts from each side and L3 does not reject. The block chosen in L4 contains xx and f(x)f(x), and L5 tries every dart yy of M2M_2 in it, including f(x)f(x); by Lemma 4 that trial succeeds, so some trial returns. If no map isomorphism exists, no trial can pass L7 by Lemma 3, and the algorithm returns None in L8 or rejects in L3. □\square

Theorem (3-connected planar graphs). For 3-connected planar graphs G1,G2G_1, G_2 with planar rotation systems R1,R2R_1, R_2, TRICONNECTED-PLANAR-ISOMORPHISM returns an isomorphism exactly when G1≅G2G_1 \cong G_2.

Proof. Any returned φ\varphi is a graph isomorphism by Lemma 3. Conversely, let ψ:G1→G2\psi : G_1 \to G_2 be an isomorphism. Transporting R1R_1 along ψ\psi gives a planar rotation system of G2G_2. By Whitney's theorem, a 3-connected planar graph has only one planar embedding up to reflection, so this system equals R2R_2 or its mirror. Then ψ\psi induces a map isomorphism R1→R2R_1 \to R_2 or R1→mirror(R2)R_1 \to \text{mirror}(R_2), and one of the two calls succeeds by the theorem above. □\square

Termination. REFINE terminates by Lemma 1; the trial loop runs at most ∣D∣|D| times; there are two calls. ■\blacksquare

Back to Hopcroft-Tarjan planar isomorphism algorithm