簡體   English   中英

根據它們的中心性着色頂點

[英]Coloring vertexes according to their centrality

我試圖改變igraph生成圖中頂點的顏色。 更具體地說,我有一個從鄰接矩陣創建的95節點圖,我想根據它們的度/中間性/特征值中心性/親密度對它們進行着色,但我猜想在我知道如何用一個,我將能夠與其他人一起做。

所以我編寫了圖形生成的基礎知識,直到現在:

數據集< - read.csv(“〜/ Google Drive / Cours M2 / Network Economics / Data / Collabs_2013.csv”,sep =“;”)
基質<-as.matrix(數據集)
ADJ <-graph.adjacency(基體)
劇情(形容詞)
btw <-betweenness(adj,directed = FALSE)

我現在有一個95個中間值的向量,我想繪制一個顏色漸變的圖形,該顏色跟隨中介值(例如,從最低值的紅色到綠色到最高值)。 我猜我必須弄亂頂點的屬性,但我不知道如何輸入矢量作為顏色屬性。

好像你已經完成了大部分工作。 您只需要知道colorRamppalette並為網絡設置vertex.color 假設你必須線性改變顏色,

做就是了

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)

歸功於 在回答這個問題之前,我正在使用一種效率更低的方法來分配顏色。

請注意:

定義可能會有問題

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

作為'調色板'功能,也被igraph使用,因此igraph后來產生錯誤。

請參閱R中igraph網絡中頂點的顏色調色板問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM