traversal

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver = func(ctx context.Context, tx graph.Transaction, segment *graph.PathSegment) ([]*graph.PathSegment, error)

Driver is a function that drives sending queries to the graph and retrieving vertexes and edges. Traversal drivers are expected to operate on a cactus tree representation of path space using the graph.PathSegment data structure. Path segments returned by a traversal driver are considered extensions of path space that require further expansion. If a traversal driver returns no descending path segments, then the given segment may be considered terminal.

func LightweightDriver

func LightweightDriver(direction graph.Direction, cache graphcache.Cache, criteria graph.Criteria, filter SegmentFilter, terminalVisitors ...SegmentVisitor) Driver

LightweightDriver is a Driver constructor that fetches only IDs and Kind information from vertexes and edges stored in the database. This cuts down on network transit and is appropriate for traversals that may involve a large number of or all vertexes within a target graph.

type NodeCollector

type NodeCollector struct {
	Nodes graph.NodeSet
	// contains filtered or unexported fields
}

func NewNodeCollector

func NewNodeCollector() *NodeCollector

func (*NodeCollector) Add

func (s *NodeCollector) Add(node *graph.Node)

func (*NodeCollector) Collect

func (s *NodeCollector) Collect(next *graph.PathSegment)

func (*NodeCollector) PopulateProperties

func (s *NodeCollector) PopulateProperties(ctx context.Context, db graph.Database, propertyNames ...string) error

type PathCollector

type PathCollector struct {
	Paths graph.PathSet
	// contains filtered or unexported fields
}

func NewPathCollector

func NewPathCollector() *PathCollector

func (*PathCollector) Add

func (s *PathCollector) Add(path graph.Path)

func (*PathCollector) PopulateNodeProperties

func (s *PathCollector) PopulateNodeProperties(ctx context.Context, db graph.Database, propertyNames ...string) error

type PatternContinuation

type PatternContinuation interface {
	Outbound(criteria ...graph.Criteria) PatternContinuation
	OutboundWithDepth(min, max int, criteria ...graph.Criteria) PatternContinuation
	Inbound(criteria ...graph.Criteria) PatternContinuation
	InboundWithDepth(min, max int, criteria ...graph.Criteria) PatternContinuation
	Do(delegate PatternMatchDelegate) Driver
}

PatternContinuation is an openCypher inspired fluent pattern for defining parallel chained expansions. After building the pattern the user may call the Do(...) function and pass it a delegate for handling paths that match the pattern.

The return value of the Do(...) function may be passed directly to a Traversal via a Plan as the Plan.Driver field.

func NewPattern

func NewPattern() PatternContinuation

NewPattern returns a new PatternContinuation for building a new pattern.

type PatternMatchDelegate

type PatternMatchDelegate = func(terminal *graph.PathSegment) error

type Plan

type Plan struct {
	Root        *graph.Node
	RootSegment *graph.PathSegment
	Driver      Driver
}

type SegmentFilter

type SegmentFilter = func(next *graph.PathSegment) bool

SegmentFilter is a function type that takes a given path segment and returns true if further descent into the path is allowed.

func AcyclicNodeFilter

func AcyclicNodeFilter(filter SegmentFilter) SegmentFilter

AcyclicNodeFilter is a SegmentFilter constructor that will allow traversal to a node only once. It will ignore all but the first inbound or outbound edge that traverses to it.

func FilteredSkipLimit

func FilteredSkipLimit(filter SkipLimitFilter, visitorFilter SegmentVisitor, skip, limit int) SegmentFilter

FilteredSkipLimit is a SegmentFilter constructor that allows a caller to inform the skip-limit algorithm when a result was collected and if the traversal should continue to descend further during traversal.

func UniquePathSegmentFilter

func UniquePathSegmentFilter(delegate SegmentFilter) SegmentFilter

UniquePathSegmentFilter is a SegmentFilter constructor that will allow a traversal to all unique paths. This is done by tracking edge IDs traversed in a bitmap.

type SegmentVisitor

type SegmentVisitor = func(next *graph.PathSegment)

SegmentVisitor is a function that receives a path segment as part of certain traversal strategies.

type SkipLimitFilter

type SkipLimitFilter = func(next *graph.PathSegment) (bool, bool)

A SkipLimitFilter is a function that represents a collection and descent filter for PathSegments. This function must return two boolean values:

The first boolean value in the return tuple communicates to the FilteredSkipLimit SegmentFilter if the given PathSegment is eligible for collection and therefore should be counted when considering the traversal's skip and limit parameters.

The second boolean value in the return tuple communicates to the FilteredSkipLimit SegmentFilter if the given PathSegment is eligible for further descent. When this value is true the path will be expanded further during traversal.

type Traversal

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

func New

func New(db graph.Database, numParallelWorkers int) Traversal

func (Traversal) BreadthFirst

func (s Traversal) BreadthFirst(ctx context.Context, plan Plan) error

Jump to

Keyboard shortcuts

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