Skip to content

feat: add observer-based recording and animation for the canonicalizer#207

Merged
gksmail merged 4 commits into
QPauLie:mainfrom
Gmin2:graph-trans-animation
Jun 10, 2026
Merged

feat: add observer-based recording and animation for the canonicalizer#207
gksmail merged 4 commits into
QPauLie:mainfrom
Gmin2:graph-trans-animation

Conversation

@Gmin2

@Gmin2 Gmin2 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #199

this brings back the animation feature for the classification algorithm, which got dropped when the algorithm was rewritten. it wraps the current Canonicalizer using the observer pattern: the canonicalizer is the publisher and emits an event at each step (lighting, contraction, attach, p/q merge, removals, replacements, dependent vertices), and a recorder subscribes to capture frames. nothing in the algorithm changes, the recorder only watches, so all existing tests still pass and a recorded run gives the same algebra as a plain one.

a renderer turns the recording into a gif with a color per node role, and the two worked examples in classification.rst (A-type 4*so(5) and B-type sp(4)) now have embedded animations plus a color legend. added tests for the frame invariants and a script to regenerate the doc gifs.

classification_a_type classification_b_type

@Gmin2

Gmin2 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

cc @AmanieOxana

@gksmail

gksmail commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

There are lint errors in the code, please look at them and correct them
https://github.com/QPauLie/PauLie/actions/runs/26919430510/job/79425007865?pr=207

@Gmin2

Gmin2 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Hey @gksmail now thw ci should be green!

@gksmail

gksmail commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator
image

Hi, can you change the title of the last frame? Add the algebra name to the title.
Something like "Canonical graph of type B3: su(1024)". So the result is visible in the image.

Comment thread docs/source/user/classification.rst Outdated

.. table:: Colour legend for the node roles tracked while building the canonical graph.

+-----------------------+--------------------------------------------------------------+

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

People cannot associate uncommon colours with names easily. I would suggest placing a box showing the colour next to the name or something similar, and/or using more distinguishable colours.

Comment thread docs/source/user/classification.rst Outdated
algebra = 4*so(5)

.. Here we should add some definitions like lit, dependent etc.
The animation below follows the construction of one of the four canonical components. Starting from

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The animations as they are right now change very fast. Previously, animations had a control bar where you could step through the animation frame-by-frame, or play/rewind/stop/etc. This needs to be brought back. You may refer to earlier commits in this repository to check how that looked like.

return NODE_ROLE_COLORS["lit"]
return NODE_ROLE_COLORS["unlit"]

def _animation_graph(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This entire function could do with more inline comments to explain the purpose of each block. Particular, lines 162-249 are not clear at a glance.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is my code. I wrote it a long time ago, even before lint and comments. There the geometry of the graph is calculated.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see, but I still think some comments should be added to explain the geometry. For example "this block aligns all unlit vertices in a row for Step IV", like that.

@Gmin2

Gmin2 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

thanks @Newtech66 @gksmail , pushed fixes for everything yu mentioned above in the review, algebra name in the last frame title, a more distinguishable colour palette with a swatch legend, an interactive play/pause/step player instead of the gif, and comments through build_positions explaining the geometry.

one note, i described the geometry blocks by what they do rather than the old "Step IV" labels since the current algorithm has no numbered steps, happy to reword if you prefer.

@gksmail

gksmail commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator
image image

Thanks! A small detail is that when a vertex is added to the end of a long line graph, the distance between the transferred lines increases. This is not serious, it would be good if the position of the graph and distances did not jump during animation. It will look smoother this way. I'm looking at algebra a17, with n=10

@gksmail

gksmail commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

It will be necessary to rebase. After the adoption of PR on isomorphism, a conflict arose

@Gmin2 Gmin2 force-pushed the graph-trans-animation branch from 43bd8f6 to f6f6181 Compare June 10, 2026 09:59
@Gmin2

Gmin2 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@gksmail all frames now share one fixed viewport and spacing so the graph stays put during the animation, and also rebased

@Gmin2 Gmin2 requested a review from gksmail June 10, 2026 10:01
@gksmail

gksmail commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator
a1_10

Last time it was better. The image is no longer centered. It jumps even more. And the picture is not stretched.

@Gmin2 Gmin2 force-pushed the graph-trans-animation branch from f6f6181 to b97b1c2 Compare June 10, 2026 11:13
@Gmin2

Gmin2 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

my bad on the last push, i only checked that consecutive frames dont jump, not the overall composition, so the fixed viewport left the graph small and off-centre; now every frame is centred with one shared spacing and the labels are staggered so they stay readable at n=10:

see the image
a17_n10_fixed

@gksmail

gksmail commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

@Gmin2 Gmin2 force-pushed the graph-trans-animation branch from b97b1c2 to 37fe626 Compare June 10, 2026 16:05
@Gmin2

Gmin2 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

hey the lint err should be fixed now !

@gksmail

gksmail commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks

@gksmail gksmail merged commit 32a067d into QPauLie:main Jun 10, 2026
2 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.

Animations of Graph Transformation

3 participants