Algorithm Search⌘K

Proofs: de Fraysseix-Pach-Pollack algorithm

These are the human proofs of de Fraysseix-Pach-Pollack algorithm, at full length.

Correctness of the de Fraysseix-Pach-Pollack algorithm full

This proof shows: correctness, termination.

Setting. GG is maximal planar with n≥4n \ge 4 vertices (for n=3n = 3 the output is the triangle (0,0)(0,0), (2,0)(2,0), (1,1)(1,1)), embedded by a rotation system with outer face v1,v2,vnv_1, v_2, v_n counterclockwise, and v1,…,vnv_1, \ldots, v_n is a canonical ordering. GkG_k is the plane graph induced by v1,…,vkv_1, \ldots, v_k, and its contour is c1=v1,…,ct=v2c_1 = v_1, \ldots, c_t = v_2. By the definition of a canonical ordering, GkG_k is 2-connected, its bounded faces are triangles, and its outer boundary is the cycle formed by the contour and the edge v1v2v_1 v_2. We write Mk(c)M_k(c) for the set M(c)M(c) after step kk, with Mk(ct+1)=∅M_k(c_{t+1}) = \emptyset.

Termination. The loop of line L3 runs n−3n - 3 times, and each iteration does a finite amount of work. The canonical ordering exists and is computed by a terminating procedure (see the canonical ordering page). So the algorithm terminates.

Facts about the sets MM

Lemma 1. For every k≥3k \ge 3: Mk(c1)⊋Mk(c2)⊋⋯⊋Mk(ct)M_k(c_1) \supsetneq M_k(c_2) \supsetneq \cdots \supsetneq M_k(c_t), Mk(c1)=V(Gk)M_k(c_1) = V(G_k), ci∈Mk(ci)c_i \in M_k(c_i), and cj∈Mk(ci)c_j \in M_k(c_i) exactly when j≥ij \ge i.

Proof. For k=3k = 3: M(v1)={v1,v3,v2}M(v_1) = \{v_1, v_3, v_2\}, M(v3)={v3,v2}M(v_3) = \{v_3, v_2\}, M(v2)={v2}M(v_2) = \{v_2\}. Step kk (line L8) adds vkv_k to M(ci)M(c_i) for i≤pi \le p, sets M(vk)={vk}∪M(wp+1)M(v_k) = \{v_k\} \cup M(w_{p+1}), and keeps M(wi)M(w_i) for i≥qi \ge q. Since M(wp+1)⊇M(wq)M(w_{p+1}) \supseteq M(w_q) and wp+1∉M(wq)w_{p+1} \notin M(w_q), the chain for the new contour c1,…,wp,vk,wq,…c_1, \ldots, w_p, v_k, w_q, \ldots is again strictly decreasing, contains vkv_k exactly in the sets up to M(vk)M(v_k), and M(c1)M(c_1) gains vkv_k. □\square

So a sequence 0≤δ1≤⋯≤δt0 \le \delta_1 \le \cdots \le \delta_t defines a monotone shift of GkG_k: move each vertex of Mk(ci)∖Mk(ci+1)M_k(c_i) \setminus M_k(c_{i+1}) by δi\delta_i to the right. Lines L5 and L6 perform the monotone shift of Gk−1G_{k-1} with δi=0\delta_i = 0 for cic_i up to wpw_p, δi=1\delta_i = 1 for wp+1,…,wq−1w_{p+1}, \ldots, w_{q-1} and δi=2\delta_i = 2 from wqw_q on.

Lemma 2 (shifts restrict). Let k≥4k \ge 4 and let δ\delta be a monotone shift of GkG_k. Then the movement of the vertices of Gk−1G_{k-1} is a monotone shift δ′\delta' of Gk−1G_{k-1}; moreover vkv_k moves by some amount dd, the vertex wpw_p by at most dd, the vertices wp+1,…,wq−1w_{p+1}, \ldots, w_{q-1} by exactly dd, and wqw_q by at least dd.

