How to report path length?

I would like to determine how semantically specific a MonDO disease is, using the distance from the disease root as a proxy.

Right now I'm doing

PREFIX rdfs: <>
PREFIX mydata: <>
PREFIX owl: <>
select *
where {
    graph <> {
            a owl:Class ;
            rdfs:subClassOf+ <> .
            rdfs:subClassOf* ?mid .

But the results look funny to me, like the number of ?mids could be the sum over multiple different (not necessarily shortest) paths.

I'd like to try the Stardog path notation, but I feel like I have seen at least two styles:


PATHS START ?x = :Alice END ?y = :Charlie VIA ?p


PATH ?p FROM ([startNode AS] ?s) TO ([endNode AS] ?e) {
[ORDER BY condition]
[LIMIT int]

Are both of these still functional?

Can either be used to report the lenght of the shortest path?

Hey Mark,

The syntax from the documentation is the supported syntax. The blog post was an initial version which was refined in the final design.

Regarding the path lengths, you can do this in the API with the Path result instances in the PathQueryResult. The size of the edges sequence is the length of the path.


Thanks. Does that mean I would have to write something in a JVM language to access it? Is there a REST API?

You will have to write a little bit of code to piece the paths back together. The general format is described in the thread PATHS queries via HTTP API?.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.