From Euler’s Formula to Linear-Time Testing
Euler supplied the first numerical invariant of a crossing-free drawing. Kuratowski later identified the two unavoidable topological obstructions, and Hopcroft and Tarjan showed that planarity can be decided in linear time. The modern problem is richer than a yes/no test: when a graph is planar, we want an embedding; when it is not, we often want a compact witness.
The conceptual progression
A Crossed Drawing Is Not a Nonplanarity Proof
A graph is planar if it has some drawing in the plane where edges meet only at common endpoints. A plane graph is a planar graph together with one particular crossing-free embedding.
Topology, not aesthetics
Edge curves may bend as much as needed. Their exact coordinates do not matter; only which vertices are joined and whether edge interiors intersect.
Euler’s Formula Gives Fast Rejection Bounds
For a connected plane graph, with $n$ vertices, $m$ edges, and $f$ faces including the outer face:
In a simple planar graph with $n\ge3$, each face boundary has length at least $3$, while every edge borders two face-sides. Thus $3f\le2m$. Combining the inequalities with Euler’s formula gives:
If the graph is bipartite, it has no odd cycle, so every face has length at least $4$ and the stronger bound is:
| Check | If it fails | If it passes |
|---|---|---|
| Simple bound $m\le3n-6$ | Definitely nonplanar | Still unknown |
| Bipartite bound $m\le2n-4$ | Definitely nonplanar | Still unknown |
| Full planarity test | Returns an obstruction | Returns an embedding |
A bound is a one-way filter
Too many edges proves nonplanarity. Few enough edges proves nothing. Subdividing obstruction edges adds vertices without removing the topological obstruction, so a nonplanar graph can be very sparse.
The Two Shapes Behind Every Nonplanar Graph
$K_5$ connects every pair of five vertices. $K_{3,3}$ connects each of three left vertices to each of three right vertices. Neither is planar.
A subdivision replaces an edge with a path by inserting degree-2 vertices. Suppressing those degree-2 vertices recovers the original obstruction. This explains why edge-density bounds are incomplete: subdivisions make a graph larger and sparser without making it planar.
Kuratowski view
Look for a subgraph that is a subdivision of $K_5$ or $K_{3,3}$.
Wagner view
A graph is planar exactly when it has neither $K_5$ nor $K_{3,3}$ as a minor.
What a Linear-Time Tester Actually Does
Production algorithms differ in their data structures, but the shared logic is to expose how non-tree edges must attach around a DFS skeleton and check whether all left/right placement constraints can be satisfied.
flowchart TD
G[Normalize graph and split components] --> B[Process biconnected blocks]
B --> D[Build DFS tree and lowpoint data]
D --> C[Propagate embedding constraints]
C --> Q{Constraints consistent?}
Q -->|Yes| P[Return planar rotation system]
Q -->|No| K[Return Kuratowski witness]
- Normalize: handle isolated vertices, components, self-loops, and parallel edges according to the library’s contract.
- Decompose: planarity can be checked block by block because articulation vertices can join planar pieces.
- Search: a DFS tree orders ancestor paths; lowpoint information summarizes how subtrees reconnect upward.
- Constrain: back-edge attachments must be placed consistently on the two sides of partial embeddings.
- Certify: produce a rotation system or extract a $K_5/K_{3,3}$ subdivision.
A certificate is more useful than a boolean
A planar embedding can drive a drawing or face traversal. A Kuratowski witness explains exactly which part of a nonplanar input makes success impossible.
The Real Positive Output: A Rotation System
A combinatorial embedding records the cyclic order of incident edges around every vertex. This rotation system determines how edges thread through the plane without committing to screen coordinates.
| Output | What it contains | What it enables |
|---|---|---|
| Boolean | Planar or nonplanar | Filtering only |
| Rotation system | Cyclic neighbor order at each vertex | Face traversal, dual graph, drawing |
| Kuratowski witness | Obstruction subgraph with subdivision paths | Debugging and explanation |
| Coordinates | A geometric realization | Rendering; usually produced by a later layout step |
For simple planar graphs, Fáry’s theorem guarantees that some crossing-free straight-line drawing exists. The planarity tester usually supplies the topology first; a planar drawing algorithm then chooses coordinates and visual spacing.
Embedding is not layout
A rotation system answers “which edge comes next around this vertex?” It does not decide edge lengths, angles, labels, or aesthetic balance.
Implement the Safe Prechecks; Reuse the Full Tester
Density checks are simple and valuable, but their return type should communicate definite rejection, not planarity. The snippets assume a simple graph.
Recommended software boundary
Keep normalization and cheap rejection checks in application code. Delegate the full embedding constraints to a mature planarity implementation, and request its rotation system or obstruction witness rather than only a boolean.
Integration checklist
- Confirm whether the tester accepts multigraphs, self-loops, and disconnected inputs.
- Preserve an edge-ID map if simplified edges must be restored later.
- Request an embedding when faces, a dual graph, or coordinates will follow.
- Validate that every original edge appears exactly twice in the directed-edge face traversal.
- Request or verify a nonplanarity witness when diagnostics matter.
Worked Examples: What Each Check Can Prove
| Graph | $n$ | $m$ | Density result | Actual status |
|---|---|---|---|---|
| $K_4$ | $4$ | $6$ | Meets $3n-6=6$ | Planar |
| $K_5$ | $5$ | $10$ | Fails $m\le9$ | Nonplanar immediately |
| $K_{3,3}$, general bound | $6$ | $9$ | Passes $m\le12$ | Still nonplanar |
| $K_{3,3}$, bipartite bound | $6$ | $9$ | Fails $m\le8$ | Nonplanar immediately |
| Every $K_{3,3}$ edge subdivided once | $15$ | $18$ | Passes even $m\le26$ | Nonplanar by Kuratowski |
The final row is the important one: adding degree-2 vertices dilutes density while preserving the obstruction. No edge-count inequality can replace the structural test.
Reason about a subdivision
Subdivide every edge of $K_5$ once. The new graph has $15$ vertices and $20$ edges. Does passing both density bounds make it planar?
Answer: no. Suppressing the ten new degree-2 vertices recovers $K_5$, so Kuratowski’s obstruction is still present.
Where Planarity Testing Pays Off
Single-Layer Feasibility
A topological routing model can reveal whether crossings are unavoidable before geometric spacing and manufacturing rules are added.
Embedding Before Layout
A rotation system provides the face structure needed by planar straight-line and orthogonal drawing algorithms.
Topological Validation
Check whether an abstract adjacency model can be represented without unintended intersections.
Unlock Planar Algorithms
Verified planar structure enables separators, duality, and specialized algorithms with stronger guarantees.
Topology is only the first routing layer
A planar abstract graph may still be difficult to route with fixed terminal positions, obstacles, minimum spacing, or restricted bend counts. Those are geometric constraints beyond planarity.
Common Misreadings and Boundary Cases
| Mistake | Why it fails | Better interpretation |
|---|---|---|
| “My sketch crosses, so the graph is nonplanar.” | Another embedding may remove crossings. | Test the abstract graph. |
| “The edge bound passes, so it is planar.” | The bounds are necessary, not sufficient. | Continue to a full test. |
| Treating a geometric crossing as a vertex | That changes the graph’s adjacency. | Crossings are not vertices unless explicitly modeled. |
| Using simple-graph bounds on loops or parallel edges | Face-length assumptions change. | Simplify first or use the tester’s multigraph rules. |
| Expecting coordinates from an embedding | A rotation system is combinatorial. | Run a planar layout stage afterward. |
| Confusing planarity with minimum crossings | Testing zero crossings is easier than optimizing a positive number. | Use a crossing-number or crossing-minimization method. |
Complexity and Choosing the Right Tool
Hopcroft–Tarjan, Boyer–Myrvold, and other established approaches run in $O(n+m)$ time. The asymptotic result is elegant; the implementation details are subtle enough that a mature library is usually safer than a fresh production implementation.
| Goal | Good starting point | Output |
|---|---|---|
| Cheap rejection | Euler density bounds | Definitely nonplanar or unknown |
| Decide planarity | Linear-time planarity tester | Boolean |
| Draw a planar graph | Tester + embedding + planar layout | Coordinates and routes |
| Explain nonplanarity | Tester with witness extraction | $K_5/K_{3,3}$ subdivision |
| Minimize crossings | Crossing-minimization method | A drawing with few crossings |
| Maintain planarity under updates | Dynamic planarity data structure | Update-aware embedding state |
Mental model to keep
Density bounds can reject, obstructions can explain, and a full tester decides. A successful result is best understood as a cyclic edge order around every vertex—not merely a prettier version of the input sketch.