Ive got a directed igraph:
library( igraph )
links <- data.frame( from = c(1,1, 2,2,3, 3,3,4,6,7,7, 8),
to = c(2,10,3,4,12,4,8,5,7,3,11,9) )
nodes <- data.frame( name = 1:12 )
net <- graph_from_data_frame( d = links, vertices = nodes, directed = TRUE )
plot(net)
What i want is:
- get a subset of the graph, of all nodes that are within one step of node 3 (in and out)
- get a list of all paths in the subset, that go through node 3
For step 1, I can do:
ego.list <- make_ego_graph( net, order = 1, nodes = 3, mode = "all")
desired_subset <- NULL
for (i in seq_along(ego.list) ){
x <- ego.list[[i]]
desired_subset <- graph.union( desired_subset, x )
}
plot(desired_subset)
But now I'm stuck.. What i want, is to find all paths in the entire (directed) subset, that go through node 3, so:
- 2->3->12
- 2->3->4
- 2->3->8
- 7->3->12
- 7->3->4
- 7->3->8
All I've found so far is to get a list of paths from one node to another node. But I want to get a list of all paths through a certain node.
Any ideas?