graph

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package graph is the pure, kind-agnostic dependsOn DAG: no Kubernetes, no I/O. It derives strongly connected components (cycles), transitive ancestors, and unknown (dangling) edge targets from a flat edge map of adapter.NodeRef.

Index

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 is the derived dependsOn graph. It is immutable after Build except for the TransitiveAncestors memoization cache, which is safe for concurrent use.

func Build

func Build(nodes map[adapter.NodeRef][]adapter.NodeRef) *Graph

Build constructs the DAG from nodes and their dependsOn edges. Edges to refs absent from nodes are auto-registered as external nodes (retrievable via Unknown()); the caller decides their semantics. Build never fails: cycles are reported, not errors.

func (*Graph) Cycles

func (g *Graph) Cycles() [][]adapter.NodeRef

Cycles returns the strongly connected components with len > 1 (plus self-loops). Each member list is sorted by String(); the outer list is sorted by its first member.

func (*Graph) DependsOn

func (g *Graph) DependsOn(ref adapter.NodeRef) []adapter.NodeRef

DependsOn returns ref's direct dependencies, deduplicated and sorted by String(). It returns nil for a ref unknown to the graph.

func (*Graph) InCycle

func (g *Graph) InCycle(ref adapter.NodeRef) bool

InCycle reports whether ref belongs to, or transitively depends on, a cycle.

func (*Graph) Nodes

func (g *Graph) Nodes() iter.Seq[adapter.NodeRef]

Nodes returns every node known to the graph (both supplied and external), in deterministic (String()-sorted) order.

func (*Graph) TransitiveAncestors

func (g *Graph) TransitiveAncestors(ref adapter.NodeRef) []adapter.NodeRef

TransitiveAncestors returns every ancestor reachable via dependsOn (memoized), deduplicated and sorted by String().

func (*Graph) Unknown

func (g *Graph) Unknown() []adapter.NodeRef

Unknown returns refs that appear only as edge targets (not supplied as nodes), sorted by String().

Jump to

Keyboard shortcuts

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