4 deleted 32 characters in body
source | link

In general, here's another way to style multigraph edges without using SetProperty. Just make a matrix of the edges and their styles:

$styles = {{a -> e, Green}, {e -> b, Green}, {a -> b, Red}, 
           {a -> b, Directive[Dashing[{Small, Small}], Blue]}, {a -> b, RGBColor[1, 0.5, 0]}, 
           {a -> b, Directive[RGBColor[0.5, 0, 0.5], Dashing[0.01`]]}};

ef = (Block[{st, p}, st = $styles[[p = 
          FirstPosition[$styles, #2 | (#2 /. DirectedEdge -> Rule)][[1]]]][[2]];
          $styles = Delete[$styles, p]; 
          {Thickness[0.008], Arrowheads[{{.08, .5}}], st, Arrow@#}] &)

Graph[{a -> b, a -> b, a -> b, a -> b, a -> eGraph[$styles[[All, e -> b}1]], 
  VertexLabels -> Placed["Name", Center], VertexSize -> 0.14, 
  VertexLabelStyle -> Directive[FontSize -> 17, FontColor -> White], 
  EdgeShapeFunction -> ef
]

enter image description here

Here's your example:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = 
          FirstPosition[$styles, #2][[1]]]][[2]]; $styles = 
      Delete[$styles, p];
     {Arrowheads[{{.03, .95}}], st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

In general, here's another way to style multigraph edges without using SetProperty. Just make a matrix of the edges and their styles:

$styles = {{a -> e, Green}, {e -> b, Green}, {a -> b, Red}, 
           {a -> b, Directive[Dashing[{Small, Small}], Blue]}, {a -> b, RGBColor[1, 0.5, 0]}, 
           {a -> b, Directive[RGBColor[0.5, 0, 0.5], Dashing[0.01`]]}};

