Skip to content

Commit

Permalink
perf: switch source and target for dijkstra
Browse files Browse the repository at this point in the history
When exploring from the root, the tendency will be to
explore around all the zero weighted previously traced paths
whereas if you start from the target, you'll locally explore
(which we had to do anyway) and the soon as you find a zero
weighted path you accelerate towards the root.
  • Loading branch information
william-silversmith committed Mar 9, 2020
1 parent ee1f0c9 commit 4dccd3b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kimimaro/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ def compute_paths(
target = kimimaro.skeletontricks.find_target(labels, DAF)

if fix_branching:
path = dijkstra3d.dijkstra(parents, root, target, bidirectional=soma_mode)
# faster to trace from target to root than root to target
# because that way local exploration finds any zero weighted path
# and finishes vs exploring from the neighborhood of the entire zero
# weighted path
path = dijkstra3d.dijkstra(parents, target, root, bidirectional=soma_mode)
else:
path = dijkstra3d.path_from_parents(parents, target)

Expand Down

0 comments on commit 4dccd3b

Please sign in to comment.