graph

package
v0.1.56 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package graph contains small reusable graph primitives used by Boxy domain models that need explicit dependency traversal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAG

type DAG[N comparable] struct {
	// contains filtered or unexported fields
}

DAG is a directed acyclic graph with generic node identifiers.

func New

func New[N comparable]() *DAG[N]

func (*DAG[N]) Add

func (g *DAG[N]) Add(node N)

func (*DAG[N]) AddEdge

func (g *DAG[N]) AddEdge(parent, child N) error

AddEdge adds parent -> child and rejects an edge that would create a cycle.

func (*DAG[N]) Ancestors

func (g *DAG[N]) Ancestors(node N) ([]N, error)

Ancestors returns every transitive parent of node once.

func (*DAG[N]) Parents

func (g *DAG[N]) Parents(node N) []N

Parents returns the direct parents of node. The returned slice is a copy; callers that need stable presentation ordering should sort their node type.

Jump to

Keyboard shortcuts

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