graph

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

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"`
	Type        RelationType `json:"type"`
	Description string       `json:"description,omitempty"`
}

type Graph

type Graph struct {
	Nodes map[string]*Node `json:"nodes"`
	Edges []*Edge          `json:"edges"`
}

func New

func New() *Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(source, target string, relType RelationType, description string)

func (*Graph) AddNode

func (g *Graph) AddNode(id string, nType NodeType, name, description string)

func (*Graph) FormatCompact

func (g *Graph) FormatCompact() string

FormatCompact returns a compact string representation of the graph suitable for an LLM context. Each node and edge renders on a single line: newlines, tabs, and carriage returns in descriptions are collapsed to a single space so multi-line tool docs (e.g. firecrawl tool descriptions containing JSON usage examples) don't break the one-line-per-entry layout that downstream consumers (LLM prompts, lattice docs) depend on.

func (*Graph) Subgraph

func (g *Graph) Subgraph(nodeID string) *Graph

Subgraph returns a new Graph containing the center node and all directly connected neighbors and edges.

type Node

type Node struct {
	ID          string   `json:"id"`
	Type        NodeType `json:"type"`
	Name        string   `json:"name"`
	Description string   `json:"description,omitempty"`
}

type NodeType

type NodeType string
const (
	NodeSkill    NodeType = "skill"
	NodeTool     NodeType = "tool"
	NodeResource NodeType = "resource"
)

type RelationType

type RelationType string
const (
	RelHasTool         RelationType = "HAS_TOOL"
	RelPrerequisiteFor RelationType = "PREREQUISITE_FOR"
	RelProduces        RelationType = "PRODUCES"
	RelRequires        RelationType = "REQUIRES"
	RelCommonNextStep  RelationType = "COMMON_NEXT_STEP"
)

Jump to

Keyboard shortcuts

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