Skip to content

Commit 319c127

Browse files
committed
Add documentation for the write label procedure
1 parent d3d1715 commit 319c127

File tree

4 files changed

+94
-2
lines changed

4 files changed

+94
-2
lines changed

doc-test-tools/src/main/java/org/neo4j/gds/doc/syntax/SyntaxMode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public enum SyntaxMode {
5959
PIPELINE_EXISTS("pipeline-exists-syntax"),
6060
PIPELINE_DROP("pipeline-drop-syntax"),
6161
SYSTEM_MONITOR("system-monitor-syntax", false),
62-
SYS_INFO("debug-sysinfo-syntax", false);
62+
SYS_INFO("debug-sysinfo-syntax", false),
63+
WRITE_NODE_LABEL("include-with-write-node-label", false),;
6364

6465
private final String mode;
6566
public final boolean hasParameters;

doc-test/src/test/java/org/neo4j/gds/doc/NodeOperationsDocTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.neo4j.gds.catalog.GraphDropNodePropertiesProc;
2323
import org.neo4j.gds.catalog.GraphProjectProc;
2424
import org.neo4j.gds.catalog.GraphStreamNodePropertiesProc;
25+
import org.neo4j.gds.catalog.GraphWriteNodeLabelProc;
2526
import org.neo4j.gds.catalog.GraphWriteNodePropertiesProc;
2627
import org.neo4j.gds.degree.DegreeCentralityMutateProc;
2728
import org.neo4j.gds.functions.AsNodeFunc;
@@ -38,7 +39,8 @@ protected List<Class<?>> procedures() {
3839
DegreeCentralityMutateProc.class,
3940
GraphStreamNodePropertiesProc.class,
4041
GraphWriteNodePropertiesProc.class,
41-
GraphDropNodePropertiesProc.class
42+
GraphDropNodePropertiesProc.class,
43+
GraphWriteNodeLabelProc.class
4244
);
4345
}
4446

doc-test/src/test/java/org/neo4j/gds/doc/syntax/GraphCatalogNodeOperationsSyntaxTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ protected Iterable<SyntaxModeMeta> syntaxModes() {
2929
SyntaxModeMeta.of(SyntaxMode.STREAM),
3030
SyntaxModeMeta.of(SyntaxMode.STREAM_SINGLE_PROPERTY),
3131
SyntaxModeMeta.of(SyntaxMode.WRITE),
32+
SyntaxModeMeta.of(SyntaxMode.WRITE_NODE_LABEL),
3233
SyntaxModeMeta.of(SyntaxMode.REMOVE)
3334
);
3435
}

doc/modules/ROOT/pages/graph-catalog-node-ops.adoc

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,51 @@ YIELD
161161
|===
162162
======
163163
164+
[.include-with-write-node-label]
165+
======
166+
[source, cypher, role=noplay]
167+
----
168+
CALL gds.alpha.graph.nodeLabel.write(
169+
graphName: String,
170+
nodeLabel: String,
171+
configuration: Map
172+
)
173+
YIELD
174+
writeMillis: Integer,
175+
nodeLabelsWritten: Integer,
176+
nodeLabel: String,
177+
graphName: String
178+
----
179+
180+
.Parameters
181+
[opts="header",cols="1,3,1,5"]
182+
|===
183+
| Name | Type | Optional | Description
184+
| graphName | String | no | The name under which the graph is stored in the catalog.
185+
| nodeLabel | String | no | The node label to write back.
186+
| configuration | Map | yes | Additional parameters to configure writeNodeProperties.
187+
|===
188+
189+
.Configuration
190+
[opts="header",cols="1,1,1,7"]
191+
|===
192+
| Name | Type | Default | Description
193+
| nodeFilter | String | n/a | A Cypher predicate for filtering nodes in the input graph. See xref:management-ops/projections/graph-project-subgraph.adoc[Projecting a subgraph].
194+
| concurrency | Integer | 4 | The number of concurrent threads used for running the procedure. Also provides the default value for `writeConcurrency`
195+
| writeConcurrency | Integer | 'concurrency' | The number of concurrent threads used for writing the node properties.
196+
|===
197+
198+
.Results
199+
[opts="header",cols="2,3,5"]
200+
|===
201+
| Name | Type | Description
202+
| writeMillis | Integer | Milliseconds for writing result data back to Neo4j.
203+
| nodeLabelsWritten | Integer | Number of node labels written.
204+
| graphName | String | The name of a graph stored in the catalog.
205+
| nodeLabel | String | The written node label.
206+
|===
207+
======
208+
164209
[.include-with-remove]
165210
======
166211
[source, cypher, role=noplay]
@@ -393,6 +438,49 @@ If the `nodeLabels` parameter is specified, it is required that _all_ given node
393438
--
394439

395440

441+
[[catalog-graph-write-node-label-example]]
442+
=== Write Node Label
443+
444+
To write a new node label to the database for nodes with score higher than `0`, we use the following query:
445+
446+
[role=query-example, group=write-label]
447+
--
448+
.Write the `Reader` node label back to Neo4j:
449+
[source, cypher, role=noplay]
450+
----
451+
CALL gds.alpha.graph.nodeLabel.write('socialGraph', 'Reader', { nodeFilter: 'n.score > 0.0' })
452+
YIELD nodeLabelsWritten
453+
----
454+
455+
.Results
456+
[opts="header"]
457+
|===
458+
| nodeLabelsWritten
459+
| 2
460+
|===
461+
--
462+
463+
[role=query-example, group=write-label]
464+
--
465+
.Query the `Reader` node label:
466+
[source, cypher, role=noplay]
467+
----
468+
MATCH (n:Reader) RETURN n.name AS name, labels(n) AS labels
469+
ORDER BY name ASC
470+
----
471+
472+
.Results
473+
[opts="header"]
474+
|===
475+
| name | labels
476+
| "Adam" | [Person, Reader]
477+
| "Florentin" | [Person, Reader]
478+
|===
479+
--
480+
481+
As we can see from the database `Veselin` who has `score: 0.0` is not a `Reader`.
482+
483+
396484
[[catalog-graph-remove-node-properties-example]]
397485
=== Remove
398486

0 commit comments

Comments
 (0)