in reply to Finding All Paths From a Graph From a Given Source and End Node

neversaint,
I noticed you asked a graph question the other day too. If they are related, then perhaps it might be useful for you to explain the bigger picture. There are a few monks I lean on heavily whenever I have a graph question. Using Graph or some other high level abstraction model is usually faster for the programmer to write - but can end up being terribly slow runtime.

If you only wanted the shortest path between the two end points (assuming cyclical path avoidance), I would go with modified Bidirectional search which I discovered in A Better Word Morph Builder. To find all paths I might go with a self-pruning Depth-first search. This is still a brute force search but you pay attention to which paths are invalid and do not descend into them when reaching the node from a different path.

If you need example code beyond the explanation above, let me know but it won't happen until tonight.

Cheers - L~R

  • Comment on Re: Finding All Paths From a Graph From a Given Source and End Node