graph

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: AGPL-3.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 Builder

type Builder struct{}

Builder constructs dependency graphs from nodes.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new graph builder.

func (*Builder) Build

func (b *Builder) Build(nodes []domain.Node) (*domain.Graph, error)

Build creates a Graph from a slice of nodes. Returns an error if duplicate node IDs are found.

func (*Builder) BuildDependencyMap

func (b *Builder) BuildDependencyMap(g *domain.Graph) map[string][]string

BuildDependencyMap creates a map of node dependencies. For each node, returns a list of node IDs it depends on (via Refs.Uses). Related refs are NOT considered dependencies.

func (*Builder) BuildReverseIndex

func (b *Builder) BuildReverseIndex(g *domain.Graph) map[string][]string

BuildReverseIndex creates a reverse reference index. For each node, returns a list of node IDs that reference it (via Uses or Related). This is useful for finding all nodes that depend on or are related to a given node.

func (*Builder) DetectCycle

func (b *Builder) DetectCycle(g *domain.Graph) (bool, []string)

DetectCycle checks for circular dependencies in the graph. Returns true and the cycle path if a cycle is found, false and nil otherwise.

func (*Builder) TopologicalSort

func (b *Builder) TopologicalSort(g *domain.Graph) ([]domain.Node, error)

TopologicalSort returns nodes sorted in dependency order. Nodes with no dependencies come first; nodes appear only after all their dependencies. 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