I am using neo4j.rb in my rails application.
I already have two nodes n1 and n2 retrieved from the database.
Now i need to check if they have a path between them, i was thinking of using cypher queries using Neo4j::Session.query
But since i already have the two nodes i do not want to retrieve them again inside the query,(does it affect performance?) is there a way to do it?
I know i can use query1 = n1.query_as(:node1) and use it as the node identifier but how can i introduce n2 within the same query object so that i can check connectivity between them.
I want something equivalent to the query
RETURN
CASE
WHEN node1-[*..6]-node2
THEN 'Connected within 6 nodes'
ELSE 'Not connected within 6'
END
Where i already have node1 and node2.
Is a way to do this and also can this be done without using the CYPHER DSL?