Documentation ¶
Overview ¶
Package dag provides the Directed-Acyclic-Graph (DAG) primitives required by Terramate. The nodes can be added by providing both the descendants and ancestors of each node but only the descendant -> ancestors relationship is kept.
Index ¶
- Constants
- type DAG
- func (d *DAG[V]) AddNode(id ID, value V, descendants, ancestors []ID) error
- func (d *DAG[V]) AncestorsOf(id ID) []ID
- func (d *DAG[V]) HasCycle(id ID) bool
- func (d *DAG[V]) IDs() []ID
- func (d *DAG[V]) Node(id ID) (V, error)
- func (d *DAG[V]) Order() []ID
- func (d *DAG[V]) Reduce(predicate func(id ID) bool)
- func (d *DAG[V]) Validate() (reason string, err error)
- type ID
- type Visited
Constants ¶
const ( ErrDuplicateNode errors.Kind = "duplicate node" ErrNodeNotFound errors.Kind = "node not found" ErrCycleDetected errors.Kind = "cycle detected" )
Errors returned by operations on the DAG.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DAG ¶
type DAG[V any] struct { // contains filtered or unexported fields }
DAG is a Directed-Acyclic Graph
func Transform ¶ added in v0.5.0
Transform transforms a DAG of D's to a DAG of S's by applying the given function to each node. Afterwards, source DAG must be discarded.
func (*DAG[V]) AddNode ¶
AddNode adds a new node to the dag. The lists of descendants and ancestors defines its edge. The value is anything related to the node that needs to be retrieved later when processing the DAG.
func (*DAG[V]) AncestorsOf ¶
AncestorsOf returns the list of ancestor node ids of the given id.
func (*DAG[V]) Order ¶
Order returns the topological order of the DAG. The node ids are lexicographic sorted whenever possible to give a consistent output.