Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-07-2018 07:36 AM
I started by uploading my database and then I set the weight for all relationships by running this query :
match (a:Attributaires)--(h:Attributaires)
with a, count(h) as AttributaireCount
match (a)-[r]-()
set r.weight = AttributaireCount
Now I want to regroup/put in clusters , all '"Attributaires" that have the same relationships' weight .
How can I make this ? thanks in advance everyone 🙂
Solved! Go to Solution.
11-07-2018 08:57 AM
If i understand correctly from you are trying to find groups of nodes that have the same number of relationships.
I don't know how you want them returned but here is a simple query that would return that stream results:
MATCH (a:Attributaires)
WITH a, size((a)--()) as number_of_rels
RETURN number_of_rels,collect(a) as members
If you want to write back results in the graph you could do:
MATCH (a:Attributaires)
WITH a, size((a)--()) as number_of_rels
MERGE (cluster:Cluster{size: number_of_rels})
MERGE (a)-[:PART_OF]->(cluster)
11-07-2018 08:57 AM
If i understand correctly from you are trying to find groups of nodes that have the same number of relationships.
I don't know how you want them returned but here is a simple query that would return that stream results:
MATCH (a:Attributaires)
WITH a, size((a)--()) as number_of_rels
RETURN number_of_rels,collect(a) as members
If you want to write back results in the graph you could do:
MATCH (a:Attributaires)
WITH a, size((a)--()) as number_of_rels
MERGE (cluster:Cluster{size: number_of_rels})
MERGE (a)-[:PART_OF]->(cluster)
All the sessions of the conference are now available online