Question

I have a graph in an adjacency matrix format:

https://dl.dropboxusercontent.com/u/22681355/network.csv

The nodes in the first column are connected to the corresponding nodes in the second column.

Is it possible to convert this graph to a format that makes it possible to visualize?

Was it helpful?

Solution

try this:

 #use igraph for example
 library(igraph)

 #get your data into x
 x <- read.table("~/Downloads/network.csv", sep=";", quote="\"")
 x <- as.matrix(x)
 a <- numeric(0)
 for(i in 1:nrow(x)){
   a <- c(a, x[i,])
 }

 #plot it
 b <- graph(a)
 plot.igraph(b, edge.arrow.size=0.05, vertex.size = 5, vertex.label.cex = 0.5)
 #or tree
 plot.igraph(b, layout=layout.reingold.tilford, edge.arrow.size=0.05, vertex.size = 5, vertex.label.cex = 0.5)
 #or circle
 plot.igraph(b, layout=layout.circle, edge.arrow.size=0.05, vertex.size = 5, vertex.label.cex = 0.5)

OTHER TIPS

This is not an adjacency matrix, but rather an edge list. Here is a simple way to import and plot it:

csv <- read.csv("http://dl.dropboxusercontent.com/u/22681355/network.csv", sep=";")
g <- graph.data.frame(csv)             
plot(g)

If you want to really see something on the plot, you'll need to edit the plotting parameters, read ?igraph.plotting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top