funkelab / spatial_graph

A spatial graph datastructure for python
MIT License
2 stars 0 forks source link

Feature: Get all nodes/edges as numpy array #2

Open cmalinmayor opened 1 month ago

funkey commented 1 month ago

For context, at the moment, Graph.{nodes,{in_,out_,}edges} return generators. Those are slow convenience methods for cases where users do not want to allocate a lot of memory. I am not sure if this use case is common, though.

One option is to always return numpy arrays. That can be a footgun if someone asks for all nodes/edges with data, as this will basically make a copy of everything stored in the graph. Maybe acceptable.

The alternative is to provide separate functions for numpy array access. That'll clutter the interface.

I think I am leaning towards the first option. Opinions?

cmalinmayor commented 1 month ago

I like the default being returning numpy arrays. We can add a generator (for individual nodes or "pages" of nodes) if we find that it is necessary, but I think the numpy array is how we want people to interact with the spatial graph and should be the default.