Ideas for colorfully and clearly highlighting graph edges according to weightsStandardForm on Graph edgesColoring edges of a graph according to their weight?Styling the edges of a graph according to the multiplicities of the edgesChanging edge weights in a graph using PropertyValueCannot get Mathematica to recognise Vertex Weights of GraphOther Ideas for Clickable Graph BuildupHow to style a graph according to the direction of the edges and the centrality of the vertices?FindShortestPath in a Random Geometric Graph: Quick Version?How to filter-out edges in a HighlightGraph[] visualization based on VertexCoordinates[]?Finding the dangling free part of a percolating cluster

Are cabin dividers used to "hide" the flex of the airplane?

Does bootstrapped regression allow for inference?

Could a US political party gain complete control over the government by removing checks & balances?

Where else does the Shulchan Aruch quote an authority by name?

Are objects structures and/or vice versa?

Are white and non-white police officers equally likely to kill black suspects?

Can I legally use front facing blue light in the UK?

Why was the "bread communication" in the arena of Catching Fire left out in the movie?

How to deal with fear of taking dependencies

What is it called when one voice type sings a 'solo'?

Domain expired, GoDaddy holds it and is asking more money

Was there ever an axiom rendered a theorem?

Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore

Prime joint compound before latex paint?

Is a vector space a subspace of itself?

Is there a way to make member function NOT callable from constructor?

If a centaur druid Wild Shapes into a Giant Elk, do their Charge features stack?

Does it makes sense to buy a new cycle to learn riding?

Why doesn't a const reference extend the life of a temporary object passed via a function?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

map list to bin numbers

Why do we use polarized capacitors?

Is ipsum/ipsa/ipse a third person pronoun, or can it serve other functions?

LWC and complex parameters



Ideas for colorfully and clearly highlighting graph edges according to weights


StandardForm on Graph edgesColoring edges of a graph according to their weight?Styling the edges of a graph according to the multiplicities of the edgesChanging edge weights in a graph using PropertyValueCannot get Mathematica to recognise Vertex Weights of GraphOther Ideas for Clickable Graph BuildupHow to style a graph according to the direction of the edges and the centrality of the vertices?FindShortestPath in a Random Geometric Graph: Quick Version?How to filter-out edges in a HighlightGraph[] visualization based on VertexCoordinates[]?Finding the dangling free part of a percolating cluster













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 15 hours ago









      user929304user929304

      30629




      30629




















          3 Answers
          3






          active

          oldest

          votes


















          3












          $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$




















            3












            $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$




















              1












              $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$













                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









                3












                $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$

















                  3












                  $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$















                    3












                    3








                    3





                    $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 14 hours ago









                    halmirhalmir

                    10.6k2544




                    10.6k2544





















                        3












                        $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$

















                          3












                          $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$















                            3












                            3








                            3





                            $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 14 hours ago









                            SzabolcsSzabolcs

                            163k14448945




                            163k14448945





















                                1












                                $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$

















                                  1












                                  $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$















                                    1












                                    1








                                    1





                                    $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 8 hours ago









                                    Vitaliy KaurovVitaliy Kaurov

                                    57.8k6162283




                                    57.8k6162283



























                                        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

                                        How to create a command for the “strange m” symbol in latex? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do you make your own symbol when Detexify fails?Writing bold small caps with mathpazo packageplus-minus symbol with parenthesis around the minus signGreek character in Beamer document titleHow to create dashed right arrow over symbol?Currency symbol: Turkish LiraDouble prec as a single symbol?Plus Sign Too Big; How to Call adfbullet?Is there a TeX macro for three-legged pi?How do I get my integral-like symbol to align like the integral?How to selectively substitute a letter with another symbol representing the same letterHow do I generate a less than symbol and vertical bar that are the same height?

                                        Българска екзархия Съдържание История | Български екзарси | Вижте също | Външни препратки | Литература | Бележки | НавигацияУстав за управлението на българската екзархия. Цариград, 1870Слово на Ловешкия митрополит Иларион при откриването на Българския народен събор в Цариград на 23. II. 1870 г.Българската правда и гръцката кривда. От С. М. (= Софийски Мелетий). Цариград, 1872Предстоятели на Българската екзархияПодмененият ВеликденИнформационна агенция „Фокус“Димитър Ризов. Българите в техните исторически, етнографически и политически граници (Атлас съдържащ 40 карти). Berlin, Königliche Hoflithographie, Hof-Buch- und -Steindruckerei Wilhelm Greve, 1917Report of the International Commission to Inquire into the Causes and Conduct of the Balkan Wars

                                        Чепеларе Съдържание География | История | Население | Спортни и природни забележителности | Културни и исторически обекти | Религии | Обществени институции | Известни личности | Редовни събития | Галерия | Източници | Литература | Външни препратки | Навигация41°43′23.99″ с. ш. 24°41′09.99″ и. д. / 41.723333° с. ш. 24.686111° и. д.*ЧепелареЧепеларски Linux fest 2002Начало на Зимен сезон 2005/06Национални хайдушки празници „Капитан Петко Войвода“Град ЧепелареЧепеларе – народният ски курортbgrod.orgwww.terranatura.hit.bgСправка за населението на гр. Исперих, общ. Исперих, обл. РазградМузей на родопския карстМузей на спорта и скитеЧепеларебългарскибългарскианглийскитукИстория на градаСки писти в ЧепелареВремето в ЧепелареРадио и телевизия в ЧепелареЧепеларе мами с родопски чар и добри пистиЕвтин туризъм и снежни атракции в ЧепелареМестоположениеИнформация и снимки от музея на родопския карст3D панорами от ЧепелареЧепелареррр