paths

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: 1 Imported by: 0

Documentation

Overview

Package paths provides APOC advanced path operations.

This package implements all apoc.paths.* functions for advanced path finding and analysis (plural of path package).

Index

Constants

This section is empty.

Variables

Storage is the interface for database operations.

Functions

func Count

func Count(start, end *Node, relType string, maxLength int) int

Count counts paths between nodes.

Example:

apoc.paths.count(start, end, 'KNOWS', 10) => count

func Distance

func Distance(start, end *Node, relType string) int

Distance calculates path distance (length).

Example:

apoc.paths.distance(start, end, 'KNOWS') => distance

func Exists

func Exists(start, end *Node, relType string, maxLength int) bool

Exists checks if any path exists.

Example:

apoc.paths.exists(start, end, 'KNOWS', 10) => true/false

Types

type Node

type Node = storage.Node

Node represents a graph node.

func Common

func Common(paths []*Path) []*Node

Common finds common nodes in multiple paths.

Example:

apoc.paths.common([path1, path2, path3]) => common nodes

func Unique

func Unique(paths []*Path) []*Node

Unique finds unique nodes across paths.

Example:

apoc.paths.unique([path1, path2]) => all unique nodes

type Path

type Path = storage.Path

Path represents a path through the graph.

func All

func All(start, end *Node, relType string, maxLength int) []*Path

All finds all paths between two nodes.

Example:

apoc.paths.all(start, end, 'KNOWS', 5) => all paths

func Cycles

func Cycles(start *Node, relType string, maxLength int) []*Path

Cycles finds all cycles starting from a node.

Example:

apoc.paths.cycles(start, 'KNOWS', 10) => cycles

func Disjoint

func Disjoint(start, end *Node, relType string, maxLength, count int) []*Path

Disjoint finds node-disjoint paths.

Example:

apoc.paths.disjoint(start, end, 'KNOWS', 10, 3) => disjoint paths

func EdgeDisjoint

func EdgeDisjoint(start, end *Node, relType string, maxLength, count int) []*Path

EdgeDisjoint finds edge-disjoint paths.

Example:

apoc.paths.edgeDisjoint(start, end, 'KNOWS', 10, 3) => edge-disjoint paths

func Elementary

func Elementary(start, end *Node, relType string, maxLength int) []*Path

Elementary finds elementary paths (no repeated edges).

Example:

apoc.paths.elementary(start, end, 'KNOWS', 10) => elementary paths

func Eulerian

func Eulerian(start, end *Node) []*Path

Eulerian finds Eulerian paths (visiting all edges once).

Example:

apoc.paths.eulerian(start, end) => Eulerian paths

func Hamiltonian

func Hamiltonian(nodes []*Node, start, end *Node) []*Path

Hamiltonian finds Hamiltonian paths (visiting all nodes once).

Example:

apoc.paths.hamiltonian(nodes, start, end) => Hamiltonian paths

func KShortest

func KShortest(start, end *Node, relType string, maxLength, k int) []*Path

KShortest finds k shortest paths.

Example:

apoc.paths.kShortest(start, end, 'KNOWS', 10, 5) => 5 shortest paths

func Longest

func Longest(start, end *Node, relType string, maxLength int) []*Path

Longest finds longest paths between two nodes.

Example:

apoc.paths.longest(start, end, 'KNOWS', 10) => longest paths

func Merge

func Merge(paths []*Path) *Path

Merge merges multiple paths into one.

Example:

apoc.paths.merge([path1, path2]) => merged path

func Reverse

func Reverse(path *Path) *Path

Reverse reverses a path.

Example:

apoc.paths.reverse(path) => reversed path

func Shortest

func Shortest(start, end *Node, relType string, maxLength int) []*Path

Shortest finds shortest paths between two nodes.

Example:

apoc.paths.shortest(start, end, 'KNOWS', 10) => shortest paths

func Simple

func Simple(start, end *Node, relType string, maxLength int) []*Path

Simple finds simple paths (no repeated nodes).

Example:

apoc.paths.simple(start, end, 'KNOWS', 10) => simple paths

func Slice

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

Slice extracts a subpath.

Example:

apoc.paths.slice(path, 1, 3) => subpath

func WithLength

func WithLength(start, end *Node, relType string, length int) []*Path

WithLength finds paths of specific length.

Example:

apoc.paths.withLength(start, end, 'KNOWS', 3) => paths of length 3

func WithinLength

func WithinLength(start, end *Node, relType string, minLength, maxLength int) []*Path

WithinLength finds paths within length range.

Example:

apoc.paths.withinLength(start, end, 'KNOWS', 2, 5) => paths length 2-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