Depth parameter in K-Shortest path queries

After more discussion internally with folks - depth parameter represents the level/depth of the tree when calculating from from the root node of the query. This means when specifying depth=k, the graph will be explored till depth=k starting from the root node and the shortest paths will be restricted to only those paths which have nodes that have been explored till the given depth.

More concretely for the first example:

We should get two paths 1. A-B-C-D-E-F-G-H-I-L and 2. A-R-Q-P-O-N-M-F-G-H-I-L

For the second example:

We should get the path: Alice - Manan - Naman - Bob - Tom - Mallory

Another edge case to note is in the following graph:
Screenshot from 2020-05-14 20-18-21
Below query would return only one path: Michone - Andrea - Bob - Alice because even though Matt gets discovered at depth=4 but Matt - Alice edge gets discovered only at depth=5

{ 
  var(func: eq(name, "Michone")){
   SOURCE as uid
  }
  var(func: eq(name, "Alice")){
   TARGET as uid
  }  

  path as shortest(from: uid(SOURCE), to: uid(TARGET), numpaths: 2, depth: 4) {
    friend
  }
  
   path(func: uid(path)) {
    name
   } 
}
2 Likes