我一直在尝试使用ggnet2
. 为此,我使用以下代码:
library(igraph)
lapply(c("sna", "intergraph", "GGally", "igraph", "network"), require, character.only=T)
data <- read.table('CA-CondMat.txt',sep="\t",header=TRUE)
g = graph.data.frame(data, directed = TRUE)
N = vcount(g)
E = ecount(g)
perc = 0.1
d.g = degree(g,mode='all')/N
new_nodes = sample.int(N,ceiling(perc*N),replace=FALSE,prob =d.g)
new_g = subgraph(g,new_nodes)
dg = degree(g,mode='all')
prob = dg/sum(dg)
png('example_plot2.png')
ggnet2(new_g, size = "degree", node.color = "steelblue", size.cut = 4,
edge.size = 1, edge.color="grey" )
dev.off()
我得到一个完全蓝色的图表。
我正在使用包igraph
。
文件链接:
https ://snap.stanford.edu/data/ca-CondMat.html
编辑:
添加了完整示例