From 76da978a3ba7aa5cc5c3b4a114fdfdf6dd775688 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 26 Aug 2026 00:42:54 +0100 Subject: Traverse symmetrically in both directions with extract. --- domagi/domagi.py | 12 ++++++++++-- tests/test_domagi.py | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/domagi/domagi.py b/domagi/domagi.py index 6175c08..4d9bb45 100644 --- a/domagi/domagi.py +++ b/domagi/domagi.py @@ -259,10 +259,18 @@ def extract(con, outfile, segment_name, path_range, steps, threads, progress): SELECT id, 0 FROM initial_segment UNION ALL SELECT DISTINCT to_segment, distance+1 FROM cte - INNER JOIN link ON from_segment=id + INNER JOIN ( + -- Eliminate directionality of the link table. We must traverse both + -- to segments leading out of and to segments leading into the + -- current segment. + SELECT from_segment, to_segment FROM link + UNION + SELECT to_segment AS from_segment, from_segment AS to_segment FROM link + ) + ON from_segment=id WHERE distance