[R] Minimum Spanning Tree
jpearl01
joshearl1 at hotmail.com
Wed Apr 8 22:20:49 CEST 2009
That's like a miracle! The only thing that would make this graph perfect is
if the lengths of the edges were in the same ratio as the actual edge
lengths from the matrix. Is it possible to alter that?
Thank you!!
~josh
Actually,
library(igraph)
tab <- read.csv("http://www.nabble.com/file/p22957493/sp_matrix.csv")
tab <- tab[,-1]
g <- graph.adjacency(as.matrix(tab), weighted=TRUE)
V(g)$label <- V(g)$name
mst <- as.undirected(minimum.spanning.tree(g))
lay <- layout.reingold.tilford(mst, root=which.max(degree(mst))-1)
lay <- cbind(lay[,2], lay[,1]) # rotate
x11(width=15, height=8)
plot(mst, layout=lay, vertex.size=25, vertex.size2=10,
vertex.shape="rectangle", asp=FALSE,
vertex.label.cex=0.7, vertex.color="white")
works relatively well for me on your graph. It doesn't for you?
Best,
Gabor
--
View this message in context: http://www.nabble.com/Minimum-Spanning-Tree-tp22934813p22958820.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list