5
$\begingroup$

Is it possible to combine two edges into one with a double arrow?

For example:

GraphPlot[{1 -> 2, 2 -> 1}, VertexLabeling -> True, 
 DirectedEdges -> True]

results something like

enter image description here

Is it possible to change it to something like

enter image description here

without using the drawing tool to edit the graphics directly?

$\endgroup$
2
  • $\begingroup$ Which version of Mathematica are you using? $\endgroup$
    – Szabolcs
    Commented Apr 20, 2013 at 19:02
  • $\begingroup$ version 8 on Mac. $\endgroup$
    – user0501
    Commented Apr 20, 2013 at 19:05

2 Answers 2

3
$\begingroup$

This is a hack, but it'll work with GraphPlot:

GraphPlot[{1 -> 2, 2 -> 1, 1 -> 3, 3 -> 2}, MultiedgeStyle -> .001, 
 DirectedEdges -> True]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks, that works. But the combined line seems slightly thicker than the others, do you know how to deal with that? $\endgroup$
    – user0501
    Commented Apr 20, 2013 at 19:23
  • $\begingroup$ @user0501 Unfortunately no. I'd have to search the docs more for that and right now I do not have the time. Also, ideally there should be a solution for Graph objects, not just GraphPlot. My answer is by no means complete. $\endgroup$
    – Szabolcs
    Commented Apr 20, 2013 at 19:35
  • $\begingroup$ @user0501 I'm trying to do the same thing with LayeredGraphPlot with little success, so I might try Szabolcs solution. However, from your comment, to deal with the thicker double arrow, could you add something in such that if a rule and its inverse are both found, to reduce the thickness of each resulting edge by 50%? $\endgroup$
    – iwantmyphd
    Commented Jun 12, 2015 at 19:47
2
$\begingroup$

The option settings False and None are not listed among documented typical settings, but both MultiedgeStyle -> False and MultiedgeStyle -> None give the desired result.

GraphPlot[{1 -> 2, 2 -> 1}, 
 MultiedgeStyle -> False,  
 DirectedEdges -> True, VertexLabeling -> True]

enter image description here

GraphPlot[{1 -> 2, 2 -> 1, 1 -> 3, 3 -> 2}, 
  MultiedgeStyle -> False, 
  DirectedEdges -> True,  VertexLabeling -> True]

enter image description here

GraphPlot[{1 -> 2, 2 -> 1, 1 -> 3, 3 -> 2}, 
  MultiedgeStyle -> None, 
  DirectedEdges -> True,  VertexLabeling -> True]

enter image description here

Notes:

  • This works in version 9 (windows 10) and in version 11.2 on Wolfram Cloud.
  • After major updates in version 12.0, GraphPlot usage/options changed completely. Use GraphComputation`GraphPlotLegacy instead of GraphPlot for the code above to work.
$\endgroup$

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