Vertex sizes scaled by vertex degree?

Is there any way of scaling the sizes of the vertices of a network proportional to the vertex-degrees of the vertices in Mathematica?




I believe there is a topic about that here but I can’t find it. Meanwhile a community topic: On design of styles for small weighted graphs
– Kuba
May 6 at 18:11


1 Answer


g = RandomGraph[{6, 10}]

vd = Thread[VertexList@g -> Normalize[VertexDegree@g, Total]];
g2 = SetProperty[g, VertexSize -> vd]



Great! Why are you dividing by 20 here?
– dbm
May 6 at 18:21



@dbm, dividing by 20 was to scale the vertex sizes. It is removed in the updated post.
– kglr
May 6 at 18:26



Got it. However, this code doesn’t work for say g = RandomGraph[{90, 120}]
– dbm
May 6 at 18:29



@dbm, maybe you can use Normalize[VertexDegree@g, Max] for large graphs.
– kglr
May 6 at 18:33



No I mean when you draw the larger network with your code, it doesn’t show any nodes at all. I guess you just need to multiply Normalize by 100 or something, otherwise the node size would be scaled too small to see.
– dbm
May 6 at 18:37