Documentation
¶
Overview ¶
Package dag provides directed acyclic graph operations for model dependencies. It supports cycle detection, topological sorting, and incremental change detection.
Index ¶
- type Graph
- func (g *Graph) AddEdge(parentID, childID string) error
- func (g *Graph) AddNode(id string, data interface{})
- func (g *Graph) Clear()
- func (g *Graph) EdgeCount() int
- func (g *Graph) GetAffectedNodes(changedIDs []string) []string
- func (g *Graph) GetAllNodes() []*Node
- func (g *Graph) GetChildren(id string) []string
- func (g *Graph) GetExecutionLevels() ([][]string, error)
- func (g *Graph) GetLeaves() []string
- func (g *Graph) GetNode(id string) (*Node, bool)
- func (g *Graph) GetParents(id string) []string
- func (g *Graph) GetRoots() []string
- func (g *Graph) GetUpstreamNodes(id string) []string
- func (g *Graph) HasCycle() (bool, []string)
- func (g *Graph) NodeCount() int
- func (g *Graph) Subgraph(nodeIDs []string) *Graph
- func (g *Graph) TopologicalSort() ([]*Node, error)
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents a directed acyclic graph.
func (*Graph) AddEdge ¶
AddEdge adds a directed edge from parent to child (child depends on parent).
func (*Graph) GetAffectedNodes ¶
GetAffectedNodes returns all nodes affected by changes to the given nodes. This includes the changed nodes and all their downstream dependents.
func (*Graph) GetAllNodes ¶
GetAllNodes returns all nodes in the graph.
func (*Graph) GetChildren ¶
GetChildren returns the children (dependents) of a node.
func (*Graph) GetExecutionLevels ¶
GetExecutionLevels returns nodes grouped by execution level. Nodes at level N can be executed in parallel after level N-1 completes. Level 0 contains nodes with no dependencies.
func (*Graph) GetParents ¶
GetParents returns the parents (dependencies) of a node.
func (*Graph) GetUpstreamNodes ¶
GetUpstreamNodes returns all nodes upstream of the given node (its dependencies and their dependencies).
func (*Graph) HasCycle ¶
HasCycle returns true if the graph contains a cycle, along with the cycle path.
func (*Graph) Subgraph ¶
Subgraph returns a new graph containing only the specified nodes and their edges.
func (*Graph) TopologicalSort ¶
TopologicalSort returns nodes in topological order (dependencies before dependents). Returns an error if the graph contains a cycle.