Graph path search algorithms such as Shortest Path and All Paths are not possible with the SPARQL standard's pattern-matching approach.
But Ontotext GraphDB has these algorithms (and much more) built in, so that you can call them from SPARQL queries.
This video shows how to use them and why they're useful.
Link to GraphDB documentation's "Graph path search" page: https://graphdb.ontotext.com/documentation/10.7/graph-path-search.html