[R] Minimum Spanning Tree

Gábor Csárdi csardi at rmki.kfki.hu
Wed Apr 8 19:19:54 CEST 2009


On Wed, Apr 8, 2009 at 6:12 PM, jpearl01 <joshearl1 at hotmail.com> wrote:
>
>
>>I am not sure what you mean. Of course you can plot it using different
>>layouts, e.g. with layout.reingold.tilford (after choosing the root
>>vertex in some way) and then it looks like a usual tree plot, but why
>>would that be any better?
>
> I'd like to be able to distinguish between the nodes better.  For example
> the image that I get looks like:
> http://www.nabble.com/file/p22954099/mst.gif mst.gif
>
> The tree nodes are just too close together to be able to read.  I think the
> problem might be that some distances between the nodes are *much* smaller
> than other edges.    The graph does not need to be directed, since the
> distance metric does not imply a direction. The most important part is just
> being able to see and differentiate between the nodes, and right now they
> seem to be all lumped together.  How can I make it more readable?

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,
> ~josh
>
>
> --
> View this message in context: http://www.nabble.com/Minimum-Spanning-Tree-tp22934813p22954099.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Gabor Csardi <Gabor.Csardi at unil.ch>     UNIL DGM




More information about the R-help mailing list