Skip to content

Commit e114465

Browse files
committed
Add documentation for gds.util.nodeProperty
1 parent a3287f5 commit e114465

File tree

4 files changed

+79
-16
lines changed

4 files changed

+79
-16
lines changed

doc/asciidoc/appendix-a.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,17 @@ The following table lists all functions in the GDS library:
220220
|===
221221
|Group | Function
222222
.2+<.^| Miscellaneous
223-
| `gds.version`
223+
| `<<utility-functions, gds.version>>`
224224
| `gds.list`
225225
|Graph Operations | `gds.graph.exists`
226226
.7+<.^| Utilities
227-
| `gds.util.asNode`
228-
| `gds.util.asNodes`
229-
| `gds.util.nodeProperty`
230-
| `gds.util.infinity`
231-
| `gds.util.isFinite`
232-
| `gds.util.isInfinite`
233-
| `gds.util.NaN`
227+
| `<<utility-functions-node-path, gds.util.asNode>>`
228+
| `<<utility-functions-node-path, gds.util.asNodes>>`
229+
| `<<utility-functions-catalog, gds.util.nodeProperty>>`
230+
| `<<utility-functions-numeric, gds.util.NaN>>`
231+
| `<<utility-functions-numeric, gds.util.infinity>>`
232+
| `<<utility-functions-numeric, gds.util.isFinite>>`
233+
| `<<utility-functions-numeric, gds.util.isInfinite>>`
234234
.6+<.^| Link Prediction
235235
| `<<algorithms-linkprediction-adamic-adar-syntax, gds.alpha.linkprediction.adamicAdar>>`
236236
| `<<algorithms-linkprediction-common-neighbors-syntax, gds.alpha.linkprediction.commonNeighbors>>`

doc/asciidoc/common-usage/running-algorihms.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This execution mode is especially useful in three scenarios:
5353

5454
* Algorithms can depend on the results of previous algorithms without the need to write to Neo4j.
5555
* Algorithm results can be written altogether (see <<catalog-graph-write-node-properties, write node properties>> and <<catalog-graph-write-relationship, write relationships>>).
56-
* Algorithm results can be queried via Cypher without the need to write to Neo4j at all (see `gds.util.nodeProperty`).
56+
* Algorithm results can be queried via Cypher without the need to write to Neo4j at all (see `<<utility-functions-catalog, gds.util.nodeProperty>>`).
5757

5858
A statistical summary of the computation is returned as a Cypher result row.
5959
As for the `write` mode, mutated data can be node properties (such as Page Rank scores), new relationships (such as Node Similarity similarities), or relationship properties.

doc/asciidoc/management-ops/utility-functions.adoc

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This section describes the utility functions and shows their usage in concrete examples.
55

66
[[utility-functions-table]]
7-
[opts=header,cols="1m,1m"]
7+
[opts=header,cols="1m,1"]
88
|===
99
| Name | Description
1010
| gds.version | Return the version of the installed Neo4j Graph Data Science library.
@@ -26,11 +26,13 @@ RETURN gds.version() AS version
2626
|===
2727
--
2828

29+
30+
[[utility-functions-numeric]]
2931
== Numeric Functions
3032

3133
.Numeric Functions
3234
[[Numeric-functions-table]]
33-
[opts=header,cols="1m,1m"]
35+
[opts=header,cols="1m,1"]
3436
|===
3537
| Name | Description
3638
| gds.util.NaN | Returns NaN as a Cypher value.
@@ -42,7 +44,7 @@ RETURN gds.version() AS version
4244
=== Syntax
4345

4446
[[Numeric-functions-syntax-table]]
45-
[opts=header,cols="1m,1m"]
47+
[opts=header,cols="1m,1"]
4648
|===
4749
| Name | Parameter
4850
| gds.util.NaN() | -
@@ -94,6 +96,8 @@ RETURN gds.util.isInfinite(value) AS isInfinite
9496
The utility function `gds.util.NaN` can be used as an default value for input parameters, as shown in the examples of <<algorithms-similarity-cosine-procedure-sample, cosine similarity>>.
9597
A common usage of `gds.util.IsFinite` and `gds.util.IsInfinite` is for filtering streamed results, as for instance seen in the examples of <<algorithm-all-pairs-shortest-path-sample, `gds.alpha.allShortestPaths`>>.
9698

