APOC.Path.export and avoiding circular paths

I have a query with APOC.PATH.EXPORT but I need to exclude recurring nodes.

I do not directly see the option in the export function.

Is my only option to use dependencies?

Koen_Algoet_0-1661858810103.png

Did you mean apoc.path,expand instead of export, as that is what is shown in your screenshot? If so, the expandConfig procedure has a uniqueness option, which can specify 'unique nodes' or 'unique relationships.' Sounds like you want to set this option to node to remove the duplicate node.

Another options is to use the following predicate to identify if a list does not have duplicate entries. The 'all' predicate will return true if 'list' does not contain duplicates, false otherwise.

with [1, 2, 3, 4, 2] as list
return all(x in list where size([i in list where i = x | 1])=1)

Or, since you are using apoc, you can try this instead:

RETURN size(apoc.coll.duplicates([1, 2, 3, 4, 2])) = 0

Need to check the result in detail but looks like using coll.duplicates did the trick! THANKS

Still wondering what the uniqueness parameter does and how to use it.

MATCH (n:Connection )

CALL apoc.path.expandConfig(n, {

relationshipFilter:"CanHighbenzeenBoardBoard>", minLevel:1, maxLevel:12,labelFilter:"/Connection"

})

YIELD path

WITH ([n IN nodes(path) | n.Name] ) AS PathNodes

where Size(apoc.coll.duplicates(PathNodes))=0

RETURN PathNodes

I'm trying to use uniqueness="NODE_GLOBAL" but no success.

Still have paths like ["V5.3", "HB-V5", "V5.3"] .

My paths are nodes with pipelines; So need to avoid circular paths.

MATCH (n:Connection )

CALL apoc.path.expandConfig(n, {

relationshipFilter:"CanHighbenzeenBoardBoard>", minLevel:1, maxLevel:12,uniqueness:"NODE_GLOBAL" ,labelFilter:"/Connection"

})

YIELD path

WITH ([n IN nodes(path) | n.Name] ) AS PathNodes

RETURN PathNodes