Objective: Find the minimum and maximum relationship lengths between two Node Types.
Example: Following are the dummy connections for a Node type 'T'
(Aplha)-->(Bravo)
(Bravo)-->(Charlie)
So the minimum hops to reach two nodes is 1 (i.e. Aplha is directly linked to Charlie), and the maximum hops to reach two nodes is 2 (i.e. (Aplha)--(Beta)--(Charlie)).
Query I have is like:
g.V().hasLabel("Process").as("from", "to")
.repeat(both().as("to").dedup("from", "to")).emit(hasLabel("Process"))
.hasLabel("Process")
// I was unable to get only min and max, using both min and max did not work so I made a work-around (.as("len").max().dedup())
.select(all, "to").count(local).as("count").math("count - 1").as("len").dedup()
This is pretty slow as compared to using NEO4J APOC as in this solution
Is there any way to achieve this operations is a faster way?
Solutions I CANNOT use:
Limit relationship length: I have to use it at n levels, so cannot limit it to 3 or 4 levels.