cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Running Graph Algorithms on connected components via cypher projections

Hi! I am rewriting some of my queries using graph algos to run only on some components. While I run the original query on node-label and relationship-type projection: example

CALL algo.beta.louvain('alias', 'through_citations', {graph: 'huge', 
 weightProperty: 'weight', direction : 'OUTGOING', seedProperty: 'GraphProperty_louvain_throughCitations', writeProperty: 'GraphProperty_louvain_throughCitations'
})YIELD loadMillis, computeMillis, writeMillis;

running for some specific components run on cypher:

 CALL apoc.periodic.iterate("
MATCH (a:alias) 
WHERE a.found_person_via_bulk_update = FALSE 
RETURN a.GraphProperty_wcc_throughCitations AS component",  
"
WITH DISTINCT component AS component
CALL algo.beta.louvain(
'MATCH (n:alias {GraphProperty_wcc_throughCitations : $component}) RETURN id(n) AS id',
'MATCH (n)-[r:through_citations]-(m:alias) RETURN id(n) AS source, id(m) AS target, r.weight as weight', 
 	{graph:'cypher', 
 	params: {component: component}, 
 	weightProperty: 'weight', 
 	direction : 'OUTGOING', 
 	seedProperty: 'GraphProperty_louvain_throughCitations', 
 	writeProperty: 'GraphProperty_louvain_throughCitations'})
YIELD nodes, loadMillis, computeMillis, writeMillis
RETURN nodes,loadMillis, computeMillis, writeMillis", {batchSize:5000, iterateList:true});    

Will this later code experience slow downs because it is on cypher projections. If so, for how large components? Thanks

1 REPLY 1

I think I found a solution to avoid cypher projections while subsetting a graph and running graph algos:

  1. Set the nodes and edges in the components of interest with a new label
  2. Run the graph algos with huge graph projection (instead of cypher projection)
  3. Drop the new label

@alicia.frame @andrew.bowman could you comment on this approach? Also, if this strategy is already implemented within graph algos library - I do not want to re-invent the wheel. Thanks.