Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-19-2020 11:18 AM
Hello dear community,
I'm trying to construct a Cypher query, which returns a subgraph from a specific node with arbitrary depth. The only constraint is, that it shouldn't continue from or include any node with a certain label.
More specific in my example:
There is a specific node with label submission (let's call it x) and a few nodes {y} connected with direction to the submission node x. Now I want to get the whole subgraph of y while I don't want to have x or anything beyond it.
I have no information about node or edge labels which are included in the subgraph of y.
I tried the following:
match (x:submission)<--(y) where x.name="0A28VDC" call apoc.path.subgraphNodes(y, {labelFilter: "/submission"}) yield node return node,x,y
Problem: the labelfilter only returns subgraphs where the paths end at the node x. It would require something exluding submission and not searching beyond it, while including everything else. I couldn't find this functionality...
match (x:submission)--(y)-[ ]-(z) WHERE x.name="0A28VDC" AND NOT z:submission return x,y,z
Problem: somehow this query doesn't terminate, probably because any y and z continuously appear in the search again. The problem is, that the subgraph I want to return has connections of any direction...
Somebody maybe has an idea how to solve this?
I would be so happy for any answer!
Thank you and best wishes
Adrian
05-19-2020 02:17 PM
You may be able to use the blacklist filter symbol instead, so labelFilter:"-submission"
, that should exclude all :submission nodes from results.
Keep in mind that subgraphNodes() will only give you distinct nodes. It will not give you relationships. If you want relationships, you may want to use apoc.path.expandConfig()
instead, possibly with uniqueness:'RELATIONSHIP_GLOBAL'
, that should get all connected nodes and relationships.
All the sessions of the conference are now available online