Hi there, Victor. It sounds like a K Shortest Path Query might suit your needs.
A as var(func: eq(name, "test1")) # Obtain uid of your starting node
B as var(func: eq(name, "test5")) # Obtain uid of your ending node
path as shortest(from: uid(A), to: uid(B)) {
next # Specifying the predicate(s) potentially traversed in your path
}
path(func: uid(path)) {
name
}
This is an adaptation of the examples provided in the documentation. You might also look at the docs to see if any of the optional arguments (numpaths and depth) or weighting of edge traversal by facet values are useful to you. Hope this helps.