Graph Element Functions

Node Functions

The relTypes argument of node.degree(), node.degree.in(), node.degree.out(), node.relationship.exists() and node.relationship.types() is APOC’s relationship pattern, the same syntax as the relationship filter of the path.* procedures: TYPE matches the type in both directions, TYPE> outgoing only, <TYPE incoming only, > and < every type in one direction, and | separates the alternatives ('KNOWS>|<LIKES'). A null or blank pattern matches every relationship. A count sums per alternative, as APOC does. The optional direction argument (IN, OUT or BOTH) narrows the pattern: an alternative without a marker is followed in that direction, and one marked the other way matches nothing. node.degree.in() and node.degree.out() read the pattern with their direction fixed, so node.degree.in(n, 'KNOWS>') is 0. Since v26.12.1; earlier versions read the whole string as one type name, so node.degree(n, 'KNOWS>') answered 0.

node.degree()

Get the total degree (in + out) of a node.

Syntax: node.degree(node, [relTypes], [direction])

Returns: Long - Total degree

APOC Compatible: apoc.node.degree


node.degree.in()

Get the incoming degree of a node.

Syntax: node.degree.in(node, [relTypes])

Returns: Long - Incoming degree

APOC Compatible: apoc.node.degree.in


node.degree.out()

Get the outgoing degree of a node.

Syntax: node.degree.out(node, [relTypes])

Returns: Long - Outgoing degree

APOC Compatible: apoc.node.degree.out


node.id()

Get the internal ID of a node.

Syntax: node.id(node)

Returns: String - Node ID (RID)

APOC Compatible: apoc.node.id


node.labels()

Get all labels of a node.

Syntax: node.labels(node)

Returns: List - List of labels

APOC Compatible: apoc.node.labels


node.relationship.exists()

Check if a relationship exists from a node.

Syntax: node.relationship.exists(node, [relTypes], [direction])

Returns: Boolean - true if relationship exists

APOC Compatible: apoc.node.relationship.exists


node.relationship.types()

Get the relationship types connected to a node. With a pattern, the answer is the types the pattern names that the node has a relationship of, in the pattern’s order.

Syntax: node.relationship.types(node, [relTypes], [direction])

Returns: List - List of relationship types

Since v26.12.1 the second argument is the relationship pattern, as in APOC, and the direction is the third one: node.relationship.types(n, null, 'IN') (or (n, '<')) lists the incoming types. A call written for the old signature keeps its answer: a second argument that is a direction word (IN, INCOMING, OUT, OUTGOING, BOTH, in any case) with no third argument is still read as the direction, unless the schema has an edge type with exactly that name.

APOC Compatible: apoc.node.relationship.types


Relationship Functions

rel.endNode()

Get the end node of a relationship.

Syntax: rel.endNode(relationship)

Returns: Node - End node

APOC Compatible: apoc.rel.endNode


rel.id()

Get the internal ID of a relationship.

Syntax: rel.id(relationship)

Returns: String - Relationship ID (RID)

APOC Compatible: apoc.rel.id


rel.startNode()

Get the start node of a relationship.

Syntax: rel.startNode(relationship)

Returns: Node - Start node

APOC Compatible: apoc.rel.startNode


rel.type()

Get the type of a relationship.

Syntax: rel.type(relationship)

Returns: String - Relationship type

APOC Compatible: apoc.rel.type