path

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 4 Imported by: 1 module, 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

Overview

Package path provides APOC path finding functions.

This package implements all apoc.path.* functions for finding and analyzing paths in graph queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Elements

func Elements(path *Path) []interface{}

Elements returns all elements (nodes and relationships) in a path.

Example:

apoc.path.elements(path) => [node1, rel1, node2, rel2, ...]

Types

type Config

type Config struct {
	MinLevel           int
	MaxLevel           int
	RelationshipFilter string
	LabelFilter        string
	Limit              int
	Unique             string
	BFS                bool
}

Config holds path finding configuration.

type Functions

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

Functions binds this package's storage-dependent helpers to one storage backend. The backend is fixed when the instance is created, so a handler an already-admitted caller holds keeps the backend it was built for.

func New

func New(backend storage.Storage) *Functions

New returns this package's helpers bound to backend. One instance serves one backend; a reconfiguration builds a new instance instead of rebinding this one.

func (*Functions) AllShortestPaths

func (f *Functions) AllShortestPaths(ctx context.Context, start, end *Node, relFilter string, maxHops int) ([]*Path, error)

AllShortestPaths finds all shortest paths between two nodes.

Example:

apoc.path.allShortestPaths(start, end, 'KNOWS>', 10)

func (*Functions) ExpandConfig

func (f *Functions) ExpandConfig(ctx context.Context, start *Node, config Config) ([]*Path, error)

ExpandConfig expands from a start node with configuration.

Example:

apoc.path.expandConfig(startNode, {relationshipFilter: 'KNOWS>'})

func (*Functions) ShortestPath

func (f *Functions) ShortestPath(ctx context.Context, start, end *Node, relFilter string, maxHops int) (*Path, error)

ShortestPath finds the shortest path between two nodes.

Example:

apoc.path.shortestPath(start, end, 'KNOWS>', 10)

func (*Functions) SpanningTree

func (f *Functions) SpanningTree(ctx context.Context, start *Node, config Config) ([]*Path, error)

SpanningTree finds a spanning tree from a start node.

Example:

apoc.path.spanningTree(startNode, {maxLevel: 5})

func (*Functions) SubgraphAll

func (f *Functions) SubgraphAll(ctx context.Context, start *Node, config Config) (map[string]interface{}, error)

SubgraphAll returns nodes and relationships in the map keys "nodes" and "rels". Cancellation and backend failures return no partial map.

Example:

apoc.path.subgraphAll(startNode, {maxLevel: 3})

func (*Functions) SubgraphNodes

func (f *Functions) SubgraphNodes(ctx context.Context, start *Node, config Config) ([]*Node, error)

SubgraphNodes finds all nodes in a subgraph from a start node.

Example:

apoc.path.subgraphNodes(startNode, {maxLevel: 3})

type Node

type Node = storage.Node

Node represents a graph node.

type Path

type Path = storage.Path

Path represents a path through the graph.

func Combine

func Combine(paths ...*Path) *Path

Combine combines multiple paths into one.

Example:

apoc.path.combine(path1, path2)

func Slice

func Slice(path *Path, start, end int) *Path

Slice returns a slice of a path.

Example:

apoc.path.slice(path, 1, 3) => path from index 1 to 3

type Relationship

type Relationship = storage.Relationship

Relationship represents a graph relationship.

Jump to

Keyboard shortcuts

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