From a5d4b72b439b0df6eb75e865167963287e15ad23 Mon Sep 17 00:00:00 2001 From: Philipp Schlegel Date: Tue, 9 Jan 2024 18:23:54 +0000 Subject: [PATCH] fix geodesic_matrix when using networkx over igraph --- navis/graph/graph_utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/navis/graph/graph_utils.py b/navis/graph/graph_utils.py index b9f2c226..6cff299b 100644 --- a/navis/graph/graph_utils.py +++ b/navis/graph/graph_utils.py @@ -682,6 +682,10 @@ def geodesic_matrix(x: 'core.NeuronObject', indices = None ix = nodeList + # For some reason csgrpah.dijkstra expects indices/indptr as int32 + # igraph seems to do that by default but networkx uses int64 for indices + m.indptr = m.indptr.astype('int32', copy=False) + m.indices = m.indices.astype('int32', copy=False) dmat = csgraph.dijkstra(m, directed=directed, indices=indices,