|
From: | Ana Sofia Morais |
Subject: | [igraph] find weights along all paths between two vertices |
Date: | Sun, 1 Dec 2013 23:52:14 +0100 |
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 advance, Sofia |
[Prev in Thread] | Current Thread | [Next in Thread] |