graph

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package graph provides structural dependency analysis for code reviews. It builds and queries a graph of code units to identify blast-radius impacts and minimal review sets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlastRadiusResult

type BlastRadiusResult struct {
	Files       []string `json:"files"`
	Direct      int      `json:"direct"`
	Transitive  int      `json:"transitive"`
	MaxDepth    int      `json:"max_depth"`
	ImpactScore float64  `json:"impact_score"`
}

BlastRadiusResult represents the results of a blast-radius analysis.

func (*BlastRadiusResult) Score

func (b *BlastRadiusResult) Score() float64

Score computes an overall impact score.

type DependencyGraph

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

DependencyGraph represents structural dependencies between code units.

func New

func New() *DependencyGraph

New creates a new DependencyGraph.

func (*DependencyGraph) AddEdge

func (g *DependencyGraph) AddEdge(from, to string, _ EdgeType)

AddEdge adds a dependency edge between two nodes.

func (*DependencyGraph) AddNode

func (g *DependencyGraph) AddNode(node *Node)

AddNode adds a node to the graph.

func (*DependencyGraph) Build

func (g *DependencyGraph) Build(ctx context.Context, modulePath string) error

Build parses a Go module and builds the dependency graph.

func (*DependencyGraph) GetAllDependents

func (g *DependencyGraph) GetAllDependents(uri string) []string

GetAllDependents returns all transitive dependents.

func (*DependencyGraph) GetBlastRadius

func (g *DependencyGraph) GetBlastRadius(files []string) *BlastRadiusResult

GetBlastRadius returns files affected by changing the given files.

func (*DependencyGraph) GetDirectDependents

func (g *DependencyGraph) GetDirectDependents(uri string) []string

GetDirectDependents returns direct dependents (outgoing edges).

func (*DependencyGraph) GetNode

func (g *DependencyGraph) GetNode(uri string) *Node

GetNode returns a node by URI.

type EdgeType

type EdgeType int

EdgeType represents the type of dependency between nodes.

const (
	EdgeCalls EdgeType = iota
	EdgeReturns
	EdgeParameter
	EdgeReceiver
	EdgeImport
)

func (EdgeType) String

func (e EdgeType) String() string

String returns a string representation of the edge type.

type Node

type Node struct {
	URI  string
	Name string
	Type NodeType
}

Node represents a code unit in the dependency graph.

type NodeType

type NodeType int

NodeType represents the type of node.

const (
	NodeTypeFunction NodeType = iota
	NodeTypeMethod
	NodeTypeType
	NodeTypeStruct
	NodeTypeInterface
	NodeTypePackage
	NodeTypeFile
)

func (NodeType) String

func (n NodeType) String() string

String returns a string representation of the node type.

Jump to

Keyboard shortcuts

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