Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-16-2020 04:39 AM
Hi graphers,
i am a total noob at neo4j and this is my first post here ! I apologize in advance if i am not posting this in the right topic or with the appropriate terms and tags.
As a part of my Msc thesis on AI, i'm writing a python algorithm to use neo4j as a support system for machine learning processes. I am trying not to use the obvious path that is to export data in tabular format and use regular machine learning libraries like Keras or pyTorch. In this spirit i am trying to develop simple graph manipulations i will use to create my algorithm in the big picture.
I've already been able to create isolated graphs (not connected between themselves) in star like formations. with a central node thats connects to all the other nodes (now i have 35 peripheral nodes but i expected it to largely grow).
The central node is of Type "Perception_Group" and the peripheric nodes are of type "Perception". This last node has "name" and "value" (float) attributes. The "Perception_Group" only has a "date" attribute.
What i would like to understand is how can i compare every star graph with the rest of the star graphs in an efficient way using cypher. The comparison must not return a true or false for equality. The goal is to have a "likelihood" measurement based on the "Perception" nodes "value" attributes.
I have other questions, but will post them later, after getting feedback from you guys on how to post properly.
Thank you !
José Salvador
edit:
so far have came up with this cypher (yet not working as i need and a bit slow):
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE pg1.id = 20132
WITH pg1, p1
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
RETURN pg1,pg2,p1.name,p1.value,p2.name,p2.value,sum(abs(p1.value-p2.value))
Solved! Go to Solution.
05-16-2020 11:52 AM
For the comparaison, there are at least 2 options:
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE ID(pg1) = 20132
WITH pg1, p1
CALL apoc.cypher.run('
WITH $pg1 AS pg1, $p1 AS p1, $val AS val
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
WITH pg2, sum(abs(p1.value-p2.value)) AS difference
WHERE difference <= val
ORDER BY difference ASC', {pg1:pg1, p1:p1, val:10})
YIELD value
RETURN value.pg2 AS pg2, value.difference AS difference
OR
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE ID(pg1) = 20132
WITH pg1, p1
CALL apoc.cypher.run('
WITH $pg1 AS pg1, $p1 AS p1
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
RETURN pg2, sum(abs(p1.value-p2.value)) AS difference
ORDER BY difference ASC', {pg1:pg1, p1:p1})
YIELD value
WITH value.pg2 AS pg2, value.difference AS difference
WHERE difference <= 10
RETURN pg2, difference
You can replace 10 with what you want:)
05-16-2020 09:54 AM
Hello and welcome to the beautiful Neo4j world 🙂
If I understand your problem correctly, you want a Cypher query which could add the values of each Perception_Group and return a list with the Perception_Group id and their statistics that represents them and then use this result to make the likelihood measurement?
05-16-2020 10:09 AM
Hi Maxime, thanks for your reply. You got it. Except that the values are in the "Perception" Nodes. The "Perception_Group" is a central node that aggregates several "Perception" Nodes. I want to return the "Perception_Group" nodes that are linked to the "Perception" nodes that have the lower differences when compared to another set of "Perception" nodes also aggregated by a "Perception_Group" node.
I think i got it using this cypher:
// get nodes that are similar to a specific node
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE ID(pg1) = 20132
WITH pg1, p1
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
RETURN pg2,round(sum(abs(p1.value-p2.value))) as difference
ORDER BY difference ASC
Please tell me if i am doing anything wrong or can have some optimization.
05-16-2020 10:22 AM
If I don't misunderstand your Cypher request, you should put the second part of your request in this apoc procedure CALL apoc.cypher.run(fragment, params) yield value
(https://neo4j.com/docs/labs/apoc/current/cypher-execution/)
Your first 'WITH': WITH pg1, p1
is returning something like:
id, value
20132, 12
20132, 15
20132, 127
20132, 187
Or you want to compare each node? So the second part of your request should be like this:
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE ID(pg1) = 20132
WITH pg1, p1
CALL apoc.cypher.run('
WITH $pg1 AS pg1, $p1 AS p1
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
RETURN pg2, round(sum(abs(p1.value-p2.value))) AS difference ORDER BY difference ASC', {pg1:pg1, p1:p1})
YIELD value
RETURN value.pg2, value.difference
Don't forget to install APOC plugin on your database:)
05-16-2020 10:35 AM
Maxime, thanks for the tip.
Yes i want to compare each p1 "Perception" node connected to the node pg1 "Perception_Group" id = 20132 with p2 "Perception" nodes connected to pg2 "Perception_Group" as long as p1.name = p2.name.
Can you explain me the difference between using apoc to run the second part of the query and not using apoc ?
05-16-2020 10:40 AM
Yes, of course, this procedure will apply the Cypher request to each row of the previous request:
I retake the example, your first 'WITH': WITH pg1, p1
is returning something like:
id, value
20132, 12
20132, 15
20132, 127
20132, 187
So with this APOC procedure, the cypher request in it will be applied to each row of the result of the first WITH
, so in my example, it will be executed 4 times:)
05-16-2020 10:45 AM
I see now ! Thank you very much for the help Maxime. Can you help me in a last thing ? How do i compare aggregate function "sum" with a value and only have returned the nodes that pass the comparison ?
05-16-2020 10:50 AM
No problem:)
Can you give an example of the output of your request?
So you give the value to compare?
05-16-2020 11:26 AM
Sure Maxime, i will post an output here. Looking at apoc installation so i can send you an output.
05-16-2020 11:28 AM
No problem, do you use Neo4j Desktop or Neo4j Server?
05-16-2020 11:42 AM
I'm using Neo4j Desktop. Found the apoc install in manage > plugins
here is part of my output with this query
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE ID(pg1) = 20132
WITH pg1, p1
CALL apoc.cypher.run('
WITH $pg1 AS pg1, $p1 AS p1
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
RETURN pg2, round(sum(abs(p1.value-p2.value))) AS difference ORDER BY difference ASC', {pg1:pg1, p1:p1})
YIELD value
RETURN value.pg2, value.difference
value.pg2 | value.difference |
---|---|
{"id":"20095","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:24.549701"}} | 0.0 |
{"id":"20169","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:29.603277"}} | 0.0 |
{"id":"20206","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:21.513837"}} | 0.0 |
{"id":"20279","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:22.019647"}} | 0.0 |
{"id":"20316","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:26.568816"}} | 0.0 |
{"id":"20353","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.481929"}} | 0.0 |
{"id":"20390","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.978828"}} | 0.0 |
{"id":"20427","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.081917"}} | 0.0 |
{"id":"20464","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:30.091260"}} | 0.0 |
{"id":"20501","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:27.569511"}} | 0.0 |
{"id":"20538","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:23.537048"}} | 0.0 |
{"id":"20575","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:20.490064"}} | 0.0 |
{"id":"20612","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.592894"}} | 0.0 |
{"id":"20649","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.233649"}} | 0.0 |
{"id":"20690","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.246834"}} | 0.0 |
{"id":"20732","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:08.835851"}} | 0.0 |
{"id":"20774","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.748825"}} | 0.0 |
{"id":"20815","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:10.847765"}} | 0.0 |
{"id":"20857","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.200009"}} | 0.0 |
{"id":"20897","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:58.274311"}} | 0.0 |
{"id":"20939","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:06.317193"}} | 0.0 |
{"id":"20981","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.688463"}} | 0.0 |
{"id":"21021","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.743179"}} | 0.0 |
{"id":"21063","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:05.304956"}} | 0.0 |
{"id":"21104","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:00.775204"}} | 0.0 |
{"id":"21146","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.737990"}} | 0.0 |
{"id":"21187","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.254422"}} | 0.0 |
{"id":"21228","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:02.280656"}} | 0.0 |
{"id":"20095","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:24.549701"}} | 0.0 |
{"id":"20169","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:29.603277"}} | 0.0 |
{"id":"20206","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:21.513837"}} | 0.0 |
{"id":"20243","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:18.459334"}} | 0.0 |
{"id":"20279","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:22.019647"}} | 0.0 |
{"id":"20316","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:26.568816"}} | 0.0 |
05-16-2020 11:47 AM
Can you remove the round
? It's a bit weird in Cypher, you must first multiply and after round the result:)
05-16-2020 11:52 AM
Sure, took the round
value.pg2 | value.difference |
---|
|{"id":"20095","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:24.549701"}}|0.0|
|{"id":"20169","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:29.603277"}}|0.0|
|{"id":"20206","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:21.513837"}}|0.0|
|{"id":"20279","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:22.019647"}}|0.0|
|{"id":"20316","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:26.568816"}}|0.0|
|{"id":"20427","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.081917"}}|0.0|
|{"id":"20464","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:30.091260"}}|0.0|
|{"id":"20501","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:27.569511"}}|0.0|
|{"id":"20538","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:23.537048"}}|0.0|
|{"id":"20575","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:20.490064"}}|0.0|
|{"id":"20612","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.592894"}}|0.0|
|{"id":"20649","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.233649"}}|0.042545031344274564|
|{"id":"20690","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.246834"}}|0.042545031344274564|
|{"id":"20732","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:08.835851"}}|0.042545031344274564|
|{"id":"20774","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.748825"}}|0.042545031344274564|
|{"id":"20815","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:10.847765"}}|0.042545031344274564|
|{"id":"20857","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.200009"}}|0.042545031344274564|
|{"id":"20897","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:58.274311"}}|0.042545031344274564|
|{"id":"20939","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:06.317193"}}|0.042545031344274564|
|{"id":"20981","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.688463"}}|0.042545031344274564|
|{"id":"21021","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.743179"}}|0.042545031344274564|
|{"id":"21063","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:05.304956"}}|0.042545031344274564|
|{"id":"21104","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:00.775204"}}|0.042545031344274564|
|{"id":"21146","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.737990"}}|0.042545031344274564|
|{"id":"21187","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.254422"}}|0.042545031344274564|
|{"id":"21228","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:02.280656"}}|0.042545031344274564|
|{"id":"20390","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.978828"}}|0.10000000000000009|
|{"id":"20353","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.481929"}}|0.20000000000000007|
|{"id":"20206","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:21.513837"}}|2.6656310438077924E-5|
|{"id":"20575","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:20.490064"}}|3.100551009097008E-5|
|{"id":"20279","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:22.019647"}}|5.3370287190712684E-5|
|{"id":"20390","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.978828"}}|1.8358258195143307E-4|
|{"id":"20243","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:18.459334"}}|0.008551133034149672|
|{"id":"20353","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.481929"}}|0.008687547220908878|
|{"id":"20538","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:23.537048"}}|0.07780129372546173|
|{"id":"20095","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:24.549701"}}|0.07832544349879707|
|{"id":"20316","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:26.568816"}}|0.07881734422865662|
|{"id":"20501","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:27.569511"}}|0.07892215806603652|
|{"id":"20427","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.081917"}}|0.07895626008386748|
|{"id":"20612","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.592894"}}|0.07898208692178944|
|{"id":"20169","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:29.603277"}}|0.07901653330463797|
|{"id":"20464","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:30.091260"}}|0.07902788131664364|
|{"id":"21063","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:05.304956"}}|2.5446969132768706|
|{"id":"20939","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:06.317193"}}|2.5470468454364203|
|{"id":"20690","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.246834"}}|2.8409042837924128|
|{"id":"20774","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.748825"}}|2.8411682773046447|
|{"id":"21187","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.254422"}}|2.8415108331360823|
|{"id":"21146","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.737990"}}|2.8420907325966045|
|{"id":"20649","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.233649"}}|2.8427137662795667|
|{"id":"20732","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:08.835851"}}|2.858075119399255|
|{"id":"20897","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:58.274311"}}|2.9246340143444947|
|{"id":"21021","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.743179"}}|2.925595287082562|
|{"id":"20815","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:10.847765"}}|2.9265401139304412|
|{"id":"20981","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.688463"}}|2.9873337181090114|
|{"id":"21104","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:00.775204"}}|3.0271467531155674|
|{"id":"21228","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:02.280656"}}|3.027636566918324|
|{"id":"20857","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.200009"}}|3.1124638166056697|
|{"id":"20206","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:21.513837"}}|5.234343938675945E-5|
|{"id":"20575","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:20.490064"}}|5.289834295985063E-5|
|{"id":"20390","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.978828"}}|6.686117499166144E-5|
|{"id":"20279","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:22.019647"}}|1.0456201958009004E-4|
|{"id":"20353","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.481929"}}|6.628374507938739E-4|
|{"id":"20243","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:18.459334"}}|0.008897570793634957|
|{"id":"20464","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:30.091260"}}|0.027167230708835532|
|{"id":"20169","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:29.603277"}}|0.0272505583393734|
|{"id":"20612","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.592894"}}|0.02742281229951571|
|{"id":"20427","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:28.081917"}}|0.02751257693465292|
|{"id":"20501","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:27.569511"}}|0.02760556549629689|
|{"id":"20316","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:26.568816"}}|0.027804346629534127|
|{"id":"20095","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:24.549701"}}|0.02829713719484328|
|{"id":"20538","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:23.537048"}}|0.02860351670418626|
|{"id":"20857","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.200009"}}|0.4268185081487963|
|{"id":"20981","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.688463"}}|0.4345143868557879|
|{"id":"21146","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.737990"}}|0.46546036244159206|
|{"id":"20649","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.233649"}}|0.46553031961461677|
|{"id":"21187","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.254422"}}|0.4658225116166195|
|{"id":"20774","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.748825"}}|0.4659469560838323|
|{"id":"20690","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.246834"}}|0.46601114579621683|
|{"id":"21228","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:02.280656"}}|0.47621154247855824|
|{"id":"21104","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:00.775204"}}|0.47680577907278776|
|{"id":"20897","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:58.274311"}}|0.4776072878367983|
|{"id":"21021","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.743179"}}|0.4817358082098935|
|{"id":"20815","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:10.847765"}}|0.6727962998591157|
|{"id":"20939","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:06.317193"}}|0.6778355399882396|
|{"id":"21063","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:05.304956"}}|0.6788779860398249|
|{"id":"20732","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:08.835851"}}|0.6808771172199073|
|{"id":"20206","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:21.513837"}}|5.52183997948319E-6|
|{"id":"20279","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:22.019647"}}|1.1138528230425493E-5|
|{"id":"20575","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:20.490064"}}|1.1825634420592479E-5|
|{"id":"20390","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:19.978828"}}|1.9718035320437366E-4|
|{"id":"21063","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:05.304956"}}|2.403027491227956|
|{"id":"20939","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:06.317193"}}|2.4054353044516743|
|{"id":"20732","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:08.835851"}}|2.7196175556779227|
|{"id":"20815","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:10.847765"}}|2.7888665433281896|
|{"id":"20857","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.200009"}}|2.985413188349379|
|{"id":"21228","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:02.280656"}}|3.042149982972614|
|{"id":"21104","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:36:00.775204"}}|3.0426248525860244|
|{"id":"20981","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:43.688463"}}|3.1257739435723657|
|{"id":"21021","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.743179"}}|3.152324006365701|
|{"id":"20897","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:58.274311"}}|3.153410291611244|
|{"id":"20649","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.233649"}}|3.2393928817613653|
|{"id":"21146","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:51.737990"}}|3.2400814992283906|
|{"id":"21187","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.254422"}}|3.240890180087979|
|{"id":"20774","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:54.748825"}}|3.241294053954559|
|{"id":"20690","labels":["Perception_Group"],"properties":{"date":"2020-05-15 00:35:55.246834"}}|3.2416160221203163|
05-16-2020 11:54 AM
It's better no?
I gave you 2 options for the comparison on my last post 🙂
05-16-2020 11:52 AM
For the comparaison, there are at least 2 options:
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE ID(pg1) = 20132
WITH pg1, p1
CALL apoc.cypher.run('
WITH $pg1 AS pg1, $p1 AS p1, $val AS val
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
WITH pg2, sum(abs(p1.value-p2.value)) AS difference
WHERE difference <= val
ORDER BY difference ASC', {pg1:pg1, p1:p1, val:10})
YIELD value
RETURN value.pg2 AS pg2, value.difference AS difference
OR
MATCH (pg1:Perception_Group)-[r:RELATED]-(p1:Perception)
WHERE ID(pg1) = 20132
WITH pg1, p1
CALL apoc.cypher.run('
WITH $pg1 AS pg1, $p1 AS p1
MATCH (pg2:Perception_Group)-[:RELATED]-(p2:Perception)
WHERE pg1 <> pg2 AND p1.name = p2.name
RETURN pg2, sum(abs(p1.value-p2.value)) AS difference
ORDER BY difference ASC', {pg1:pg1, p1:p1})
YIELD value
WITH value.pg2 AS pg2, value.difference AS difference
WHERE difference <= 10
RETURN pg2, difference
You can replace 10 with what you want:)
05-16-2020 11:54 AM
Wonderful Maxime, you have been a big help !
05-16-2020 11:56 AM
No problem!
Regards,
Cobra
05-16-2020 11:57 AM
Done ! Cheers and have a very good weekend Maxime.
05-16-2020 11:58 AM
It was not the good post but it's fine:) Good weekend too:)
05-16-2020 11:59 AM
Sorry i did it wrong first and changed it after
05-16-2020 12:03 PM
Everything good, don't worry
All the sessions of the conference are now available online