Proofs: Finding faces of a planar graph
These are the human proofs of Finding faces of a planar graph, at full length.
Face tracing outputs each cycle of the face permutation exactly once full
This proof shows: correctness, termination.
Let be a simple undirected graph with a rotation system , and let be its set of darts. For a vertex of degree write , read cyclically, and let pos be the index of in . Define
which is exactly the dart computed by lines L8 and L9.
Lemma 1 ( is a permutation of ). Define with . Both maps send darts to darts: is a dart because is a neighbour of for each . For each dart , , because the index of 's head in is pos, and adding 1 gives back . Likewise . So is a bijection of the finite set .
Hence is the disjoint union of the cycles of : for each there is a least with , and the cycle of is , with distinct elements.
Lemma 2 (one walk is one whole cycle). Suppose that at line L5 the start dart is not visited, and that every visited dart lies in a cycle that is disjoint from . Then the loop of lines L6 to L9 visits exactly the darts in this order, appends their tails to , and stops.
Proof. Invariant at the test of line L6, after iterations with : , the darts are visited and are the last darts marked, and holds their tails in order. It holds for . If , then is in and differs from the darts of the cycle visited so far, and it was not visited before the walk by the hypothesis. So the test succeeds, line L7 marks it and appends its tail, and line L9 sets . If , then , which line L7 marked in the first iteration, so the loop stops.
Theorem (correctness and termination). FACES stops after exactly iterations of line L7, and the list it returns contains each cycle of exactly once, as the sequence of tails of its darts in the order of .
Proof. We show by induction over the iterations of the loop of line L3 that, at the start of each iteration, the visited set is the union of the cycles already appended to , and that these cycles are distinct.
At the start, both are empty. Consider the iteration for the dart . If is visited, line L4 skips it and nothing changes. If not, then by the induction hypothesis the visited darts form whole cycles that do not contain ; since cycles are disjoint, none of them meets . Lemma 2 applies: the walk appends exactly , a cycle not yet in , and the visited set becomes the union of the old cycles and this one. So the statement holds after the iteration.
Each dart of is taken once by line L3. At the end, every dart was either visited before its turn or started a walk, so every dart is visited, and the visited set, which is the union of the cycles in , is all of . Since the cycles in are distinct and cover , contains each cycle exactly once. Line L7 marks each dart once, so it runs exactly times, and line L3 runs times; the algorithm stops.
Faces of a drawing. Suppose now that is read from a straight-line planar drawing, with in counterclockwise order. Fix a vertex and a disc around so small that it meets only the segments at and no other vertex. The segments at cut into open sectors, one between each pair of rays that are consecutive in , and each sector lies in one face. Let a walk arrive at along the dart . Put at the origin with the ray to pointing in the direction of angle 0. Walking from toward moves in the direction of angle , and its left side is the side of angles just below , which is the sector between the ray to and the next ray clockwise. That next ray goes to the neighbour just before in the counterclockwise order , so the sector is the one between the rays to and to . Leaving along , the left side is the side just counterclockwise of the ray to , which is the same sector. So the face on the left of near is also on the left of . By induction along a cycle, all darts of one cycle of have the same face on their left. Conversely, each face of a connected plane graph has a boundary that is one closed walk (Mohar and Thomassen, Chapters 3 and 4), so it is the face on the left of exactly one cycle of . Therefore, for a connected drawing, the walks in are the face boundaries, one for each face.