graph

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 1 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 graph provides APOC graph manipulation functions.

This package implements all apoc.graph.* functions for creating and manipulating virtual graphs and graph structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stats

func Stats(graph *Graph) map[string]interface{}

Stats returns statistics about a graph.

Example:

apoc.graph.stats(graph) => {nodes: 10, relationships: 15}

func ToMap

func ToMap(graph *Graph) map[string]interface{}

ToMap converts a graph to a map representation.

Example:

apoc.graph.toMap(graph) => {nodes: [...], relationships: [...]}

func Validate

func Validate(graph *Graph) map[string]interface{}

Validate validates a graph structure.

Example:

apoc.graph.validate(graph) => {valid: true, errors: []}

Types

type Graph

type Graph struct {
	Nodes         []*Node
	Relationships []*Relationship
}

Graph represents a virtual graph.

func Clone

func Clone(graph *Graph) *Graph

Clone creates a deep copy of a graph.

Example:

apoc.graph.clone(graph) => cloned graph

func From

func From(nodes []*Node, rels []*Relationship, name string) *Graph

From creates a virtual graph from nodes and relationships.

Example:

apoc.graph.from(nodes, rels, 'MyGraph') => virtual graph

func FromCypher

func FromCypher(query string, params map[string]interface{}) *Graph

FromCypher creates a virtual graph from Cypher query results.

Example:

apoc.graph.fromCypher('MATCH (n) RETURN n', {}) => virtual graph

func FromData

func FromData(data map[string]interface{}, name string) *Graph

FromData creates a virtual graph from data.

Example:

apoc.graph.fromData(data, 'MyGraph') => virtual graph

func FromDocument

func FromDocument(doc map[string]interface{}, config map[string]interface{}) *Graph

FromDocument creates a virtual graph from a document structure.

Example:

apoc.graph.fromDocument(doc, {}) => virtual graph

func FromMap

func FromMap(data map[string]interface{}) *Graph

FromMap creates a graph from a map representation.

Example:

apoc.graph.fromMap(map) => graph

func FromPath

func FromPath(nodes []*Node, rels []*Relationship, name string) *Graph

FromPath creates a virtual graph from a path.

Example:

apoc.graph.fromPath(path, 'MyGraph') => virtual graph

func FromPaths

func FromPaths(paths []map[string]interface{}, name string) *Graph

FromPaths creates a virtual graph from multiple paths.

Example:

apoc.graph.fromPaths(paths, 'MyGraph') => virtual graph

func Merge

func Merge(graphs ...*Graph) *Graph

Merge merges multiple graphs into one.

Example:

apoc.graph.merge(graph1, graph2) => merged graph

func Subgraph

func Subgraph(graph *Graph, nodeIDs []int64) *Graph

Subgraph extracts a subgraph based on node IDs.

Example:

apoc.graph.subgraph(graph, [1, 2, 3]) => subgraph

type Node

type Node struct {
	ID         int64
	Labels     []string
	Properties map[string]interface{}
}

Node represents a graph node.

func Nodes

func Nodes(graph *Graph) []*Node

Nodes returns all nodes in a graph.

Example:

apoc.graph.nodes(graph) => [node1, node2, ...]

type Relationship

type Relationship struct {
	ID         int64
	Type       string
	StartNode  int64
	EndNode    int64
	Properties map[string]interface{}
}

Relationship represents a graph relationship.

func Relationships

func Relationships(graph *Graph) []*Relationship

Relationships returns all relationships in a graph.

Example:

apoc.graph.relationships(graph) => [rel1, rel2, ...]

Jump to

Keyboard shortcuts

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