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

Shortest paths: prevent producing loops and remove some duplicated work #1747

Merged
merged 5 commits into from
Mar 31, 2021

Conversation

thomash-acinq
Copy link
Member

Several improvements to yenKshortestPaths:

  • Run yenKshortestPaths backwards like what is already done in dijkstraShortestPath. It allows to compute the correct weights directly.
  • Prevent producing loops by excluding the root path nodes
  • Do not run dijkstraShortestPath several times on the same input by only computing spur paths for new edges. shortestPaths(k) often has a lot of overlap with the previous shortestPaths so a lot of the poential spur nodes were already considered.

Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!
I'll run some tests on a real-world graph.

@codecov-io
Copy link

Codecov Report

Merging #1747 (0998e47) into master (e5429eb) will decrease coverage by 0.19%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1747      +/-   ##
==========================================
- Coverage   86.67%   86.47%   -0.20%     
==========================================
  Files         154      154              
  Lines       11996    12004       +8     
  Branches      516      528      +12     
==========================================
- Hits        10397    10381      -16     
- Misses       1599     1623      +24     
Impacted Files Coverage Δ
.../src/main/scala/fr/acinq/eclair/router/Graph.scala 98.15% <100.00%> (-0.63%) ⬇️
...c/main/scala/fr/acinq/eclair/channel/Channel.scala 86.60% <0.00%> (-1.75%) ⬇️
...cala/fr/acinq/eclair/payment/relay/NodeRelay.scala 94.02% <0.00%> (-1.46%) ⬇️
...cala/fr/acinq/eclair/crypto/TransportHandler.scala 90.21% <0.00%> (-0.55%) ⬇️
...la/fr/acinq/eclair/payment/relay/NodeRelayer.scala 100.00% <0.00%> (ø)
...-core/src/main/scala/fr/acinq/eclair/io/Peer.scala 89.89% <0.00%> (+0.05%) ⬆️
...r/acinq/eclair/payment/send/PaymentInitiator.scala 96.62% <0.00%> (+0.11%) ⬆️
...ir-core/src/main/scala/fr/acinq/eclair/Setup.scala 71.13% <0.00%> (+0.30%) ⬆️
...nq/eclair/blockchain/electrum/ElectrumClient.scala 73.89% <0.00%> (+0.36%) ⬆️
... and 1 more

Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@t-bast t-bast merged commit 75cb777 into master Mar 31, 2021
@thomash-acinq thomash-acinq deleted the shortest-path branch September 9, 2021 13:50
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

Successfully merging this pull request may close these issues.

3 participants