Skip to content

Improved Pattern.draw_graph visualization#444

Open
CodeMaverick2 wants to merge 7 commits intoTeamGraphix:masterfrom
CodeMaverick2:improve-draw-graph-visualization
Open

Improved Pattern.draw_graph visualization#444
CodeMaverick2 wants to merge 7 commits intoTeamGraphix:masterfrom
CodeMaverick2:improve-draw-graph-visualization

Conversation

@CodeMaverick2
Copy link
Contributor

@CodeMaverick2 CodeMaverick2 commented Feb 17, 2026

Before submitting, please check the following:

  • Make sure you have tests for the new code and that test passes (run nox)
  • If applicable, add a line to the [unreleased] part of CHANGELOG.md, following keep-a-changelog.
  • Format added code by ruff
    • See CONTRIBUTING.md for more details
  • Make sure the checks (github actions) pass.

Then, please fill in below:

Context (if applicable):

  • The current draw_graph uses color-only node differentiation, dashed lines for both edges and layer separators (causing visual confusion), and has no angle display or legend.

Description of the change:

  • Node shapes follow MBQC literature conventions: squares for inputs, filled circles for measured, empty circles for outputs
  • Replaced vertical dashed layer separators with gray labels and a "Measurement order" arrow
  • Graph edges are light dashed lines; correction arrows remain solid — clear visual hierarchy
  • Added show_measurements parameter to display measurement labels (plane + angle in units of π)
  • Added show_legend parameter for node/edge type legend
  • Added _format_measurement_label static method with unit tests
  • Regenerated baseline images

From issue -

523657674-01c8766d-25cb-4236-828b-76b94bc7cb19

Generated with PR changes -

after_issue_legend

The first image (before) is the example from the issue; the second (after) is the same pattern rendered with this PR.
Inputs (node 1) are now squares instead of red circles, measured nodes are filled black, Pauli-measured nodes (node 3) are blue, and outputs (2, 6, 7) are empty circles.
Dashed layer separators are replaced by a horizontal arrow with layer labels.
Measurement labels show plane and angle (e.g. XZ(π/10)).
Graph edges (light dashed) are visually distinct from correction arrows (solid). A legend explains all visual elements.

Related issue:
#387

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 95.38462% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.82%. Comparing base (03a89c9) to head (d3adee9).

Files with missing lines Patch % Lines
graphix/visualization.py 95.38% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
+ Coverage   88.76%   88.82%   +0.06%     
==========================================
  Files          44       44              
  Lines        6308     6343      +35     
==========================================
+ Hits         5599     5634      +35     
  Misses        709      709              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CodeMaverick2
Copy link
Contributor Author

CI fails on Python 3.10–3.13 due to a pre-existing bug in the veriphix reverse dependency, unrelated to this PR. Passes on Python 3.14 because veriphix is excluded from that version. All graphix tests and other reverse dependencies pass.

@thierry-martinez
Copy link
Collaborator

Veriphix CI is now fixed. It's all green now!

@CodeMaverick2
Copy link
Contributor Author

CodeMaverick2 commented Feb 18, 2026

Hey @thierry-martinez, could someone from the team please review my PR and let me know if any changes are required

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.

2 participants

Comments