[[rest-api-find-all-shortest-paths]]
=== Find all shortest paths ===

The +shortestPath+ algorithm can find multiple paths between the same
nodes, like in this example.


.Final Graph
["dot", "Final-Graph-Find-all-shortest-paths.svg", "neoviz"]
----
  N0 [
    label = "{Node\[0\]|}"
  ]
  N10 [
    label = "{Node\[10\]|name = \'f\'\l}"
  ]
  N10 -> N11 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N11 [
    label = "{Node\[11\]|name = \'g\'\l}"
  ]
  N12 [
    label = "{Node\[12\]|name = \'d\'\l}"
  ]
  N12 -> N13 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N12 -> N11 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N13 [
    label = "{Node\[13\]|name = \'e\'\l}"
  ]
  N13 -> N11 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N14 [
    label = "{Node\[14\]|name = \'b\'\l}"
  ]
  N14 -> N10 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N15 [
    label = "{Node\[15\]|name = \'c\'\l}"
  ]
  N15 -> N14 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N15 -> N10 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N15 -> N11 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N16 [
    label = "{Node\[16\]|name = \'a\'\l}"
  ]
  N16 -> N15 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N16 -> N12 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/node/16/paths+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "to" : "http://localhost:7474/db/data/node/11",
  "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/16",
  "nodes" : [ "http://localhost:7474/db/data/node/16", "http://localhost:7474/db/data/node/12", "http://localhost:7474/db/data/node/11" ],
  "length" : 2,
  "relationships" : [ "http://localhost:7474/db/data/relationship/1", "http://localhost:7474/db/data/relationship/7" ],
  "end" : "http://localhost:7474/db/data/node/11"
}, {
  "start" : "http://localhost:7474/db/data/node/16",
  "nodes" : [ "http://localhost:7474/db/data/node/16", "http://localhost:7474/db/data/node/15", "http://localhost:7474/db/data/node/11" ],
  "length" : 2,
  "relationships" : [ "http://localhost:7474/db/data/relationship/0", "http://localhost:7474/db/data/relationship/9" ],
  "end" : "http://localhost:7474/db/data/node/11"
} ]
----


