cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Pass results of a Query as parameters of cypher projection

zunio
Node

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

harvey_nguyen
Node Clone

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

howie_limu
Node Link

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!