Jatt
Jatt

Reputation: 785

Getting a unclear graph for a graph data set using igraph

I am trying to visualize a graph data set as downloaded from snap.stanford.edu using igraph. Here is what I did:

library(igraph)

graph_file = '4.txt'
#Read the data in using igraph
glist<-read.table(graph_file)
gframe <- graph.data.frame(as.data.frame(glist))
plot(gframe)

The plot produced from the above code is multilayer and is impossible to visualize anything from it. It looks like: enter image description here

Is there something that I am missing? Is there a way I could visually improve this graph?

The graph data set is in the link I mentioned above.

Upvotes: 0

Views: 95

Answers (1)

mysteRious
mysteRious

Reputation: 4294

Usually with k-core decomposition, you can plot the subset of the nodes that are most tightly connected to one another, and it helps a lot in terms of being able to see important elements of the structure. For this dataset, not so much, but here's how to go through the process:

> library(igraph)
> con <- gzcon(url("http://snap.stanford.edu/data/p2p-Gnutella04.txt.gz"))
> txt <- readLines(con)
> edgelist <- strsplit(txt[5:39998],"\t")
> m <- matrix(unlist(edgelist),nc=2,byrow=TRUE)
> g <- graph.data.frame(m)
> coreness <- graph.coreness(g)

Find max number of connections:

> max(V(g)$core)
[1] 7

Then plot:

> kcore <- induced.subgraph(graph=g,vids=which(coreness>6))
> plot(kcore)

Yuck:

still terrible

To plot the ego network around a particular node:

> g3109 <- make_ego_graph(g, 1, "3109")
> plot(g3109[[1]], asp=0)

igraph better

Upvotes: 1

Related Questions