# [pgrouting-users] Least cost path

Sankepally Rohith Reddy rohith.reddy at research.iiit.ac.in
Tue Apr 10 00:29:46 PDT 2018

```Hello Dave,

According to my understanding you would like to compute a path which is the shortest and also takes the least effort to navigate. According to the description of "edges_sql" query [1] which is given as an input to the dijkstra function[2], the "cost" column in "edges_sql" query [1] represents the weight of the edge. In your case this weight can a metric which is a combination of both the distance and the effort of travelling across the edge. You can create your own weight metric, for example "distance + effort" or "distance * effort" or any other such function which tries to capture the entity you want to minimize. This metric and now be used as the "cost" column in the "edges_sql" query [1] to get a path which minimizes both the distance and the effort.

Regards,
Rohith Reddy.

[1] http://docs.pgrouting.org/latest/en/pgr_dijkstra.html#description-of-the-edges-sql-query-for-dijkstra-like-functions
[2] http://docs.pgrouting.org/latest/en/pgr_dijkstra.html#minimal-signature

----- Original Message -----
From: "Dave Potts" <mrdapotts at gmail.com>
To: "pgrouting-users" <pgrouting-users at lists.osgeo.org>
Sent: Tuesday, April 10, 2018 12:03:43 PM
Subject: [pgrouting-users] Least cost path

As any thought ever being put in to creating a function to return the least cost path?

If I have a network which for example represents he amount of effort it takes to get from one places to another and the distances between places, what I would like to do is calculate the path across the network that is going to reflect the lowest cost.

If I use one of the many dykstra calls on the distance metric it will generate a path that follows the shortest route. What I actually one to get is the shortest path that also requires the least effort to navigate. Any suggestions ?

Dave/.

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/pgrouting-users
```