我一直试图用图表绘制图表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()
Run Code Online (Sandbox Code Playgroud)
我得到一个完全蓝色的图表.
我正在使用这个包igraph.
我想要绘制的是一个图表,节点的颜色基于它们的程度,如下所示:

链接到该文件:https:
//snap.stanford.edu/data/ca-CondMat.html
编辑:
完整示例添加