Skip to content

Commit 5972740

Browse files
Remove anonymous projections in similarity algo docs
Co-authored-by: Jacob Sznajdman <[email protected]>
1 parent ac8186b commit 5972740

File tree

10 files changed

+16
-134
lines changed

10 files changed

+16
-134
lines changed

alpha/alpha-proc/src/test/java/org/neo4j/graphalgo/similarity/ApproxNearestNeighborsDocTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ void stream() {
8787
" WITH {item:id(p), categories: collect(id(cuisine))} AS userData " +
8888
" WITH collect(userData) AS data " +
8989
" CALL gds.alpha.ml.ann.stream({" +
90-
" nodeProjection: '*'," +
91-
" relationshipProjection: '*', " +
9290
" data: data," +
9391
" algorithm: 'jaccard'," +
9492
" similarityCutoff: 0.1," +
@@ -125,8 +123,6 @@ void write() {
125123
" WITH {item:id(p), categories: collect(id(cuisine))} AS userData " +
126124
" WITH collect(userData) AS data " +
127125
" CALL gds.alpha.ml.ann.write({ " +
128-
" nodeProjection: '*', " +
129-
" relationshipProjection: '*', " +
130126
" algorithm: 'jaccard', " +
131127
" data: data, " +
132128
" similarityCutoff: 0.1, " +

alpha/alpha-proc/src/test/java/org/neo4j/graphalgo/similarity/CosineDocTest.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void stream() {
144144
" OPTIONAL MATCH (p)-[likes:LIKES]->(c)" +
145145
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} as userData" +
146146
" WITH collect(userData) AS data" +
147-
" CALL gds.alpha.similarity.cosine.stream({nodeProjection: '*', relationshipProjection: '*', data: data, topK: 0})" +
147+
" CALL gds.alpha.similarity.cosine.stream({data: data, topK: 0})" +
148148
" YIELD item1, item2, count1, count2, similarity" +
149149
" RETURN gds.util.asNode(item1).name AS from, gds.util.asNode(item2).name AS to, similarity" +
150150
" ORDER BY similarity DESC";
@@ -177,8 +177,6 @@ void streamWithSymCutoff() {
177177
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} as userData" +
178178
" WITH collect(userData) AS data" +
179179
" CALL gds.alpha.similarity.cosine.stream({" +
180-
" nodeProjection: '*', " +
181-
" relationshipProjection: '*', " +
182180
" data: data," +
183181
" similarityCutoff: 0.0," +
184182
" topK: 0" +
@@ -212,8 +210,6 @@ void streamWithTopK() {
212210
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} as userData" +
213211
" WITH collect(userData) AS data" +
214212
" CALL gds.alpha.similarity.cosine.stream({" +
215-
" nodeProjection: '*', " +
216-
" relationshipProjection: '*', " +
217213
" data: data, " +
218214
" similarityCutoff: 0.0," +
219215
" topK: 1" +
@@ -244,8 +240,6 @@ void write() {
244240
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} as userData" +
245241
" WITH collect(userData) as data" +
246242
" CALL gds.alpha.similarity.cosine.write({" +
247-
" nodeProjection: '*', " +
248-
" relationshipProjection: '*', " +
249243
" data: data," +
250244
" topK: 1, " +
251245
" similarityCutoff: 0.1" +
@@ -288,8 +282,6 @@ void sourceTargetIds() {
288282
" WITH personCuisines," +
289283
" [value in personCuisines WHERE value.name IN [\"Praveena\", \"Arya\"] | value.item ] AS sourceIds" +
290284
" CALL gds.alpha.similarity.cosine.stream({" +
291-
" nodeProjection: '*', " +
292-
" relationshipProjection: '*', " +
293285
" data: personCuisines, " +
294286
" sourceIds: sourceIds, " +
295287
" topK: 1" +
@@ -327,8 +319,6 @@ void embeddings() {
327319
" WITH {item:id(c), weights: c.embedding} AS userData" +
328320
" WITH collect(userData) AS data" +
329321
" CALL gds.alpha.similarity.cosine.stream({" +
330-
" nodeProjection: '*', " +
331-
" relationshipProjection: '*', " +
332322
" data: data," +
333323
" skipValue: null" +
334324
" })" +
@@ -371,8 +361,6 @@ void cypherProjection() {
371361
String query = " WITH 'MATCH (person:Person)-[likes:LIKES]->(c)" +
372362
" RETURN id(person) AS item, id(c) AS category, likes.score AS weight' AS query" +
373363
" CALL gds.alpha.similarity.cosine.write({" +
374-
" nodeProjection: '*', " +
375-
" relationshipProjection: '*', " +
376364
" data: query," +
377365
" graph: 'cypher'," +
378366
" topK: 1," +

alpha/alpha-proc/src/test/java/org/neo4j/graphalgo/similarity/EuclideanDocTest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ void stream() {
140140
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} AS userData" +
141141
" WITH collect(userData) AS data" +
142142
" CALL gds.alpha.similarity.euclidean.stream({" +
143-
" nodeProjection: '*', " +
144-
" relationshipProjection: '*', " +
145143
" data: data," +
146144
" topK: 0" +
147145
" })" +
@@ -176,8 +174,6 @@ void streamFinite() {
176174
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} as userData" +
177175
" WITH collect(userData) as data" +
178176
" CALL gds.alpha.similarity.euclidean.stream({" +
179-
" nodeProjection: '*', " +
180-
" relationshipProjection: '*', " +
181177
" data: data," +
182178
" topK: 0" +
183179
" })" +
@@ -212,8 +208,6 @@ void streamSimilarityCutoff()
212208
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} as userData" +
213209
" WITH collect(userData) as data" +
214210
" CALL gds.alpha.similarity.euclidean.stream({" +
215-
" nodeProjection: '*', " +
216-
" relationshipProjection: '*', " +
217211
" data: data," +
218212
" similarityCutoff: 4.0," +
219213
" topK: 0" +
@@ -244,8 +238,6 @@ void streamTopK()
244238
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} AS userData" +
245239
" WITH collect(userData) AS data" +
246240
" CALL gds.alpha.similarity.euclidean.stream({" +
247-
" nodeProjection: '*', " +
248-
" relationshipProjection: '*', " +
249241
" data: data," +
250242
" topK: 1" +
251243
" })" +
@@ -276,8 +268,6 @@ void write()
276268
" WITH {item:id(p), weights: collect(coalesce(likes.score, gds.util.NaN()))} AS userData" +
277269
" WITH collect(userData) AS data" +
278270
" CALL gds.alpha.similarity.euclidean.write({" +
279-
" nodeProjection: '*', " +
280-
" relationshipProjection: '*', " +
281271
" data: data," +
282272
" topK: 1" +
283273
" })" +
@@ -321,8 +311,6 @@ void sourceIds()
321311
" WITH personCuisines," +
322312
" [value IN personCuisines WHERE value.name IN ['Praveena', 'Arya'] | value.item ] AS sourceIds" +
323313
" CALL gds.alpha.similarity.euclidean.stream({" +
324-
" nodeProjection: '*', " +
325-
" relationshipProjection: '*', " +
326314
" data: personCuisines," +
327315
" sourceIds: sourceIds," +
328316
" topK: 1" +
@@ -362,8 +350,6 @@ void embeddings()
362350
" WITH {item:id(c), weights: c.embedding} AS userData" +
363351
" WITH collect(userData) AS data" +
364352
" CALL gds.alpha.similarity.euclidean.stream({" +
365-
" nodeProjection: '*', " +
366-
" relationshipProjection: '*', " +
367353
" data: data," +
368354
" skipValue: null" +
369355
" })" +
@@ -407,8 +393,6 @@ void cypherProjection() {
407393
" WITH \"MATCH (person:Person)-[likes:LIKES]->(c)\n" +
408394
" RETURN id(person) AS item, id(c) AS category, likes.score AS weight\" AS query" +
409395
" CALL gds.alpha.similarity.euclidean.write({" +
410-
" nodeProjection: '*', " +
411-
" relationshipProjection: '*', " +
412396
" data: query," +
413397
" graph: 'cypher'," +
414398
" topK: 1," +

alpha/alpha-proc/src/test/java/org/neo4j/graphalgo/similarity/OverlapDocTest.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void stream() {
9191
" MATCH (book:Book)-[:HAS_GENRE]->(genre) " +
9292
" WITH {item:id(genre), categories: collect(id(book))} AS userData " +
9393
" WITH collect(userData) AS data " +
94-
" CALL gds.alpha.similarity.overlap.stream({nodeProjection: '*', relationshipProjection: '*', data: data}) " +
94+
" CALL gds.alpha.similarity.overlap.stream({data: data}) " +
9595
" YIELD item1, item2, count1, count2, intersection, similarity " +
9696
" RETURN gds.util.asNode(item1).name AS from, gds.util.asNode(item2).name AS to, " +
9797
" count1, count2, intersection, similarity " +
@@ -120,8 +120,6 @@ void streamSimilarityCutoff()
120120
" WITH {item:id(genre), categories: collect(id(book))} as userData " +
121121
" WITH collect(userData) as data " +
122122
" CALL gds.alpha.similarity.overlap.stream({ " +
123-
" nodeProjection: '*', " +
124-
" relationshipProjection: '*', " +
125123
" data: data, " +
126124
" similarityCutoff: 0.75 " +
127125
" }) " +
@@ -151,8 +149,6 @@ void streamTopK()
151149
" WITH {item:id(genre), categories: collect(id(book))} as userData " +
152150
" WITH collect(userData) as data " +
153151
" CALL gds.alpha.similarity.overlap.stream({ " +
154-
" nodeProjection: '*', " +
155-
" relationshipProjection: '*', " +
156152
" data: data, " +
157153
" topK: 2 " +
158154
" }) " +
@@ -183,8 +179,6 @@ void write()
183179
" WITH {item:id(genre), categories: collect(id(book))} as userData " +
184180
" WITH collect(userData) as data " +
185181
" CALL gds.alpha.similarity.overlap.write({ " +
186-
" nodeProjection: '*', " +
187-
" relationshipProjection: '*', " +
188182
" data: data, " +
189183
" topK: 2, " +
190184
" similarityCutoff: 0.5 " +
@@ -227,8 +221,6 @@ void sourceIds()
227221
" WITH data, " +
228222
" [value in data WHERE value.name IN [\"Fantasy\", \"Classics\"] | value.item ] AS sourceIds " +
229223
" CALL gds.alpha.similarity.overlap.stream({ " +
230-
" nodeProjection: '*', " +
231-
" relationshipProjection: '*', " +
232224
" data: data, " +
233225
" sourceIds: sourceIds " +
234226
" }) " +

alpha/alpha-proc/src/test/java/org/neo4j/graphalgo/similarity/PearsonDocTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ void stream() {
147147
" WITH {item:id(p), weights: collect(coalesce(rated.score, gds.util.NaN()))} as userData" +
148148
" WITH collect(userData) as data" +
149149
" CALL gds.alpha.similarity.pearson.stream({" +
150-
" nodeProjection: '*', " +
151-
" relationshipProjection: '*', " +
152150
" data: data," +
153151
" topK: 0" +
154152
"})" +
@@ -182,8 +180,6 @@ void streamCutOff() {
182180
" WITH {item:id(p), weights: collect(coalesce(rated.score, gds.util.NaN()))} as userData" +
183181
" WITH collect(userData) as data" +
184182
" CALL gds.alpha.similarity.pearson.stream({" +
185-
" nodeProjection: '*', " +
186-
" relationshipProjection: '*', " +
187183
" data: data," +
188184
" similarityCutoff: 0.1," +
189185
" topK: 0" +
@@ -213,8 +209,6 @@ void streamTopK() {
213209
" WITH {item:id(p), weights: collect(coalesce(rated.score, gds.util.NaN()))} as userData" +
214210
" WITH collect(userData) as data" +
215211
" CALL gds.alpha.similarity.pearson.stream({" +
216-
" nodeProjection: '*', " +
217-
" relationshipProjection: '*', " +
218212
" data: data, " +
219213
" topK: 1, " +
220214
" similarityCutoff: 0.0" +
@@ -243,8 +237,6 @@ void write() {
243237
" WITH {item:id(p), weights: collect(coalesce(rated.score, gds.util.NaN()))} as userData" +
244238
" WITH collect(userData) as data" +
245239
" CALL gds.alpha.similarity.pearson.write({" +
246-
" nodeProjection: '*', " +
247-
" relationshipProjection: '*', " +
248240
" data: data," +
249241
" topK: 1, " +
250242
" similarityCutoff: 0.1 " +
@@ -285,8 +277,6 @@ void sourceIds() {
285277
" WITH personCuisines," +
286278
" [value in personCuisines WHERE value.name IN [\"Praveena\", \"Arya\"] | value.item ] AS sourceIds" +
287279
" CALL gds.alpha.similarity.pearson.stream({" +
288-
" nodeProjection: '*', " +
289-
" relationshipProjection: '*', " +
290280
" data: personCuisines, " +
291281
" sourceIds: sourceIds, " +
292282
" topK: 1" +
@@ -323,8 +313,6 @@ void embeddingGraph() {
323313
" WITH {item:id(m), weights: m.embedding} as userData" +
324314
" WITH collect(userData) as data" +
325315
" CALL gds.alpha.similarity.pearson.stream({" +
326-
" nodeProjection: '*', " +
327-
" relationshipProjection: '*', " +
328316
" data: data," +
329317
" skipValue: null," +
330318
" topK: 0" +
@@ -357,8 +345,6 @@ void cypherProjection() {
357345
String query = " WITH \"MATCH (person:Person)-[rated:RATED]->(c)" +
358346
" RETURN id(person) AS item, id(c) AS category, rated.score AS weight\" AS query" +
359347
" CALL gds.alpha.similarity.pearson.write({" +
360-
" nodeProjection: '*', " +
361-
" relationshipProjection: '*', " +
362348
" data: query," +
363349
" graph: 'cypher'," +
364350
" topK: 1," +

doc/asciidoc/algorithms/alpha/alpha-similarity-ann.adoc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ Otherwise a list of maps of the following structure: `{item: nodeId, weights: [d
4848
| p | Float | 0.5 | yes | Influences the sample size: `min(1.0, p) * \|topK\|`.
4949
| similarityCutoff | Integer | -1 | yes | The threshold for similarity. Values below this will not be returned.
5050
| degreeCutoff | Integer | 0 | yes | The threshold for the number of items in the `targets` list. If the list contains less than this amount, that node will be excluded from the calculation.
51-
| concurrency | Integer | 4 | yes | The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency' and 'writeConcurrency'.
52-
| readConcurrency | Integer | value of 'concurrency' | yes | The number of concurrent threads used for reading the graph.
51+
| concurrency | Integer | 4 | yes | The number of concurrent threads used for running the algorithm. Also provides the default value for 'writeConcurrency'.
5352
| writeConcurrency | Integer | value of 'concurrency' | yes | The number of concurrent threads used for writing the result.
5453
| writeBatchSize | Integer | 10000 | yes | The batch size to use when storing results.
5554
| writeRelationshipType | String | SIMILAR | yes | The relationship type to use when storing results.
@@ -99,11 +98,10 @@ Otherwise a list of maps of the following structure: `{item: nodeId, weights: [d
9998
| topK | Integer | 3 | yes | The number of similar values to return per node.
10099
| randomSeed | Integer | 1 | yes | The random-seed used for neighbor-sampling.
101100
| sampling | Boolean | true | yes | Whether the potential neighbors should be sampled.
102-
| p | Float | 0.5 | yes | Influences the sample size: `min(1.0, p) * |topK|`
101+
| p | Float | 0.5 | yes | Influences the sample size: `min(1.0, p) * \|topK\|`
103102
| similarityCutoff | Integer | -1 | yes | The threshold for similarity. Values below this will not be returned.
104103
| degreeCutoff | Integer | 0 | yes | The threshold for the number of items in the `targets` list. If the list contains less than this amount, that node will be excluded from the calculation.
105-
| concurrency | Integer | 4 | yes | The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency'.
106-
| readConcurrency | Integer | value of 'concurrency' | yes | The number of concurrent threads used for reading the graph.
104+
| concurrency | Integer | 4 | yes | The number of concurrent threads used for running the algorithm.
107105
|===
108106

109107
.Results
@@ -170,8 +168,6 @@ The corresponding k-Nearest Neighbors Graph can then be used as part of recommen
170168
WITH {item:id(p), categories: collect(id(cuisine))} AS userData
171169
WITH collect(userData) AS data
172170
CALL gds.alpha.ml.ann.stream({
173-
nodeProjection: '*',
174-
relationshipProjection: '*',
175171
data: data,
176172
algorithm: 'jaccard',
177173
similarityCutoff: 0.1,
@@ -212,8 +208,6 @@ We'd probably want to filter those out, which we can do by passing in the `simil
212208
WITH {item:id(p), categories: collect(id(cuisine))} AS userData
213209
WITH collect(userData) AS data
214210
CALL gds.alpha.ml.ann.write({
215-
nodeProjection: '*',
216-
relationshipProjection: '*',
217211
algorithm: 'jaccard',
218212
data: data,
219213
similarityCutoff: 0.1,

0 commit comments

Comments
 (0)