title: Keep the nearest length between nodes
body: <p>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):</p>
  
  <pre><code>-----------------
  | start | end   |
  =================
  | :1    | :1    |
  | :2    | :4    |
  | :5    | :5    |
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/a2vNb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a2vNb.png" alt="nodes"></a></p>
  
  <p>Also, if I have two properties, I would like to weight one property.</p>
  
  <p>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.</p>
  
  <pre><code>-----------------
  | start | end   |
  =================
  | :1    | :1    |
  | :2    | :4    |
  | :3    | :6    |
  | :4    | :4    |
  | :5    | :5    |
  | :6    | :6    |
  | :7    | :7    |
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hagox.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hagox.png" alt="enter image description here"></a></p>
  
  <p>And now, if there is no solution through the first level, see the second level
  <a href="https://i.stack.imgur.com/a5iLg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a5iLg.png" alt="enter image description here"></a></p>
  
  <pre><code>-----------------
  | start | end   |
  =================
  | :1    | :6    |
  | :3    | :6    |
  | :6    | :6    |
  | :7    | :7    |
  </code></pre>
  
  <p>Is it possible to get this result with one sparql request?
  For the moment, I used a quite long sparql&lt;->python algorithm. I calculate the distance between nodes and keep the shortest lengh to create a new triple. It is clearly not optimized.</p>