Proof. Let δ′\delta' give cic_i the value of δ\delta at cic_i for contour vertices of Gk−1G_{k-1} up to wpw_p and from wqw_q on, and the value d=δ(vk)d = \delta(v_k) to wp+1,…,wq−1w_{p+1}, \ldots, w_{q-1}. It is nondecreasing because vkv_k lies between wpw_p and wqw_q on the contour of GkG_k. By line L8, Mk(c)=Mk−1(c)∪{vk}M_k(c) = M_{k-1}(c) \cup \{v_k\} for cc up to wpw_p, Mk(vk)∖{vk}=Mk−1(wp+1)M_k(v_k) \setminus \{v_k\} = M_{k-1}(w_{p+1}), and Mk(c)=Mk−1(c)M_k(c) = M_{k-1}(c) from wqw_q on. So a vertex uu of Gk−1G_{k-1} lies in Mk(ci)∖Mk(ci+1)M_k(c_i) \setminus M_k(c_{i+1}) for the same contour position under both descriptions, with wp+1,…,wq−1w_{p+1}, \ldots, w_{q-1} and their sets merged into the class of vkv_k. Hence uu moves by the same amount under δ\delta and δ′\delta'. The statements about wpw_p, wqw_q and the covered vertices follow from monotonicity. □\square

The invariants

For k≥3k \ge 3, after step kk (and after any later shifts, which restrict to monotone shifts of GkG_k by Lemma 2), consider:

  • (A) x(c1)<x(c2)<⋯<x(ct)x(c_1) < x(c_2) < \cdots < x(c_t), y(c1)=y(ct)=0y(c_1) = y(c_t) = 0, and y(ci)>0y(c_i) > 0 for 1<i<t1 < i < t; every contour edge satisfies ∣y(ci+1)−y(ci)∣≤x(ci+1)−x(ci)|y(c_{i+1}) - y(c_i)| \le x(c_{i+1}) - x(c_i).
  • (B) Right after step kk, every contour edge has slope exactly +1+1 or −1-1.
  • (C) Every bounded face a,b,ca, b, c of GkG_k, listed counterclockwise in the embedding, is drawn as a positively oriented triangle: det⁡(b−a,c−a)>0\det(b - a, c - a) > 0. This holds after step kk and after any monotone shift of GkG_k.

(A) and (C) are preserved by monotone shifts: shifts keep y-coordinates, never decrease x(ci+1)−x(ci)x(c_{i+1}) - x(c_i), and (C) is stated for all monotone shifts.

Base, k=3k = 3. The triangle (0,0)(0,0), (1,1)(1,1), (2,0)(2,0): (A) and (B) hold. The only bounded face is v1,v2,v3v_1, v_2, v_3, counterclockwise; under a monotone shift v1v_1 moves by δ1\delta_1, v3v_3 by δ2\delta_2, v2v_2 by δ3\delta_3, and det⁡(v2−v1,v3−v1)=(x2−x1)⋅1−0⋅(x3−x1)=x2−x1≥2>0\det(v_2 - v_1, v_3 - v_1) = (x_2 - x_1) \cdot 1 - 0 \cdot (x_3 - x_1) = x_2 - x_1 \ge 2 > 0.

Step k≥4k \ge 4. Assume the invariants for Gk−1G_{k-1}. Lines L5 and L6 apply a monotone shift, after which (A) and (C) hold for Gk−1G_{k-1}, contour edges outside wp,…,wqw_p, \ldots, w_q keep slope ±1\pm 1 (both ends move by the same amount), and the edges wpwp+1w_p w_{p+1} and wq−1wqw_{q-1} w_q have gained 1 in width.

Claim 1: every covered vertex wjw_j (p<j<qp < j < q) satisfies yj−yp<xj−xpy_j - y_p < x_j - x_p and yj−yq<xq−xjy_j - y_q < x_q - x_j, and also ∣yq−yp∣<xq−xp|y_q - y_p| < x_q - x_p. By (A) summed along the contour, ∣yj−yi∣≤xj−xi|y_j - y_i| \le x_j - x_i for contour positions i<ji < j before the shift. The shift adds at least 1 to xj−xpx_j - x_p for j>pj > p and at least 1 to xq−xjx_q - x_j for j<qj < q, without changing y-coordinates. This gives strict inequalities.

