Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-05-2021 05:49 AM
Dear all,
Thanks to the brillliant request bellow, I'm able to add an ID to each nodes related to the network size where he belongs :
CALL gds.wcc.stream({
nodeProjection: "Entity",
relationshipProjection: "IRW"
})
YIELD nodeId, componentId
WITH componentId, collect(gds.util.asNode(nodeId).EntityID) AS libraries
WITH size(libraries) AS size, libraries
WITH size, apoc.coll.flatten(collect(libraries)) AS nodes_list
CALL apoc.periodic.iterate('
MATCH (n)
WHERE n.EntityID IN $nodes_list
RETURN n
', '
SET n.community_id = $community_id
', {batchSize:1000, params:{nodes_list:nodes_list, community_id:size}}) YIELD batch, operations
RETURN 1
In this case 2 nodes from 2 differnents networks could have the same id.
I would like to keed this ID related to the network size but I would also like to another ID related to the network components (Each network will have a unique ID)
So for each nodes, I will know the network size he belongs and the networks ID he belongs too.
What should I add in this request or should I run another request that will add this ID ?
Thanks in advance !
11-07-2021 11:42 AM
Hi @1113 !
You already have an ID that works as network ID... The communityId.
So:
CALL gds.wcc.stream({
nodeProjection: "Entity",
relationshipProjection: "IRW"
})
YIELD nodeId, componentId
WITH componentId, collect(nodeId) AS libraries
WITH componentId, size(libraries) AS size, libraries
UNWIND libraries as nodeId
MATCH (n)
WHERE id(n) = nodeId
SET n.community_id = componentId,
n.community_size = size
Bennu
12-14-2021 08:08 AM
Hi,
Sorry for the late feedback and thank you very much for your answer !
All the best !
All the sessions of the conference are now available online