Coloring the vertices according to their centrality

I am trying to change the color of the vertices in the graph generated by the graph. To be more specific, I have a 95-node graph created from an adjacency matrix, and I would like to color them according to their degree / interconnection / intrinsic value / proximity, but I assume that after I know how do it with one, I can do it with others.

So, I have encoded the basics of graph generation so far:

dataset <- read.csv ("~ / Google Drive / Chick M2 / Network Economy / Data / Collabs_2013.csv", sep = ";")
matrix <-as.matrix (data set)
adj <-graph.adjacency (matrix )
section (adj)
btw <-betweenness (adj, direct = FALSE)

Now I have a vector of 95 internode values, and I would like to plot a color gradient that follows the internode values ​​(for example, from red for the lowest value to green to the highest). I suppose I need to mess up the attributes of the vertices, but I have no idea how to enter a vector as a color attribute.

+4
source share
2 answers

It looks like you've already done most of the work. All you need to know is colorRamppalettesetup vertex.colorfor the network. Assuming you need to change colors linearly,

simply

fine = 500 # this will adjust the resolving power.
pal = colorRampPalette(c('red','green'))

#this gives you the colors you want for every point
graphCol = pal(fine)[as.numeric(cut(btw,breaks = fine))]

# now you just need to plot it with those colors
plot(adj, vertex.color=graphCol)

loans. I used a much more inefficient method to assign colors before replying to this.

+5
source

:

palette = colorRampPalette(c('blue','green'))

"", igraph, .

. igraph R

+3

All Articles