I've done some profiling which led to these changes.
avoiding re-creation of adjacency and re-sorting already sorting arrays in _sparse_to_arrays - cuts time to about half
faster _reorder_adjtable_by_ids (no apply) (10x faster than original)
_validate_sparse_input is removed as it is not used anywhere
We still do sorting multiple times in many places but if I short-circuit that, we hit #687 and issues with sparse round tripping. The final sorting either needs to happen in __init__ as now or would need to happen in .sparse. Keeping it in the constructor is probably better idea as we know that a Graph is always correct as is.
I've done some profiling which led to these changes.
_sparse_to_arrays
- cuts time to about half_reorder_adjtable_by_ids
(no apply) (10x faster than original)_validate_sparse_input
is removed as it is not used anywhereWe still do sorting multiple times in many places but if I short-circuit that, we hit #687 and issues with sparse round tripping. The final sorting either needs to happen in
__init__
as now or would need to happen in.sparse
. Keeping it in the constructor is probably better idea as we know that a Graph is always correct as is.