﻿{"id":7870,"date":"2019-01-22T05:30:21","date_gmt":"2019-01-22T04:30:21","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=7870"},"modified":"2019-01-22T17:32:07","modified_gmt":"2019-01-22T16:32:07","slug":"developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/","title":{"rendered":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Given a graph and a source vertex in the\ngraph, Dijkstra&rsquo;s\nalgorithm &nbsp;finds the shortest\npaths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive\nnumbers and a top source as root. This is to build gradually a subgraph where\nthe different vertices are classified in ascending order according their\nminimum distance from the root. The distance is the sum of the weights of the\narcs followed. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The syntax of the Dijkstra algorithm is as follows : <\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\"><strong>pgr_dijkstrar<\/strong> <strong>(<\/strong> <strong>sql<\/strong> text <strong>, source<\/strong> integer <strong>,\ntarget<\/strong> integer <strong>, directed<\/strong> boolean <strong>);<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where <strong><em>source<\/em><\/strong> is the desired starting point desired, <strong><em>target<\/em><\/strong>\nis the end point of the route and the chain sql is as follows: <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>SELECT id, source, target, cost [,<\/strong> <strong>reverse_cost<\/strong> <strong>] FROM<\/strong>\n<strong>network<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The \u201cdirected\u201d Boolean variable allows taking into account of one-way\nroute. &nbsp;By default it is \u00a0\u00bb &nbsp; true\n&nbsp; \u00ab\u00a0. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The order returns a set of elements ( seq , path_seq [, start_vid ] [,\nend_vid ], node, edge, cost, agg_cost ). Unlike the A * algorithm, which has a\nstarting point and an end point for the route, the Dijstra algorithm admits several\npoints of entry and exit. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the output set, <strong><em>seq<\/em><\/strong> is the order number of the segment\nin the global set , <strong><em>path_seq<\/em><\/strong> is the order number of the segment\nin the route , <strong><em>start_vid<\/em><\/strong> and <strong><em>end_vid<\/em><\/strong> are the point\nof departure and arrival of the route and are not informed unless there are\nseveral <strong><em>sources<\/em><\/strong> or <strong><em>targets<\/em><\/strong> in parameter of the\nalgorithm , <strong><em>node<\/em><\/strong> and <strong><em>edge<\/em><\/strong> are the start and end\npoints of the section considered , <strong><em>cost<\/em><\/strong> is the cost of the sectionand\n<strong><em>agg_cost<\/em><\/strong> is the cost accrued since the departure of the route . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Choice<\/strong> <strong>of the \u00ab\u00a0cost<\/strong> <strong>\u00a0\u00bb of a<\/strong> <strong>section<\/strong> <strong>.<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/qgis-shortest-path-network-analysis-tools\/\">shortest path<\/a> algorithm searches the path with the lowest cost. According\nto your goals , it is up to you to decide which cost element you going take into\naccount. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s take back our OpensStreetMap database . You have a \u00ab\u00a0cost\u00a0\u00bb\nfield that considers the length of the section in degrees . If you use this\nfield in the Dijkstra algorithm as cost value, the proposed route will be the\nshortest path between the two selected points . Let&rsquo;s see an example . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The following order calculates the route between the points 69072 and\n64204 by using the \u00ab\u00a0cost\u00a0\u00bb field which corresponds to the length of\nthe section . \n\nSELECT seq , path_seq , node, &nbsp; edge,\ndi.cost , agg_cost , the_geom <br>\nFROM pgr_dijkstra ( <br>\n&lsquo;SELECT gid as id, source, target, cost, reverse_cost FROM public.ways &lsquo;, <br>\n69072, 64204, false &nbsp; ) as di <br>\nJOIN public.ways ways_vertices_pgr <br>\nON di.edge = ways_vertices_pgr.gid ; &nbsp;&nbsp;\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"273\" data-attachment-id=\"7871\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/221-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/221.png?fit=525%2C273&amp;ssl=1\" data-orig-size=\"525,273\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"221\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/221.png?fit=525%2C273&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/221.png?resize=525%2C273&#038;ssl=1\" alt=\"\" class=\"wp-image-7871\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/221.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/221.png?resize=300%2C156&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nOnce\nloaded in QGis, the result is the same as for algorithm A * &nbsp;&nbsp;\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"293\" data-attachment-id=\"7872\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/222-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/222.png?fit=525%2C293&amp;ssl=1\" data-orig-size=\"525,293\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"222\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/222.png?fit=525%2C293&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/222.png?resize=525%2C293&#038;ssl=1\" alt=\"\" class=\"wp-image-7872\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/222.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/222.png?resize=300%2C167&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Problems<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When comparing this algorithm with the algorithm A *, you will notice that\nthere is less need to formatting the layer network . By cons, if you use the cost_s\nand reverse_cost_s fields , you will obtain the same error messages as if there\nwere null values . Refer to a previous article ( <a href=\"https:\/\/translate.google.com\/translate?hl=fr&amp;prev=_t&amp;sl=fr&amp;tl=en&amp;u=http:\/\/www.sigterritoires.fr\/index.php\/developper-une-application-avec-pgrouting-sous-windows-2lalgorithme-a-star\/\">Developping<\/a> <a href=\"https:\/\/translate.google.com\/translate?hl=fr&amp;prev=_t&amp;sl=fr&amp;tl=en&amp;u=http:\/\/www.sigterritoires.fr\/index.php\/developper-une-application-avec-pgrouting-sous-windows-2lalgorithme-a-star\/\">an application with pgrouting in Windows (2): the algorithm\nA *<\/a> ) to solve these problems . \n\nFor this article we use pgrouting &nbsp;version 2.2.3. If you use earlier versions you\ncan encounter a <strong><em>source<\/em><\/strong> and <strong><em>target<\/em><\/strong> field type problem of your\ndatabase: &nbsp;&nbsp;\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"139\" data-attachment-id=\"7873\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/223-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/223.png?fit=525%2C139&amp;ssl=1\" data-orig-size=\"525,139\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"223\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/223.png?fit=525%2C139&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/223.png?resize=525%2C139&#038;ssl=1\" alt=\"\" class=\"wp-image-7873\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/223.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/223.png?resize=300%2C79&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Indeed , if the number of nodes in your network is high, the <strong><em>source<\/em><\/strong>\nand <strong><em>target<\/em><\/strong> fields can be bigint type . Earlier pgRouting versions\ndid not take into account this type of integer . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check your version with the SQL query <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>SELECT<\/strong> <strong>pgr_version<\/strong> <strong>();<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Multiple<\/strong> <strong>routes<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example of a path calculation with three starting points and\none arrival point : <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SELECT seq , path_seq , start_vid , node, &nbsp; edge, di.cost ,\nagg_cost , the_geom <br>\nFROM pgr_dijkstra ( <br>\n&lsquo;SELECT gid as id, source, target, cost_s as cost, reverse_cost_s as\nreverse_cost FROM public.ways &lsquo;, <br>\n<strong>ARRAY [69072,21576,62667]<\/strong> , 64204, true &nbsp; ) as di <br>\nJOIN public.ways ways_vertices_pgr <br>\nON di.edge = ways_vertices_pgr.gid ; \n\nThis request calculates the paths between the\nstarting points &nbsp; 69072, 21576 and 62667 and the point of arrival 64204 &nbsp;&nbsp;\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"271\" data-attachment-id=\"7874\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/224-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/224.png?fit=525%2C271&amp;ssl=1\" data-orig-size=\"525,271\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"224\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/224.png?fit=525%2C271&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/224.png?resize=525%2C271&#038;ssl=1\" alt=\"\" class=\"wp-image-7874\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/224.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/224.png?resize=300%2C155&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nOnce\nQGis is loaded, the result is the following \n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"293\" data-attachment-id=\"7875\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/225-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/225.png?fit=525%2C293&amp;ssl=1\" data-orig-size=\"525,293\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"225\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/225.png?fit=525%2C293&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/225.png?resize=525%2C293&#038;ssl=1\" alt=\"\" class=\"wp-image-7875\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/225.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/225.png?resize=300%2C167&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Variant<\/strong> <strong>pgr_dijkstraCost<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You have a Dijkstra algorithm variant with which you state the starting and\narrival point and in return you retrieve the total cost of the path. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example with the path between points 69072 and 64204 \n\nSELECT * FROM pgr_dijkstraCost ( <br>\n&lsquo;SELECT gid as id, source, target, cost_s as cost, reverse_cost_s as\nreverse_cost FROM public.ways &lsquo;, <br>\n69072, 64204); \n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"269\" data-attachment-id=\"7876\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/226-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/226.png?fit=525%2C269&amp;ssl=1\" data-orig-size=\"525,269\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"226\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/226.png?fit=525%2C269&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/226.png?resize=525%2C269&#038;ssl=1\" alt=\"\" class=\"wp-image-7876\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/226.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/226.png?resize=300%2C154&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Given a graph and a source vertex in the graph, Dijkstra&rsquo;s algorithm &nbsp;finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1260],"tags":[],"class_list":["post-7870","post","type-post","status-publish","format-standard","hentry","category-non-classe-en"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Given a graph and a source vertex in the graph, Dijkstra&#039;s algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Atilio Francois\"\/>\n\t<meta name=\"google-site-verification\" content=\"ByXHZUbGNn7RNv-Xk5A-ysTZrM65VLIO2RxfSJ2nIEQ\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"fr_FR\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Blog SIG &amp; Territoires | le portail des professionnels du SIG\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG &amp; Territoires\" \/>\n\t\t<meta property=\"og:description\" content=\"Given a graph and a source vertex in the graph, Dijkstra&#039;s algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-01-22T04:30:21+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-01-22T16:32:07+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/atilio.francois\/\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@SigTerritoires\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG &amp; Territoires\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Given a graph and a source vertex in the graph, Dijkstra&#039;s algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@SigTerritoires\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#article\",\"name\":\"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG & Territoires\",\"headline\":\"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm\",\"author\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.sigterritoires.fr\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/221.png?fit=525%2C273&ssl=1\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#articleImage\",\"width\":525,\"height\":273},\"datePublished\":\"2019-01-22T05:30:21+01:00\",\"dateModified\":\"2019-01-22T17:32:07+01:00\",\"inLanguage\":\"fr-FR\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#webpage\"},\"articleSection\":\"Non class\\u00e9, English\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sigterritoires.fr\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/non-classe-en\\\/#listItem\",\"name\":\"Non class\\u00e9\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/non-classe-en\\\/#listItem\",\"position\":2,\"name\":\"Non class\\u00e9\",\"item\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/non-classe-en\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#listItem\",\"name\":\"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#listItem\",\"position\":3,\"name\":\"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/category\\\/non-classe-en\\\/#listItem\",\"name\":\"Non class\\u00e9\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#person\",\"name\":\"Atilio Francois\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Atilio Francois\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/\",\"name\":\"Atilio Francois\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Atilio Francois\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#webpage\",\"url\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/\",\"name\":\"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG & Territoires\",\"description\":\"Given a graph and a source vertex in the graph, Dijkstra's algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are\",\"inLanguage\":\"fr-FR\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/en\\\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/index.php\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2019-01-22T05:30:21+01:00\",\"dateModified\":\"2019-01-22T17:32:07+01:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#website\",\"url\":\"https:\\\/\\\/www.sigterritoires.fr\\\/\",\"name\":\"Blog SIG & Territoires\",\"description\":\"le portail des professionnels du SIG\",\"inLanguage\":\"fr-FR\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sigterritoires.fr\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG & Territoires","description":"Given a graph and a source vertex in the graph, Dijkstra's algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are","canonical_url":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"ByXHZUbGNn7RNv-Xk5A-ysTZrM65VLIO2RxfSJ2nIEQ","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#article","name":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG & Territoires","headline":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm","author":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/www.sigterritoires.fr\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/221.png?fit=525%2C273&ssl=1","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#articleImage","width":525,"height":273},"datePublished":"2019-01-22T05:30:21+01:00","dateModified":"2019-01-22T17:32:07+01:00","inLanguage":"fr-FR","mainEntityOfPage":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#webpage"},"isPartOf":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#webpage"},"articleSection":"Non class\u00e9, English"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr#listItem","position":1,"name":"Home","item":"https:\/\/www.sigterritoires.fr","nextItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/non-classe-en\/#listItem","name":"Non class\u00e9"}},{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/non-classe-en\/#listItem","position":2,"name":"Non class\u00e9","item":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/non-classe-en\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#listItem","name":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#listItem","position":3,"name":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm","previousItem":{"@type":"ListItem","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/non-classe-en\/#listItem","name":"Non class\u00e9"}}]},{"@type":"Person","@id":"https:\/\/www.sigterritoires.fr\/#person","name":"Atilio Francois","image":{"@type":"ImageObject","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g","width":96,"height":96,"caption":"Atilio Francois"}},{"@type":"Person","@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author","url":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/","name":"Atilio Francois","image":{"@type":"ImageObject","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/f76dc2a720162999bce81d6c99b6d7b9517d6600ad7ceb5ed5268f02cefaa0ee?s=96&d=mm&r=g","width":96,"height":96,"caption":"Atilio Francois"}},{"@type":"WebPage","@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#webpage","url":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/","name":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG & Territoires","description":"Given a graph and a source vertex in the graph, Dijkstra's algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are","inLanguage":"fr-FR","isPartOf":{"@id":"https:\/\/www.sigterritoires.fr\/#website"},"breadcrumb":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/#breadcrumblist"},"author":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author"},"creator":{"@id":"https:\/\/www.sigterritoires.fr\/index.php\/author\/admin\/#author"},"datePublished":"2019-01-22T05:30:21+01:00","dateModified":"2019-01-22T17:32:07+01:00"},{"@type":"WebSite","@id":"https:\/\/www.sigterritoires.fr\/#website","url":"https:\/\/www.sigterritoires.fr\/","name":"Blog SIG & Territoires","description":"le portail des professionnels du SIG","inLanguage":"fr-FR","publisher":{"@id":"https:\/\/www.sigterritoires.fr\/#person"}}]},"og:locale":"fr_FR","og:site_name":"Blog SIG &amp; Territoires | le portail des professionnels du SIG","og:type":"article","og:title":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG &amp; Territoires","og:description":"Given a graph and a source vertex in the graph, Dijkstra's algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are","og:url":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/","article:published_time":"2019-01-22T04:30:21+00:00","article:modified_time":"2019-01-22T16:32:07+00:00","article:publisher":"https:\/\/www.facebook.com\/atilio.francois\/","twitter:card":"summary","twitter:site":"@SigTerritoires","twitter:title":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm | Blog SIG &amp; Territoires","twitter:description":"Given a graph and a source vertex in the graph, Dijkstra's algorithm finds the shortest paths from source to all vertices in the given graph. It takes as input an oriented graph weighted by real positive numbers and a top source as root. This is to build gradually a subgraph where the different vertices are","twitter:creator":"@SigTerritoires"},"aioseo_meta_data":{"post_id":"7870","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-21 13:57:00","updated":"2025-06-04 16:49:52","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.sigterritoires.fr\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/non-classe-en\/\" title=\"Non class\u00e9\">Non class\u00e9<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to develop an application with pgrouting in Windows (3): the Dijkstra algorithm\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.sigterritoires.fr"},{"label":"Non class\u00e9","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/category\/non-classe-en\/"},{"label":"How to develop an application with pgrouting in Windows (3): the Dijkstra algorithm","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/developing-and-application-with-pgrouting-in-windows-3-the-dijkstra-algorithm\/"}],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-22W","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/7870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/comments?post=7870"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/7870\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=7870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=7870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=7870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}