Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-09-2021 11:10 AM
I'm didn't find a good and, at the same time, clean way to search complete paths that constains a specific node. The solution that I reach is giving me the following warning:
MATCH p = (...)-[...]-(...) WITH *, relationships(p) AS r1)
EXPLAIN MATCH p=(n1:WaterNode)-[r1:CONNECTED*]->(n:WaterNode{name:"Pisão", type:"Barragem"})-[r2:CONNECTED*]->(n2:WaterNode)
^
Solved! Go to Solution.
02-09-2021 04:39 PM
Hi @bmalbusca
Variables are only used for Where comparisons and returns.
If you don't use them, you don't need variables.
- gives all the link between 2 nodes
Yes
If the depth of the graph is predictable, it is best to write down the limit.
-[r1:CONNECTED*..30]->
02-09-2021 02:41 PM
Hi @bmalbusca
What variable do you want to return? All?
If all you want in the return value is p, then you don't need any other variables.
EXPLAIN MATCH p=(:WaterNode)-[:CONNECTED*]->(:WaterNode{name:"Pisão", type:"Barragem"})-[:CONNECTED*]->(:WaterNode)
02-09-2021 04:11 PM
Hello @koji , I'm trying to collect all paths p which uses the relation CONNECTED
and contains a specific node WaterNode{name:"Pisão", type:"Barragem
// Find all full paths that contains a specific water node
// Ex. name:"Pisão", type:"Barragem"
MATCH p=(n1:WaterNode)-[r1:CONNECTED*]->(n:WaterNode{name:"Pisão", type:"Barragem"})-[r2:CONNECTED*]->(n2:WaterNode)
RETURN collect(p)
I'm not sure about what i'm doing wrong when you say then you don't need any other variables.
.
I'm new with this, but *
gives all the link between 2 nodes, rigth? With (n1:WaterNode)-[r1:CONNECTED*]->(n:WaterNode{name:"Pisão", type:"Barragem"})
I'm getting all paths from back of the node and with (n:WaterNode{name:"Pisão", type:"Barragem"})-[r2:CONNECTED*]->(n2:WaterNode)
I'm getting all paths upfront.
Thank you
02-09-2021 04:39 PM
Hi @bmalbusca
Variables are only used for Where comparisons and returns.
If you don't use them, you don't need variables.
- gives all the link between 2 nodes
Yes
If the depth of the graph is predictable, it is best to write down the limit.
-[r1:CONNECTED*..30]->
All the sessions of the conference are now available online