Ideas for colorfully and clearly highlighting graph edges according to weights












5












$begingroup$


I am trying to figure out a way to include edgeweights in the visualisation of a graph in Mathematica, to find an idea for the drawing such that even for relatively large node numbers the graphs remain visually clear. But the basic built-in feature leads to rather messy layouts as soon as there are large number of nodes/edges. Here's an example below:



SeedRandom[100]
n = 500;
m = 1000;
edgeweights = 1./RandomReal[{0.1, 1}, m];
G = RandomGraph[{n, m}, EdgeWeight -> edgeweights]


Produces:
enter image description here



Including GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True} into the definition of G produces:



enter image description here



It seems to simply draw the nodes whose connecting edge weight is larger closer to one another, which leads to a very dense embedded layout.



Would it be possible to:




  • Modulate the edge thickness and color [*] according to their weights? The weights do not necessarily have to be given in the graph definition (G), they could also simply be called for the purpose of the visualisation.


[*]: That is, the greater the weight, the thicker and the more brightly colored the edge. For normalization, we can use the maximal weight in the vector of edgeweights.










share|improve this question









$endgroup$

















    5












    $begingroup$


    I am trying to figure out a way to include edgeweights in the visualisation of a graph in Mathematica, to find an idea for the drawing such that even for relatively large node numbers the graphs remain visually clear. But the basic built-in feature leads to rather messy layouts as soon as there are large number of nodes/edges. Here's an example below:



    SeedRandom[100]
    n = 500;
    m = 1000;
    edgeweights = 1./RandomReal[{0.1, 1}, m];
    G = RandomGraph[{n, m}, EdgeWeight -> edgeweights]


    Produces:
    enter image description here



    Including GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True} into the definition of G produces:



    enter image description here



    It seems to simply draw the nodes whose connecting edge weight is larger closer to one another, which leads to a very dense embedded layout.



    Would it be possible to:




    • Modulate the edge thickness and color [*] according to their weights? The weights do not necessarily have to be given in the graph definition (G), they could also simply be called for the purpose of the visualisation.


    [*]: That is, the greater the weight, the thicker and the more brightly colored the edge. For normalization, we can use the maximal weight in the vector of edgeweights.










    share|improve this question









    $endgroup$















      5












      5








      5





      $begingroup$


      I am trying to figure out a way to include edgeweights in the visualisation of a graph in Mathematica, to find an idea for the drawing such that even for relatively large node numbers the graphs remain visually clear. But the basic built-in feature leads to rather messy layouts as soon as there are large number of nodes/edges. Here's an example below:



      SeedRandom[100]
      n = 500;
      m = 1000;
      edgeweights = 1./RandomReal[{0.1, 1}, m];
      G = RandomGraph[{n, m}, EdgeWeight -> edgeweights]


      Produces:
      enter image description here



      Including GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True} into the definition of G produces:



      enter image description here



      It seems to simply draw the nodes whose connecting edge weight is larger closer to one another, which leads to a very dense embedded layout.



      Would it be possible to:




      • Modulate the edge thickness and color [*] according to their weights? The weights do not necessarily have to be given in the graph definition (G), they could also simply be called for the purpose of the visualisation.


      [*]: That is, the greater the weight, the thicker and the more brightly colored the edge. For normalization, we can use the maximal weight in the vector of edgeweights.










      share|improve this question









      $endgroup$




      I am trying to figure out a way to include edgeweights in the visualisation of a graph in Mathematica, to find an idea for the drawing such that even for relatively large node numbers the graphs remain visually clear. But the basic built-in feature leads to rather messy layouts as soon as there are large number of nodes/edges. Here's an example below:



      SeedRandom[100]
      n = 500;
      m = 1000;
      edgeweights = 1./RandomReal[{0.1, 1}, m];
      G = RandomGraph[{n, m}, EdgeWeight -> edgeweights]


      Produces:
      enter image description here



      Including GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True} into the definition of G produces:



      enter image description here



      It seems to simply draw the nodes whose connecting edge weight is larger closer to one another, which leads to a very dense embedded layout.



      Would it be possible to:




      • Modulate the edge thickness and color [*] according to their weights? The weights do not necessarily have to be given in the graph definition (G), they could also simply be called for the purpose of the visualisation.


      [*]: That is, the greater the weight, the thicker and the more brightly colored the edge. For normalization, we can use the maximal weight in the vector of edgeweights.







      graphics graphs-and-networks visualization






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      user929304user929304

      30629




      30629






















          3 Answers
          3






          active

          oldest

          votes


















          5












          $begingroup$

          edgeStyle[weights_, thickbounds_:{0.0001,0.01}, colorf_:ColorData["SolarColors"]]:=
          Block[{minmax, thickness, color},
          minmax = MinMax[weights];
          thickness = Thickness /@ Rescale[weights, minmax, thickbounds];
          color = colorf /@ Rescale[weights, minmax, {0, 1}];
          Thread[Directive[Opacity[.7], CapForm["Round"], thickness, color]]
          ]


          Here's the example:



          Graph[G, EdgeStyle -> Thread[EdgeList[G] -> edgeStyle[edgeweights]], 
          VertexSize -> 1, VertexStyle -> Blue]


          enter image description here



          With different thickness and color:



          Graph[G, EdgeStyle -> 
          Thread[EdgeList[G] ->
          edgeStyle[edgeweights, {0.0001, 0.02},
          ColorData["BrightBands"]]], VertexSize -> 1, VertexStyle -> Blue]


          enter image description here






          share|improve this answer









          $endgroup$





















            5












            $begingroup$

            I do not think that any good way exists. Once a graph is large enough, it will always look like a hairball unless it has a clear structure that might be made visible. For example, this is a similarity graph of musicians. The musicians cluster into groups, and it is possible to make this structure visible. Your example graph, on the other hand, is completely random, with random edge weights. Since there are lots of nodes and edges, but no real information is contained within them, I do not think that it can be visualized in a meaningful way.



            Assuming that there is something to show, things you can try are:





            • Take edge weights into consideration when computing the layout. Look up individual graph layouts on the GraphLayout doc page, and see if they support weights. You have already found GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True}, but it's still useful to mention this for other readers.



              The example I linked above was created by one of the authors of the igraph library. IGraph/M is a Mathematica interface to igraph (and much more), and exposes multiple layout algorithms that support weights. The above example was created using the DrL layout (IGLayoutDrL function in IGraph/M)




            • Visualize weights as not edge lengths, but edge weights or edge colours. You can do this with EdgeStyle. IGraph/M provides a very convenient way to do it:



              SeedRandom[137]
              g = RandomGraph[{10, 20}, EdgeWeight -> RandomReal[{.1, 1}, 20]]

              Graph[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/3]]] //
              IGEdgeMap[AbsoluteThickness[10 #] &, EdgeStyle -> IGEdgeProp[EdgeWeight]]


              enter image description here




            • Use colours in the same way.



              Graph[g, EdgeStyle -> Directive[CapForm["Round"], AbsoluteThickness[4]]] //
              IGEdgeMap[ColorData["RustTones"], EdgeStyle -> Rescale@*IGEdgeProp[EdgeWeight]]


              enter image description here




            • Use all of the above: edge length, edge thickness and edge colour.



              IGLayoutFruchtermanReingold[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/2]]] // 
              IGEdgeMap[
              Directive[ColorData["RustTones"][#], AbsoluteThickness[10 #]] &,
              EdgeStyle -> (#/Max[#] &)@*IGEdgeProp[EdgeWeight]]


              enter image description here




            • Cluster the graph vertices before visualizing them. The clustering can take weights into account.



              CommunityGraphPlot[g]


              enter image description here



              This related to what I said above. First, try to identify the structure, then explicitly make it visible.








            share|improve this answer









            $endgroup$





















              4












              $begingroup$

              When you have a lot of things to display in a small space you get a mess no matter what. But you can always try to make it better. I suggest 2 steps:




              1. Untangle a bit the mess with GraphLayout

              2. Avoid noise in style logic


              1. Untangle a bit the mess with GraphLayout



              I would use a proper GraphLayout for a specific cases. For instance, a general messy graph can benefit from "GravityEmbedding" which will be available in V12 (compare left and right images):



              RandomGraph[{100,100},ImageSize->400,GraphLayout->#]&/@
              {Automatic,"GravityEmbedding"}


              enter image description here



              But on the other hand in case of trees you are better of with "RadialEmbedding"



              Graph[RandomInteger[#]<->#+1&/@Range[0,500],ImageSize->400,GraphLayout->#]&/@
              {Automatic,"RadialEmbedding"}


              enter image description here



              And so on depending on your specific graph structure.



              2. Avoid noise in style logic



              I recommend to read an article I wrote (even so your graphs are larger a lot of logic still holds):



              On design of styles for small weighted graphs: https://community.wolfram.com/groups/-/m/t/838652



              enter image description here






              share|improve this answer









              $endgroup$













              • $begingroup$
                So what is this "GravityEmbedding" anyway? It's the first new piece of functionality added in a long time. Is it explained what it does? If not, why do you think it's more appropriate? And why does a layout change the appearance of edges? That is counterproductive and people will end up having to keep switching back to the default (I bet most won't even know how).
                $endgroup$
                – Szabolcs
                20 hours ago












              • $begingroup$
                I remember watching the graphs Twitch stream. SW asked the very same questions and there was no answer to either one. Why did it make it so far in this state then?
                $endgroup$
                – Szabolcs
                20 hours ago










              • $begingroup$
                @Szabolcs I did not have a chance too look at it in depth, but something like "energy with vertices as mass points and edges as springs". If you mean bent edges - not sure why but I like it. My guess is that close about parallel edges will have an opposite curvature to not overlap --- but I am not sure. There are too many things for one person to be aware of :-)
                $endgroup$
                – Vitaliy Kaurov
                20 hours ago










              • $begingroup$
                If you like curved edges, maybe you can convince the developer to document EdgeShapeFunction -> "CurvedArc", something we've been requesting for years. A graph layout should not affect edge rendering, as these are separate concepts. BTW I do not see any documented way to switch back to the default edge rendering.
                $endgroup$
                – Szabolcs
                20 hours 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',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194811%2fideas-for-colorfully-and-clearly-highlighting-graph-edges-according-to-weights%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              5












              $begingroup$

              edgeStyle[weights_, thickbounds_:{0.0001,0.01}, colorf_:ColorData["SolarColors"]]:=
              Block[{minmax, thickness, color},
              minmax = MinMax[weights];
              thickness = Thickness /@ Rescale[weights, minmax, thickbounds];
              color = colorf /@ Rescale[weights, minmax, {0, 1}];
              Thread[Directive[Opacity[.7], CapForm["Round"], thickness, color]]
              ]


              Here's the example:



              Graph[G, EdgeStyle -> Thread[EdgeList[G] -> edgeStyle[edgeweights]], 
              VertexSize -> 1, VertexStyle -> Blue]


              enter image description here



              With different thickness and color:



              Graph[G, EdgeStyle -> 
              Thread[EdgeList[G] ->
              edgeStyle[edgeweights, {0.0001, 0.02},
              ColorData["BrightBands"]]], VertexSize -> 1, VertexStyle -> Blue]


              enter image description here






              share|improve this answer









              $endgroup$


















                5












                $begingroup$

                edgeStyle[weights_, thickbounds_:{0.0001,0.01}, colorf_:ColorData["SolarColors"]]:=
                Block[{minmax, thickness, color},
                minmax = MinMax[weights];
                thickness = Thickness /@ Rescale[weights, minmax, thickbounds];
                color = colorf /@ Rescale[weights, minmax, {0, 1}];
                Thread[Directive[Opacity[.7], CapForm["Round"], thickness, color]]
                ]


                Here's the example:



                Graph[G, EdgeStyle -> Thread[EdgeList[G] -> edgeStyle[edgeweights]], 
                VertexSize -> 1, VertexStyle -> Blue]


                enter image description here



                With different thickness and color:



                Graph[G, EdgeStyle -> 
                Thread[EdgeList[G] ->
                edgeStyle[edgeweights, {0.0001, 0.02},
                ColorData["BrightBands"]]], VertexSize -> 1, VertexStyle -> Blue]


                enter image description here






                share|improve this answer









                $endgroup$
















                  5












                  5








                  5





                  $begingroup$

                  edgeStyle[weights_, thickbounds_:{0.0001,0.01}, colorf_:ColorData["SolarColors"]]:=
                  Block[{minmax, thickness, color},
                  minmax = MinMax[weights];
                  thickness = Thickness /@ Rescale[weights, minmax, thickbounds];
                  color = colorf /@ Rescale[weights, minmax, {0, 1}];
                  Thread[Directive[Opacity[.7], CapForm["Round"], thickness, color]]
                  ]


                  Here's the example:



                  Graph[G, EdgeStyle -> Thread[EdgeList[G] -> edgeStyle[edgeweights]], 
                  VertexSize -> 1, VertexStyle -> Blue]


                  enter image description here



                  With different thickness and color:



                  Graph[G, EdgeStyle -> 
                  Thread[EdgeList[G] ->
                  edgeStyle[edgeweights, {0.0001, 0.02},
                  ColorData["BrightBands"]]], VertexSize -> 1, VertexStyle -> Blue]


                  enter image description here






                  share|improve this answer









                  $endgroup$



                  edgeStyle[weights_, thickbounds_:{0.0001,0.01}, colorf_:ColorData["SolarColors"]]:=
                  Block[{minmax, thickness, color},
                  minmax = MinMax[weights];
                  thickness = Thickness /@ Rescale[weights, minmax, thickbounds];
                  color = colorf /@ Rescale[weights, minmax, {0, 1}];
                  Thread[Directive[Opacity[.7], CapForm["Round"], thickness, color]]
                  ]


                  Here's the example:



                  Graph[G, EdgeStyle -> Thread[EdgeList[G] -> edgeStyle[edgeweights]], 
                  VertexSize -> 1, VertexStyle -> Blue]


                  enter image description here



                  With different thickness and color:



                  Graph[G, EdgeStyle -> 
                  Thread[EdgeList[G] ->
                  edgeStyle[edgeweights, {0.0001, 0.02},
                  ColorData["BrightBands"]]], VertexSize -> 1, VertexStyle -> Blue]


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  halmirhalmir

                  10.7k2544




                  10.7k2544























                      5












                      $begingroup$

                      I do not think that any good way exists. Once a graph is large enough, it will always look like a hairball unless it has a clear structure that might be made visible. For example, this is a similarity graph of musicians. The musicians cluster into groups, and it is possible to make this structure visible. Your example graph, on the other hand, is completely random, with random edge weights. Since there are lots of nodes and edges, but no real information is contained within them, I do not think that it can be visualized in a meaningful way.



                      Assuming that there is something to show, things you can try are:





                      • Take edge weights into consideration when computing the layout. Look up individual graph layouts on the GraphLayout doc page, and see if they support weights. You have already found GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True}, but it's still useful to mention this for other readers.



                        The example I linked above was created by one of the authors of the igraph library. IGraph/M is a Mathematica interface to igraph (and much more), and exposes multiple layout algorithms that support weights. The above example was created using the DrL layout (IGLayoutDrL function in IGraph/M)




                      • Visualize weights as not edge lengths, but edge weights or edge colours. You can do this with EdgeStyle. IGraph/M provides a very convenient way to do it:



                        SeedRandom[137]
                        g = RandomGraph[{10, 20}, EdgeWeight -> RandomReal[{.1, 1}, 20]]

                        Graph[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/3]]] //
                        IGEdgeMap[AbsoluteThickness[10 #] &, EdgeStyle -> IGEdgeProp[EdgeWeight]]


                        enter image description here




                      • Use colours in the same way.



                        Graph[g, EdgeStyle -> Directive[CapForm["Round"], AbsoluteThickness[4]]] //
                        IGEdgeMap[ColorData["RustTones"], EdgeStyle -> Rescale@*IGEdgeProp[EdgeWeight]]


                        enter image description here




                      • Use all of the above: edge length, edge thickness and edge colour.



                        IGLayoutFruchtermanReingold[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/2]]] // 
                        IGEdgeMap[
                        Directive[ColorData["RustTones"][#], AbsoluteThickness[10 #]] &,
                        EdgeStyle -> (#/Max[#] &)@*IGEdgeProp[EdgeWeight]]


                        enter image description here




                      • Cluster the graph vertices before visualizing them. The clustering can take weights into account.



                        CommunityGraphPlot[g]


                        enter image description here



                        This related to what I said above. First, try to identify the structure, then explicitly make it visible.








                      share|improve this answer









                      $endgroup$


















                        5












                        $begingroup$

                        I do not think that any good way exists. Once a graph is large enough, it will always look like a hairball unless it has a clear structure that might be made visible. For example, this is a similarity graph of musicians. The musicians cluster into groups, and it is possible to make this structure visible. Your example graph, on the other hand, is completely random, with random edge weights. Since there are lots of nodes and edges, but no real information is contained within them, I do not think that it can be visualized in a meaningful way.



                        Assuming that there is something to show, things you can try are:





                        • Take edge weights into consideration when computing the layout. Look up individual graph layouts on the GraphLayout doc page, and see if they support weights. You have already found GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True}, but it's still useful to mention this for other readers.



                          The example I linked above was created by one of the authors of the igraph library. IGraph/M is a Mathematica interface to igraph (and much more), and exposes multiple layout algorithms that support weights. The above example was created using the DrL layout (IGLayoutDrL function in IGraph/M)




                        • Visualize weights as not edge lengths, but edge weights or edge colours. You can do this with EdgeStyle. IGraph/M provides a very convenient way to do it:



                          SeedRandom[137]
                          g = RandomGraph[{10, 20}, EdgeWeight -> RandomReal[{.1, 1}, 20]]

                          Graph[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/3]]] //
                          IGEdgeMap[AbsoluteThickness[10 #] &, EdgeStyle -> IGEdgeProp[EdgeWeight]]


                          enter image description here




                        • Use colours in the same way.



                          Graph[g, EdgeStyle -> Directive[CapForm["Round"], AbsoluteThickness[4]]] //
                          IGEdgeMap[ColorData["RustTones"], EdgeStyle -> Rescale@*IGEdgeProp[EdgeWeight]]


                          enter image description here




                        • Use all of the above: edge length, edge thickness and edge colour.



                          IGLayoutFruchtermanReingold[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/2]]] // 
                          IGEdgeMap[
                          Directive[ColorData["RustTones"][#], AbsoluteThickness[10 #]] &,
                          EdgeStyle -> (#/Max[#] &)@*IGEdgeProp[EdgeWeight]]


                          enter image description here




                        • Cluster the graph vertices before visualizing them. The clustering can take weights into account.



                          CommunityGraphPlot[g]


                          enter image description here



                          This related to what I said above. First, try to identify the structure, then explicitly make it visible.








                        share|improve this answer









                        $endgroup$
















                          5












                          5








                          5





                          $begingroup$

                          I do not think that any good way exists. Once a graph is large enough, it will always look like a hairball unless it has a clear structure that might be made visible. For example, this is a similarity graph of musicians. The musicians cluster into groups, and it is possible to make this structure visible. Your example graph, on the other hand, is completely random, with random edge weights. Since there are lots of nodes and edges, but no real information is contained within them, I do not think that it can be visualized in a meaningful way.



                          Assuming that there is something to show, things you can try are:





                          • Take edge weights into consideration when computing the layout. Look up individual graph layouts on the GraphLayout doc page, and see if they support weights. You have already found GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True}, but it's still useful to mention this for other readers.



                            The example I linked above was created by one of the authors of the igraph library. IGraph/M is a Mathematica interface to igraph (and much more), and exposes multiple layout algorithms that support weights. The above example was created using the DrL layout (IGLayoutDrL function in IGraph/M)




                          • Visualize weights as not edge lengths, but edge weights or edge colours. You can do this with EdgeStyle. IGraph/M provides a very convenient way to do it:



                            SeedRandom[137]
                            g = RandomGraph[{10, 20}, EdgeWeight -> RandomReal[{.1, 1}, 20]]

                            Graph[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/3]]] //
                            IGEdgeMap[AbsoluteThickness[10 #] &, EdgeStyle -> IGEdgeProp[EdgeWeight]]


                            enter image description here




                          • Use colours in the same way.



                            Graph[g, EdgeStyle -> Directive[CapForm["Round"], AbsoluteThickness[4]]] //
                            IGEdgeMap[ColorData["RustTones"], EdgeStyle -> Rescale@*IGEdgeProp[EdgeWeight]]


                            enter image description here




                          • Use all of the above: edge length, edge thickness and edge colour.



                            IGLayoutFruchtermanReingold[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/2]]] // 
                            IGEdgeMap[
                            Directive[ColorData["RustTones"][#], AbsoluteThickness[10 #]] &,
                            EdgeStyle -> (#/Max[#] &)@*IGEdgeProp[EdgeWeight]]


                            enter image description here




                          • Cluster the graph vertices before visualizing them. The clustering can take weights into account.



                            CommunityGraphPlot[g]


                            enter image description here



                            This related to what I said above. First, try to identify the structure, then explicitly make it visible.








                          share|improve this answer









                          $endgroup$



                          I do not think that any good way exists. Once a graph is large enough, it will always look like a hairball unless it has a clear structure that might be made visible. For example, this is a similarity graph of musicians. The musicians cluster into groups, and it is possible to make this structure visible. Your example graph, on the other hand, is completely random, with random edge weights. Since there are lots of nodes and edges, but no real information is contained within them, I do not think that it can be visualized in a meaningful way.



                          Assuming that there is something to show, things you can try are:





                          • Take edge weights into consideration when computing the layout. Look up individual graph layouts on the GraphLayout doc page, and see if they support weights. You have already found GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> True}, but it's still useful to mention this for other readers.



                            The example I linked above was created by one of the authors of the igraph library. IGraph/M is a Mathematica interface to igraph (and much more), and exposes multiple layout algorithms that support weights. The above example was created using the DrL layout (IGLayoutDrL function in IGraph/M)




                          • Visualize weights as not edge lengths, but edge weights or edge colours. You can do this with EdgeStyle. IGraph/M provides a very convenient way to do it:



                            SeedRandom[137]
                            g = RandomGraph[{10, 20}, EdgeWeight -> RandomReal[{.1, 1}, 20]]

                            Graph[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/3]]] //
                            IGEdgeMap[AbsoluteThickness[10 #] &, EdgeStyle -> IGEdgeProp[EdgeWeight]]


                            enter image description here




                          • Use colours in the same way.



                            Graph[g, EdgeStyle -> Directive[CapForm["Round"], AbsoluteThickness[4]]] //
                            IGEdgeMap[ColorData["RustTones"], EdgeStyle -> Rescale@*IGEdgeProp[EdgeWeight]]


                            enter image description here




                          • Use all of the above: edge length, edge thickness and edge colour.



                            IGLayoutFruchtermanReingold[g, EdgeStyle -> Directive[CapForm["Round"], Opacity[1/2]]] // 
                            IGEdgeMap[
                            Directive[ColorData["RustTones"][#], AbsoluteThickness[10 #]] &,
                            EdgeStyle -> (#/Max[#] &)@*IGEdgeProp[EdgeWeight]]


                            enter image description here




                          • Cluster the graph vertices before visualizing them. The clustering can take weights into account.



                            CommunityGraphPlot[g]


                            enter image description here



                            This related to what I said above. First, try to identify the structure, then explicitly make it visible.









                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered yesterday









                          SzabolcsSzabolcs

                          163k14448945




                          163k14448945























                              4












                              $begingroup$

                              When you have a lot of things to display in a small space you get a mess no matter what. But you can always try to make it better. I suggest 2 steps:




                              1. Untangle a bit the mess with GraphLayout

                              2. Avoid noise in style logic


                              1. Untangle a bit the mess with GraphLayout



                              I would use a proper GraphLayout for a specific cases. For instance, a general messy graph can benefit from "GravityEmbedding" which will be available in V12 (compare left and right images):



                              RandomGraph[{100,100},ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"GravityEmbedding"}


                              enter image description here



                              But on the other hand in case of trees you are better of with "RadialEmbedding"



                              Graph[RandomInteger[#]<->#+1&/@Range[0,500],ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"RadialEmbedding"}


                              enter image description here



                              And so on depending on your specific graph structure.



                              2. Avoid noise in style logic



                              I recommend to read an article I wrote (even so your graphs are larger a lot of logic still holds):



                              On design of styles for small weighted graphs: https://community.wolfram.com/groups/-/m/t/838652



                              enter image description here






                              share|improve this answer









                              $endgroup$













                              • $begingroup$
                                So what is this "GravityEmbedding" anyway? It's the first new piece of functionality added in a long time. Is it explained what it does? If not, why do you think it's more appropriate? And why does a layout change the appearance of edges? That is counterproductive and people will end up having to keep switching back to the default (I bet most won't even know how).
                                $endgroup$
                                – Szabolcs
                                20 hours ago












                              • $begingroup$
                                I remember watching the graphs Twitch stream. SW asked the very same questions and there was no answer to either one. Why did it make it so far in this state then?
                                $endgroup$
                                – Szabolcs
                                20 hours ago










                              • $begingroup$
                                @Szabolcs I did not have a chance too look at it in depth, but something like "energy with vertices as mass points and edges as springs". If you mean bent edges - not sure why but I like it. My guess is that close about parallel edges will have an opposite curvature to not overlap --- but I am not sure. There are too many things for one person to be aware of :-)
                                $endgroup$
                                – Vitaliy Kaurov
                                20 hours ago










                              • $begingroup$
                                If you like curved edges, maybe you can convince the developer to document EdgeShapeFunction -> "CurvedArc", something we've been requesting for years. A graph layout should not affect edge rendering, as these are separate concepts. BTW I do not see any documented way to switch back to the default edge rendering.
                                $endgroup$
                                – Szabolcs
                                20 hours ago


















                              4












                              $begingroup$

                              When you have a lot of things to display in a small space you get a mess no matter what. But you can always try to make it better. I suggest 2 steps:




                              1. Untangle a bit the mess with GraphLayout

                              2. Avoid noise in style logic


                              1. Untangle a bit the mess with GraphLayout



                              I would use a proper GraphLayout for a specific cases. For instance, a general messy graph can benefit from "GravityEmbedding" which will be available in V12 (compare left and right images):



                              RandomGraph[{100,100},ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"GravityEmbedding"}


                              enter image description here



                              But on the other hand in case of trees you are better of with "RadialEmbedding"



                              Graph[RandomInteger[#]<->#+1&/@Range[0,500],ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"RadialEmbedding"}


                              enter image description here



                              And so on depending on your specific graph structure.



                              2. Avoid noise in style logic



                              I recommend to read an article I wrote (even so your graphs are larger a lot of logic still holds):



                              On design of styles for small weighted graphs: https://community.wolfram.com/groups/-/m/t/838652



                              enter image description here






                              share|improve this answer









                              $endgroup$













                              • $begingroup$
                                So what is this "GravityEmbedding" anyway? It's the first new piece of functionality added in a long time. Is it explained what it does? If not, why do you think it's more appropriate? And why does a layout change the appearance of edges? That is counterproductive and people will end up having to keep switching back to the default (I bet most won't even know how).
                                $endgroup$
                                – Szabolcs
                                20 hours ago












                              • $begingroup$
                                I remember watching the graphs Twitch stream. SW asked the very same questions and there was no answer to either one. Why did it make it so far in this state then?
                                $endgroup$
                                – Szabolcs
                                20 hours ago










                              • $begingroup$
                                @Szabolcs I did not have a chance too look at it in depth, but something like "energy with vertices as mass points and edges as springs". If you mean bent edges - not sure why but I like it. My guess is that close about parallel edges will have an opposite curvature to not overlap --- but I am not sure. There are too many things for one person to be aware of :-)
                                $endgroup$
                                – Vitaliy Kaurov
                                20 hours ago










                              • $begingroup$
                                If you like curved edges, maybe you can convince the developer to document EdgeShapeFunction -> "CurvedArc", something we've been requesting for years. A graph layout should not affect edge rendering, as these are separate concepts. BTW I do not see any documented way to switch back to the default edge rendering.
                                $endgroup$
                                – Szabolcs
                                20 hours ago
















                              4












                              4








                              4





                              $begingroup$

                              When you have a lot of things to display in a small space you get a mess no matter what. But you can always try to make it better. I suggest 2 steps:




                              1. Untangle a bit the mess with GraphLayout

                              2. Avoid noise in style logic


                              1. Untangle a bit the mess with GraphLayout



                              I would use a proper GraphLayout for a specific cases. For instance, a general messy graph can benefit from "GravityEmbedding" which will be available in V12 (compare left and right images):



                              RandomGraph[{100,100},ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"GravityEmbedding"}


                              enter image description here



                              But on the other hand in case of trees you are better of with "RadialEmbedding"



                              Graph[RandomInteger[#]<->#+1&/@Range[0,500],ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"RadialEmbedding"}


                              enter image description here



                              And so on depending on your specific graph structure.



                              2. Avoid noise in style logic



                              I recommend to read an article I wrote (even so your graphs are larger a lot of logic still holds):



                              On design of styles for small weighted graphs: https://community.wolfram.com/groups/-/m/t/838652



                              enter image description here






                              share|improve this answer









                              $endgroup$



                              When you have a lot of things to display in a small space you get a mess no matter what. But you can always try to make it better. I suggest 2 steps:




                              1. Untangle a bit the mess with GraphLayout

                              2. Avoid noise in style logic


                              1. Untangle a bit the mess with GraphLayout



                              I would use a proper GraphLayout for a specific cases. For instance, a general messy graph can benefit from "GravityEmbedding" which will be available in V12 (compare left and right images):



                              RandomGraph[{100,100},ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"GravityEmbedding"}


                              enter image description here



                              But on the other hand in case of trees you are better of with "RadialEmbedding"



                              Graph[RandomInteger[#]<->#+1&/@Range[0,500],ImageSize->400,GraphLayout->#]&/@
                              {Automatic,"RadialEmbedding"}


                              enter image description here



                              And so on depending on your specific graph structure.



                              2. Avoid noise in style logic



                              I recommend to read an article I wrote (even so your graphs are larger a lot of logic still holds):



                              On design of styles for small weighted graphs: https://community.wolfram.com/groups/-/m/t/838652



                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered yesterday









                              Vitaliy KaurovVitaliy Kaurov

                              57.8k6162283




                              57.8k6162283












                              • $begingroup$
                                So what is this "GravityEmbedding" anyway? It's the first new piece of functionality added in a long time. Is it explained what it does? If not, why do you think it's more appropriate? And why does a layout change the appearance of edges? That is counterproductive and people will end up having to keep switching back to the default (I bet most won't even know how).
                                $endgroup$
                                – Szabolcs
                                20 hours ago












                              • $begingroup$
                                I remember watching the graphs Twitch stream. SW asked the very same questions and there was no answer to either one. Why did it make it so far in this state then?
                                $endgroup$
                                – Szabolcs
                                20 hours ago










                              • $begingroup$
                                @Szabolcs I did not have a chance too look at it in depth, but something like "energy with vertices as mass points and edges as springs". If you mean bent edges - not sure why but I like it. My guess is that close about parallel edges will have an opposite curvature to not overlap --- but I am not sure. There are too many things for one person to be aware of :-)
                                $endgroup$
                                – Vitaliy Kaurov
                                20 hours ago










                              • $begingroup$
                                If you like curved edges, maybe you can convince the developer to document EdgeShapeFunction -> "CurvedArc", something we've been requesting for years. A graph layout should not affect edge rendering, as these are separate concepts. BTW I do not see any documented way to switch back to the default edge rendering.
                                $endgroup$
                                – Szabolcs
                                20 hours ago




















                              • $begingroup$
                                So what is this "GravityEmbedding" anyway? It's the first new piece of functionality added in a long time. Is it explained what it does? If not, why do you think it's more appropriate? And why does a layout change the appearance of edges? That is counterproductive and people will end up having to keep switching back to the default (I bet most won't even know how).
                                $endgroup$
                                – Szabolcs
                                20 hours ago












                              • $begingroup$
                                I remember watching the graphs Twitch stream. SW asked the very same questions and there was no answer to either one. Why did it make it so far in this state then?
                                $endgroup$
                                – Szabolcs
                                20 hours ago










                              • $begingroup$
                                @Szabolcs I did not have a chance too look at it in depth, but something like "energy with vertices as mass points and edges as springs". If you mean bent edges - not sure why but I like it. My guess is that close about parallel edges will have an opposite curvature to not overlap --- but I am not sure. There are too many things for one person to be aware of :-)
                                $endgroup$
                                – Vitaliy Kaurov
                                20 hours ago










                              • $begingroup$
                                If you like curved edges, maybe you can convince the developer to document EdgeShapeFunction -> "CurvedArc", something we've been requesting for years. A graph layout should not affect edge rendering, as these are separate concepts. BTW I do not see any documented way to switch back to the default edge rendering.
                                $endgroup$
                                – Szabolcs
                                20 hours ago


















                              $begingroup$
                              So what is this "GravityEmbedding" anyway? It's the first new piece of functionality added in a long time. Is it explained what it does? If not, why do you think it's more appropriate? And why does a layout change the appearance of edges? That is counterproductive and people will end up having to keep switching back to the default (I bet most won't even know how).
                              $endgroup$
                              – Szabolcs
                              20 hours ago






                              $begingroup$
                              So what is this "GravityEmbedding" anyway? It's the first new piece of functionality added in a long time. Is it explained what it does? If not, why do you think it's more appropriate? And why does a layout change the appearance of edges? That is counterproductive and people will end up having to keep switching back to the default (I bet most won't even know how).
                              $endgroup$
                              – Szabolcs
                              20 hours ago














                              $begingroup$
                              I remember watching the graphs Twitch stream. SW asked the very same questions and there was no answer to either one. Why did it make it so far in this state then?
                              $endgroup$
                              – Szabolcs
                              20 hours ago




                              $begingroup$
                              I remember watching the graphs Twitch stream. SW asked the very same questions and there was no answer to either one. Why did it make it so far in this state then?
                              $endgroup$
                              – Szabolcs
                              20 hours ago












                              $begingroup$
                              @Szabolcs I did not have a chance too look at it in depth, but something like "energy with vertices as mass points and edges as springs". If you mean bent edges - not sure why but I like it. My guess is that close about parallel edges will have an opposite curvature to not overlap --- but I am not sure. There are too many things for one person to be aware of :-)
                              $endgroup$
                              – Vitaliy Kaurov
                              20 hours ago




                              $begingroup$
                              @Szabolcs I did not have a chance too look at it in depth, but something like "energy with vertices as mass points and edges as springs". If you mean bent edges - not sure why but I like it. My guess is that close about parallel edges will have an opposite curvature to not overlap --- but I am not sure. There are too many things for one person to be aware of :-)
                              $endgroup$
                              – Vitaliy Kaurov
                              20 hours ago












                              $begingroup$
                              If you like curved edges, maybe you can convince the developer to document EdgeShapeFunction -> "CurvedArc", something we've been requesting for years. A graph layout should not affect edge rendering, as these are separate concepts. BTW I do not see any documented way to switch back to the default edge rendering.
                              $endgroup$
                              – Szabolcs
                              20 hours ago






                              $begingroup$
                              If you like curved edges, maybe you can convince the developer to document EdgeShapeFunction -> "CurvedArc", something we've been requesting for years. A graph layout should not affect edge rendering, as these are separate concepts. BTW I do not see any documented way to switch back to the default edge rendering.
                              $endgroup$
                              – Szabolcs
                              20 hours ago




















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Mathematica Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194811%2fideas-for-colorfully-and-clearly-highlighting-graph-edges-according-to-weights%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Bruad Bilen | Luke uk diar | NawigatsjuunCommonskategorii: BruadCommonskategorii: RunstükenWikiquote: Bruad

                              What is the offset in a seaplane's hull?

                              Slayer Innehåll Historia | Stil, komposition och lyrik | Bandets betydelse och framgångar | Sidoprojekt och samarbeten | Kontroverser | Medlemmar | Utmärkelser och nomineringar | Turnéer och festivaler | Diskografi | Referenser | Externa länkar | Navigeringsmenywww.slayer.net”Metal Massacre vol. 1””Metal Massacre vol. 3””Metal Massacre Volume III””Show No Mercy””Haunting the Chapel””Live Undead””Hell Awaits””Reign in Blood””Reign in Blood””Gold & Platinum – Reign in Blood””Golden Gods Awards Winners”originalet”Kerrang! Hall Of Fame””Slayer Looks Back On 37-Year Career In New Video Series: Part Two””South of Heaven””Gold & Platinum – South of Heaven””Seasons in the Abyss””Gold & Platinum - Seasons in the Abyss””Divine Intervention””Divine Intervention - Release group by Slayer””Gold & Platinum - Divine Intervention””Live Intrusion””Undisputed Attitude””Abolish Government/Superficial Love””Release “Slatanic Slaughter: A Tribute to Slayer” by Various Artists””Diabolus in Musica””Soundtrack to the Apocalypse””God Hates Us All””Systematic - Relationships””War at the Warfield””Gold & Platinum - War at the Warfield””Soundtrack to the Apocalypse””Gold & Platinum - Still Reigning””Metallica, Slayer, Iron Mauden Among Winners At Metal Hammer Awards””Eternal Pyre””Eternal Pyre - Slayer release group””Eternal Pyre””Metal Storm Awards 2006””Kerrang! Hall Of Fame””Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Bullet-For My Valentine booed at Metal Hammer Golden Gods Awards””Unholy Aliance””The End Of Slayer?””Slayer: We Could Thrash Out Two More Albums If We're Fast Enough...””'The Unholy Alliance: Chapter III' UK Dates Added”originalet”Megadeth And Slayer To Co-Headline 'Canadian Carnage' Trek”originalet”World Painted Blood””Release “World Painted Blood” by Slayer””Metallica Heading To Cinemas””Slayer, Megadeth To Join Forces For 'European Carnage' Tour - Dec. 18, 2010”originalet”Slayer's Hanneman Contracts Acute Infection; Band To Bring In Guest Guitarist””Cannibal Corpse's Pat O'Brien Will Step In As Slayer's Guest Guitarist”originalet”Slayer’s Jeff Hanneman Dead at 49””Dave Lombardo Says He Made Only $67,000 In 2011 While Touring With Slayer””Slayer: We Do Not Agree With Dave Lombardo's Substance Or Timeline Of Events””Slayer Welcomes Drummer Paul Bostaph Back To The Fold””Slayer Hope to Unveil Never-Before-Heard Jeff Hanneman Material on Next Album””Slayer Debut New Song 'Implode' During Surprise Golden Gods Appearance””Release group Repentless by Slayer””Repentless - Slayer - Credits””Slayer””Metal Storm Awards 2015””Slayer - to release comic book "Repentless #1"””Slayer To Release 'Repentless' 6.66" Vinyl Box Set””BREAKING NEWS: Slayer Announce Farewell Tour””Slayer Recruit Lamb of God, Anthrax, Behemoth + Testament for Final Tour””Slayer lägger ner efter 37 år””Slayer Announces Second North American Leg Of 'Final' Tour””Final World Tour””Slayer Announces Final European Tour With Lamb of God, Anthrax And Obituary””Slayer To Tour Europe With Lamb of God, Anthrax And Obituary””Slayer To Play 'Last French Show Ever' At Next Year's Hellfst””Slayer's Final World Tour Will Extend Into 2019””Death Angel's Rob Cavestany On Slayer's 'Farewell' Tour: 'Some Of Us Could See This Coming'””Testament Has No Plans To Retire Anytime Soon, Says Chuck Billy””Anthrax's Scott Ian On Slayer's 'Farewell' Tour Plans: 'I Was Surprised And I Wasn't Surprised'””Slayer””Slayer's Morbid Schlock””Review/Rock; For Slayer, the Mania Is the Message””Slayer - Biography””Slayer - Reign In Blood”originalet”Dave Lombardo””An exclusive oral history of Slayer”originalet”Exclusive! Interview With Slayer Guitarist Jeff Hanneman”originalet”Thinking Out Loud: Slayer's Kerry King on hair metal, Satan and being polite””Slayer Lyrics””Slayer - Biography””Most influential artists for extreme metal music””Slayer - Reign in Blood””Slayer guitarist Jeff Hanneman dies aged 49””Slatanic Slaughter: A Tribute to Slayer””Gateway to Hell: A Tribute to Slayer””Covered In Blood””Slayer: The Origins of Thrash in San Francisco, CA.””Why They Rule - #6 Slayer”originalet”Guitar World's 100 Greatest Heavy Metal Guitarists Of All Time”originalet”The fans have spoken: Slayer comes out on top in readers' polls”originalet”Tribute to Jeff Hanneman (1964-2013)””Lamb Of God Frontman: We Sound Like A Slayer Rip-Off””BEHEMOTH Frontman Pays Tribute To SLAYER's JEFF HANNEMAN””Slayer, Hatebreed Doing Double Duty On This Year's Ozzfest””System of a Down””Lacuna Coil’s Andrea Ferro Talks Influences, Skateboarding, Band Origins + More””Slayer - Reign in Blood””Into The Lungs of Hell””Slayer rules - en utställning om fans””Slayer and Their Fans Slashed Through a No-Holds-Barred Night at Gas Monkey””Home””Slayer””Gold & Platinum - The Big 4 Live from Sofia, Bulgaria””Exclusive! Interview With Slayer Guitarist Kerry King””2008-02-23: Wiltern, Los Angeles, CA, USA””Slayer's Kerry King To Perform With Megadeth Tonight! - Oct. 21, 2010”originalet”Dave Lombardo - Biography”Slayer Case DismissedArkiveradUltimate Classic Rock: Slayer guitarist Jeff Hanneman dead at 49.”Slayer: "We could never do any thing like Some Kind Of Monster..."””Cannibal Corpse'S Pat O'Brien Will Step In As Slayer'S Guest Guitarist | The Official Slayer Site”originalet”Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Kerrang! Awards 2006 Blog: Kerrang! Hall Of Fame””Kerrang! Awards 2013: Kerrang! Legend”originalet”Metallica, Slayer, Iron Maien Among Winners At Metal Hammer Awards””Metal Hammer Golden Gods Awards””Bullet For My Valentine Booed At Metal Hammer Golden Gods Awards””Metal Storm Awards 2006””Metal Storm Awards 2015””Slayer's Concert History””Slayer - Relationships””Slayer - Releases”Slayers officiella webbplatsSlayer på MusicBrainzOfficiell webbplatsSlayerSlayerr1373445760000 0001 1540 47353068615-5086262726cb13906545x(data)6033143kn20030215029