Hi,
I have a graph G with n nodes (n=1..100).
I want to find the spanning tree over only some specific nodes (not all
nodes in G), for instance nodes (2,3,6).
Is there any way in R that can do this?
Maybe one solution is create another subgraph g' of graph G which
consists nodes 2,3,6 and their
On Wed, Apr 8, 2009 at 10:20 PM, jpearl01 wrote:
>
> 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?
Not really. The thing is that the nod
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/p
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(
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 <-
On Wed, Apr 8, 2009 at 6:12 PM, jpearl01 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 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 bett
On Tue, Apr 7, 2009 at 11:06 PM, jpearl01 wrote:
>
> There was an error in the file... an extraneous comma. That's taken care of.
> however, my tree prints out an image that doesn't seem like a mst. Attached
> is the csv file I used...
Well, it looks definitely a tree to me.
> http://www.nabbl
Josh, I would recommend to use a package that supports networks, e.g.
igraph, but there are others as well.
You can read in the data using 'read.csv()', transform it to a matrix
with 'as.matrix()', and then create an igraph object from it with
'graph.adjacency()'.
Then call 'minimum.spanning.tree
There was an error in the file... an extraneous comma. That's taken care of.
however, my tree prints out an image that doesn't seem like a mst. Attached
is the csv file I used...
http://www.nabble.com/file/p22938299/sp_matrix.csv sp_matrix.csv
I'd like it to look something like the image fil
Hi all, I'm very new to R and read a few tutorials, however I'm having
difficulty trying to figure out how to plot a minimum spanning tree. I have
a csv file that contains an n-by-n matrix of distances between strains of
bacteria called matrix.csv.
Looks like:
id,strain1, strain2,strain3
strain1
's?
No, I don't think so. Check what is in D, it should be a "square" data
frame containing numbers.
Gabor
> Thanks for your help!
>
> ~josh
>
>
>
>
>> Date: Tue, 7 Apr 2009 20:35:16 +0200
>> Subject: Re: [R] Minimum Spanning Tree
>> Fro
12 matches
Mail list logo