Crafting a shortest path to a specific type of relationship

Hi,
Data is in and now the fun stuff. Doing a query that is pretty hard in relational database.

My question is about getting the shortest path on a constrained pathway.
The use case case here is patents. I have one patent that is linked to another as prior art and I have created the relationship as such (the '731 is citing the '854 in patent speak). and this relationship is clearly the shortest path. There are a second set of linkages in green the are the classification codes. The classification codes in themselves also have linkages - basically a tree hierarchy. What I am interested in is finding the highest order linkage (closest branching point). The classification nodes have a label that indicates the branching level. The closest ones in this example are 14 and the meeting point is level 13. The overall path is the pink line I added to show the goal.
The relationship between patent classification code is called Is_classified and within the classification codes the relationship is called child_of.

How would I go about crafting this query? There is a follow on in that are often many classifications for each patent so I will be interested in the whole range of paths. Note: any two codes may not have a path.

A bit an aggressive problem for a newbie, but that's how I roll (fall, stumble,....)
Andy

Hi,

Made some progress using this query
MATCH p=(a)-[r*1..5]-(b)
WHERE a.PatNum='7037854'AND b.PatNum='9381731' AND NONE (rel in r WHERE type(rel)='Reads_On' )
Return p

Query

The result still shows the Reads_On relationship (the pink line that says 'applicant').
How would I feed this into a shortest path algorithm.
EDIT: (I figured out how to exclude the Assigned_To relationship also).

Andy

If you want to ensure you don't return paths of a single relationship connecting the two nodes, you can increase the lower bound of your var-length pattern to 2 instead of 1, that ensures that there should always be a node between the two.

As far as finding the shortest path, if you don't need to consider weights, you can just use the shortestPath() in your MATCH, providing the restrictions in your WHERE clause.

1 Like