I would like to determine the shortest length between the nodes and the nearest node linked to a "true" statment, and then CONSTRUCT new graph that represents the shortest length for each node. For instance (see picture below):
-----------------
| start | end |
=================
| :1 | :1 |
| :2 | :4 |
| :5 | :5 |
Also, if I have two properties, I would like to weight one property.
For instance, the "is similar to" property is priorized on "part of". If there is no answer with the first level of similar nodes (green), look at a higher level (orange) and then look for similar "true" nodes, then higher level (red) etc.
-----------------
| start | end |
=================
| :1 | :1 |
| :2 | :4 |
| :3 | :6 |
| :4 | :4 |
| :5 | :5 |
| :6 | :6 |
| :7 | :7 |
And now, if there is no solution through the first level, see the second level
-----------------
| start | end |
=================
| :1 | :6 |
| :3 | :6 |
| :6 | :6 |
| :7 | :7 |
Is it possible to get this result with one sparql request? For the moment, I used a quite long sparql<->python algorithm. I calculate the distance between nodes and keep the shortest lengh to create a new triple. It is clearly not optimized.