igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] adding weights on edges


From: Laís Mozzaquattro
Subject: Re: [igraph] adding weights on edges
Date: Thu, 10 Oct 2013 12:27:53 -0300

I'm having a problem with calculating the shortest.path of a graph. 

dist.contra.fluxo<-shortest.paths(forqueta.ligeiro.contra.fluxo,v=V(forqueta.ligeiro.contra.fluxo), to=V(forqueta.ligeiro.contra.fluxo), mode='out')

The error that I'm getting is:
 Erro em shortest.paths(forqueta.ligeiro.dire.fluxo, v = V(forqueta.ligeiro.dire.fluxo),  : 
  At structural_properties.c:5011 : Weight vector length does not match, Invalid value

But I have checked the lenght of my edge sequence and weight vector, and both are 15. 

> length(E(forqueta.ligeiro.contra.fluxo))
[1] 15
> length(E(forqueta.ligeiro.contra.fluxo)$weights)
[1] 15

Where should be the problem?
Thank you.


Laís Bohrer Mozzaquattro
Bacharel em Ciências Biológicas, ênfase em Gestão Ambiental Marinha e Costeira
Mestranda em Ecologia - UFRGS


2013/10/9 Laís Mozzaquattro <address@hidden>
Thank you very much!

Laís Bohrer Mozzaquattro
Bacharel em Ciências Biológicas, ênfase em Gestão Ambiental Marinha e Costeira
Mestranda em Ecologia - UFRGS


2013/10/9 Gábor Csárdi <address@hidden>
Hi, e.g.

E(forqueta.ligeiro)$weight <- rowSums(custos, na.rm=TRUE)

or you can create the graph with edge weight in the first place, from a data frame, using graph.data.frame(). See

?"igraph-package"
?graph.data.frame
?set.edge.attribute
?E

for details.

Gabor




On Wed, Oct 9, 2013 at 2:22 PM, Laís Mozzaquattro <address@hidden> wrote:
I'm new in igraph and R and i'm having some trouble to add weights is edges on a graph that I created. The only way that I found to do it is by adding it one by one, like this:

forqueta.ligeiro[1,2,attr="weight"]<-sum(custos[1,],na.rm=T)
forqueta.ligeiro[2,3,attr="weight"]<-sum(custos[2,],na.rm=T)
forqueta.ligeiro[3,4,attr="weight"]<-sum(custos[3,],na.rm=T)

and so on...

My problem is that I have a big graph, with at least 90 edges, and I want to know if there's a more automatic way to do it, like inserting a vector with all my weight on the edges of a graph.

Thank you!

Laís Bohrer Mozzaquattro


_______________________________________________
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]