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: Vincent Matossian
Subject: Re: [igraph] edge attributes and delete.edges
Date: Mon, 13 Nov 2006 17:13:49 -0500

Thanks Gabor, the workaround code you sent seems to work ok for a random graph but fails for a barabasi.game with the error

Error in E(g, P = t(get.edgelist(mst))) : At type_indexededgelist.c:935 : Cannot get edge id, no such edge, Invalid value

Also, I am not interested in weight as edge attributes and so do not want the MST to be affected by it. I will think of a way around this...but if you have any idea let me know :)

Thanks again for your input

-
vincent


On 11/13/06, Gabor Csardi <address@hidden> wrote:
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


_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

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