Weighted graph with multiple different coloured non-weighted paths - styling

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite
1












This follows on from my previous question answered here.



Ultimately, I now have a graph which I've simplified for posting here:



g1 = Graph[1 [UndirectedEdge] 2, 2 [UndirectedEdge] 3, 
3 [UndirectedEdge] 1, EdgeWeight -> 10, 10, 10,
VertexLabels -> Table[i -> Placed[i, Center], i, 3],
VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1,
GraphLayout -> "VertexLayout" -> "SpringElectricalEmbedding",
"EdgeWeighted" -> True]

r0 = 1, 2, 3;
e0 = DirectedEdge @@@ Partition[r0, 2, 1];

r1 = 1, 2, 1;
e1 = DirectedEdge @@@ Partition[r1, 2, 1];

g2 = SetProperty[EdgeAdd[g1, Join[
e0, e1
]], VertexCoordinates -> GraphEmbedding[g1],
VertexStyle -> 1 -> Red, EdgeStyle ->
Alternatives @@ e0 -> Green, Thick,
Alternatives @@ e1 -> Blue, Thick
]


Which outputs the following:



Example Graph



Ideally, one of the arrows from v1 to v2 would be green. However, as Mathematica views this edge in e1 as the same as the equivalent edge in e0, the formatting of the latter defined edge overwrites the e0 edge.



Research into options so far has spanned: (1) using this EdgeShapeFunction technique, which is not working as I believe the syntax isn't handling the collection of edges correctly and (2) looking into constructing custom sub DirectedEdge type objects to trick Mathematica into thinking they were different, which I don't believe is possible given my layman's understanding of the software.










share|improve this question









