I have the following SPARQL query that supposed to retrieve the common categroies between Category:Computer_science category and Category:German_scientists
SELECT DISTINCT ?subject WHERE {
?subject <http://purl.org/dc/terms/subject> ?cat1, ?cat2 .
?cat1 skos:broader? / skos:broader? / skos:broader?
<http://dbpedia.org/resource/Category:Computer_science> .
?cat2 skos:broader? / skos:broader? / skos:broader?
<http://dbpedia.org/resource/Category:German_scientists>.
} LIMIT 10
I need to get the closest category to them or who has the shortest path to both categories , How Can I do that ? How to get the lenght between each common categroy between (computer_science) and (German_scientists) for example ?