[[rest-api-find-one-of-the-shortest-paths-between-nodes]]
=== Find one of the shortest paths between nodes ===

If no path algorithm is specified, a +ShortestPath+ algorithm with a max
depth of 1 will be chosen. In this example, the +max_depth+ is set to +3+
in order to find the shortest path between 3 linked nodes.


.Final Graph
["dot", "Final-Graph-Find-one-of-the-shortest-paths-between-nodes.svg", "neoviz"]
----
  N254 [
    label = "{Node\[254\]|name = \'f\'\l}"
  ]
  N254 -> N255 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N255 [
    label = "{Node\[255\]|name = \'g\'\l}"
  ]
  N256 [
    label = "{Node\[256\]|name = \'d\'\l}"
  ]
  N256 -> N257 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N256 -> N255 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N257 [
    label = "{Node\[257\]|name = \'e\'\l}"
  ]
  N257 -> N255 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N258 [
    label = "{Node\[258\]|name = \'b\'\l}"
  ]
  N258 -> N254 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N259 [
    label = "{Node\[259\]|name = \'c\'\l}"
  ]
  N259 -> N258 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N259 -> N254 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N259 -> N255 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N260 [
    label = "{Node\[260\]|name = \'a\'\l}"
  ]
  N260 -> N259 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N260 -> N256 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/node/260/path+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "to" : "http://localhost:7474/db/data/node/255",
  "max_depth" : 3,
  "relationships" : {
    "type" : "to",
    "direction" : "out"
  },
  "algorithm" : "shortestPath"
}
----


_Example response_

* *+200:+* +OK+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "start" : "http://localhost:7474/db/data/node/260",
  "nodes" : [ "http://localhost:7474/db/data/node/260", "http://localhost:7474/db/data/node/256", "http://localhost:7474/db/data/node/255" ],
  "length" : 2,
  "relationships" : [ "http://localhost:7474/db/data/relationship/137", "http://localhost:7474/db/data/relationship/143" ],
  "end" : "http://localhost:7474/db/data/node/255"
}
----


