4
$\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$
  • $\begingroup$ Which version of Mathematica are you using? $\endgroup$ – Szabolcs Apr 20 '13 at 19:02
  • $\begingroup$ version 8 on Mac. $\endgroup$ – user0501 Apr 20 '13 at 19:05
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$
  • $\begingroup$ Thanks, that works. But the combined line seems slightly thicker than the others, do you know how to deal with that? $\endgroup$ – user0501 Apr 20 '13 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 Apr 20 '13 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 Jun 12 '15 at 19:47
2
$\begingroup$

The option setting False is not listed among documented typical settings, but MultiedgeStyle -> False gives 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

Note: This works in version 9 (windows 10) and in version 11.2 on Wolfram Cloud.

$\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.