Could someone tell me how to color two different edges between the same two vertices with a different color? The last time a related question was asked is 4 years ago, so I am wondering if the following can sort of be made to work now ... This is what I have tried:

1) {Style[DirectedEdge[1,2],Red],Style[DirectedEdge[1,2],Green]}//Graph

I would like the edges in the above multigraph to be red and green, however this makes them all red. If I use EdgeStyle in the usual way, the edges take the last color that appears instead of the first one. I have never had to do this, surprisingly, and I thought it would be a cinch (I know the graph functionality of M quite well) but to my surprise I couldn’t make this work. So help will be appreciated. Perhaps a more complex fix is needed ???

I wonder also, if this is not easy to achieve, whether there is igraph functionality for it. I am not thoroughly familiar with the package

Thank you in advance.

  • $\begingroup$ As of v12 this is still impossible out-of-the-box. Try this answer in the (duplicate?) q/a Graph: Coloring parallel edges individually. $\endgroup$ – kglr Aug 26 '19 at 15:59
  • $\begingroup$ @kglr Thank you, I guess that will have to do! $\endgroup$ – EGME Aug 26 '19 at 16:03
  • $\begingroup$ @kglr Hmmm, I am trying to make your original answer work for just two edges, as in my question, but I can’t ... well, let’s see what develops ... might I ask for help if I can’t make this work? $\endgroup$ – EGME Aug 26 '19 at 16:17
  • $\begingroup$ @kglr Ok, I got it to work, although I don’t understand how it works ... $\endgroup$ – EGME Aug 26 '19 at 16:20
  • $\begingroup$ @kglr But it only works for two edges :( oh well ... $\endgroup$ – EGME Aug 26 '19 at 16:47

Your Answer

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

Browse other questions tagged or ask your own question.