Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-26-2020 11:47 AM
Can nodes for each community (of Louvain/ LPA/ unionFind) and their relationships to individual nodes be created AT RUNTIME instead of assembling all of these after completion of the algorithm version that stores the communities on individual nodes "CALL algo.unionFind ... YIELD"? Is it better to create these community node creation in the stream version of the algorithms "CALL algo.unionFind.stream() ... YIELD"?
Here's what I am trying to optimize : replace the below set of two queries by one. possible?
// Find weakly connected components
CALL algo.unionFind('alias', 'co_authors', {graph:'huge', seedProperty:'GraphProperty_wcc_coauthors', write:true, writeProperty:'GraphProperty_wcc_coauthors'})
YIELD nodes AS Nodes, setCount AS NbrOfComponents, writeProperty AS PropertyName;
// Create a node for each community and connect each node to its community
CALL apoc.periodic.iterate(
"MATCH (n:alias) RETURN n",
"WITH n.GraphProperty_wcc_coauthors as component, COLLECT(n) as component_nodes
WITH component, component_nodes, size(component_nodes) as component_size
CREATE (comp :GraphProperty_wcc_coauthors {GraphProperty_component : component, GraphProperty_size : component_size})
WITH comp, component_nodes
UNWIND component_nodes as component_node
WITH comp, component_node
CREATE (comp) <-[:in_WCC_coauthors]- (component_node)", {batchSize:5000})
YIELD batches, total, errorMessages;
Thanks,
Lavanya
All the sessions of the conference are now available online