navis-org / fastcore

[WIP] Fast core functions for navis re-implemented in Cython.
GNU General Public License v3.0
1 stars 2 forks source link

DAG traversal #4

Open schlegelp opened 3 years ago

schlegelp commented 3 years ago

Skeletons being directed acyclic graphs (DAGs) opens up some neat options for graph traversal that would not work on general graphs. We can leverage that to speed up certain operations. Off the top of my head:

schlegelp commented 10 months ago
ceesem commented 3 months ago

Fast DAG-assuming implementations that are drop in replacements for spicy.sparse.csgraph functions (dijkstra, connected components) would be particularly awesome...

schlegelp commented 3 months ago

I have since restarted re-implementing the fastcore functions in Rust (nice build system + the potential for R bindings): https://github.com/schlegelp/fastcore-rs

That library is more mature and importantly already on PyPI with pre-compiled binaries:

pip install navis-fastcore

As mentioned on Slack: it's called navis-fastcore but the only dependency is numpy.

The functions you were looking for already exist:

Both functions are ~ on par with the csgraph pendants in terms of functionality but not exactly drop-in replacements. Nothing a small wrapper can't fix though - happy to discuss adding a navis_fastcore.csgraph module that exactly mimics the csgraph interface.

Let me know how this works for you! I'm also still looking for other operation that may benefit from this approach - just in case you have more suggestions.

schlegelp commented 3 months ago

I just quickly cobbled something together: https://github.com/schlegelp/fastcore-rs/blob/main/navis_fastcore/wrappers/csgraph.py

So far this lives only on Github but with it you could do this:

try:
   from navis_fastcore.wrappers.csgraph import dijkstra
except ImportError:
   from scipy.sparse.csgraph import dijkstra

Have a look at the functions and let me know what you think.