I have the following code for finding all the paths between two nodes ( 1 and 5) in the graph.
pxy= all_simple_paths(graph,1,5) #get all paths between node 1 and 5
It gives me all the paths between nodes, but it is computationally too expensive. If there is a large graph with thousands of nodes and edges, it will take hours or more than hours for just finding paths between two nodes. I have a thousands of pair of nodes for which I will find all simple paths of specified length (i.e., length 2, length 3, length 4 etc.). The following code satisfying me in finding all the simple path of specified length, but it is too expensive. Anyone help me.
L=2 #set length
for (i in 1:length(pxy)){
plist = as.vector(pxy[[i]]) #check every path one by one
if(length(plist)==L){ #find path of specified length
print(plist) #display path
}
}