ef = (Block[{st, p}, st = $styles[[p = 
          FirstPosition[$styles, #2 | (#2 /. DirectedEdge -> Rule)][[1]]]][[2]];
          $styles = Delete[$styles, p]; 
          {Thickness[0.008], Arrowheads[{{.08, .5}}], st, Arrow@#}] &)

Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b}, 
  VertexLabels -> Placed["Name", Center], VertexSize -> 0.14, 
  VertexLabelStyle -> Directive[FontSize -> 17, FontColor -> White], 
  EdgeShapeFunction -> ef
]

enter image description here

Here's your example:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = 
          FirstPosition[$styles, #2][[1]]]][[2]]; $styles = 
      Delete[$styles, p];
     {Arrowheads[{{.03, .95}}], st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

In general, here's another way to style multigraph edges without using SetProperty. Just make a matrix of the edges and their styles:

$styles = {{a -> e, Green}, {e -> b, Green}, {a -> b, Red}, 
           {a -> b, Directive[Dashing[{Small, Small}], Blue]}, {a -> b, RGBColor[1, 0.5, 0]}, 
           {a -> b, Directive[RGBColor[0.5, 0, 0.5], Dashing[0.01`]]}};

ef = (Block[{st, p}, st = $styles[[p = 
          FirstPosition[$styles, #2 | (#2 /. DirectedEdge -> Rule)][[1]]]][[2]];
          $styles = Delete[$styles, p]; 
          {Thickness[0.008], Arrowheads[{{.08, .5}}], st, Arrow@#}] &)

Graph[$styles[[All,1]], 
  VertexLabels -> Placed["Name", Center], VertexSize -> 0.14, 
  VertexLabelStyle -> Directive[FontSize -> 17, FontColor -> White], 
  EdgeShapeFunction -> ef
]

enter image description here

Here's your example:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = 
          FirstPosition[$styles, #2][[1]]]][[2]]; $styles = 
      Delete[$styles, p];
     {Arrowheads[{{.03, .95}}], st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

3 added 916 characters in body
source | link

Here'sIn general, here's another way to write it,style multigraph edges without using SetProperty. Just make a matrix of the edges and their styles:

$styles = {{a -> e, Green}, {e -> b, Green}, {a -> b, Red}, 
           {a -> b, Directive[Dashing[{Small, Small}], Blue]}, {a -> b, RGBColor[1, 0.5, 0]}, 
           {a -> b, Directive[RGBColor[0.5, 0, 0.5], Dashing[0.01`]]}};

ef = (Block[{st, p}, st = $styles[[p = 
          FirstPosition[$styles, #2 | (#2 /. DirectedEdge -> Rule)][[1]]]][[2]];
          $styles = Delete[$styles, p]; 
          {Thickness[0.008], Arrowheads[{{.08, .5}}], st, Arrow@#}] &)

Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b}, 
  VertexLabels -> Placed["Name", Center], VertexSize -> 0.14, 
  VertexLabelStyle -> Directive[FontSize -> 17, FontColor -> White], 
  EdgeShapeFunction -> ef
]

enter image description here

Here's your example:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = 
          FirstPosition[$styles, #2][[1]]]][[2]]; $styles = 
      Delete[$styles, p];
     {Arrowheads[{{.03, .95}}], st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

Here's another way to write it, without using SetProperty:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = 
          FirstPosition[$styles, #2][[1]]]][[2]]; $styles = 
      Delete[$styles, p];
     {Arrowheads[{{.03, .95}}], st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

In general, here's another way to style multigraph edges without using SetProperty. Just make a matrix of the edges and their styles:

$styles = {{a -> e, Green}, {e -> b, Green}, {a -> b, Red}, 
           {a -> b, Directive[Dashing[{Small, Small}], Blue]}, {a -> b, RGBColor[1, 0.5, 0]}, 
           {a -> b, Directive[RGBColor[0.5, 0, 0.5], Dashing[0.01`]]}};

ef = (Block[{st, p}, st = $styles[[p = 
          FirstPosition[$styles, #2 | (#2 /. DirectedEdge -> Rule)][[1]]]][[2]];
          $styles = Delete[$styles, p]; 
          {Thickness[0.008], Arrowheads[{{.08, .5}}], st, Arrow@#}] &)

Graph[{a -> b, a -> b, a -> b, a -> b, a -> e, e -> b}, 
  VertexLabels -> Placed["Name", Center], VertexSize -> 0.14, 
  VertexLabelStyle -> Directive[FontSize -> 17, FontColor -> White], 
  EdgeShapeFunction -> ef
]

enter image description here

Here's your example:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = 
          FirstPosition[$styles, #2][[1]]]][[2]]; $styles = 
      Delete[$styles, p];
     {Arrowheads[{{.03, .95}}], st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

2 added 374 characters in body
source | link

Here's another way to write it, without using SetProperty:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
styles = {Blue, Green, u, u, Green, u, Blue};
i = 1;
g$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
   3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
   2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3},
  EdgeWeight -> {10, 10, 10, 0, 0, 0, 0},
  VertexLabels -> Table[i -> Placed[i, Center], {i, 3}],
  VertexLabelStyle -> Directive[White, Bold, 15],
  VertexSize -> 0.1, VertexStyle -> {1 ->FirstPosition[$styles, #2][[1]]]][[2]]; $styles Red},= 
  GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding"Delete[$styles, p];
      "EdgeWeighted" -> True}}, 
   EdgeShapeFunction -> ({Arrowheads[{{.03, .95}}], Thick, 
      styles[[i++]]st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

Here's another way to write it, without using SetProperty:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
styles = {Blue, Green, u, u, Green, u, Blue};
i = 1;
g = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
   3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
   2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3},
  EdgeWeight -> {10, 10, 10, 0, 0, 0, 0},
  VertexLabels -> Table[i -> Placed[i, Center], {i, 3}],
  VertexLabelStyle -> Directive[White, Bold, 15],
  VertexSize -> 0.1, VertexStyle -> {1 -> Red}, 
  GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
      "EdgeWeighted" -> True}}, 
   EdgeShapeFunction -> ({Arrowheads[{{.03, .95}}], Thick, 
      styles[[i++]], Arrow@#} &), VertexLabels -> "Name"]

enter image description here

Here's another way to write it, without using SetProperty:

u = Directive[Gray, Thickness[0.002], Arrowheads[0]];
$styles = {1 \[DirectedEdge] 2 -> RGBColor[0, 0, 1], 
   1 \[DirectedEdge] 2 -> RGBColor[0, 1, 0], 
   1 \[UndirectedEdge] 2 -> u, 1 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 3 -> RGBColor[0, 1, 0], 
   2 \[UndirectedEdge] 3 -> u, 
   2 \[DirectedEdge] 1 -> RGBColor[0, 0, 1]};
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
  3 \[UndirectedEdge] 1, 1 \[DirectedEdge] 2, 1 \[DirectedEdge] 2, 
  2 \[DirectedEdge] 1, 2 \[DirectedEdge] 3}, 
 EdgeWeight -> {10, 10, 10, 0, 0, 0, 0}, 
 VertexLabels -> Table[i -> Placed[i, Center], {i, 3}], 
 VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1, 
 VertexStyle -> {1 -> Red}, 
 GraphLayout -> {"VertexLayout" -> {"SpringElectricalEmbedding", 
     "EdgeWeighted" -> True}}, EdgeShapeFunction -> (
   Module[{st, p},
     st = $styles[[p = 
          FirstPosition[$styles, #2][[1]]]][[2]]; $styles = 
      Delete[$styles, p];
     {Arrowheads[{{.03, .95}}], st, Arrow@#}] &), 
 VertexLabels -> "Name"]

enter image description here

1
source | link