Relationship uniqueness for QPP on relationships

Hi everyone,

I have the following query:

MATCH (parent:CI)<-[r:HAS_PARENT]-+(child:CI)
WITH DISTINCT(r), parent, child
WHERE ((apoc.bitwise.op(parent.consumerTag,">>",1) % 2 = 1 AND parent.consumerTag % 2 = 1) OR ( (apoc.bitwise.op(parent.consumerTag,">>",9) % 2 = 1))) AND (((apoc.bitwise.op(child.consumerTag,">>",1) % 2 = 1 AND child.consumerTag % 2 = 1) OR ( (apoc.bitwise.op(child.consumerTag,">>",9) % 2 = 1)))) 
MERGE (parent)<-[:HAS_PARENT_CUS]-(child)

which is basically trying to introduce a new relationship between the tagged parent and child while skipping the ones that are not tagged (in the path). This query produces this resultset for the following cases:

The question relies on how to make the query behave as unique for those paths that already traverses and then produce some result as the following image:

Would something like this be even feasible without having some programming layer at all or not really?

What makes the crossed out paths wrong, as they meet the criteria between the parent and child?

Also, wouldn’t it be easier to use actual properties to describe each node instead encoding information into bits of a number?

Well more than being wrong is what is expected to be achieved. Basically when the path is traversed once, and there exists already a connection between two tagged nodes (consumerTag = 7) then to stop there and not link the root node to the last node.

True that, when consumerTag = 7 the new relationship needs to be created, while when there is a consumerTag = 2 (in between) that nodes has to be skipped.

So, 7 - 7 (direct connection) while 7 - 2 - 7 (the new relation has to be from 7 - 7).