ManimCommunity / ManimCommunity/manim

DiGraph edges not being laid out properly

Open
#4,323 1 comment 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 I added a DiGraph the edges were 'crocked'. They were not aligned from center-to-center to each 'Node' (or vertex).

![Image](https://github.com/user-attachments/assets/25dd1828-cc03-4372-a1fa-6adf4545a657)

## Expected behavior

This should be the expected output (this oe i got drom modifying the Graph.

![Image](https://github.com/user-attachments/assets/adb28365-2e09-489a-9789-180783710394)

## How to reproduce the issue

The error code
```python
class Issue(Scene):
def construct(self):
vertices = [0, 1, 2, 3, 4, 5, 6, 7]
verticesGraph = [3, 1, 2, 0, 4, 7, 6, 5]
edges = [(0,2), (0,3), (0,4), (1,2), (1,7), (2,5), (3,5), (3,7), (4,7), (5,6), (6,7)]

adj_list = {v: [] for v in vertices}
for i, j in edges:
adj_list[i].append(j)

graph = DiGraph(verticesGraph, edges, layout='circular', layout_scale=2.7,
vertex_mobjects={v : Node(v) for v in vertices},
edge_config={"stroke_color": EDGE_COL, "stroke_width": 6})

self.add(graph)
```

This is the code i used for the 'Expected' output
```python
class DAGArrow(Arrow):
def __init__(
self,
*args: Any,
**kwargs: Any,
):
super().__init__(buff=0.46, *args, **kwargs)

class Issue(Scene):
def construct(self):
vertices = [0, 1, 2, 3, 4, 5, 6, 7]
verticesGraph = [3, 1, 2, 0, 4, 7, 6, 5]
edges = [(0,2), (0,3), (0,4), (1,2), (1,7), (2,5), (3,5), (3,7), (4,7), (5,6), (6,7)]

adj_list = {v: [] for v in vertices}
for i, j in edges:
adj_list[i].append(j)

graph = Graph(verticesGraph, edges, layout='circular', layout_scale=2.7,
vertex_mobjects={v : Node(v) for v in vertices},
edge_config={"stroke_color": EDGE_COL, "stroke_width": 6},
edge_type=DAGArrow)

self.add(graph)
```

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

Start by running the provided Python Scene reproduction with DiGraph and compare its edge construction with the Graph example using DAGArrow. Inspect the DiGraph, Graph, Arrow, and Node entry points involved in edge placement; done means directed edges align center-to-center with the vertices in the circular layout.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.