I need to show the tree structure of a data stored in a triple store (Stardog). I can get all sub-classes of a specific class via rdfs:subClassOf+, but it does not tell me the level/depth of each sub-class. Also I can get parent of each sub-class, but still I need to process the result to get the tree. This is the SPARQL query that I use:
SELECT DISTINCT subClass ?parent
WHERE {
?subClass rdfs:subClassOf+ <A Class URI> .
?subClass rdfs:subClassOf ?parent
}
Does anybody know a better way of doing this by SPARQL query?