graph

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package graph builds and analyzes task dependency graphs.

It detects cycles, computes upstream/downstream relationships, and generates visualization output in ASCII, Mermaid, and Graphviz formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASCIIFormatter

type ASCIIFormatter struct {
	FormatID              func(id string) string
	FormatTitle           func(title, status string) string
	FormatStatusIndicator func(indicator, status string) string
	FormatConnector       func(connector string) string
	FormatReference       func(text string) string
}

ASCIIFormatter provides optional formatting callbacks for ASCII tree output. When nil or when a field is nil, the corresponding text is returned unmodified.

type Graph

type Graph struct {
	Tasks        []*model.Task
	TaskMap      map[string]*model.Task
	Adjacency    map[string][]string // task ID -> list of dependent task IDs
	RevAdjacency map[string][]string // task ID -> list of dependency task IDs
}

Graph represents a task dependency graph

func NewGraph

func NewGraph(tasks []*model.Task) *Graph

NewGraph creates a new graph from a list of tasks

func (*Graph) DetectCycles

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

DetectCycles finds all cycles in the graph

func (*Graph) FilterTasks

func (g *Graph) FilterTasks(taskIDs map[string]bool) *Graph

FilterTasks creates a subgraph with only the specified task IDs

func (*Graph) GetDownstream

func (g *Graph) GetDownstream(taskID string) map[string]bool

GetDownstream returns all tasks that depend on the given task (transitively)

func (*Graph) GetUpstream

func (g *Graph) GetUpstream(taskID string) map[string]bool

GetUpstream returns all tasks that the given task depends on (transitively)

func (*Graph) ToASCII

func (g *Graph) ToASCII(rootTaskID string, downstream bool, f *ASCIIFormatter) string

ToASCII generates an ASCII tree representation. An optional ASCIIFormatter applies styling callbacks; pass nil for plain text.

func (*Graph) ToDot

func (g *Graph) ToDot(focusTaskID string) string

ToDot generates a Graphviz DOT format

func (*Graph) ToJSON

func (g *Graph) ToJSON() map[string]any

ToJSON generates a JSON graph structure

func (*Graph) ToMermaid

func (g *Graph) ToMermaid(focusTaskID string) string

ToMermaid generates a Mermaid diagram

Jump to

Keyboard shortcuts

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