I am using Neo4j randomWalk algorithm on a base 2 types of nodes (N1 and N2) and one type of relationship (R1). The random walk algorithm returns a list of NodeId. The issue here is that I'd like to get the relationships R1 between the nodes of each path.
I've tried the following query :
MATCH (n:N1) WHERE ID(n) = 38
CALL algo.randomWalk.stream(ID(n), 4, 4)
YIELD nodeIds
UNWIND nodeIds as nodeId
OPTIONAL MATCH (l:N1)-[r:R1]-(q:N2)
WHERE (ID(l) = nodeId) AND (ID(q) in nodeIds)
RETURN l,q, nodeIds, nodeId,ID(q), ID(l)
However, this is not a good solution cause it is showing every relationships between node l
and node q
that are present in nodeIds. Hence I don't get the path.
Do you know how could I solve this problem?
Thanks for your time, Syndorik