Skip to content

~/labs/dagx

dagx

A minimal, deterministic DAG library with topological sorting.

A lightweight, zero-dependency directed acyclic graph (DAG) library for Go.

Made for task scheduling and dependency resolution, build order, data pipelines, workflow engines and package dependency management.

Install

go get github.com/oshturhq/dagx

Features

  • A simple, small API
  • Zero external dependencies
  • Cycle detection
  • Topological sorting with Kahn's algorithm
  • Parent and child traversal, and in-degree calculation
  • JSON-serializable Node and Edge types

Example

dag := dagx.NewDAG()

// Add edges (A -> B -> C)
dag.AddEdge("A", "B")
dag.AddEdge("B", "C")

order, err := dag.TopologicalOrder()
fmt.Println(order) // Output: [A B C]