1
$\begingroup$

Assortativity and disassortativity are graph properties that represent how hub-and-spoke-like a graph is, where assortative graphs have hubs that connect to each other, while disassortative graphs have hubs which tend to connected only to low degree nodes (see the figure below).

Seeing a transition visually from assortativity to disassortativity can be important. Can Mathematica do this with a graph layout that highlights these features?

enter image description here

$\endgroup$
4
  • 2
    $\begingroup$ I think you should specify more precisely what exactly you want. For example, if you just want to color the vertices by ther degree, you can use g = UndirectedGraph[RandomTree[15], GraphLayout -> "SpringElectricalEmbedding"]; GraphPlot[g, VertexSize -> 1/2, VertexStyle -> Thread[VertexList@g -> ColorData["SiennaTones"] /@ (1 - Normalize[VertexDegree@g, Max])]] But if you actually want the algorithm to decide whether the network is assortative or disassortative, you should check GraphAssortativity. $\endgroup$
    – Domen
    Oct 20, 2023 at 13:09
  • $\begingroup$ I suppose I'm looking for a graph layout that will provide some good visualization of assortativity. Maybe colouring the edges based on the correlation of the degree of their endpoints might be good. $\endgroup$
    – apg
    Oct 20, 2023 at 13:19
  • $\begingroup$ In that case, please include an example of your graph in the question. $\endgroup$
    – Domen
    Oct 20, 2023 at 13:57
  • $\begingroup$ Just a random graph is fine, for example RandomGraph[BarabasiAlbertGraphDistribution[100, 4]] $\endgroup$
    – apg
    Oct 20, 2023 at 14:45

1 Answer 1

3
$\begingroup$

For the style, you could do the following:

g = ExampleData[{"NetworkGraph", "ZacharyKarateClub"}];

vdeg = VertexDegree[g];
vstyle1 = 
  Blend[{Orange, Darker[Red]}, #] & /@ Rescale[VertexDegree[g]];
vstyle2 = 
  Blend[{LightBlue, Darker[Blue]}, #] & /@ Rescale[VertexDegree[g]];
hdeg = Pick[VertexList[g], vdeg, 
   Alternatives @@ Keys[KeySort[Counts[vdeg]][[-4 ;;]]]];

Row[Graph[g, 
    BaseStyle -> {Opacity[1], Thickness[.006], Black, 
      EdgeForm[{Opacity[1], Thickness[.006]}]}, 
    VertexStyle -> Thread[VertexList[g] -> #], 
    VertexLabels -> 
     Thread[VertexList[g] -> Thread[Placed[vdeg, Center]]], 
    VertexSize -> .16 {1, 1}, 
    VertexLabelStyle -> {Directive[Bold, 11], 
      Sequence @@ Thread[hdeg -> Directive[Bold, 12, White]]}, 
    GraphLayout -> "SpringEmbedding", 
    ImageSize -> 300] & /@ {vstyle1, vstyle2}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.