From da8481c1aaa7f1ec356e179f033cdb94437a5977 Mon Sep 17 00:00:00 2001 From: skudasov Date: Thu, 14 May 2026 13:36:44 +0200 Subject: [PATCH] fix --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4183968..0c448f5 100644 --- a/main.go +++ b/main.go @@ -238,8 +238,8 @@ func (s *state) transitiveReduction() { s.deps[m] = slices.DeleteFunc(deps, func(d string) bool { // BFS for indirect paths to d, tracking nodes we touch along the way var touched []string - // visited guards against cycles in the graph - visited := make(map[string]struct{}) + // visited prevents BFS from looping on cycles; pre-marking m blocks paths like m→…→m→d from counting as indirect + visited := map[string]struct{}{m: {}} children := slices.DeleteFunc(slices.Clone(deps), func(s string) bool { return s == d }) // exclude direct for len(children) > 0 { var next []string