Hello,
I was able to execute the following commands with no issues for small graph of size 100000 nodes:
CALL algo.closeness.stream(
'MATCH (n:alias) RETURN id(n) AS id',
"MATCH (n)--(m:alias) RETURN id(n) AS source, id(m) AS target",
{graph: "cypher"})
YIELD nodeId, centrality
WITH algo.asNode(nodeId) AS node, centrality AS centrality_stream
SET node.centrality = centrality_stream
CALL algo.closeness(
'MATCH (n:alias) RETURN id(n) AS id',
"MATCH (n)--(m:alias) RETURN id(n) AS source, id(m) AS target",
{graph:'cypher', direction: 'BOTH', write:true, writeProperty:'closeness.centrality'})
YIELD nodes,loadMillis, computeMillis, writeMillis;
with the first command running slightly faster than the second. For larger graph, I understand I could stream the results out and use the apoc periodic iterate to write the data back to the db:
CALL apoc.periodic.iterate(
"CALL algo.closeness.stream(
'MATCH (n:alias) RETURN id(n) AS id',
"MATCH (n)--(m:alias) RETURN id(n) AS source, id(m) AS target",
{graph: "cypher"})
YIELD nodeId, centrality",
"match (n) where id(n) = nodeId SET node.centrality = centrality", {batchSize:100})
YIELD batches, total, errorMessages
Can I do something similar with CALL algo.closeness
, especially if the graph instance is in a server with multiple CPUs (if I manage to achieve getting multiple CPUs for the instance) or AWS? What is the recommendation?
Thanks,
Lavanya