From 4d5497b703a3b34e08426e231ace5d9dff2dcfa6 Mon Sep 17 00:00:00 2001 From: Philipp Schlegel Date: Thu, 26 Oct 2023 16:33:38 +0100 Subject: [PATCH] rewire_skeleton: make sure graph is DAG --- navis/graph/graph_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/navis/graph/graph_utils.py b/navis/graph/graph_utils.py index da78797d..b9f2c226 100644 --- a/navis/graph/graph_utils.py +++ b/navis/graph/graph_utils.py @@ -2072,6 +2072,8 @@ def rewire_skeleton(x: 'core.TreeNeuron', if g.is_directed(): g = g.to_undirected() + g = nx.minimum_spanning_tree(g, weight='weight') + if not root: root = x.root[0] if x.root[0] in g.nodes else next(iter(g.nodes))