graph

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAcyclic

func IsAcyclic(edgeType string) bool

IsAcyclic returns true if the edge type enforces DAG constraint.

Types

type Graph

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

Graph wraps a Store and provides DAG operations + traversal.

func New

func New(store *storage.Store) *Graph

New creates a Graph engine backed by the given Store.

func (*Graph) AddEdge

func (g *Graph) AddEdge(e *storage.Edge) error

AddEdge creates an edge, enforcing cycle detection for acyclic types.

func (*Graph) AddNode

func (g *Graph) AddNode(n *storage.Node) error

AddNode delegates to store.

func (*Graph) Ancestors

func (g *Graph) Ancestors(id string) ([]string, error)

Ancestors walks backwards through acyclic edges from the given node.

func (*Graph) BFS

func (g *Graph) BFS(startID string, maxDepth int) ([]string, error)

BFS performs breadth-first traversal from startID up to maxDepth, returning visited node IDs.

func (*Graph) Descendants

func (g *Graph) Descendants(id string) ([]string, error)

Descendants walks forward through acyclic edges from the given node.

func (*Graph) ExtractSubgraph

func (g *Graph) ExtractSubgraph(startID string, maxDepth int) (*Subgraph, error)

ExtractSubgraph returns the full subgraph (nodes + edges) around startID up to maxDepth.

func (*Graph) Impact

func (g *Graph) Impact(filePath string, maxDepth int) ([]string, error)

Impact returns node IDs affected by a file change, walking backwards through the graph.

func (*Graph) IntentBFS

func (g *Graph) IntentBFS(startID string, maxDepth int, queryIntent intent.Intent) ([]string, error)

IntentBFS performs intent-aware BFS from startID. Edge traversal is weighted by the query intent (MAGMA-style adaptive traversal). Edges with higher intent weight are traversed first and given higher scores.

func (*Graph) RemoveEdge

func (g *Graph) RemoveEdge(id string) error

RemoveEdge delegates to store.

func (*Graph) RemoveNode

func (g *Graph) RemoveNode(id string) error

RemoveNode delegates to store.

type Subgraph

type Subgraph struct {
	Nodes []*storage.Node
	Edges []*storage.Edge
}

Subgraph holds a set of nodes and edges.

Jump to

Keyboard shortcuts

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