99+
100+
[[utility-functions-node-path]]
97101
== Node and Path Functions
98102

99103
.Node and Path Functions
@@ -108,7 +112,7 @@ A common usage of `gds.util.IsFinite` and `gds.util.IsInfinite` is for filtering
108112
=== Syntax
109113

110114
[[Node-and-Path-functions-syntax-table]]
111-
[opts=header,cols="1m,1m"]
115+
[opts=header,cols="1m,1"]
112116
|===
113117
| Name | Parameters
114118
| gds.util.asNode(nodeId: NUMBER) | nodeId of a node in the neo4j-graph
@@ -167,3 +171,60 @@ RETURN [x in gds.util.asNodes(nodeIds)| x.name] AS nodes
167171
--
168172

169173
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.
174+
175+
176+
[[utility-functions-catalog]]
177+
== Catalog Functions
178+
179+
Catalog functions allow accessing in-memory graphs directly from a Cypher query.
180+
181+
.Catalog Functions
182+
[opts=header,cols="1m,1"]
183+
|===
184+
| Name | Description
185+
| gds.util.nodeProperty | Allows accessing a node property stored in a named graph.
186+
|===
187+
188+
=== Syntax
189+
190+
[opts=header,cols="1m,1"]
191+
|===
192+
| Name | Description
193+
| gds.util.nodeProperty(graphName: STRING, nodeId: INTEGER, propertyKey: STRING) | Named graph in the catalog, Neo4j node id and node property key present in the named-graph.
194+
|===
195+
196+
=== Examples
197+
198+
.Create a graph in the catalog:
199+
[source, cypher, role=setup-query]
200+
----
201+
CALL gds.graph.create('my-graph', 'User', 'LINK');
202+
----
203+
204+
.Run an algorithm that updates the named-graph:
205+
[source, cypher, role=setup-query]
206+
----
207+
CALL gds.pageRank.mutate('my-graph', { mutateProperty: 'score' })
208+
----
209+
210+
We can now access the property `score` without writing the data to Neo4j.
211+
212+
[role=query-example]
213+
--
214+
.Access a property node property for Alice:
215+
[source, cypher]
216+
----
217+
MATCH (alice:User)
218+
WHERE alice.name = 'Alice'
219+
RETURN
220+
alice.name AS name,
221+
gds.util.nodeProperty('my-graph', id(alice), 'score') AS score
222+
----
223+
224+
.Results
225+
[opts="header",cols="2"]
226+
|===
227+
| name | score
228+
| "Alice" | 0.15000000000000002
229+
|===
230+
--

doc/src/test/java/org/neo4j/graphalgo/doc/UtilityDocTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@
1919
*/
2020
package org.neo4j.graphalgo.doc;
2121

22+
import org.neo4j.graphalgo.catalog.GraphCreateProc;
2223
import org.neo4j.graphalgo.functions.GetNodeFunc;
2324
import org.neo4j.graphalgo.functions.IsFiniteFunc;
25+
import org.neo4j.graphalgo.functions.NodePropertyFunc;
2426
import org.neo4j.graphalgo.functions.VersionFunc;
27+
import org.neo4j.graphalgo.pagerank.PageRankMutateProc;
2528

2629
import java.util.Arrays;
27-
import java.util.Collections;
2830
import java.util.List;
2931

3032
class UtilityDocTest extends DocTestBase {
3133

3234
@Override
3335
List<Class<?>> functions() {
34-
return Arrays.asList(GetNodeFunc.class, VersionFunc.class, IsFiniteFunc.class);
36+
return Arrays.asList(GetNodeFunc.class, VersionFunc.class, IsFiniteFunc.class, NodePropertyFunc.class);
3537
}
3638

3739
@Override
3840
List<Class<?>> procedures() {
39-
return Collections.emptyList();
41+
return Arrays.asList(GraphCreateProc.class, PageRankMutateProc.class);
4042
}
4143

4244
@Override

0 commit comments

Comments
 (0)