Calculating shortest path using average or multiplication of facets

The built-in shortest function calculates best path using weights by adding the weight, but I need a query for calculating best path by multiplying or average of edges. I was wondering if there is an easier way instead of traversing all edges.

Hello @Ali_Sayyadi and welcome to Dgraph Community

As far as I know dgraph uses the Dijkstra Algorithm to calculate shortest path and it does not support what you mentioned.

So you think that i should consider another way?
Is there anyway so I can pass an lambda function to shortest path?

I’m afraid passing a lambda function to shortest path function would not work. The only way that comes to my mind is having a lambda resolver that uses k-shortest path and then custom recalculation for these paths. There are two serious problem with this approach:
1- Performance: As a result of running k-shortest path and custom calculation
2- Wrong Answers: It is feasible that the final path that you are looking for is not between these k-shortest paths you found(This could happen if there is a significant difference between weights).