Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-13-2020 10:33 PM
Hi
i have read trough this
" ```
Match (a {name:"_AdminOrg"})-[r*1..3]->(b) Return Distinct
a, r, b "
but i have also read that the syntax "...*1..3" should not be used anymore:
so I came up with the following query
MATCH p = (n {name: "_AdminOrg"})-[r]-(m) return DISTINCT n, labels(n), relationships(p) AS r, type(r), m, labels(m);
I really appreciate your help.
rob
11-14-2020 12:34 PM
Try this:
MATCH (c:A{ID:'123'})
CALL apoc.path.spanningTree(c, {maxLevel:3}) YIELD path
RETURN path
Change the level number to suit your query.
11-14-2020 10:52 PM
cool thanks i will !
11-23-2020 04:05 AM
I have this query at the moment
Match (n: process {guid: "96e7f3fe-cfa9-490c-9913-d288f738f76a"}) CALL apoc.path.spanningTree(n, {labelFilter: "status", relationshipFilter: "next_status|current_status", maxLevel: "3"}) YIELD path RETURN labels(n), path;
with labels(n) i can see the label of the source node
Thanks for the answeres and your help!
rob
11-23-2020 04:14 AM
OHH it is easy ...
Match ((n: process {guid: "96e7f3fe-cfa9-490c-9913-d288f738f76a"})-[r]-(m)) CALL apoc.path.spanningTree(n, {labelFilter: "status", relationshipFilter: "next_status|current_status", maxLevel: "3"}) YIELD path RETURN labels(n), path, type(r), labels(m);
or is this a stupied way to do?
11-23-2020 09:30 AM
WITH nodes(path) as n1, relationships(path) as rels
UNWIND n1 as n11
UNWIND rels as r1
RETURN labels(n11) as lbl, type(r1) as rel
11-16-2020 07:43 AM
Don't worry about that deprecated warning, we don't have any replacement for that feature, and it won't be removed until we have such a replacement. You can keep using a variable on a variable-length rel pattern.
That said, with a path variable (like your p
), we can do what we need.
Also keep in mind that getting distinct node results (as in the apoc spanningTree() call) will not include any results where a different relationship is used to reach an already-visited node. You'll have to determine yourself what's more important for results, or if your results need to have their format changed.
11-24-2020 12:33 AM
Wow - Thank you - This works!
MATCH (n: process {guid: "44b77af0-3b7e-4ce7-b74f-e967007cfdf8"})
CALL apoc.path.spanningTree(n, {maxLevel:3}) YIELD path WITH nodes(path) as nodes, relationships(path) as relationships
UNWIND nodes as nodesrow
UNWIND relationships as relationshipsrow
RETURN nodesrow as Node, labels(nodesrow) as Nodetype, relationshipsrow AS Relationship,type(relationshipsrow) AS RelationshipType
But is ther a way to Acess the NEXT element in the Row aswell? So i HAve access to the Left and the right Node of a relationship?
MATCH (n: process {guid: "44b77af0-3b7e-4ce7-b74f-e967007cfdf8"})
CALL apoc.path.spanningTree(n, {maxLevel:3}) YIELD path WITH nodes(path) as nodes, relationships(path) as relationships
UNWIND nodes as nodesrow
UNWIND relationships as relationshipsrow
RETURN nodesrow as LeftNode, labels(nodesrow) as LeftNodetype, relationshipsrow AS Relationship,type(relationshipsrow) AS RelationshipType, **nodesrow[1] as
RightNode , labels(nodesrow[1]) as RightNodetype**
This would help me a lot !
thansk rob
11-24-2020 03:34 AM
I also do the following DISTINCT at the moment to get less data
Match (n: process {guid: "5faacb1f-bf87-45a6-92fd-0ae735f74eee"})-[r]-(m) CALL apoc.path.spanningTree(n, {labelFilter: "status", relationshipFilter: "start_status|next_status|current_status", maxLevel: "4"}) YIELD path WITH nodes(path) as nodes, relationships(path) as relationships UNWIND nodes as nodesrow UNWIND relationships as relationshipsrow RETURN Distinct(nodesrow+labels(nodesrow)+relationshipsrow+type(relationshipsrow));
is this ok?
All the sessions of the conference are now available online