# [pgrouting-users] Calculating the shortest way between pairs

Daniel Kastl daniel at georepublic.de
Fri Mar 14 07:33:06 PDT 2014

```On Fri, Mar 14, 2014 at 11:26 PM, Carsten Hogertz <carsten.hogertz at gmail.com
> wrote:

> Maybe to clearify.
>
> I've got the following two tables:
>
> Table at_2po_4pgr with the columns:
>
>   id integer NOT NULL,
>   osm_id bigint,
>   osm_name character varying,
>   osm_meta character varying,
>   osm_source_id bigint,
>   osm_target_id bigint,
>   clazz integer,
>   flags integer,
>   source integer,
>   target integer,
>   km double precision,
>   kmh integer,
>   cost2 double precision,
>   reverse_cost double precision,
>   x1 double precision,
>   y1 double precision,
>   x2 double precision,
>   y2 double precision,
>   geom_way geometry(LineString,4326)
>
> and Table routing_pair with the columns:
>
>   id integer,
>   h_key integer,
>   lat_htl double precision,
>   lon_htl double precision,
>   source integer,
>   geom_htl geometry(Point,4326),
>   lat_bhf double precision,
>   lon_bhf double precision,
>   target integer,
>   geom_bhf geometry(Point,4326)
>
>
> The routing_pair table hold three important information:
> ID
> SOURCE
> TARGET
>
> All columns are filled (source + target are calculated from at_2po_4pgr.
>
> The task seems to be quite simple: I want for each row from the
> routing_pair the distance between soure + target (and if possible its geom).
>
>
Hi Carsten,

There is a function named kDijkstra and it allows you to calculate all
paths from one node to many:
http://docs.pgrouting.org/2.0/en/src/kdijkstra/doc/index.html#pgr-kdijkstra

If something is not clear with the page above, feel free to ask.

Daniel

--
Georepublic UG & Georepublic Japan
eMail: daniel.kastl at georepublic.de
Web: http://georepublic.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20140314/32803502/attachment.html>
```