TransWikia.com

How to reverse the arrows in a graph?

Mathematica Asked by ablmf on December 17, 2020

I have a directed graph for which I want to reverse the direction of the arrows (not the direction of edges). I don’t want to use ReverseGraph because it changes the layout of the graph. Can I achieve this changing EdgeStyle?

One Answer

g1 = Graph[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}]

enter image description here

1. EdgeStyle

Graph[g1, EdgeStyle-> Arrowheads[{-.05,0}]] 

enter image description here

2. EdgeShapeFunction

Graph[g1, EdgeShapeFunction -> (Arrow @ Reverse @ # &)] 

enter image description here

3. ReverseGraph + VertexCoordinates:

You can also use ReverseGraph and keep the vertex layout of g1:

ReverseGraph[g1, VertexCoordinates -> GraphEmbedding[g1]] 

enter image description here

Correct answer by kglr on December 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP