igraph-help
[Top][All Lists]
Advanced

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

[igraph] find all paths from multiple sources


From: Morais, Ana Sofia
Subject: [igraph] find all paths from multiple sources
Date: Thu, 8 Dec 2011 18:41:05 +0100

Dear all,

 

I have a question on how to find all paths from multiple source-vertices to a particular destination-vertex in a graph.

 

As an example, please consider the following graph.

 

  > mat <- matrix(c(0,0,0,0,0,2,0,4,2,0,0,0,0,5,3,3,0,0,0,5,0,0,0,0,0), 5, byrow = T)

  > g = graph.adjacency(mat, mode="directed", weighted=TRUE)

  > plot(g, edge.label=E(g)$weight)

 

For each source-vertex 2:5 in graph g:

 

a. Find all paths to the destination-vertex 1 and

b. calculate the sum of the weights of all (non-redundant) arcs in those paths, divided by the total number of (non-redundant) arcs in the paths.

 

Results for the graph above:

 

Vertex 2

a.

  2->1

  2->3->4->1

  2->4->1

b. 

  (2+4+5+3+2)/5

 

Vertex 3

a.

  3->4->1

b.

  (5+3)/2

 

Vertex 4

a.

  4->1

b.

  3

 

Vertex 5

a.

  no path to vertex 1

b.

  0

 

Is there a function in Igraph that I could use to achieve this? Thank you for your time.

 

Best wishes,

 

Sofia


reply via email to

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