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.

Pass results of a Query as parameters of cypher projection

Hi,

I'm wondering if it's possible pass results from a query in a graph algo apoc with a cypher projection.

Here a toy example

CALL algo.unionFind.stream("
                    with  [1,2,3,4] as nodes unwind nodes as nod
                    return  nod as id",
                    "with [{source:1, target:2},
                             {source:1, target:3}] as rels 
                     unwind rels as rel 
                     return rel.source as source,rel.target as target",
                     {graph:'cypher', iterations:20})
YIELD nodeId,setId
RETURN nodeId, setId

Pseudo code

WITH 
[1,2,3,4] as nodes,
[{source:1, target:2},
 {source:1, target:3}] as rels
CALL algo.unionFind.stream("
                    with  $nodes as nodes unwind nodes as nod
                    return  nod as id",
                    "with $rels as rels 
                     unwind rels as rel 
                     return rel.source as source,rel.target as target",
                     {graph:'cypher', iterations:20})
YIELD nodeId,setId
RETURN nodeId, setId

Thank you,
Nunzio

2 REPLIES 2

I also meeting this problem, are there any solutions for this ?

I was needing to do the same for algo.ShortestPath.astar.stream and I came across the solution in the Cypher Projection documentation.

For your case, it would look something like this:
{graph: 'cypher', params: {rels: rels, nodes: nodes}, iterations: 20}

Hope this helps!