<p>These implementations use some form of the Dijkstra algorithm which is implemented in the open source networkx python lib <a href="https://networkx.github.io/documentation/stable/reference/algorithms/shortest_paths.html" rel="nofollow noreferrer">https://networkx.github.io/documentation/stable/reference/algorithms/shortest_paths.html</a> also electrum wallet is working on lightning. I think they followed pretty much the lnd code base so one could check their pathfing implementation at <a href="https://github.com/spesmilo/electrum/blob/master/electrum/lnrouter.py" rel="nofollow noreferrer">https://github.com/spesmilo/electrum/blob/master/electrum/lnrouter.py</a></p>

CC BY-SA 4.0
2019-10-03T12:00:33.223Z
Thank you for the great reply! The default networkX algorithms won't do because the Lightning algorithms require self defined and dynamic weights which is not supported by the library. The electrum routing is definitely helpful since the function lnrouter.py does exactly what I was looking for. However, Electrum is an entire client and it will be very tricky to isolate just the function that I want to use but it is definitely worth trying. Thanks again!
George 
CC BY-SA 4.0
2019-10-03T09:11:56.743Z
2019-10-03T09:11:56.743Z
Rene Pickhardt
<p>The most common Lightning nodes use <code>GO</code>, <code>C</code> or <code>Scala</code> for their implementation. Is there any publicly available <code>Python</code> implementation for the <code>path finding algorithm</code> any of the most known clients use (<code>LND</code>, <code>C-Lightning</code>, <code>Eclair</code>)?</p>

<lightning-network><python><implementation>
Python implementation for LND path finding algorithm
George 
# Python implementation for LND path finding algorithm

(Asked by: username_0 on 2019-10-03)

The most common Lightning nodes use `GO`, `C` or `Scala` for their implementation. Is there any publicly available `Python` implementation for the `path finding algorithm` any of the most known clients use (`LND`, `C-Lightning`, `Eclair`)?

**Tags:** lightning-network, python, implementation


---

## 1 answers

### Answer by username_1 on 2019-10-03. Score: 2 | Accepted answer

These implementations use some form of the Dijkstra algorithm which is implemented in the open source networkx python lib <https://networkx.github.io/documentation/stable/reference/algorithms/shortest_paths.html> also electrum wallet is working on lightning. I think they followed pretty much the lnd code base so one could check their pathfing implementation at <https://github.com/spesmilo/electrum/blob/master/electrum/lnrouter.py>

> **Comments:**
> **username_0**: Thank you for the great reply! The default networkX algorithms won't do because the Lightning algorithms require self defined and dynamic weights which is not supported by the library. The electrum routing is definitely helpful since the function lnrouter.py does exactly what I was looking for. However, Electrum is an entire client and it will be very tricky to isolate just the function that I want to use but it is definitely worth trying. Thanks again!  

---

