Skip to content

Commit 039aef8

Browse files
Added toUndirected proc documentation
Co-Authored-By: Florentin Dörre <florentin.dorre@neotechnology.com>
1 parent 15cbc03 commit 039aef8

File tree

6 files changed

+83
-2
lines changed

6 files changed

+83
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public enum SyntaxMode {
3535
STREAM_SINGLE_PROPERTY("include-with-stream-single-property"),
3636

3737
STREAM_MULTIPLE_PROPERTIES("include-with-stream-multiple-properties"),
38+
CONVERT_TO_UNDIRECTED("include-with-convert-to-undirected"),
3839
STREAM_TOPOLOGY("include-with-stream-topology"),
3940
GRAPH_EXISTS("graph-exists-syntax"),
4041
MODEL_EXISTS("model-exists-syntax"),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.neo4j.gds.doc;
2121

22+
import org.neo4j.gds.beta.undirected.ToUndirectedProc;
2223
import org.neo4j.gds.catalog.GraphDropRelationshipProc;
2324
import org.neo4j.gds.catalog.GraphProjectProc;
2425
import org.neo4j.gds.catalog.GraphStreamRelationshipPropertiesProc;
@@ -43,6 +44,7 @@ protected List<Class<?>> procedures() {
4344
NodeSimilarityMutateProc.class,
4445
GraphStreamRelationshipsProc.class,
4546
GraphStreamRelationshipPropertiesProc.class,
47+
ToUndirectedProc.class,
4648
GraphWriteRelationshipProc.class,
4749
GraphDropRelationshipProc.class
4850
);

doc-test/src/test/java/org/neo4j/gds/doc/syntax/GraphCatalogRelationshipOperationsSyntaxTest.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_SINGLE_PROPERTY),
3030
SyntaxModeMeta.of(SyntaxMode.STREAM_TOPOLOGY),
3131
SyntaxModeMeta.of(SyntaxMode.STREAM_MULTIPLE_PROPERTIES),
32+
SyntaxModeMeta.of(SyntaxMode.CONVERT_TO_UNDIRECTED),
3233
SyntaxModeMeta.of(SyntaxMode.WRITE),
3334
SyntaxModeMeta.of(SyntaxMode.DELETE_RELATIONSHIPS)
3435
);

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,55 @@ a|
165165
|===
166166
======
167167
168+
[.include-with-convert-to-undirected]
169+
======
170+
[source, cypher, role=noplay]
171+
----
172+
CALL gds.beta.graph.relationships.toUndirected(
173+
graphName: String,
174+
configuration: Map
175+
)
176+
YIELD
177+
inputRelationships: Integer,
178+
relationshipsWritten: Integer,
179+
mutateMillis: Integer,
180+
postProcessingMillis: Integer,
181+
preProcessingMillis: Integer,
182+
computeMillis: Integer,
183+
configuration: Map
184+
----
185+
186+
.Parameters
187+
[opts="header",cols="1,1,1,7"]
188+
|===
189+
| Name | Type | Optional | Description
190+
| graphName | String | no | The name under which the graph is stored in the catalog.
191+
| configuration | Map | yes | Additional parameters to configure streamNodeProperties.
192+
|===
193+
194+
.Configuration
195+
[opts="header",cols="1,1,1,1,6"]
196+
|===
197+
| Name | Type | Optional | Default | Description
198+
| relationshipType | String | no | n/a | The relationship type to make undirected.
199+
| mutateRelationshipType | String | no | n/a | The relationship type to be added to the graph.
200+
include::partial$/algorithms/common-configuration/common-configuration-jobid-concurrency-entries.adoc[]
201+
|===
202+
203+
.Results
204+
[opts="header",cols="2,1,7"]
205+
|===
206+
| Name | Type | Description
207+
| inputRelationships | Integer | The number of relationships that were processed.
208+
| relationshipsWritten | Integer | The number of relationships that were added.
209+
| preProcessingMillis | Integer | Milliseconds for preprocessing the graph.
210+
| computeMillis | Integer | Milliseconds for running the algorithm.
211+
| postProcessingMillis | Integer | Unused.
212+
| mutateMillis | Integer | Milliseconds for adding relationships to the projected graph.
213+
| configuration | Map | The configuration used for running the algorithm.
214+
|===
215+
======
216+
168217
[.include-with-write]
169218
======
170219
[source, cypher, role=noplay]
@@ -612,6 +661,33 @@ ORDER BY source ASC, target ASC
612661

613662
NOTE: The properties we want to stream must exist for each specified relationship type.
614663

664+
=== Convert to undirected
665+
666+
Some algorithms such as Triangle Count and Link Prediction expect undirected relationships. The following shows how to convert the relationships of type `LIKES` in the graph from directed to undirected by creating an undirected relationship of new type `INTERACTS`.
667+
668+
[role=query-example]
669+
--
670+
.Convert relationships from directed to undirected:
671+
[source, cypher, role=noplay]
672+
----
673+
CALL gds.beta.graph.relationships.toUndirected(
674+
'personsAndInstruments', // <1>
675+
{relationshipType: 'LIKES', mutateRelationshipType: 'INTERACTS'} // <2>
676+
)
677+
YIELD
678+
inputRelationships, relationshipsWritten
679+
----
680+
<1> The name of the projected graph.
681+
<2> A map that includes the relationship type to make undirected and the relationship type to be added to the graph.
682+
683+
.Results
684+
[opts="header"]
685+
|===
686+
| inputRelationships | relationshipsWritten
687+
| 19 | 18
688+
|===
689+
--
690+
615691
[[catalog-graph-write-relationship-example]]
616692
=== Write
617693

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
| xref:common-usage/running-algos.adoc#common-configuration-node-labels[nodeLabels] | List of String | ['*'] | yes | Filter the named graph using the given node labels.
22
| xref:common-usage/running-algos.adoc#common-configuration-relationship-types[relationshipTypes] | List of String | ['*'] | yes | Filter the named graph using the given relationship types.
3-
| xref:common-usage/running-algos.adoc#common-configuration-concurrency[concurrency] | Integer | 4 | yes | The number of concurrent threads used for running the algorithm.
4-
| xref:common-usage/running-algos.adoc#common-configuration-jobid[jobId] | String | Generated internally | yes | An ID that can be provided to more easily track the algorithm's progress.
3+
include::partial$/algorithms/common-configuration/common-configuration-jobid-concurrency-entries.adoc[]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| xref:common-usage/running-algos.adoc#common-configuration-concurrency[concurrency] | Integer | 4 | yes | The number of concurrent threads used for running the algorithm.
2+
| xref:common-usage/running-algos.adoc#common-configuration-jobid[jobId] | String | Generated internally | yes | An ID that can be provided to more easily track the algorithm's progress.

0 commit comments

Comments
 (0)