Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder accumulates nodes and edges, then produces an immutable Graph. Builder is not safe for concurrent use.
func (*Builder) AddEdge ¶
AddEdge registers a directed edge. Returns ErrUnknownNode if either endpoint is not already registered. Returns ErrSelfLoop if From == To.
type FilterOptions ¶
type FilterOptions struct {
// MaxDepth limits traversal depth from root nodes. -1 means unlimited.
MaxDepth int
// IncludePatterns are regular expressions; a node is kept only if its Name
// matches at least one pattern. Empty means keep all.
IncludePatterns []*regexp.Regexp
// ExcludePatterns are regular expressions; a node is removed if its Name
// matches any pattern.
ExcludePatterns []*regexp.Regexp
// NoIndirect removes nodes that are only reachable as indirect dependencies.
NoIndirect bool
}
FilterOptions controls which nodes and edges are included in a filtered graph.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is an immutable view of a dependency graph. All accessor methods return copies so callers cannot mutate internal state.
func Filter ¶
func Filter(g *Graph, opts FilterOptions) (*Graph, error)
Filter returns a new Graph containing only the nodes (and their connecting edges) that satisfy opts. The original graph is not modified.
func (*Graph) Ancestors ¶
Ancestors returns a copy of the slice of node IDs that depend on id (reverse edges).
func (*Graph) Neighbors ¶
Neighbors returns a copy of the slice of node IDs that id directly depends on.
type Node ¶
type Node struct {
ID NodeID
Name string
Version string
Kind NodeKind
Indirect bool
Dev bool
ReplacedBy *Replacement
Metadata map[string]any
}
Node is an immutable value representing a single module in the graph.
type NodeID ¶
type NodeID string
NodeID is the canonical identifier for a node: "<module-path>@<version>". The main module uses an empty version: "example.com/myapp@".
func Descendants ¶
Descendants returns all node IDs reachable from id via forward edges, excluding id itself. Honors maxDepth (-1 = unlimited).
type Replacement ¶
Replacement describes a module that stands in for another.