[[rest-api-execute-a-dijkstra-algorithm-with-weights-on-relationships]]
=== Execute a Dijkstra algorithm with weights on relationships ===

.Final Graph
["dot", "Final-Graph-Execute-a-Dijkstra-algorithm-with-weights-on-relationships.svg", "neoviz"]
----
  N24 [
    label = "{Node\[24\]|name = \'f\'\l}"
  ]
  N25 [
    label = "{Node\[25\]|name = \'d\'\l}"
  ]
  N25 -> N32 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 3.0\l"
  ]
  N25 -> N26 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N26 [
    label = "{Node\[26\]|name = \'e\'\l}"
  ]
  N26 -> N32 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N26 -> N24 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 2.0\l"
  ]
  N27 [
    label = "{Node\[27\]|name = \'b\'\l}"
  ]
  N27 -> N32 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 7.0\l"
  ]
  N27 -> N28 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N28 [
    label = "{Node\[28\]|name = \'c\'\l}"
  ]
  N28 -> N32 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 5.0\l"
  ]
  N28 -> N32 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 4.0\l"
  ]
  N28 -> N25 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N29 [
    label = "{Node\[29\]|name = \'start\'\l}"
  ]
  N29 -> N30 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N30 [
    label = "{Node\[30\]|name = \'a\'\l}"
  ]
  N30 -> N32 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 9.0\l"
  ]
  N30 -> N27 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N31 [
    label = "{Node\[31\]|name = \'y\'\l}"
  ]
  N32 [
    label = "{Node\[32\]|name = \'x\'\l}"
  ]
  N32 -> N31 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 2.0\l"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/node/29/path+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "to" : "http://localhost:7474/db/data/node/32",
  "cost_property" : "cost",
  "relationships" : {
    "type" : "to",
    "direction" : "out"
  },
  "algorithm" : "dijkstra"
}
----


_Example response_

* *+200:+* +OK+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "weight" : 6.0,
  "start" : "http://localhost:7474/db/data/node/29",
  "nodes" : [ "http://localhost:7474/db/data/node/29", "http://localhost:7474/db/data/node/30", "http://localhost:7474/db/data/node/27", "http://localhost:7474/db/data/node/28", "http://localhost:7474/db/data/node/25", "http://localhost:7474/db/data/node/26", "http://localhost:7474/db/data/node/32" ],
  "length" : 6,
  "relationships" : [ "http://localhost:7474/db/data/relationship/20", "http://localhost:7474/db/data/relationship/22", "http://localhost:7474/db/data/relationship/24", "http://localhost:7474/db/data/relationship/27", "http://localhost:7474/db/data/relationship/29", "http://localhost:7474/db/data/relationship/30" ],
  "end" : "http://localhost:7474/db/data/node/32"
}
----


