带R的igraph中的节点大小

332nm8kg  于 2023-01-15  发布在  其他
关注(0)|答案(1)|浏览(163)

我有这样的矩阵来构建一个有向图(社交图):

sc=as.matrix(sociogram)
head(sc)

enter image description here
然后我用下面的代码来构建我的图

ig <- graph.adjacency(sc, mode="directed", weighted=T)
coords <- layout_(ig, in_circle())

plot(ig, frame=T,
     edge.arrow.size=.5, 
     vertex.label.color="black", 
     vertex.label.dist=1.5,
     vertex.size=7.5,
     layout = coords)

enter image description here
有没有办法根据进入节点本身的箭头数量来改变节点的大小?
不知道怎么解

deyfvvtc

deyfvvtc1#

试试vertex.size = degree(ig, mode = "in"),就像这样:

g <- sample_gnp(20, .15, directed = TRUE)
plot(g, vertex.label = "", vertex.size = degree(g, mode = "in") *3)

相关问题