Select edges and nodes between nodes with certain distance

hi gays, does anybody knows how to select nodes and edges between two nodes with certian distance, not really the shortest path or longest path.

for example:
1: (node1 to node3 from this path) node1 --> node2 --> node3
2: (node1 to node 3 from this path) node1 --> node3
3: (node1 to node3 from this path) node1 --> node2 --> node4 --> node3

all those paths can lead node1 to node3 but I only want the the first one, which is not the shortest or longest path.

anybody known how to do this in R package igraph?

You can all the all_simple_paths function to get all paths, then group them by length.

thanks, that’s really helpfull