Skip to content

Commit

Permalink
StableTopologicalSort: don't eagerly sort queue
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Johnson <[email protected]>
  • Loading branch information
jonjohnsonjr committed Jun 5, 2023
1 parent c0f5621 commit 1f49f8f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ func StableTopologicalSort[K comparable, T any](g Graph[K, T], less func(K, K) b

if len(predecessors) == 0 {
queue = append(queue, vertex)

sort.Slice(queue, func(i, j int) bool {
return less(queue[i], queue[j])
})
}
}

sort.Slice(queue, func(i, j int) bool {
return less(queue[i], queue[j])
})
}

gOrder, err := g.Order()
Expand Down

0 comments on commit 1f49f8f

Please sign in to comment.