Skip to content

[spqr_tree] Per-node planarity testing + virtual-edge skeleton embeddings - #18

Open
devin-ai-integration[bot] wants to merge 7 commits into
spqrfrom
devin/1753172000-spqr-embedding
Open

[spqr_tree] Per-node planarity testing + virtual-edge skeleton embeddings#18
devin-ai-integration[bot] wants to merge 7 commits into
spqrfrom
devin/1753172000-spqr-embedding

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds planarity testing and combinatorial embedding to spqr_tree, computed per SPQR node as each skeleton is sealed (in finalize_node), not as a separate pass.

New API:

  • nodes[n].planar (only R skeletons can fail), blocks[b].planar, is_planar (conjunctions).
  • embed_next: a rotation system over virtual-edge half-edges, node by node — half-edge 2*ve+k is vedges[ve]'s endpoint at vs[k], embed_next[h] is the next half-edge around that skeleton vertex. Glue across nodes via vedges[ve].o_ve (R rotations unique up to reflection, P freely permutable, S/Q/I/O rigid).

How: each sealed vedge range is already a DFS of the node's skeleton (every tree vedge appears after its whole subtree; every vedge is a collapsed 2-attachment component, so it acts as a single tree/back edge). emit_node_embedding handles Q/I/O/S/P trivially; emit_rigid does four passes over the range: index skeleton vertices → recompute skeleton lowpoints bottom-up + re-sort each vertex's outgoing vedges by skeleton nesting depth (collapsing a subtree can change its lowpt/chordality, so the original bucket-sorted order is not a valid nesting order — this was verified empirically) → Brandes' left-right test on the skeleton (conflict-pair stack, implicit two-coloring via lr_ref/lr_side) → sign resolution + rotation emission. A non-planar R skeleton only clears its own flag and falls back to an arbitrary (still circular) rotation; the rest of the block is unaffected.

Design notes in doc/spqr_planarity.md.

Validation

  • Existing structural tests + new per-node checks (rotation at each skeleton vertex is a circular permutation of exactly its incident half-edges; every planar node satisfies V - E + F == 2, i.e. genus 0) pass under ASan/UBSan, including 4000 extra random multigraphs up to 60 vertices / 140 edges.
  • Fixtures: K4, K5, K5−e, K3,3, Petersen, cube, multigraphs with self loops/parallels/bridges; K5 + square through a cutvertex (per-block flags); K5 and K4 sharing an edge (one block, two R nodes, only one non-planar).
  • is_planar matches networkx on 60,000 random multigraphs.

Link to Devin session: https://app.devin.ai/sessions/8d675c3c6ba24d019643c3fabdd14e23
Requested by: @ecnerwala


Open in Devin Review (Beta)

@ecnerwala ecnerwala self-assigned this Jul 22, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@beta-devin-ai-integration beta-devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review (Beta)

Co-Authored-By: Andrew He <he.andrew.mail@gmail.com>
@devin-ai-integration devin-ai-integration Bot changed the title [spqr_tree] Integrated LR planarity testing + combinatorial embedding [spqr_tree] Per-node planarity testing + virtual-edge skeleton embeddings Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant