I have an igraph network that contains two types of nodes, one set that describes my points/nodes of interest (NOI) and another set that act as barriers (B) in my network. Now I'd like to measure the total length of all edges that are connected starting from a specific NOI until a barrier is approached.
Here a short example using a ring-shape in igraph:
set.seed(123)
g <- make_ring(10) %>%
set_edge_attr("weight", value = rnorm(10,100,20))%>%
set_vertex_attr("barrier", value = c(0,0,1,0,0,1,0,0,1,0))%>%
set_vertex_attr("color", value = c("green","green","red",
"green","green","red",
"green","green","red","green"))
For example when starting from my node 1 (NOI, green) all edges until the nodes 9 and 3 are reachable (the nodes 9 and 3 are barriers B and block). Thus the total connected length of edges for NOI 1 is the sum of the lengths/weights of edges 1--2,2--3,1--10 and 10--9. The same value is true for node 10 as starting node. I the end I am interested in a list/dataframe of all NOI and their total length of reachable network. How to best proceed in R using igraph? Is there a built-in function in igraph?
