Skip to content

Interactive tool for Pattern.draw_graph #388

@matulni

Description

@matulni

This issue qualifies for UnitaryDESIGN 2026 !

Context

In MBQC, patterns represent programs and consist of a sequence of commands (see graphix.pattern and graphix.commands, and [1]):

  • $N(i)$: initializes qubit $i$
  • $E(i, j)$: entangles qubits $i, j$ (applies a $CZ_{ij}$ gate).
  • $M(i)$: measures qubit $i$.
  • $X(i), Z(i)$: applies a $X$ or $Z$ Pauli correction on qubit $i$.

Accordingly and provided the pattern is runable, a qubit $i$ (also denoted node in the MBQC jargon) can be found in three different states:

  • Uninitialized [before the $N(i)$ command].
  • Alive [after the $N(i)$ command and before the $M(i)$].
  • Measured [after the $M(i)$ command].

Graphix offers tools to manipulate, simulate and visualize these patterns. See #387 for additional information on how patterns are represented in Graphix.

Task

Design an interactive, educational tool for visualizing patterns. We propose implementing it as a new module built on top of matplotlib, though we are open to alternative approaches.

The tool should display:

  • The sequence of commands (see :func: Pattern.to_unicode).
  • A graphical visualization of the pattern (see :func: Pattern.draw_graph).

The user should be able to execute up to a command in the pattern by clicking on it. On this click event:

  • Executed commands (commands on the right including the selected one) should be highlighted (e.g., executed commands in green, unexecuted ones in black).

  • The pattern visualization should be updated accordingly as well. That is, to show changes in qubit states (uninitialized, alive, measured) and the application of entanglement operations. (This could be achieved, for instance, by tuning the opacity of the graph's nodes and edges depending on their state).

Example:
Consider the pattern X₁⁰ M₀ E₀₋₁ N₁. If the user clicks the command E₀₋₁, the visualization should highlight E₀₋₁ N₁ and show nodes $0$ and $1$ and edge $0-1$. Upon clicking M₀, this command should be highlighted as well, and the visualization should grey out node $0$ because it's been measured.

Stretch goal:
Additionally, the highlighted part of the pattern could be simulated on the background and the resulting measurement outputs shown in the visualization as well.

References

[1] Danos, Kashefi and Panangaden, 2007 (arXiv:0704.1263).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions