MATLAB: How can i get all paths between two nodes ?
all paths between two nodesgraph theory
How can i get all paths between two nodes
Best Answer
If you're looking for the shortest paths, there are a few FEX entries that implement algorithms for this, including both depth-first and breadth-first searches. I usematlab_bgl, which includes several shortest path algorithms.
However, if you're really looking forall paths between two nodes, I found that algorithms for that are more scarce. I wrotepathbetweennodes.m to do just that... I wrote it for fairly small graphs (~50 nodes or fewer), so I'm not sure how efficient it might be for larger graphs, but it has worked well for my purposes.
Because you do not have a static node for source and destination, we are free to say that the shortest path is the single edge of minimum weight -- you have not, for example, said that the shortest path must be (say) length 3.
Best Answer