| 1 | // Copyright 2026 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Package graph provides a common abstraction for directed graphs and standard |
| 6 | // graph algorithms. |
| 7 | // |
| 8 | // In general, this package does not provide or assume any concrete graph |
| 9 | // representation. It's up to the caller of this package to implement the |
| 10 | // [Graph] interface, either directly or as an adapter around another type. |
| 11 | package graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/ |
| 12 | |
| 13 | import "iterscip-go gomod github.com/golang/go/src go1.25.0 iter/" |
| 14 | |
| 15 | // A Graph implements a directed graph where nodes in the graph are identified |
| 16 | // by the NodeID type. |
| 17 | // |
| 18 | // If a concrete graph type stores additional information about nodes and/or |
| 19 | // edges, it will conventionally provide methods of the form: |
| 20 | // |
| 21 | // Node(node NodeID) nodeInfo |
| 22 | // Edge(from, to NodeID) edgeInfo |
| 23 | type Graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#[NodeID comparable] interface { |
| 24 | // Nodes yields all nodes in this graph. |
| 25 | Nodesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#Nodes.() iterscip-go gomod github.com/golang/go/src go1.25.0 iter/.Seqscip-go gomod github.com/golang/go/src go1.25.0 iter/Seq#[NodeID] |
| 26 | |
| 27 | // NumNodes returns the total number of nodes in this graph. |
| 28 | NumNodesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#NumNodes.() int |
| 29 | |
| 30 | // Out yields the out-edges of node. Out must be deterministic, though |
| 31 | // otherwise there is no constraint on the order of the returned sequence. |
| 32 | Outscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Graph#Out.(node NodeID) iterscip-go gomod github.com/golang/go/src go1.25.0 iter/.Seqscip-go gomod github.com/golang/go/src go1.25.0 iter/Seq#[NodeID] |
| 33 | } |