graph

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	Name string
	Deps []string
}

Edge describes one process in the dependency graph.

type Graph

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

func New

func New(edges []Edge) *Graph

func (*Graph) Len

func (g *Graph) Len() int

Len returns the number of nodes in the graph.

func (*Graph) Node

func (g *Graph) Node(name string) *Node

Node returns the graph node for the given name, or nil.

func (*Graph) StartLevels

func (g *Graph) StartLevels() [][]string

StartLevels returns the graph partitioned into levels for ordered startup. Level 0 contains processes with no dependencies — start these first. Each subsequent level can be started after all previous levels are running. Processes within the same level can be started concurrently.

func (*Graph) StopLevels

func (g *Graph) StopLevels() [][]string

StopLevels returns the graph partitioned into levels for ordered shutdown. Level 0 contains processes with no dependents — stop these first. Each subsequent level can be stopped after all previous levels finish. Processes within the same level can be stopped concurrently.

func (*Graph) WalkDependents

func (g *Graph) WalkDependents(start string, fn func(name string) bool)

WalkDependents does a BFS from start following DepsBy edges (forward through the graph: start → dependents → transitive dependents). fn receives each node name. Return false from fn to stop walking deeper from that node.

type Node

type Node struct {
	Name   string
	Deps   []string
	DepsBy []string
}

Jump to

Keyboard shortcuts

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