New contributor




Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    3
    down vote

    favorite
    1












    This follows on from my previous question answered here.



    Ultimately, I now have a graph which I've simplified for posting here:



    g1 = Graph[1 [UndirectedEdge] 2, 2 [UndirectedEdge] 3, 
    3 [UndirectedEdge] 1, EdgeWeight -> 10, 10, 10,
    VertexLabels -> Table[i -> Placed[i, Center], i, 3],
    VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1,
    GraphLayout -> "VertexLayout" -> "SpringElectricalEmbedding",
    "EdgeWeighted" -> True]

    r0 = 1, 2, 3;
    e0 = DirectedEdge @@@ Partition[r0, 2, 1];

    r1 = 1, 2, 1;
    e1 = DirectedEdge @@@ Partition[r1, 2, 1];

    g2 = SetProperty[EdgeAdd[g1, Join[
    e0, e1
    ]], VertexCoordinates -> GraphEmbedding[g1],
    VertexStyle -> 1 -> Red, EdgeStyle ->
    Alternatives @@ e0 -> Green, Thick,
    Alternatives @@ e1 -> Blue, Thick
    ]


    Which outputs the following:



    Example Graph



    Ideally, one of the arrows from v1 to v2 would be green. However, as Mathematica views this edge in e1 as the same as the equivalent edge in e0, the formatting of the latter defined edge overwrites the e0 edge.



    Research into options so far has spanned: (1) using this EdgeShapeFunction technique, which is not working as I believe the syntax isn't handling the collection of edges correctly and (2) looking into constructing custom sub DirectedEdge type objects to trick Mathematica into thinking they were different, which I don't believe is possible given my layman's understanding of the software.










    share|improve this question









    New contributor




    Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      This follows on from my previous question answered here.



      Ultimately, I now have a graph which I've simplified for posting here:



      g1 = Graph[1 [UndirectedEdge] 2, 2 [UndirectedEdge] 3, 
      3 [UndirectedEdge] 1, EdgeWeight -> 10, 10, 10,
      VertexLabels -> Table[i -> Placed[i, Center], i, 3],
      VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1,
      GraphLayout -> "VertexLayout" -> "SpringElectricalEmbedding",
      "EdgeWeighted" -> True]

      r0 = 1, 2, 3;
      e0 = DirectedEdge @@@ Partition[r0, 2, 1];

      r1 = 1, 2, 1;
      e1 = DirectedEdge @@@ Partition[r1, 2, 1];

      g2 = SetProperty[EdgeAdd[g1, Join[
      e0, e1
      ]], VertexCoordinates -> GraphEmbedding[g1],
      VertexStyle -> 1 -> Red, EdgeStyle ->
      Alternatives @@ e0 -> Green, Thick,
      Alternatives @@ e1 -> Blue, Thick
      ]


      Which outputs the following:



      Example Graph



      Ideally, one of the arrows from v1 to v2 would be green. However, as Mathematica views this edge in e1 as the same as the equivalent edge in e0, the formatting of the latter defined edge overwrites the e0 edge.



      Research into options so far has spanned: (1) using this EdgeShapeFunction technique, which is not working as I believe the syntax isn't handling the collection of edges correctly and (2) looking into constructing custom sub DirectedEdge type objects to trick Mathematica into thinking they were different, which I don't believe is possible given my layman's understanding of the software.










      share|improve this question









      New contributor




      Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      This follows on from my previous question answered here.



      Ultimately, I now have a graph which I've simplified for posting here:



      g1 = Graph[1 [UndirectedEdge] 2, 2 [UndirectedEdge] 3, 
      3 [UndirectedEdge] 1, EdgeWeight -> 10, 10, 10,
      VertexLabels -> Table[i -> Placed[i, Center], i, 3],
      VertexLabelStyle -> Directive[White, Bold, 15], VertexSize -> 0.1,
      GraphLayout -> "VertexLayout" -> "SpringElectricalEmbedding",
      "EdgeWeighted" -> True]

      r0 = 1, 2, 3;
      e0 = DirectedEdge @@@ Partition[r0, 2, 1];

      r1 = 1, 2, 1;
      e1 = DirectedEdge @@@ Partition[r1, 2, 1];

      g2 = SetProperty[EdgeAdd[g1, Join[
      e0, e1
      ]], VertexCoordinates -> GraphEmbedding[g1],
      VertexStyle -> 1 -> Red, EdgeStyle ->
      Alternatives @@ e0 -> Green, Thick,
      Alternatives @@ e1 -> Blue, Thick
      ]


      Which outputs the following:



      Example Graph



      Ideally, one of the arrows from v1 to v2 would be green. However, as Mathematica views this edge in e1 as the same as the equivalent edge in e0, the formatting of the latter defined edge overwrites the e0 edge.



      Research into options so far has spanned: (1) using this EdgeShapeFunction technique, which is not working as I believe the syntax isn't handling the collection of edges correctly and (2) looking into constructing custom sub DirectedEdge type objects to trick Mathematica into thinking they were different, which I don't believe is possible given my layman's understanding of the software.







      graphs-and-networks color style object-oriented






      share|improve this question









      New contributor




      Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 1 hour ago









      kglr

      163k8188387




      163k8188387






      New contributor




      Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 hours ago









      Jordan MacLachlan

      303




      303




      New contributor




      Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Jordan MacLachlan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Using the same approach as in this answer



          i = 1;
          SetProperty[EdgeAdd[g1, Join[e0, e1]],
          VertexCoordinates -> GraphEmbedding[g1], VertexStyle -> 1 -> Red,
          EdgeShapeFunction->Alternatives @@ Intersection[e0, e1] ->
          (Arrowheads[0, 0, .05, 0], Thick, Blue, Green[[i++]], Arrow[#] &),
          EdgeStyle -> Alternatives@@e1 -> Blue, Thick, Alternatives@@e0 -> Green, Thick]


          enter image description here



          For the general case with multiple groups with arbitrary intersections, you can use the general method in the linked answer by specifying the list of styles for each distinct edge in the input graph ... as follows:



          ClearAll[index, style]
          styles = Normal @ GroupBy[Flatten[Thread[# ->
          Directive[#2, Arrowheads[0, 0, .05, 0], Thick]] & @@@
          Thread[e0, e1, Green, Blue]], First -> Last] ;
          g0 = Graph[Join[EdgeList[g1], e0, e1], EdgeStyle -> styles, VertexStyle -> 1 -> Red ,
          VertexLabels -> Table[i -> Placed[i, Center], i, 3],
           VertexLabelStyle -> Directive[White, Bold, 15],
          VertexSize -> 0.1 , VertexCoordinates -> GraphEmbedding[g1]] ;
          distinctedges = DeleteDuplicates[Join[e0, e1]] ;
          (style[#] = PropertyValue[g0, #, EdgeStyle]) & /@ distinctedges;
          (index[#] = 1) & /@ distinctedges;
          g2 = Fold[(SetProperty[#, #2, EdgeShapeFunction ->
          ( style[#2][[index[#2]++]], Arrow[#] &)]) &, g0, distinctedges]


          enter image description here
             






          share|improve this answer





























            up vote
            1
            down vote













            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






            share|improve this answer






















            • I am unsure how I am able to discern different routes via this method, sorry? On a map with 12 nodes, and five routes of length 5-10, this is quite mentally cumbersome.
              – Jordan MacLachlan
              43 mins ago











            • @JordanMacLachlan it's easy to just specify the styles explicitly
              – M.R.
              11 mins ago










            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Jordan MacLachlan is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183086%2fweighted-graph-with-multiple-different-coloured-non-weighted-paths-styling%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            Using the same approach as in this answer



            i = 1;
            SetProperty[EdgeAdd[g1, Join[e0, e1]],
            VertexCoordinates -> GraphEmbedding[g1], VertexStyle -> 1 -> Red,
            EdgeShapeFunction->Alternatives @@ Intersection[e0, e1] ->
            (Arrowheads[0, 0, .05, 0], Thick, Blue, Green[[i++]], Arrow[#] &),
            EdgeStyle -> Alternatives@@e1 -> Blue, Thick, Alternatives@@e0 -> Green, Thick]


            enter image description here



            For the general case with multiple groups with arbitrary intersections, you can use the general method in the linked answer by specifying the list of styles for each distinct edge in the input graph ... as follows:



            ClearAll[index, style]
            styles = Normal @ GroupBy[Flatten[Thread[# ->
            Directive[#2, Arrowheads[0, 0, .05, 0], Thick]] & @@@
            Thread[e0, e1, Green, Blue]], First -> Last] ;
            g0 = Graph[Join[EdgeList[g1], e0, e1], EdgeStyle -> styles, VertexStyle -> 1 -> Red ,
            VertexLabels -> Table[i -> Placed[i, Center], i, 3],
             VertexLabelStyle -> Directive[White, Bold, 15],
            VertexSize -> 0.1 , VertexCoordinates -> GraphEmbedding[g1]] ;
            distinctedges = DeleteDuplicates[Join[e0, e1]] ;
            (style[#] = PropertyValue[g0, #, EdgeStyle]) & /@ distinctedges;
            (index[#] = 1) & /@ distinctedges;
            g2 = Fold[(SetProperty[#, #2, EdgeShapeFunction ->
            ( style[#2][[index[#2]++]], Arrow[#] &)]) &, g0, distinctedges]


            enter image description here
               






            share|improve this answer


























              up vote
              1
              down vote



              accepted










              Using the same approach as in this answer



              i = 1;
              SetProperty[EdgeAdd[g1, Join[e0, e1]],
              VertexCoordinates -> GraphEmbedding[g1], VertexStyle -> 1 -> Red,
              EdgeShapeFunction->Alternatives @@ Intersection[e0, e1] ->
              (Arrowheads[0, 0, .05, 0], Thick, Blue, Green[[i++]], Arrow[#] &),
              EdgeStyle -> Alternatives@@e1 -> Blue, Thick, Alternatives@@e0 -> Green, Thick]


              enter image description here



              For the general case with multiple groups with arbitrary intersections, you can use the general method in the linked answer by specifying the list of styles for each distinct edge in the input graph ... as follows:



              ClearAll[index, style]
              styles = Normal @ GroupBy[Flatten[Thread[# ->
              Directive[#2, Arrowheads[0, 0, .05, 0], Thick]] & @@@
              Thread[e0, e1, Green, Blue]], First -> Last] ;
              g0 = Graph[Join[EdgeList[g1], e0, e1], EdgeStyle -> styles, VertexStyle -> 1 -> Red ,
              VertexLabels -> Table[i -> Placed[i, Center], i, 3],
               VertexLabelStyle -> Directive[White, Bold, 15],
              VertexSize -> 0.1 , VertexCoordinates -> GraphEmbedding[g1]] ;
              distinctedges = DeleteDuplicates[Join[e0, e1]] ;
              (style[#] = PropertyValue[g0, #, EdgeStyle]) & /@ distinctedges;
              (index[#] = 1) & /@ distinctedges;
              g2 = Fold[(SetProperty[#, #2, EdgeShapeFunction ->
              ( style[#2][[index[#2]++]], Arrow[#] &)]) &, g0, distinctedges]


              enter image description here
                 






              share|improve this answer
























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                Using the same approach as in this answer



                i = 1;
                SetProperty[EdgeAdd[g1, Join[e0, e1]],
                VertexCoordinates -> GraphEmbedding[g1], VertexStyle -> 1 -> Red,
                EdgeShapeFunction->Alternatives @@ Intersection[e0, e1] ->
                (Arrowheads[0, 0, .05, 0], Thick, Blue, Green[[i++]], Arrow[#] &),
                EdgeStyle -> Alternatives@@e1 -> Blue, Thick, Alternatives@@e0 -> Green, Thick]


                enter image description here



                For the general case with multiple groups with arbitrary intersections, you can use the general method in the linked answer by specifying the list of styles for each distinct edge in the input graph ... as follows:



                ClearAll[index, style]
                styles = Normal @ GroupBy[Flatten[Thread[# ->
                Directive[#2, Arrowheads[0, 0, .05, 0], Thick]] & @@@
                Thread[e0, e1, Green, Blue]], First -> Last] ;
                g0 = Graph[Join[EdgeList[g1], e0, e1], EdgeStyle -> styles, VertexStyle -> 1 -> Red ,
                VertexLabels -> Table[i -> Placed[i, Center], i, 3],
                 VertexLabelStyle -> Directive[White, Bold, 15],
                VertexSize -> 0.1 , VertexCoordinates -> GraphEmbedding[g1]] ;
                distinctedges = DeleteDuplicates[Join[e0, e1]] ;
                (style[#] = PropertyValue[g0, #, EdgeStyle]) & /@ distinctedges;
                (index[#] = 1) & /@ distinctedges;
                g2 = Fold[(SetProperty[#, #2, EdgeShapeFunction ->
                ( style[#2][[index[#2]++]], Arrow[#] &)]) &, g0, distinctedges]


                enter image description here
                   






                share|improve this answer














                Using the same approach as in this answer



                i = 1;
                SetProperty[EdgeAdd[g1, Join[e0, e1]],
                VertexCoordinates -> GraphEmbedding[g1], VertexStyle -> 1 -> Red,
                EdgeShapeFunction->Alternatives @@ Intersection[e0, e1] ->
                (Arrowheads[0, 0, .05, 0], Thick, Blue, Green[[i++]], Arrow[#] &),
                EdgeStyle -> Alternatives@@e1 -> Blue, Thick, Alternatives@@e0 -> Green, Thick]


                enter image description here



                For the general case with multiple groups with arbitrary intersections, you can use the general method in the linked answer by specifying the list of styles for each distinct edge in the input graph ... as follows:



                ClearAll[index, style]
                styles = Normal @ GroupBy[Flatten[Thread[# ->
                Directive[#2, Arrowheads[0, 0, .05, 0], Thick]] & @@@
                Thread[e0, e1, Green, Blue]], First -> Last] ;
                g0 = Graph[Join[EdgeList[g1], e0, e1], EdgeStyle -> styles, VertexStyle -> 1 -> Red ,
                VertexLabels -> Table[i -> Placed[i, Center], i, 3],
                 VertexLabelStyle -> Directive[White, Bold, 15],
                VertexSize -> 0.1 , VertexCoordinates -> GraphEmbedding[g1]] ;
                distinctedges = DeleteDuplicates[Join[e0, e1]] ;
                (style[#] = PropertyValue[g0, #, EdgeStyle]) & /@ distinctedges;
                (index[#] = 1) & /@ distinctedges;
                g2 = Fold[(SetProperty[#, #2, EdgeShapeFunction ->
                ( style[#2][[index[#2]++]], Arrow[#] &)]) &, g0, distinctedges]


                enter image description here
                   







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 54 mins ago

























                answered 2 hours ago









                kglr

                163k8188387




                163k8188387




















                    up vote
                    1
                    down vote













                    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






                    share|improve this answer






















                    • I am unsure how I am able to discern different routes via this method, sorry? On a map with 12 nodes, and five routes of length 5-10, this is quite mentally cumbersome.
                      – Jordan MacLachlan
                      43 mins ago











                    • @JordanMacLachlan it's easy to just specify the styles explicitly
                      – M.R.
                      11 mins ago














                    up vote
                    1
                    down vote













                    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






                    share|improve this answer






















                    • I am unsure how I am able to discern different routes via this method, sorry? On a map with 12 nodes, and five routes of length 5-10, this is quite mentally cumbersome.
                      – Jordan MacLachlan
                      43 mins ago











                    • @JordanMacLachlan it's easy to just specify the styles explicitly
                      – M.R.
                      11 mins ago












                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    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






                    share|improve this answer














                    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







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 12 mins ago

























                    answered 1 hour ago









                    M.R.

                    15.2k552178




                    15.2k552178











                    • I am unsure how I am able to discern different routes via this method, sorry? On a map with 12 nodes, and five routes of length 5-10, this is quite mentally cumbersome.
                      – Jordan MacLachlan
                      43 mins ago











                    • @JordanMacLachlan it's easy to just specify the styles explicitly
                      – M.R.
                      11 mins ago
















                    • I am unsure how I am able to discern different routes via this method, sorry? On a map with 12 nodes, and five routes of length 5-10, this is quite mentally cumbersome.
                      – Jordan MacLachlan
                      43 mins ago











                    • @JordanMacLachlan it's easy to just specify the styles explicitly
                      – M.R.
                      11 mins ago















                    I am unsure how I am able to discern different routes via this method, sorry? On a map with 12 nodes, and five routes of length 5-10, this is quite mentally cumbersome.
                    – Jordan MacLachlan
                    43 mins ago





                    I am unsure how I am able to discern different routes via this method, sorry? On a map with 12 nodes, and five routes of length 5-10, this is quite mentally cumbersome.
                    – Jordan MacLachlan
                    43 mins ago













                    @JordanMacLachlan it's easy to just specify the styles explicitly
                    – M.R.
                    11 mins ago




                    @JordanMacLachlan it's easy to just specify the styles explicitly
                    – M.R.
                    11 mins ago










                    Jordan MacLachlan is a new contributor. Be nice, and check out our Code of Conduct.









                     

                    draft saved


                    draft discarded


















                    Jordan MacLachlan is a new contributor. Be nice, and check out our Code of Conduct.












                    Jordan MacLachlan is a new contributor. Be nice, and check out our Code of Conduct.











                    Jordan MacLachlan is a new contributor. Be nice, and check out our Code of Conduct.













                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183086%2fweighted-graph-with-multiple-different-coloured-non-weighted-paths-styling%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery