I'm looking for an efficient way to do injective matching in Neo4j. If you're not sure what I mean by that; I simply want matches to be returned where every returned node in a match is unique (e.g. has a unique ID), and the same holds for paths.
Using the diagram from Wikipedia (above), the domain, X, of matching is the nodes and paths in the pattern, and the co-domain, Y, is the Database's internal Graph. The above diagram is injective as no 2 arrows from X point to the same element in Y (so no 2 nodes from the pattern are matched to the same node in the Graph, and the same holds for edges), whereas default Neo4J matching is non-injective and allows 2 nodes from the pattern to be matched to the same node in the Graph (you can visualise an example of non-injective matching as the arrows from 1 and 2 in X both pointing to D in Y in the above diagram). Conventional Graph Theory would call matching multiple items from the domain X to the same item in the co-domain Y "merging", but I can appreciate that that terminology may be confusing in this context.
I can simulate this for specific queries by specifying that matched nodes are distinct:
match (a), (b) where not id(a) = id(b) return a, b
But I want to do it in a general sense without having to be this explicit in every query. So for this example I would like to return matches where (a) and (b) are unique nodes but I would like to do this with some general behaviour rather than specifying the uniqueness based on ID.
It does seem that paths are already guaranteed to be unique when I query, but if someone could confirm that that would be great.