[R] Minimum Spanning Tree
jpearl01
joshearl1 at hotmail.com
Wed Apr 8 21:14:43 CEST 2009
Make the graph undirected first and then choose the right plotting
parameters. E.g. the following works fine for me:
set.seed(2)
g <- erdos.renyi.game(100, 300, type="gnm", directed=TRUE)
E(g)$weight <- runif(ecount(g))
mst <- minimum.spanning.tree(g)
mst <- simplify(as.undirected(mst))
lay <- layout.reingold.tilford(mst, root=which.max(degree(mst))-1)
plot(mst, layout=lay, vertex.size=5, asp=FALSE, vertex.color=NA,
vertex.frame.color=NA)
G.
Thanks for all your help Gabor, However, I'm unable to get a display in R
which is at all readable. I'm not sure why that is (if the data is
generated randomly, like in your example the tree builds/reads fine...
however on my dataset whichever node is picked as the root just completely
over powers the rest of the nodes which all clump together in a manner that
is unreadable). My dataset is:
http://www.nabble.com/file/p22957493/sp_matrix.csv sp_matrix.csv
If you would like to take a look. However, as it stands I think I'll have
to find another option. Thanks again for all your efforts.
~josh
--
View this message in context: http://www.nabble.com/Minimum-Spanning-Tree-tp22934813p22957493.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list