# How to report path length?

**URL:** https://community.stardog.com/t/how-to-report-path-length/2137
**Category:** Support
**Created:** [December 6, 2019, 11:44pm UTC](https://community.stardog.com/t/how-to-report-path-length/2137 "2019-12-06T23:44:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mamillerpa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/mamillerpa/32/515_2.png) [@mamillerpa](https://community.stardog.com/u/mamillerpa)
#### Post date: [December 6, 2019, 11:44pm UTC](https://community.stardog.com/t/how-to-report-path-length/2137/1 "2019-12-06T23:44:59Z")

</div>

I would like to determine how semantically specific a [MonDO](http://www.ontobee.org/ontology/MONDO) disease is, using the distance from the [disease root](http://purl.obolibrary.org/obo/MONDO_0000001) as a proxy.

Right now I'm doing

```SPARQL
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX mydata: <http://example.com/resource/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
select *
where {
    graph <http://purl.obolibrary.org/obo/mondo.owl> {
        ?mid 
            a owl:Class ;
            rdfs:subClassOf+ <http://purl.obolibrary.org/obo/MONDO_0000001> .
        ?leaf 
            rdfs:subClassOf* ?mid .
        filter(isuri(?mid))
    }
}

```

But the results look funny to me, like the number of `?mid`s 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:

### from [Home | Stardog Documentation Latest](https://www.stardog.com/docs/#_path_queries)

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

### from [A Path of Our Own | Stardog](https://www.stardog.com/blog/a-path-of-our-own/)

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

```

Are both of these still functional?

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

---

<div class="post-metadata">

### Author: ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)
#### Post date: [December 6, 2019, 11:55pm UTC](https://community.stardog.com/t/how-to-report-path-length/2137/2 "2019-12-06T23:55:12Z")

</div>

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`](https://www.stardog.com/docs/java/snarl/com/complexible/common/rdf/query/path) result instances in the [`PathQueryResult`](https://www.stardog.com/docs/java/snarl/com/complexible/common/rdf/query/pathqueryresult). The size of the edges sequence is the length of the path.

Jess

---

<div class="post-metadata">

### Author: ![mamillerpa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/mamillerpa/32/515_2.png) [@mamillerpa](https://community.stardog.com/u/mamillerpa)
#### Post date: [December 6, 2019, 11:58pm UTC](https://community.stardog.com/t/how-to-report-path-length/2137/3 "2019-12-06T23:58:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)
#### Post date: [December 7, 2019, 12:04am UTC](https://community.stardog.com/t/how-to-report-path-length/2137/4 "2019-12-07T00:04:21Z")

</div>

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? - #2 by pavel](https://community.stardog.com/t/paths-queries-via-http-api/852/2).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [December 21, 2019, 12:04am UTC](https://community.stardog.com/t/how-to-report-path-length/2137/5 "2019-12-21T00:04:23Z")

</div>

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