ManimCommunity / ManimCommunity/manim

Hallucinated or dropped edges in Transform of Graph

Open
#3,946 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

When `Transform`ing a `Graph` into another graph with a different number of edges, the resulting animated graph has the same number of edges as the original graph.

For example, when transforming the graph `Graph(["A", "B", "C"], [("A", "B"), ("A", "C")])` to `Graph(["A", "B", "C"], [("A", "B"), ("A", "C"), ("B", "C")])`, the resulting graph should be a triangle, but one edge is dropped.

## Expected behavior

The graph that is the result of a transformation has the number of edges that is specified in the code, not the number of edges the predecessor had.

## How to reproduce the issue

Code for reproducing the problem

```py
from manim import *

class BugDemo(Scene):
def construct(self):
# Create a graph with two edges
graph1 = Graph(["A", "B", "C"], [("A", "B"), ("A", "C")])

# Create another graph with three edges
graph2 = Graph(["A", "B", "C"], [("A", "B"), ("A", "C"), ("B", "C")])

# Display the first graph
self.play(Create(graph1))
self.wait(1)

# Attempt to transform graph1 into graph2
self.play(Transform(graph1, graph2))
self.wait(1)
```

## Additional media files

Images/GIFs

https://github.com/user-attachments/assets/f54ab219-5e51-4817-beb3-ec9b262329c0

## Logs
Terminal output

```
Manim Community v0.18.1

[10/05/24 20:26:24] DEBUG Hashing ... hashing.py:352
DEBUG Hashing done in 0.006551 s. hashing.py:364
DEBUG Hash generated : 1185818338_2661024192_223132457 hashing.py:367
DEBUG List of the first few animation hashes of the scene: ['1185818338_2661024192_223132457'] cairo_renderer.py:97
INFO Animation 0 : Partial movie file written in scene_file_writer.py:527
'/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDemo
/1185818338_2661024192_223132457.mp4'
DEBUG Animation with empty mobject animation.py:175
DEBUG Hashing ... hashing.py:352
DEBUG Hashing done in 0.005637 s. hashing.py:364
DEBUG Hash generated : 624642324_3890345977_2618601865 hashing.py:367
DEBUG List of the first few animation hashes of the scene: ['1185818338_2661024192_223132457', cairo_renderer.py:97
'624642324_3890345977_2618601865']
[10/05/24 20:26:25] INFO Animation 1 : Partial movie file written in scene_file_writer.py:527
'/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDemo
/624642324_3890345977_2618601865.mp4'
DEBUG Hashing ... hashing.py:352
DEBUG Hashing done in 0.011324 s. hashing.py:364
DEBUG Hash generated : 624642324_2810248401_2118276392 hashing.py:367
DEBUG List of the first few animation hashes of the scene: ['1185818338_2661024192_223132457', cairo_renderer.py:97
'624642324_3890345977_2618601865', '624642324_2810248401_2118276392']
INFO Animation 2 : Partial movie file written in scene_file_writer.py:527
'/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDemo
/624642324_2810248401_2118276392.mp4'
DEBUG Animation with empty mobject animation.py:175
DEBUG Hashing ... hashing.py:352
DEBUG Hashing done in 0.006592 s. hashing.py:364
DEBUG Hash generated : 624642324_3890345977_3537993160 hashing.py:367
DEBUG List of the first few animation hashes of the scene: ['1185818338_2661024192_223132457', cairo_renderer.py:97
'624642324_3890345977_2618601865', '624642324_2810248401_2118276392',
'624642324_3890345977_3537993160']
INFO Animation 3 : Partial movie file written in scene_file_writer.py:527
'/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDemo
/624642324_3890345977_3537993160.mp4'
INFO Combining to Movie file. scene_file_writer.py:617
DEBUG Partial movie files to combine (4 files): scene_file_writer.py:561
['/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDem
o/1185818338_2661024192_223132457.mp4',
'/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDemo
/624642324_3890345977_2618601865.mp4',
'/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDemo
/624642324_2810248401_2118276392.mp4',
'/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/partial_movie_files/BugDemo
/624642324_3890345977_3537993160.mp4']
INFO scene_file_writer.py:737
File ready at '/home/niplav/proj/site/anim/turning/media/videos/bug/480p15/BugDemo.mp4'

INFO Rendered BugDemo scene.py:247
Played 4 animations
```

## System specifications

System Details

- OS Void Linux:

```
› uname -a (manim)
Linux REDACTED 6.6.52_1 #1 SMP PREEMPT_DYNAMIC Sat Sep 21 15:47:36 UTC 2024 x86_64 GNU/Linux
› cat /etc/os-release (manim)
NAME="Void"
ID="void"
PRETTY_NAME="Void Linux"
HOME_URL="https://voidlinux.org/"
DOCUMENTATION_URL="https://docs.voidlinux.org/"
LOGO="void-logo"
ANSI_COLOR="0;38;2;71;128;97"

DISTRIB_ID="void"
```
- RAM: 16GB
- Python version (`python/py/python3 --version`):
```
python3 --version (manim)
Python 3.12.5
```
- Installed modules (provide output from `pip list`):
```
Package Version
-------------------- -----------
Brotli 1.1.0
build 1.2.1
CacheControl 0.14.0
certifi 2024.7.4
cffi 1.17.0
charset-normalizer 3.3.2
cleo 2.1.0
click 8.1.7
click-default-group 1.2.4
cloup 3.0.5
colorama 0.4.6
crashtest 0.4.1
cryptography 43.0.0
decorator 5.1.1
distlib 0.3.8
dulwich 0.21.7
fastjsonschema 2.20.0
filelock 3.15.4
future 1.0.0
glcontext 2.5.0
h2 4.1.0
hpack 4.0.0
hyperframe 6.0.1
idna 3.7
importlib_metadata 8.2.0
installer 0.7.0
isosurfaces 0.1.2
jaraco.classes 3.4.0
jeepney 0.8.0
keyring 24.3.1
manim 0.18.1
ManimPango 0.5.0
mapbox_earcut 1.0.1
markdown-it-py 3.0.0
mdurl 0.1.2
moderngl 5.10.0
moderngl-window 2.4.1
more-itertools 10.4.0
msgpack 1.0.8
multipledispatch 0.6.0
networkx 3.3
numpy 1.26.4
packaging 24.1
pexpect 4.9.0
pillow 10.4.0
pip 24.2
pkginfo 1.11.1
platformdirs 4.2.2
poetry 1.8.3
poetry-core 1.9.0
poetry-plugin-export 1.8.0
ptyprocess 0.7.0
pycairo 1.26.1
pycparser 2.22
pydub 0.25.1
pyglet 1.5.27
Pygments 2.18.0
pyproject_hooks 1.1.0
pyrr 0.10.3
PySocks 1.7.1
PyYAML 6.0.2
rapidfuzz 3.9.6
requests 2.32.3
requests-toolbelt 1.0.0
rich 13.7.1
scipy 1.14.0
screeninfo 0.8.1
SecretStorage 3.3.3
setuptools 72.1.0
shellingham 1.5.4
six 1.16.0
skia-pathops 0.8.0.post1
srt 3.5.3
svgelements 1.9.6
tomli 2.0.1
tomlkit 0.13.0
tqdm 4.66.5
trove-classifiers 2024.7.2
typing_extensions 4.12.2
urllib3 2.2.2
virtualenv 20.26.3
watchdog 4.0.1
wheel 0.44.0
zipp 3.19.2
zstandard 0.23.0
```

## Additional comments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Reproduce the issue with the provided Graph and Transform example, then locate the Graph transformation and edge-matching implementation. Done means transforming between graphs with different edge counts preserves exactly the edges specified by the target graph, including both added and removed edges.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.