dag

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CycleError

type CycleError struct {
	Nodes []int
}

CycleError indicates a cycle was detected in the DAG.

func (*CycleError) Error

func (e *CycleError) Error() string

type DAG

type DAG struct {
	// contains filtered or unexported fields
}

DAG represents a directed acyclic graph of tasks.

func New

func New() *DAG

New creates an empty DAG.

func (*DAG) AddEdge

func (d *DAG) AddEdge(from, to int)

AddEdge adds a dependency: `from` depends on `to`.

func (*DAG) AddNode

func (d *DAG) AddNode(id int)

AddNode adds a node to the graph.

func (*DAG) Tiers

func (d *DAG) Tiers() ([][]int, error)

Tiers returns nodes grouped into execution tiers using Kahn's algorithm. Tier 0 = nodes with no dependencies, Tier N+1 = nodes whose deps are all in tiers <= N. Returns an error if the graph contains a cycle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL