cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Use of allSimplePaths and expandConfig

madiskou
Graph Buddy

Hello,
I have this two request with apoc :

CALL apoc.path.expandConfig(start, {
relationshipFilter: "A|B>",
labelFilter: "-C",
maxLevel: 6,
minLevel: 1,
uniqueness: 'NODE_PATH',
endNodes:[end]}) YIELD path
RETURN path;

it work perfectly but i have a case that the start and end is the same node.
what i want is to return the node in this case, is it possible ? i tried minLevel:0 but it doesn't return the node

I have an another possibility :

MATCH (from), (to)
CALL apoc.algo.allSimplePaths(from, to, 'A|B>', 10)
YIELD path
RETURN path 

This one work good, even with the case of from = to but i cannot filter the labels node like the first request (labelFilter: "-C").

My question is :
how can i get the only for the first request the start node if the start = end,
or, for the seconde how i can filter the labels ?

Thank you

4 REPLIES 4

madiskou
Graph Buddy

to resolve this i use :

CALL apoc.path.expandConfig(start, {
relationshipFilter: "A|B>",
labelFilter: "-C",
maxLevel: 6,
minLevel: 1,
uniqueness: 'NODE_PATH',
endNodes:[end]}) YIELD path
WITH path, start
unwind CASE WHEN length(path) IS NULL THEN [start] ELSE nodes(path) END as n
...

i don't know if we can configure apoc.path.expandConfig to return simple node

Hello @madiskou

Why do you mean by simple node?

Regards,
Cobra

simple node means that the start and the end nodes are the same

To answer your first question on apoc.path.expandConfig(), filtering isn't applied to start nodes by default, which is why your start node isn't returned as a result. You can toggle this on by adding filterStartNode:true in the config parameter map.

The documentation on that one could use an update. It specifically mentions label filters, and those predated the node filters (where we pass in the endNodes or terminatorNodes). Though not mentioned, the filterStarNode config property also applies to them.