[[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"]
----
  N261 [
    label = "{Node\[261\]|name = \'f\'\l}"
  ]
  N262 [
    label = "{Node\[262\]|name = \'d\'\l}"
  ]
  N262 -> N269 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 3.0\l"
  ]
  N262 -> N263 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N263 [
    label = "{Node\[263\]|name = \'e\'\l}"
  ]
  N263 -> N269 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N263 -> N261 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 2.0\l"
  ]
  N264 [
    label = "{Node\[264\]|name = \'b\'\l}"
  ]
  N264 -> N269 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 7.0\l"
  ]
  N264 -> N265 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N265 [
    label = "{Node\[265\]|name = \'c\'\l}"
  ]
  N265 -> N269 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 5.0\l"
  ]
  N265 -> N269 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 4.0\l"
  ]
  N265 -> N262 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N266 [
    label = "{Node\[266\]|name = \'start\'\l}"
  ]
  N266 -> N267 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N267 [
    label = "{Node\[267\]|name = \'a\'\l}"
  ]
  N267 -> N269 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 9.0\l"
  ]
  N267 -> N264 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 1.0\l"
  ]
  N268 [
    label = "{Node\[268\]|name = \'y\'\l}"
  ]
  N269 [
    label = "{Node\[269\]|name = \'x\'\l}"
  ]
  N269 -> N268 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "to\ncost = 2.0\l"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/node/266/path+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "to" : "http://localhost:7474/db/data/node/269",
  "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/266",
  "nodes" : [ "http://localhost:7474/db/data/node/266", "http://localhost:7474/db/data/node/267", "http://localhost:7474/db/data/node/264", "http://localhost:7474/db/data/node/265", "http://localhost:7474/db/data/node/262", "http://localhost:7474/db/data/node/263", "http://localhost:7474/db/data/node/269" ],
  "length" : 6,
  "relationships" : [ "http://localhost:7474/db/data/relationship/146", "http://localhost:7474/db/data/relationship/148", "http://localhost:7474/db/data/relationship/150", "http://localhost:7474/db/data/relationship/153", "http://localhost:7474/db/data/relationship/155", "http://localhost:7474/db/data/relationship/156" ],
  "end" : "http://localhost:7474/db/data/node/269"
}
----


