[[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"]
----
  N247 [
    label = "{Node\[247\]|name = \'f\'\l}"
  ]
  N247 -> N248 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N248 [
    label = "{Node\[248\]|name = \'g\'\l}"
  ]
  N249 [
    label = "{Node\[249\]|name = \'d\'\l}"
  ]
  N249 -> N250 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N249 -> N248 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N250 [
    label = "{Node\[250\]|name = \'e\'\l}"
  ]
  N250 -> N248 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N251 [
    label = "{Node\[251\]|name = \'b\'\l}"
  ]
  N251 -> N247 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N252 [
    label = "{Node\[252\]|name = \'c\'\l}"
  ]
  N252 -> N251 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N252 -> N247 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N252 -> N248 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N253 [
    label = "{Node\[253\]|name = \'a\'\l}"
  ]
  N253 -> N252 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
  N253 -> N249 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\n"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/node/253/paths+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "to" : "http://localhost:7474/db/data/node/248",
  "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/253",
  "nodes" : [ "http://localhost:7474/db/data/node/253", "http://localhost:7474/db/data/node/252", "http://localhost:7474/db/data/node/248" ],
  "length" : 2,
  "relationships" : [ "http://localhost:7474/db/data/relationship/126", "http://localhost:7474/db/data/relationship/135" ],
  "end" : "http://localhost:7474/db/data/node/248"
}, {
  "start" : "http://localhost:7474/db/data/node/253",
  "nodes" : [ "http://localhost:7474/db/data/node/253", "http://localhost:7474/db/data/node/249", "http://localhost:7474/db/data/node/248" ],
  "length" : 2,
  "relationships" : [ "http://localhost:7474/db/data/relationship/127", "http://localhost:7474/db/data/relationship/133" ],
  "end" : "http://localhost:7474/db/data/node/248"
} ]
----


