数据集包括网络矩阵和属性数据框。网络数据集本身有 3 个数据集,我只想处理PrinFull数据集以及 PRIN 属性数据。我的数据在下面的这两个链接中上传。我在我的数据集上添加了所有属性。
https://drive.google.com/file/d/1MZCdeAZF0joIQLwVeoVXmKpf7r8IJ2wq/view?usp=sharing https://drive.google.com/file/d/1I96BAUo8TjJMWCWpn_SIhp54snfZ0Bd5/view?usp=sharing 我想绘制我的社区检测算法,代码如下,但我的情节很混乱,无法理解。我怎样才能以更好的方式进行绘图?谁能帮我?
load('/content/CISPRINWOSmatrices.RData')
load('/content/CISPRINWOS_attributes.RData')
library("igraphdata")
library("igraph")
library("network")
library("statnet")
library("intergraph")
library("dplyr")
library("stringr")
library("RColorBrewer")
library("sand")
nodePRIN <- data.frame(PRIN)
#nodePRIN
relationsp <- as.matrix(PrinFull)
PRIN_graph = graph_from_adjacency_matrix(relationsp, mode="undirected",weighted = TRUE)
PRIN_graph
# Girvan-newman algorithm
gn.comm <- cluster_edge_betweenness(PRIN_graph)
#How many communities?
unique(gn.comm$membership)
#attach community labels as vertex attribute
V(PRIN_graph)$GN.cluster <- membership(gn.comm)
PRIN_graph
V(PRIN_graph)$Author[V(PRIN_graph)$GN.cluster==69]
# visualizing the result of dividing the network into communities
par(mar=c(0,0,0,0))
colors <- rainbow(max(membership(gn.comm)))
plot(gn.comm, PRIN_graph, vertex.size = 6,
vertex.color=colors[membership(gn.comm)], vertex.label = NA, edge.width = 1)
[![enter image description here][1]][1]