Skip to content

Conversation

@darabos
Copy link
Contributor

@darabos darabos commented Nov 11, 2024

Matplotlib arrows don't have a source and a destination. They have a text and a dot. As the example shows, a <- arrow points from the dot to the text and -> points from the text to the dot.
Screenshot 2024-11-11 at 15 47 24
_visualize_graph_via_networkx() sets xy=pos[src] and xytext=pos[dst], so we want arrows from the dot (xy) to the text (xytext). That's the <- arrow.

This can also be confirmed by comparing the visualization to the GraphViz version. The arrows go the other way. Or just looking at the data and the picture, haha! It took me a while to figure out that it's not my graph that's messed up! 😅

@rusty1s rusty1s changed the title Fix arrow direction in _visualize_graph_via_networkx Fix arrow direction in _visualize_graph_via_networkx Nov 13, 2024
Copy link
Member

@rusty1s rusty1s left a comment

Choose a reason for hiding this comment

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

Nice catch :)

@rusty1s rusty1s merged commit 5e5c1a6 into pyg-team:master Nov 13, 2024
18 of 19 checks passed
mattjhayes3 pushed a commit to mattjhayes3/pytorch_geometric that referenced this pull request Dec 14, 2024
Matplotlib arrows don't have a source and a destination. They have a
text and a dot. As the
[example](https://matplotlib.org/stable/gallery/text_labels_and_annotations/fancyarrow_demo.html)
shows, a `<-` arrow points from the dot to the text and `->` points from
the text to the dot.
<img width="153" alt="Screenshot 2024-11-11 at 15 47 24"
src="https://github.com/user-attachments/assets/7a8333d3-6c58-46b2-a47b-ae6c6afff87d">
`_visualize_graph_via_networkx()` sets `xy=pos[src]` and
`xytext=pos[dst]`, so we want arrows from the dot (`xy`) to the text
(`xytext`). That's the `<-` arrow.

This can also be confirmed by comparing the visualization to the
GraphViz version. The arrows go the other way. Or just looking at the
data and the picture, haha! It took me a while to figure out that it's
not my graph that's messed up! 😅
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants