# Coloring individual edges of a multigraph each with its own color

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

• As of v12 this is still impossible out-of-the-box. Try this answer in the (duplicate?) q/a Graph: Coloring parallel edges individually.
– kglr
Commented Aug 26, 2019 at 15:59
• @kglr Thank you, I guess that will have to do!
– EGME
Commented Aug 26, 2019 at 16:03
• @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?
– EGME
Commented Aug 26, 2019 at 16:17
• @kglr Ok, I got it to work, although I don’t understand how it works ...
– EGME
Commented Aug 26, 2019 at 16:20
• @kglr But it only works for two edges :( oh well ...
– EGME
Commented Aug 26, 2019 at 16:47

Now this works in Mathematica 12.1:

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


• Thanks, this should be quite useful ...
– EGME
Commented Apr 7, 2020 at 8:28
• Thanks for this helpful answer! Commented Jul 31, 2023 at 23:37
If[#1 > 0.80, Green, Red]


Try this in style section for 80% above being green and rest as red.

• Could you illustrate this with a graphic? Commented Jul 22, 2022 at 21:30