4
$\begingroup$

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?

$\endgroup$
6
$\begingroup$
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.