Update go version

This commit is contained in:
dwrz
2026-08-21 10:23:37 +00:00
parent 78248a6145
commit c2e2d9ea02
466 changed files with 67766 additions and 2881 deletions

View File

@@ -0,0 +1,23 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package graph
// Reachable returns the set of nodes reachable from the given roots.
func Reachable[NodeID comparable](g Graph[NodeID], roots ...NodeID) map[NodeID]bool {
seen := make(map[NodeID]bool)
var visit func(node NodeID)
visit = func(node NodeID) {
if !seen[node] {
seen[node] = true
for e := range g.Out(node) {
visit(e)
}
}
}
for _, root := range roots {
visit(root)
}
return seen
}