Proofs: Schnyder drawing algorithm
These are the human proofs of Schnyder drawing algorithm, at full length.
Schnyder's algorithm draws every planar graph without crossings on the (n-2) by (n-2) grid full
This proof shows: correctness, termination.
Let be a planar rotation system of a simple graph with vertices. We show that SCHNYDER-DRAWING stops and returns integer points in that give a planar straight-line drawing of . Indices of colours are taken mod 3. A plane graph is a graph with a fixed planar rotation system; we use the Jordan curve theorem for the cycles of a plane graph.
Step 1 (line L1 gives a plane triangulation that contains ). Each new edge is drawn inside one face, between two corners of that face, so the graph stays plane, and the old edges keep their cyclic order. Joining two components at any corners merges one face of each into one face. In the second phase, the new edge sits in the corner of between and . Here , and is not an edge: otherwise is a cycle and , lie in the same biconnected component, and the union-find structure merges components exactly along such new cycles. After the pass, at every vertex any two consecutive edges, hence all edges, lie in one component, so no vertex is a cut vertex, and is 2-connected. In a 2-connected plane graph with at least 3 vertices every face is bounded by a cycle (Diestel, Section 4.2). In the third phase, a face cycle with cannot have both and as edges: both would lie outside the face, inside the disc bounded by the face cycle on the other side, with interleaved ends, and they would cross. So L1 adds a new edge each time, splits off a triangle, and stops with every face a triangle on three distinct vertices: a simple plane triangulation.
Step 2 (line L3 never gets stuck). Let with , be the current path and the graph not yet removed. Invariant: plus the edge is a cycle bounding the outer face of , and every other face of is a triangle. This holds at the start, with . Suppose . If no chord other than exists, every with is chord-free. Otherwise, take a chord other than with least. A chord from , , to some would be shorter if , and would cross inside the disc bounded by the cycle if or . So is chord-free. Let be chord-free. Since the faces around are triangles, its neighbours in , counterclockwise from to , form a path , and no is on , because has no chord. Removing replaces on the path by ; the new path is simple, and the invariant holds. The stack holds every chord-free path vertex: a new path vertex is pushed when its count is 0, and an old path vertex loses a chord only in the case , where it is pushed. So L3 removes vertices and ends with the path . Read backwards, the removal order , , is a canonical ordering.
Step 3 (two orders). For a vertex , let be its position in the canonical ordering. Line L4 sets to vertices removed later, so of smaller index, and for vertices removed later than , so of larger index. Next, build a list of vertices from left to right, going through the canonical order forwards: start with , and insert each immediately before its right lower neighbour . Since each is inserted between and , after all vertices between them, precedes , the vertices precede , and precedes . So, writing for the edge from to its parent:
| edge | position in | |
|---|---|---|
| decreases | decreases | |
| decreases | increases | |
| increases | increases |
In particular each is acyclic, and following parents of colour from an inner vertex ends at a vertex with no parent of colour . Such a vertex is outer. It is : every inner edge at is labelled of colour 1, since stays the leftmost path vertex and can only be the left neighbour ; likewise only receives colour 2, and the inner neighbours of are exactly the vertices below at the first step, which receive colour 3. So is a tree rooted at , and is well defined. Every inner edge , with earlier than , is labelled exactly once, when is removed and is one of , or below ; the edges , , get no label.
Lemma 1. For an inner vertex , the paths , , pairwise meet only in .
Proof. Along the index increases and along and it decreases, so meets the others only at . Along the position in decreases and along it increases, so they meet only at .
Step 4 (the local rule). Fix an inner vertex . Draw the path at the time is added as running from left to right, with the part already built below it. Counterclockwise around , starting at , come the vertices below , then , then the neighbours added later, from right to left. A later neighbour uses as its left neighbour while is on the path and is to the right of , as its right neighbour when is to the left, and as a vertex below exactly once, for the vertex that removes from the path. Each new edge with to the right is inserted in the rotation at next to the current edge to the right path neighbour, on the upper side, and similarly on the left. So counterclockwise around we see: the outgoing edge of colour 1 (to ), incoming edges of colour 3 (from the vertices below ), the outgoing edge of colour 2 (to ), incoming edges of colour 1 (later neighbours on the right), the outgoing edge of colour 3 (to ), and incoming edges of colour 2 (later neighbours on the left). This is the rule of a Schnyder wood. Rotating the colour names, at every inner vertex, counterclockwise:
Step 5 (regions). For an inner vertex , the cycle is simple by Lemma 1. Let be the closed disc that it bounds inside the outer triangle; we also write for the set of vertices in it. Near , the disc is one of the two wedges between and . It is the wedge that does not contain , because leaves through that edge, never meets the cycle again (Lemma 1, and is not on the cycle), and ends at the outer vertex , outside the disc. By (1) this wedge contains the incoming edges of colour at and no incoming edges of colours . Along , the disc stays on one side. At a vertex of , the path enters through an incoming edge of colour and leaves through , and by (1) the side of the disc contains and , but no incoming edge of colour , since those lie on the other side, between and . Symmetrically, at a vertex of , the side of the disc contains and , and no incoming edge of colour . At and no edge of colour enters. We record:
(A) No edge of colour enters a vertex of from inside , and no edge of colour enters a vertex of from inside . Every edge of colour that enters a boundary vertex comes from inside, and every outgoing edge of colour at a boundary vertex points outside.
The three discs , , cover the outer triangle and overlap only on the three paths, since the three paths cut the triangle into three parts.
Lemma 2. Let be inner and an inner vertex, . Then . If , then does not meet ; if , then meets only in .
Proof. Follow . It can leave the disc only through a boundary vertex. If it reaches a vertex of , it continues along , since both follow the parents in , and stays on the boundary. By (A) it cannot enter a vertex of from inside; and if it starts at , then points into the disc, as shown in Step 5. So stays in and meets at most in its start. Symmetrically, stays in . The cycle bounding therefore lies in the disc , and so does the disc it bounds.
Lemma 3. Let be inner and an inner vertex, . Then , with equality only if .
Proof. Let and . A vertex of that lies in is on the boundary of , hence on the boundary of , so it lies on or .
If , let be the first vertex of on ; it exists because both end at , and from on the two paths coincide. The vertices of before are not on , and not on by Lemma 2, so they are in . Hence
If , then is the part of from on, and the vertices before are not on by Lemma 2, so they are in , and the same computation gives .
Step 6 (lines L5 to L7 compute ). Let be strictly inside . ends at , so it reaches a first boundary vertex ; is inner, since no edge of colour enters . Conversely, by (A), the children in of a boundary vertex lie strictly inside, and a path in that touches the boundary leaves the disc through an outgoing edge of colour and can never re-enter it, since edges of colour enter the boundary only from inside. So the vertices strictly inside are the disjoint union, over the inner vertices of , of the subtrees of in without . Counting once,
which is line L7. Line L6 computes and from the root of down.
Step 7 (coordinates). Every vertex lies in exactly one region, except the vertices of , which lie in two, and , which lies in three. So
and the corners of L8 sum to too. Since and , every coordinate of an inner vertex is at least 1, hence at most . So all output points lie in .
For write if is lexicographically smaller than . Claim: for every edge and every vertex , there is an with and .
If , take this : every other vertex has when ; for the graph is a triangle and there is nothing to prove. If is inner, the edge does not cross the three paths of , so both ends lie in one region . Take an end . If is inner, Lemma 3 gives , or and . In the second case lies on the boundary path of and, by Lemma 1, not on , so Lemma 3 for colour gives . Either way . If is a corner in , it is , with , or , with and . This proves the claim.
Step 8 (no crossings). All points lie in the plane , and L9 projects it to the first two coordinates by an affine bijection. For a small , the linear function orders the integer points as does. Distinct vertices get distinct points: if , pick an edge with , which exists since every vertex of a triangulation with has degree at least 3; the claim gives , a contradiction. A vertex does not lie on an edge with , because . Two edges with a common end overlap only if one contains the other end, which was just excluded. Suppose edges and with four distinct ends intersect. By the claim there are with and with . If , both and , and the whole segment , lie in the open half-plane , which misses the segment . So , and likewise there are with beating in and in . Two 2-element subsets of meet, say . Then and , a contradiction. So the drawing of the triangulation is planar, and so is the drawing of its subgraph .
Step 9 (orientation). For the triangulation is 3-connected, so its planar embeddings are and its mirror image, and the drawing realizes one of them. The corners , , are in counterclockwise order, since , and in the outer face lists counterclockwise too. So the drawing realizes , not its mirror image, and the edges of keep their order. For this is immediate.
Termination. Every loop runs over a finite set: L1 adds at most edges, L3 removes each vertex at most once and pops each pushed vertex once, and L5 to L7 pass over each tree a constant number of times.