model

package
v0.8.1 Latest Latest
Warning

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

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

Documentation

Overview

Package model holds the graph data types shared across the pipeline: the extraction schema (nodes + edges) emitted by extractors and the assembled undirected Graph that downstream stages cluster, analyze, and export.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	Source          string  `json:"source"`
	Target          string  `json:"target"`
	Relation        string  `json:"relation"`
	Confidence      string  `json:"confidence"`
	SourceFile      string  `json:"source_file,omitempty"`
	SourceLocation  string  `json:"source_location,omitempty"`
	Weight          float64 `json:"weight,omitempty"`
	ConfidenceScore float64 `json:"confidence_score,omitempty"`
}

Edge is a directed relationship between two nodes. The graph stores edges undirected (so community detection and degree work), but Source/Target always record the true direction (caller→callee, importer→imported).

type Extraction

type Extraction struct {
	Nodes []Node `json:"nodes"`
	Edges []Edge `json:"edges"`
}

Extraction is one extractor's output for one file.

type Graph

type Graph struct {
	Nodes map[string]*Node
	// contains filtered or unexported fields
}

Graph is the assembled knowledge graph. It keeps the full directed edge list (so a→b and b→a, or two different relations on one pair, both survive) plus an undirected neighbour set used for degree, traversal, and community detection.

func New

func New() *Graph

New returns an empty graph.

func (*Graph) AddEdge

func (g *Graph) AddEdge(e Edge)

AddEdge records a directed edge between existing nodes. Exact duplicates (same source, target, and relation) are ignored; opposite directions and different relations on the same pair are all kept.

func (*Graph) AddNode

func (g *Graph) AddNode(n Node)

AddNode inserts or overwrites a node (last write wins, mirroring nx.add_node).

func (*Graph) Degree

func (g *Graph) Degree(id string) int

Degree returns the number of distinct neighbors of a node.

func (*Graph) Edges

func (g *Graph) Edges() []*Edge

Edges returns every stored edge in insertion order.

func (*Graph) HasEdge

func (g *Graph) HasEdge(a, b string) bool

HasEdge reports whether an undirected edge connects a and b.

func (*Graph) Neighbors

func (g *Graph) Neighbors(id string) []string

Neighbors returns a node's neighbor IDs in sorted order (stable iteration).

func (*Graph) NodeIDs

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

NodeIDs returns all node IDs in insertion order.

func (*Graph) NumEdges

func (g *Graph) NumEdges() int

NumEdges returns the total number of stored edges.

func (*Graph) NumNodes

func (g *Graph) NumNodes() int

NumNodes returns the node count.

type Node

type Node struct {
	ID             string `json:"id"`
	Label          string `json:"label"`
	FileType       string `json:"file_type"`
	SourceFile     string `json:"source_file"`
	SourceLocation string `json:"source_location,omitempty"`
	ComputedName   string `json:"computed_name,omitempty"`
}

Node is a single entity in the graph (a file, function, type, or method).

Jump to

Keyboard shortcuts

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