query

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package query provides graph traversal and search capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int

Direction specifies the traversal direction.

const (
	// Outgoing follows edges from source to target (what does X call?)
	Outgoing Direction = iota
	// Incoming follows edges from target to source (what calls X?)
	Incoming
	// Both follows edges in both directions
	Both
)

type TraversalResult

type TraversalResult struct {
	// StartNode is the node where traversal began.
	StartNode string

	// Visited contains all visited node IDs in order.
	Visited []string

	// Edges contains all traversed edges.
	Edges []*graph.Edge

	// Depth maps node ID to its depth from start (0 = start node).
	Depth map[string]int

	// Parents maps node ID to the edge that led to it.
	Parents map[string]*graph.Edge
}

TraversalResult holds the result of a graph traversal.

type Traverser

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

Traverser performs graph traversals.

func NewTraverser

func NewTraverser(g *graph.Graph) *Traverser

NewTraverser creates a traverser from a graph.

func NewTraverserFromEdges

func NewTraverserFromEdges(edges []*graph.Edge, nodes map[string]*graph.Node) *Traverser

NewTraverserFromEdges creates a traverser from a slice of edges.

func (*Traverser) BFS

func (t *Traverser) BFS(start string, dir Direction, maxDepth int, edgeTypes []string) *TraversalResult

BFS performs breadth-first search from a starting node.

func (*Traverser) DFS

func (t *Traverser) DFS(start string, dir Direction, maxDepth int, edgeTypes []string) *TraversalResult

DFS performs depth-first search from a starting node.

func (*Traverser) FindPath

func (t *Traverser) FindPath(from, to string, edgeTypes []string) *TraversalResult

FindPath finds a path between two nodes using BFS.

Jump to

Keyboard shortcuts

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