I've been trying to plot a graph using ggnet2
. To do this I use the following code:
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()
and I get a completely blue graph.
I'm using the package igraph
.
What I want to plot is a graph with the nodes' color based on their degree like this one:
Link to the file:
https://snap.stanford.edu/data/ca-CondMat.html
Edit:
Full example added