From 4a7ecfbed85d4203d350dc98502f3423c6484640 Mon Sep 17 00:00:00 2001 From: Bram Schoenmakers Date: Wed, 18 Aug 2021 09:50:57 +0200 Subject: [PATCH] (fix): remove duplicate edges from graphs (#1768) When a node links to the another node twice, two edges appear in the graph. To keep the graph clean, remove all duplicate edges. --- extensions/org-roam-graph.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/org-roam-graph.el b/extensions/org-roam-graph.el index 2d7c454..6b2ded5 100644 --- a/extensions/org-roam-graph.el +++ b/extensions/org-roam-graph.el @@ -207,7 +207,8 @@ WITH RECURSIVE connected_component(source) AS (SELECT dest FROM links_of WHERE source = $s1 UNION SELECT dest FROM links_of JOIN connected_component USING(source)) -SELECT source, dest, type FROM links WHERE source IN connected_component OR dest IN connected_component;" +SELECT DISTINCT source, dest, type FROM links +WHERE source IN connected_component OR dest IN connected_component;" " WITH RECURSIVE links_of(source, dest) AS @@ -224,7 +225,7 @@ WITH RECURSIVE AND json_array_length(cc.trace) < $s2)), nodes(source) as (SELECT DISTINCT source FROM connected_component GROUP BY source ORDER BY min(json_array_length(trace))) -SELECT source, dest, type FROM links WHERE source IN nodes OR dest IN nodes;"))) +SELECT DISTINCT source, dest, type FROM links WHERE source IN nodes OR dest IN nodes;"))) (org-roam-db-query query id distance))) (defun org-roam-graph--dot-option (option &optional wrap-key wrap-val)