UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Typed Graph
    • Open Graph
    • Graph Sharding and Storage
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Scalar Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Label Functions
    • Record Functions
    • Table Functions
  • Operators
  • Predicates
    • CASE
    • NULLIF
    • COALESCE
    • LET Value Expression
    • Value Query Expression
    • Index
    • Full-text Index
    • Vector Index
    • Spatial Index
    • Overview
    • Managing HDC Graphs
    • HDC Graph Queries
  • Transaction
  • Trigger
  • Stored Procedure
    • Process
    • Session
    • Job
    • Execution Plan
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • Access Control
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

Path Functions

Example Graph

The following examples run against this graph:

nodes()

Extracts all nodes from a path as a list. Supports index access and slicing.

Syntaxnodes(<pathVar>)
ArgumentsNameTypeDescription
<pathVar>PATHPath variable reference
Return TypeLIST<NODE>
GQL
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN nodes(p)

Index access (0-based, negative indices supported):

GQL
MATCH p = ({_id: "P1"})-[]->{2}()
RETURN nodes(p)[0] AS first, nodes(p)[-1] AS last

Slicing:

GQL
MATCH p = ({_id: "P1"})-[]->{3}()
RETURN nodes(p)[0:2] AS first_two, nodes(p)[1:] AS rest

path_length()

Returns the number of edges in a path.

Syntaxpath_length(<pathVar>)
ArgumentsNameTypeDescription
<pathVar>PATHPath variable reference
Return TypeUINT
GQL
MATCH p = ()->{1,3}()
RETURN p, PATH_LENGTH(p) AS length

Result:

p
length
2
1
1

pedges()

Collects edges in a path into a list.

Syntaxpedges(<pathVar>)
ArgumentsNameTypeDescription
<pathVar>PATHPath variable reference
Return TypeLIST
GQL
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pedges(p)

Result:

pedges(p)
[{"from":"P1","to":"P2","uuid":"1","from_uuid":"8791028671650463745","to_uuid":"8718971077612535810","schema":"Cites","values":{"weight":2}}]
[{"from":"P1","to":"P2","uuid":"1","from_uuid":"8791028671650463745","to_uuid":"8718971077612535810","schema":"Cites","values":{"weight":2}},{"from":"P2","to":"P3","uuid":"2","from_uuid":"8718971077612535810","to_uuid":"12033620403357220867","schema":"Cites","values":{"weight":1}}]

pedgeUuids()

Collects the _uuid values of edges in a path into a list.

SyntaxpedgeUuids(<pathAlias>)
ArgumentsNameTypeDescription
<pathAlias>PATHPath alias reference
Return TypeLIST
GQL
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pedgeUuids(p)

Result:

pedgeUuids(p)
["1"]
["1","2"]

pnodes()

Collects nodes in a path into a list.

Syntaxpnodes(<pathVar>)
ArgumentsNameTypeDescription
<pathVar>PATHPath variable reference
Return TypeLIST
GQL
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pnodes(p)

Result:

pnodes(p)
[{"id":"P1","uuid":"8791028671650463745","schema":"Paper","values":{"author":"Alex","title":"Efficient Graph Search","score":6}},{"id":"P2","uuid":"8718971077612535810","schema":"Paper","values":{"author":"Alex","title":"Optimizing Queries","score":9}}]
[{"id":"P1","uuid":"8791028671650463745","schema":"Paper","values":{"author":"Alex","title":"Efficient Graph Search","score":6}},{"id":"P2","uuid":"8718971077612535810","schema":"Paper","values":{"author":"Alex","title":"Optimizing Queries","score":9}},{"id":"P3","uuid":"12033620403357220867","schema":"Paper","values":{"author":"Zack","title":"Path Patterns","score":7}}]

pnodeIds()

Collects the _id values of nodes in a path into a list.

SyntaxpnodeIds(<pathAlias>)
ArgumentsNameTypeDescription
<pathAlias>PATHPath alias reference
Return TypeLIST
GQL
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pnodeIds(p)

Result:

pnodeIds(p)
["P1","P2"]
["P1","P2","P3"]

relationships()

Extracts all edges from a path as a list. Supports index access and slicing.

Syntaxrelationships(<pathVar>)
ArgumentsNameTypeDescription
<pathVar>PATHPath variable reference
Return TypeLIST<EDGE>
GQL
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN relationships(p)

Index access:

GQL
MATCH p = ({_id: "P1"})-[]->{2}()
RETURN relationships(p)[0] AS first_edge

Relationship to Other Path Functions

FunctionReturnsDescription
nodes(p)LIST<NODE>All nodes in the path.
relationships(p)LIST<EDGE>All edges in the path.
pnodes(p)LIST<NODE>All nodes in the path (same as nodes()).
pedges(p)LIST<EDGE>All edges in the path (same as relationships()).
NOTE

nodes(p)[0].name (chained property access) is not supported. Use nodes(p)[0] to retrieve the node, then access properties separately.