Placement. Line L7 sets xv−xp=yv−yp=(xq−xp+yq−yp)/2x_v - x_p = y_v - y_p = (x_q - x_p + y_q - y_p)/2 and xq−xv=yv−yq=(xq−xp−yq+yp)/2x_q - x_v = y_v - y_q = (x_q - x_p - y_q + y_p)/2. By Claim 1 both are positive, so xp<xv<xqx_p < x_v < x_q, and they are integers because, by (B) before the shift, xq−xp+yq−ypx_q - x_p + y_q - y_p was a sum of even numbers (xi+1−xi)±(yi+1−yi)(x_{i+1} - x_i) \pm (y_{i+1} - y_i), and the shift added 2. So the new contour satisfies (A), and its two new edges have slopes +1+1 and −1-1, so (B) holds. Also yv>0y_v > 0.

Claim 2: yv−yj>∣xv−xj∣y_v - y_j > |x_v - x_j| for every covered wjw_j. From Claim 1, yj<yp+(xj−xp)y_j < y_p + (x_j - x_p) and yj<yq+(xq−xj)y_j < y_q + (x_q - x_j). The point vv lies on both lines y=yp+(x−xp)y = y_p + (x - x_p) and y=yq+(xq−x)y = y_q + (x_q - x), so yv−yj>(xv−xp)−(xj−xp)=xv−xjy_v - y_j > (x_v - x_p) - (x_j - x_p) = x_v - x_j and yv−yj>(xq−xj)−(xq−xv)=xj−xvy_v - y_j > (x_q - x_j) - (x_q - x_v) = x_j - x_v.

The new faces. The bounded faces of GkG_k not in Gk−1G_{k-1} are the triangles wj,wj+1,vkw_j, w_{j+1}, v_k for p≤j<qp \le j < q, counterclockwise, since wjw_j lies left of wj+1w_{j+1} and vkv_k is above. Write Dj=det⁡(wj+1−wj,v−wj)=(xj+1−xj)(yv−yj)−(yj+1−yj)(xv−xj)D_j = \det(w_{j+1} - w_j, v - w_j) = (x_{j+1} - x_j)(y_v - y_j) - (y_{j+1} - y_j)(x_v - x_j).

  • If p<jp < j and j+1<qj + 1 < q, both wjw_j and wj+1w_{j+1} are covered. Write Δx=xj+1−xj>0\Delta x = x_{j+1} - x_j > 0 (by (A)) and Δy=yj+1−yj\Delta y = y_{j+1} - y_j, with ∣Δy∣≤Δx|\Delta y| \le \Delta x. By Claim 2, yv−yj>∣xv−xj∣y_v - y_j > |x_v - x_j|, so Dj>Δx ∣xv−xj∣−∣Δy∣ ∣xv−xj∣≥0D_j > \Delta x \, |x_v - x_j| - |\Delta y| \, |x_v - x_j| \ge 0.
  • If j=pj = p: vv is on the line of slope +1+1 through wpw_p, so Dp=(xp+1−xp)(xv−xp)−(yp+1−yp)(xv−xp)=(xv−xp)((xp+1−xp)−(yp+1−yp))>0D_p = (x_{p+1} - x_p)(x_v - x_p) - (y_{p+1} - y_p)(x_v - x_p) = (x_v - x_p)\big((x_{p+1} - x_p) - (y_{p+1} - y_p)\big) > 0 by Claim 1 (or by ∣yq−yp∣<xq−xp|y_q - y_p| < x_q - x_p when p+1=qp + 1 = q).
  • If j+1=qj + 1 = q: symmetric, with the line of slope −1-1 through wqw_q.

So (C) holds right after step kk. For a later monotone shift of GkG_k, Lemma 2 says that the movement restricted to Gk−1G_{k-1} is a monotone shift (so the old faces stay positive by the invariant for Gk−1G_{k-1}), and that relative to vkv_k, the vertex wpw_p moves left by some d1≥0d_1 \ge 0, wqw_q moves right by some d2≥0d_2 \ge 0, and the covered vertices do not move. Each DjD_j is an affine function of (d1,d2)(d_1, d_2). Its partial derivative in d1d_1 (when wpw_p is a corner) is yv−yj+1y_v - y_{j+1} or yv−yqy_v - y_q, and in d2d_2 (when wqw_q is a corner) is yv−yjy_v - y_j or yv−ypy_v - y_p; all are positive by Claim 2 and by yv>yp,yqy_v > y_p, y_q. So the DjD_j only grow and stay positive. This proves (C) for GkG_k.

No crossings

Lemma 3. Let HH be a 2-connected plane graph whose bounded faces are triangles, and suppose a straight-line drawing of HH (not assumed plane) draws every bounded face, listed counterclockwise, as a positively oriented triangle, and draws the outer boundary cycle, listed counterclockwise, as a simple polygon PP. Then the drawing has no crossings.

Proof. For a point zz that lies on no drawn edge and is not a vertex, let N(z)N(z) be the number of drawn bounded faces that contain zz. A positively oriented triangle has winding number 1 around its interior points and 0 around exterior points, so N(z)=∑Fw(∂F,z)N(z) = \sum_F w(\partial F, z). Each inner edge appears in two bounded faces with opposite directions, so the sum telescopes to the winding number of the outer boundary: N(z)=w(P,z)N(z) = w(P, z), which is 1 inside PP and 0 outside. If two edges crossed at an interior point, or a vertex lay in the interior of a drawn edge or face, then points near it would lie in two drawn faces: each edge has a drawn face on each side locally (or on one side for an edge of PP), and the faces at an interior vertex cover a neighbourhood with total angle 2π2\pi times a positive integer. That gives N(z)≥2N(z) \ge 2 for some zz, which is impossible. □\square

Theorem. The output is a straight-line drawing of GG without crossings, with integer coordinates in [0,2n−4]×[0,n−2][0, 2n - 4] \times [0, n - 2], that realizes the given rotation system.

Proof. After step nn, Gn=GG_n = G, every bounded face is a positively oriented triangle by (C), and the outer boundary is the triangle v1=(0,0)v_1 = (0,0), vnv_n, v2=(x,0)v_2 = (x, 0) with vnv_n above, which is a simple counterclockwise polygon. Lemma 3 gives a plane drawing. Since every face, including the outer one, keeps its cyclic order and orientation, the counterclockwise order of neighbours at each vertex is the input rotation. The coordinates are integers by the placement argument. Each step adds 2 to x(v2)x(v_2), so x(v2)=2+2(n−3)=2n−4x(v_2) = 2 + 2(n - 3) = 2n - 4; vnv_n attaches to wp=v1w_p = v_1, wq=v2w_q = v_2, so y(vn)=(2n−4)/2=n−2y(v_n) = (2n - 4)/2 = n - 2; and (A) puts every contour vertex, hence every vertex, inside the triangle (0,0)(0,0), (2n−4,0)(2n - 4, 0), (n−2,n−2)(n - 2, n - 2). □\square

The offset implementation computes the same coordinates

Let the shift tree have root v1v_1, with the next contour vertex as a child of each contour vertex, the first covered vertex as a child of the vertex that covers it, and each covered vertex's successor in its covered chain as its child. Each vertex stores its x-offset to its parent, and xx is the sum of offsets on the path from the root.

Lemma 4. After every step, for each contour vertex cc, the descendants of cc in the shift tree are exactly M(c)M(c), and the stored offsets give the same x-coordinates as the explicit shifts.

Proof. For k=3k = 3 the tree is the path v1,v3,v2v_1, v_3, v_2 with offsets 0,1,10, 1, 1, and the descendant sets are M(v1),M(v3),M(v2)M(v_1), M(v_3), M(v_2). At step kk: adding 1 to the offset of wp+1w_{p+1} moves exactly its descendants M(wp+1)M(w_{p+1}) by 1, and adding 1 to the offset of wqw_q moves M(wq)M(w_q) by 1 more, as in lines L5 and L6. The sum of the offsets of wp+1,…,wqw_{p+1}, \ldots, w_q is xq−xpx_q - x_p. Then vkv_k becomes the child of wpw_p with offset xv−xpx_v - x_p, wqw_q becomes a child of vkv_k with offset xq−xvx_q - x_v, and wp+1w_{p+1}, if covered, becomes a child of vkv_k with its offset reduced by xv−xpx_v - x_p; the covered chain keeps its internal offsets. No absolute coordinate changes in this rewiring. The descendants of vkv_k are {vk}\{v_k\}, the covered chain with its subtrees, and wqw_q with its subtree, which is {vk}∪M(wp+1)\{v_k\} \cup M(w_{p+1}); the descendants of the vertices up to wpw_p gain vkv_k; the others are unchanged. This is line L8. □\square

So the implementation outputs the coordinates of the explicit method, which are correct by the theorem. ■\blacksquare

Back to de Fraysseix-Pach-Pollack algorithm