Utility functions
1. System Functions
Name | Description |
---|---|
|
Return the version of the installed Neo4j Graph Data Science library. |
RETURN gds.version() AS version
version |
---|
"2.3.9" |
2. Numeric Functions
Name | Description |
---|---|
|
Returns NaN as a Cypher value. |
|
Return infinity as a Cypher value. |
|
Return false if the given argument is ±Infinity, NaN, or null. |
|
Return true if the given argument is ±Infinity, NaN, or null. |
2.1. Syntax
Name | Parameter |
---|---|
|
- |
|
- |
|
value to be checked if it is finite. |
|
value to be checked if it is infinite. |
2.2. Examples
UNWIND [1.0, gds.util.NaN(), gds.util.infinity()] AS value
RETURN gds.util.isFinite(value) AS isFinite
isFinite |
---|
true |
false |
false |
UNWIND [1.0, gds.util.NaN(), gds.util.infinity()] AS value
RETURN gds.util.isInfinite(value) AS isInfinite
isInfinite |
---|
false |
true |
true |
A common usage of gds.util.IsFinite
and gds.util.IsInfinite
is for filtering streamed results, as for instance seen in the examples of gds.alpha.allShortestPaths
.
3. Node id functions
Name | Description |
---|---|
|
|
|
|
3.1. Syntax
Name | Parameters |
---|---|
|
nodeId of a node in the neo4j-graph |
|
list of nodeIds of nodes in the neo4j-graph |
3.2. Examples
Consider the graph created by the following Cypher statement:
CREATE (nAlice:User {name: 'Alice'})
CREATE (nBridget:User {name: 'Bridget'})
CREATE (nCharles:User {name: 'Charles'})
CREATE (nAlice)-[:LINK]->(nBridget)
CREATE (nBridget)-[:LINK]->(nCharles)
MATCH (u:User{name: 'Alice'})
WITH id(u) AS nodeId
RETURN gds.util.asNode(nodeId).name AS node
node |
---|
"Alice" |
MATCH (u:User)
WHERE NOT u.name = 'Charles'
WITH collect(id(u)) AS nodeIds
RETURN [x in gds.util.asNodes(nodeIds)| x.name] AS nodes
nodes |
---|
[Alice, Bridget] |
As many algorithms streaming mode only return the node id, gds.util.asNode
and gds.util.asNodes
can be used to retrieve the whole node from the neo4j database.
Was this page helpful?