igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] edge attributes and delete.edges


From: Gabor Csardi
Subject: Re: [igraph] edge attributes and delete.edges
Date: Mon, 13 Nov 2006 15:42:21 -0500
User-agent: Mutt/1.5.11

On Mon, Nov 13, 2006 at 03:11:27PM -0500, Vincent Matossian wrote:
> Thanks! I will apply the patch for now.
> 
> I was actually reading those exact lines in type_indexededgelist.c when I
> received your message :)
> 
> I have another question however, minimum.spanning.tree creates a new graph and
> as a result all attributes are lost, is there a quick way to maintain edge
> attributes?

Hmmm. The vertices are preserved, so that is easy. As for the edges, that is
more tricky and for a clear solution the C code should be updated. 
A quick workaround for graphs without multiple edges:

g <- erdos.renyi.game(10, 3/10)
co <- layout.fruchterman.reingold(g)
E(g)$weight <- sample(1:10, ecount(g), repl=T)
plot(g, layout=co, edge.labels=E(g)$weight)

mst <- minimum.spanning.tree(g, weights=E(g)$weight, algorithm="prim")
E(mst)$weight <- NA
E(mst, P=t(get.edgelist(mst)))$weight <- E(g, P=t(get.edgelist(mst)))$weight
x11(); plot(mst, layout=co, edge.labels=E(mst)$weight)

A better solution would be if minimum.spanning.tree simply returned an edge
sequence, at least internally. On the TODO list.

Gabor

> Thanks again for all your help,
> 
> Vincent
> 
> 

-- 
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK




reply via email to

[Prev in Thread] Current Thread [Next in Thread]