Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading