Skip to content

Commit

Permalink
Move merge_nodes to avoid circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
e-koch committed Aug 15, 2024
1 parent 828d3c9 commit 91d6cda
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
21 changes: 19 additions & 2 deletions fil_finder/length.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Licensed under an MIT open source license - see LICENSE

from .utilities import *
from .pixel_ident import *


import numpy as np
import scipy.ndimage as nd
Expand Down Expand Up @@ -790,3 +788,22 @@ def main_length(max_path, edge_list, labelisofil, interpts, branch_lengths,
p.clf()

return main_lengths, longpath_arrays


def merge_nodes(node, G):
'''
Combine a node into its neighbors.
'''

neigb = list(G[node])

if len(neigb) != 2:
return G

new_weight = G[node][neigb[0]]['weight'] + \
G[node][neigb[1]]['weight']

G.remove_node(node)
G.add_edge(neigb[0], neigb[1], weight=new_weight)

return G
19 changes: 0 additions & 19 deletions fil_finder/pixel_ident.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,22 +862,3 @@ def is_tpoint(vallist):
return True

return False


def merge_nodes(node, G):
'''
Combine a node into its neighbors.
'''

neigb = list(G[node])

if len(neigb) != 2:
return G

new_weight = G[node][neigb[0]]['weight'] + \
G[node][neigb[1]]['weight']

G.remove_node(node)
G.add_edge(neigb[0], neigb[1], weight=new_weight)

return G

0 comments on commit 91d6cda

Please sign in to comment.