igraph-help
[Top][All Lists]

## Re: [igraph] find weights along all paths between two vertices

 From: Gábor Csárdi Subject: Re: [igraph] find weights along all paths between two vertices Date: Sat, 7 Dec 2013 19:47:41 -0500

```Hi Sofia,

http://lists.gnu.org/archive/html/igraph-help/2011-12/msg00014.html
https://github.com/igraph/igraph/issues/356

Best,
Gabor

On Sun, Dec 1, 2013 at 5:52 PM, Ana Sofia Morais
> Dear all,
>
>
>
> I need to calculate the sum of the weights along all paths from each of
> n-1vertices to a target vertex in a graph.
>
>
>
> Example:
>
>
>
> mat=matrix(c(rep(0,6),3,0,2,rep(0,3),4,rep(0,2),2,rep(0,6),rep(1,2),rep(0,2),3,rep(0,9)),byrow=T,ncol=6)
>
> graph = graph.adjacency(mat, mode="directed", weighted=TRUE)#do graph
>
> plot.igraph(graph,edge.label=E(graph)\$weight)
>
>
>
> Assuming that vertex 1 is the target, the sum of the weights (sw) along the
> paths from every other vertex in the graph should be:
>
>
>
> swV2 = 3+2+4
>
> swV3 = 4
>
> swV4 = 1+3+4
>
> swV5 = 3+4
>
> swV6 = 0
>
>
>
> Note that, in identifying all paths from a vertex to the target, only paths
> have been considered in which a vertex is traversed only once along the same
> path. This applies to vertex 5, for instance, where the sum of weights
> disregards the weights present in the cycle with vertices 3 and 4.
>
>
>
> I would appreciate any advice about how this could be achieved. Thanks in
>
>
>
> Sofia
>
>
>
>
> _______________________________________________
> igraph-help mailing list