I have the following edgelist and colors:
edges = {0 <-> 1, 0 <-> 2, 0 <-> 1, 2 <-> 1, 0 <-> 1};
colors = {Blue, Red, Red, Yellow, Green};
But I can't find a way to color the edges using these colors. My first try of course was to use something like:
Graph[edges, EdgeStyle -> {0 <-> 1 -> Blue, 0 <-> 2 -> Red, 0 <-> 1 -> Red,
2 <-> 1 -> Yellow, 0 <-> 1 -> Green}]
But in this all of the edges between 0 and 1 turn out to be green even though only one of them should be. I also tried to do this with
colors = {Blue, Red, Red, Yellow, Green};
i = 1;
Graph[{0 <-> 1, 0 <-> 2, 0 <-> 1, 2 <-> 1, 0 <-> 1},
EdgeShapeFunction -> ({Arrowheads[Large], Thick, colors[[i++]],
Arrow @ #} &)]
But now a wrong edge gets the green color for some reason. Any ideas? I already looked into Graph: Coloring parallel edges individually which didn't help me with this really.
EdgeStyle
cannot be used. Since Mathematica refers to edges by their endpoints, there is no way to distinguish between parallel edges, and assign different properties to them. Colouring is normally done through EdgeStyle. That won't work here. Thus any solution one might come up with will be inconvenient and error-prone. $\endgroup$