Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find all possible paths between two vertices on a graph #3

Open
titomiguelcosta opened this issue Feb 10, 2016 · 2 comments
Open

Find all possible paths between two vertices on a graph #3

titomiguelcosta opened this issue Feb 10, 2016 · 2 comments

Comments

@titomiguelcosta
Copy link

Is there a way to determine all possible paths between two vertices?

@letournel
Copy link
Owner

letournel commented Feb 10, 2016

Unfortunately, there is currently no out of box solution for this in the library. Feel free to make a contribution in the case you need to implement it ;)

However, i might add that depending on the size and connectivity of the graph, it can become quite slow very quickly. Indeed, to know all the paths between two vertices, we need to check and compute every simple path (no cycle) between them. There can be 2^(n-1) of them in the worst case (ie in a fully connected undirected graph of n vertices) and even more (typically O(n!) I think) if the order of the visited vertices matters (ex: the path cost would be different in a directed graph).

Food for thought :
http://stackoverflow.com/questions/9535819/find-all-paths-between-two-graph-nodes
http://stackoverflow.com/questions/713508/find-the-paths-between-two-given-nodes
http://mathematica.stackexchange.com/questions/25779/finding-all-simple-paths-between-two-vertices-in-a-graph
http://cs.stackexchange.com/questions/423/how-hard-is-counting-the-number-of-simple-paths-between-two-nodes-in-a-directed

Will let the issue open ;)

@titomiguelcosta
Copy link
Author

@letournel thanks for your reply, in the end, I followed this tutorial and implemented using a recursive sql query, something that i wasn't even aware it was possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants