igraph plot graph with vertex size dependent on betweenness centrality

5.2k views Asked by At

I would like the size of the nodes in the graph to be dependent on the calculated betweenness centrality of the vertices. How can this be done?

My current code is below:

require(igraph)
g <- read.graph("data.graphml", "graphml")
plot(g,vertex.size = x,layout = layout.fruchterman.reingold)

How can I set 'x' to be a vertex size that is dependent on the betweeness centrality of a node?

1

There are 1 answers

0
Spacedman On BEST ANSWER

Using igraph, and following the example in ?betweenness:

g <- random.graph.game(10, 3/10)
plot(g, vertex.size=betweenness(g))

graph plot

(note numbers are node numbers, not betweenness value)

You may want to rescale your vertex size if you have lots of large values or otherwise improve the visualisation.

g = graph.lattice(c(10,4))
plot(g,vertex.size=betweenness(g)/10)

scaled

without the /10 the vertices are way too large.