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

Limit max path length for Yens path finding algorithm #334

Open
lvijnck opened this issue Oct 25, 2024 · 4 comments
Open

Limit max path length for Yens path finding algorithm #334

lvijnck opened this issue Oct 25, 2024 · 4 comments
Labels
feature request A suggestion for a new feature

Comments

@lvijnck
Copy link

lvijnck commented Oct 25, 2024

Is your feature request related to a problem? Please describe.

Yes, we're aiming to compute x shortest paths in a huge graph. Yens' algorithm seems to run quite long for our use-case and produces paths that are "too long" in certain cases too.

Describe the solution you would like

It would be nice to be able to cap the max length of the algorithm, and not return any paths if the shortest path exceeds more than x hops.

Describe alternatives you have considered

Neo4Js ExpandConfig statement, but this crashes our Neo4J instance.

@lvijnck lvijnck added the feature request A suggestion for a new feature label Oct 25, 2024
@lvijnck lvijnck changed the title Limit path depth for Yens path finding algorithm Limit max path length for Yens path finding algorithm Oct 25, 2024
@IoannisPanagiotas
Copy link
Contributor

IoannisPanagiotas commented Oct 28, 2024

Hi @lvijnck,

We will have a look at your request, but I am not sure if we will be able on it directly unfortunately due to other tasks having higher priority currently.

Might I ask the value of concurrency that you are running the algorithm with and the lengths of the found paths?

If the paths are sufficiently large, allocating more cores could potentially help as the work in spur nodes is divided among cores.

Best regards,
Ioannis.

@lvijnck
Copy link
Author

lvijnck commented Oct 28, 2024

Hi @IoannisPanagiotas,

Let's say the max. path length I want to consider is 3, then finding paths of length 5 takes waaay to long due to graph size (5+M nodes and 20+M edges).

We're currently running concurrency 4 due to Neo4J licensing

@IoannisPanagiotas
Copy link
Contributor

Hi again @lvijnck ,

Thank you for your input! As I said we will put it on the backlog, but I cannot guarantee yet when or whether it will be picked up.

Since 3 is relatively small, have you tried tackling it with cypher? I would look into this document for suggestions, namely the quantified patterns section, or shortest.

Best,
Ioannis.

@IoannisPanagiotas
Copy link
Contributor

IoannisPanagiotas commented Oct 29, 2024

Also, perhaps you could try some some heuristics, if you can think about pre-processing your graph and replacing the weight of all edges, as follows:
for edge e with weight w, replace w with w + LARGE_VALUE where LARGE_VALUE is a sufficient large value such that
any path with length 5 ends up having a worst cost than any path with length 3.

Of course this has the effect that it will probably find all length-1 paths first, then all length-2, then all length-3, so you might need a larger k. But for each fixed length, the discovered paths should be ordered from best to worst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A suggestion for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants