igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] calculate edge weight based on node weight


From: Gábor Csárdi
Subject: Re: [igraph] calculate edge weight based on node weight
Date: Thu, 8 May 2014 17:05:51 -0400

No, it won't take a long time. This is in fact the fastest solution, both in practice, and also optimal in terms of time complexity. E.g.

g <- graph.ring(10)
V(g)$w <- 1:10

el <- get.edgelist(g, names=FALSE)
E(g)$w <- V(g)$w[el[,1]] * V(g)$w[el[,2]]
plot(g, edge.label=E(g)$w, vertex.label=V(g)$w)

G.


On Thu, May 8, 2014 at 4:57 PM, Wang, Jing <address@hidden> wrote:
Hi Gabor,

Thank you for your response! Indexing the vertex attributes for each edge will take a long time. Do you have any efficient way to index vertex attributes?

Thanks,
Jing

From: Gábor Csárdi <address@hidden>
Reply-To: Help for igraph users <address@hidden>
Date: Thursday, May 8, 2014 at 3:52 PM
To: Help for igraph users <address@hidden>
Subject: Re: [igraph] calculate edge weight based on node weight

Use get.edgelist() and then index your vertex attributes with the two columns it returns. Kinda hacky, but igraph does not really have a good language/syntax for manipulating attributes.

Gabor


On Thu, May 8, 2014 at 4:46 PM, Wang, Jing <address@hidden> wrote:
Dear Sir/Madam,

If I have the node weights for a network and want to calculate the edge weights based on the weights of two nodes in each edge, how can I calculate it?

Thanks,

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



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



reply via email to

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