Skip to content

Fix truncation of degree-one vertex labels - #108

Merged
john-boyer-phd merged 1 commit into
graph-algorithms:masterfrom
sjh9714:codex/20260922-105-leaf-labels
Sep 22, 2026
Merged

john-boyer-phd merged 1 commit into
graph-algorithms:masterfrom
sjh9714:codex/20260922-105-leaf-labels

Conversation

@sjh9714

@sjh9714 sjh9714 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Resolves #105.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

A degree-one vertex has identical start and end coordinates, but its rounded rectangle still has padding. The truncation check used the zero-width interval and replaced even a single digit with .... Measure the actual rectangle bounds, including padding, so labels that fit are retained. This leaves the vertex geometry and truncation algorithm unchanged.

Changes

Added

  • tests/test_draw_labels.py: path and single-edge regressions through both draw entry points at the default and reported figure sizes, plus long-label truncation coverage.

Updated

  • planarity/express/planarity.pyx: use the rounded rectangle's bounds for label width.

Testing

  • .venv/bin/python -m pip install .
  • .venv/bin/pytest -vv — 58 passed; the 10 new cases failed before the fix.
  • .venv/bin/python -m build --outdir /tmp/creator-planarity-dist — sdist and wheel built.
  • Inspected Agg-rendered PNGs for the path, single edge and long-label cases.

PATH="$PWD/.venv/bin:$PATH" .venv/bin/cython-lint planarity/express/planarity.pyx reports the same 10 pre-existing style violations before and after this change. Verified locally on macOS with Python 3.14.6; the other CI platforms/Python versions were not run locally.

@john-boyer-phd john-boyer-phd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The difference between the right line of code and the almost right line of code can be like the difference between lightning and the lightning bug.
Good work, thank you!

@john-boyer-phd
john-boyer-phd merged commit 9a67847 into graph-algorithms:master Sep 22, 2026
5 checks passed
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.

Express API: The draw() method elides the labels of degree one vertices

2 participants