path

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 2 Imported by: 0

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

Storage is the interface for database operations.

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, ...]

func SubgraphAll

func SubgraphAll(start *Node, config Config) (nodes []*Node, rels []*Relationship)

SubgraphAll finds all nodes and relationships in a subgraph.

Example:

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

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 Node

type Node = storage.Node

Node represents a graph node.

func SubgraphNodes

func SubgraphNodes(start *Node, config Config) []*Node

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

Example:

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

type Path

type Path = storage.Path

Path represents a path through the graph.

func AllShortestPaths

func AllShortestPaths(start, end *Node, relFilter string, maxHops int) []*Path

AllShortestPaths finds all shortest paths between two nodes.

Example:

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

func Combine

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

Combine combines multiple paths into one.

Example:

apoc.path.combine(path1, path2)

func ExpandConfig

func ExpandConfig(start *Node, config Config) []*Path

ExpandConfig expands from a start node with configuration.

Example:

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

func ShortestPath

func ShortestPath(start, end *Node, relFilter string, maxHops int) *Path

ShortestPath finds the shortest path between two nodes.

Example:

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

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

func SpanningTree

func SpanningTree(start *Node, config Config) []*Path

SpanningTree finds a spanning tree from a start node.

Example:

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

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