I tried looking the SPARQL documentation but couldn't find anything that helps. This is what I need to do. (PathL is pathlength)
I need to do the same and am currently trying to do it with the toolkit by Filip Ilievski. Using the "Paths API" it should be possible to retrieve all possible path between two entities, and by increasing the hops
parameter step by step, you can get the minimum path distance.