12. Appendix: Workshop Solutions

12.1. pgr_dijkstra Solutions

12.1.1. Solution to Exercise 1

Exercise 1

 seq | path_seq | node  | edge  |         cost         |      agg_cost       
-----+----------+-------+-------+----------------------+---------------------
   1 |        1 | 13224 |   815 |  0.00177810584893137 |                   0
   2 |        2 |  3495 |   820 |  0.00179225967147818 | 0.00177810584893137
   3 |        3 |   905 | 19177 | 0.000102092605022171 | 0.00357036552040955
   4 |        4 |  6893 | 19178 | 8.66225143958747e-05 | 0.00367245812543172
   5 |        5 |  7753 | 19191 |  0.00047705096163826 |  0.0037590806398276
   6 |        6 |  8159 |  7015 | 0.000513853140499986 | 0.00423613160146586
   7 |        7 |  2477 |  7016 | 9.12382595170489e-05 | 0.00474998474196585
   8 |        8 | 11902 |  7017 | 9.71560600269149e-05 | 0.00484122300148289
   9 |        9 |  2042 |  7018 | 0.000120258430056735 | 0.00493837906150981
  10 |       10 |  4004 |  7019 |  0.00102611053011065 | 0.00505863749156655
  11 |       11 |  6549 |    -1 |                    0 | 0.00608474802167719
(11 rows)

12.1.2. Solution to Exercise 2

Exercise 2

 seq | path_seq | start_vid | node  | edge  |       cost       |     agg_cost     
-----+----------+-----------+-------+-------+------------------+------------------
   1 |        1 |      1458 |  1458 |  9579 |  122.73055200169 |                0
   2 |        2 |      1458 | 15780 |  9580 | 6.81560014601373 |  122.73055200169
   3 |        3 |      1458 |   341 |  9581 | 4.34905086413433 | 129.546152147704
   4 |        4 |      1458 |  6588 |   402 | 17.8063617729128 | 133.895203011838
   5 |        5 |      1458 |  8421 | 19113 | 14.0364441669696 | 151.701564784751
   6 |        6 |      1458 |  8850 | 19103 |  10.683654675516 | 165.738008951721
   7 |        7 |      1458 |  1911 | 19259 | 187.613032772937 | 176.421663627237
   8 |        8 |      1458 |  8322 | 14424 | 262.526664010527 | 364.034696400174
   9 |        9 |      1458 |  2530 | 14423 | 8.70072320886175 |   626.5613604107
  10 |       10 |      1458 | 13428 |  5652 | 7.79067070438542 | 635.262083619562
  11 |       11 |      1458 | 14787 |  5653 | 86.9756175505619 | 643.052754323947
  12 |       12 |      1458 |  1575 | 19133 | 6.34959268407018 | 730.028371874509
  13 |       13 |      1458 | 10074 | 19248 |  9.3402101271489 | 736.377964558579
  14 |       14 |      1458 |  7508 | 19241 | 10.1373701729792 | 745.718174685728
  15 |       15 |      1458 |  5817 | 19242 | 131.813100896831 | 755.855544858708
  16 |       16 |      1458 | 10545 | 19243 | 44.4337066522576 | 887.668645755539
  17 |       17 |      1458 |  6752 | 19126 | 98.1649191817027 | 932.102352407797
  18 |       18 |      1458 |  9285 | 19125 | 10.5216529108051 |  1030.2672715895
  19 |       19 |      1458 |   427 |  6681 | 6.57912012040106 |  1040.7889245003
  20 |       20 |      1458 |  1378 |  1475 | 29.6081026350636 | 1047.36804462071
  21 |       21 |      1458 | 13617 |  1476 | 17.8372403352354 | 1076.97614725577
  22 |       22 |      1458 | 15366 |  1477 | 67.2606298149331 |   1094.813387591
  23 |       23 |      1458 | 15949 | 20080 | 20.0145316121038 | 1162.07401740594
  24 |       24 |      1458 |  6624 |  8750 | 11.4383904250565 | 1182.08854901804
  25 |       25 |      1458 | 13024 |  5565 | 9.33076750417725 |  1193.5269394431
  26 |       26 |      1458 |  7089 |  7020 | 8.03372578448151 | 1202.85770694728
  27 |       27 |      1458 |  6510 |  7329 | 10.3877884750459 | 1210.89143273176
  28 |       28 |      1458 |  4506 |  5150 | 148.622482830851 |  1221.2792212068
  29 |       29 |      1458 |  5650 |   852 | 11.6443212654931 | 1369.90170403765
  30 |       30 |      1458 |  6843 |   851 |  21.422854970965 | 1381.54602530315
  31 |       31 |      1458 |  8663 |   850 | 55.6991653165085 | 1402.96888027411
  32 |       32 |      1458 |  1550 | 19237 | 53.3042387365226 | 1458.66804559062
  33 |       33 |      1458 |   505 | 19236 | 44.5745770966455 | 1511.97228432714
  34 |       34 |      1458 | 13224 |    -1 |                0 | 1556.54686142379
  35 |        1 |      6549 |  6549 |  7019 | 87.8579034765522 |                0
  36 |        2 |      6549 |  4004 |  7018 | 10.3932702799078 | 87.8579034765522
  37 |        3 |      6549 |  2042 |  7017 | 8.28861220706259 |   98.25117375646
  38 |        4 |      6549 | 11902 |  7016 | 7.84674125730467 | 106.539785963523
  39 |        5 |      6549 |  2477 |  7015 | 43.8894876183292 | 114.386527220827
  40 |        6 |      6549 |  8159 | 19191 | 42.5887777208682 | 158.276014839156
  41 |        7 |      6549 |  7753 | 19178 | 7.42217689778284 | 200.864792560025
  42 |        8 |      6549 |  6893 | 19177 | 8.70254754116327 | 208.286969457807
  43 |        9 |      6549 |   905 |   820 | 141.535232985847 | 216.989516998971
  44 |       10 |      6549 |  3495 |   815 | 159.384330206319 | 358.524749984817
  45 |       11 |      6549 | 13224 |    -1 |                0 | 517.909080191137
  46 |        1 |      9224 |  9224 |  6711 | 60.3483603978306 |                0
  47 |        2 |      9224 |  4540 |  6710 | 18.1041351419167 | 60.3483603978306
  48 |        3 |      9224 |  5214 | 18791 | 86.9675143885569 | 78.4524955397473
  49 |        4 |      9224 | 15391 | 18790 | 49.1249972853916 | 165.420009928304
  50 |        5 |      9224 | 16045 | 18305 | 9.21179039403254 | 214.545007213696
  51 |        6 |      9224 |  8016 | 18336 | 7.40651033603231 | 223.756797607728
  52 |        7 |      9224 |  5874 |  6491 | 12.0446529541527 | 231.163307943761
  53 |        8 |      9224 | 11139 | 10968 |  12.348364913729 | 243.207960897913
  54 |        9 |      9224 | 13281 | 10969 | 10.4511579460809 | 255.556325811642
  55 |       10 |      9224 |  7908 | 18561 | 54.3874708183007 | 266.007483757723
  56 |       11 |      9224 | 13998 | 18563 |   42.66813126198 | 320.394954576024
  57 |       12 |      9224 | 12237 | 18562 | 6.92905234498241 | 363.063085838004
  58 |       13 |      9224 |  8935 | 14574 | 16.9992058206193 | 369.992138182986
  59 |       14 |      9224 | 13899 |  5746 |  7.4587093036582 | 386.991344003606
  60 |       15 |      9224 | 10042 | 18292 | 16.3418312912432 | 394.450053307264
  61 |       16 |      9224 |  9765 |  3750 | 30.7487536431985 | 410.791884598507
  62 |       17 |      9224 |  9783 | 17567 |  115.33485534348 | 441.540638241705
  63 |       18 |      9224 |  7365 | 17566 | 11.1270350484144 | 556.875493585185
  64 |       19 |      9224 |  9981 |  1075 | 9.49206261831472 |   568.0025286336
  65 |       20 |      9224 |    97 |  1074 | 21.1800610213718 | 577.494591251915
  66 |       21 |      9224 |  5894 |  1071 | 81.9656378302048 | 598.674652273286
  67 |       22 |      9224 |  4551 |  8166 | 9.58973989908899 | 680.640290103491
  68 |       23 |      9224 |  3477 |  8167 | 15.4288801285655 |  690.23003000258
  69 |       24 |      9224 |  3456 |  8168 | 20.0108629032123 | 705.658910131146
  70 |       25 |      9224 |  4676 |  4559 | 55.4237857233585 | 725.669773034358
  71 |       26 |      9224 |  2595 |  4558 | 49.5619486096759 | 781.093558757717
  72 |       27 |      9224 | 12838 |  4560 | 17.4128432070734 | 830.655507367393
  73 |       28 |      9224 | 11204 |  4561 | 8.60161020422826 | 848.068350574466
  74 |       29 |      9224 | 12284 |  4562 | 87.9066873260115 | 856.669960778694
  75 |       30 |      9224 | 15694 | 20388 | 15.2392655893867 | 944.576648104706
  76 |       31 |      9224 | 15346 |  6296 |  37.387258870361 | 959.815913694092
  77 |       32 |      9224 |  4096 |  6297 | 9.67286826384281 | 997.203172564453
  78 |       33 |      9224 | 10104 |  6298 | 33.3276981613188 |  1006.8760408283
  79 |       34 |      9224 | 13203 |  6299 | 99.2885654231848 | 1040.20373898962
  80 |       35 |      9224 |  3338 |  6300 | 14.5179940157029 |  1139.4923044128
  81 |       36 |      9224 |  9153 |  6301 | 94.0226398775099 |  1154.0102984285
  82 |       37 |      9224 |   199 | 20384 |  38.353906469412 | 1248.03293830601
  83 |       38 |      9224 |   174 | 19179 | 104.859116869741 | 1286.38684477542
  84 |       39 |      9224 |  1007 | 13470 | 25.2531278271143 | 1391.24596164517
  85 |       40 |      9224 |    94 | 20392 | 123.123704573094 | 1416.49908947228
  86 |       41 |      9224 |  6992 | 20393 | 103.944067584966 | 1539.62279404537
  87 |       42 |      9224 |  9990 | 19088 | 112.651425623678 | 1643.56686163034
  88 |       43 |      9224 |  7869 | 19306 | 15.9001052929701 | 1756.21828725402
  89 |       44 |      9224 |  2964 | 19307 | 20.6630244529838 | 1772.11839254699
  90 |       45 |      9224 |  2778 | 19308 | 10.7247941139762 | 1792.78141699997
  91 |       46 |      9224 | 11615 | 19309 | 33.8170301185012 | 1803.50621111395
  92 |       47 |      9224 | 14235 | 18830 | 126.751917752474 | 1837.32324123245
  93 |       48 |      9224 | 16021 | 19152 | 26.3271139914297 | 1964.07515898492
  94 |       49 |      9224 | 11977 |  8315 | 34.3165051038627 | 1990.40227297635
  95 |       50 |      9224 |  9454 |  8327 | 21.6067981394395 | 2024.71877808022
  96 |       51 |      9224 |  7225 |  8326 | 23.4769498840559 | 2046.32557621966
  97 |       52 |      9224 |   658 |  8325 |  27.790258354941 | 2069.80252610371
  98 |       53 |      9224 | 13696 |  8312 | 7.81823916646078 | 2097.59278445865
  99 |       54 |      9224 | 10632 |  8306 | 12.2413813971404 | 2105.41102362511
 100 |       55 |      9224 |  7472 |  4646 | 14.4499537156249 | 2117.65240502225
 101 |       56 |      9224 |   660 |  4645 | 3.36009392379962 | 2132.10235873788
 102 |       57 |      9224 |  1390 |  4644 | 24.6122660541766 | 2135.46245266168
 103 |       58 |      9224 |  2632 |  4643 | 1.63969373355472 | 2160.07471871585
 104 |       59 |      9224 |  2423 |  4642 | 27.5976419225495 | 2161.71441244941
 105 |       60 |      9224 |  6229 |  4641 | 9.57404219475669 | 2189.31205437196
 106 |       61 |      9224 |  6985 |  4640 |  9.8710432555303 | 2198.88609656671
 107 |       62 |      9224 |  4237 |  4639 | 13.1492471950675 | 2208.75713982225
 108 |       63 |      9224 |  4835 |  4638 | 9.11584760567648 | 2221.90638701731
 109 |       64 |      9224 |  5870 |  2450 | 10.2399222270489 | 2231.02223462299
 110 |       65 |      9224 |    72 |  2451 | 15.1322061725404 | 2241.26215685004
 111 |       66 |      9224 |   107 |  2452 | 32.8272922016361 | 2256.39436302258
 112 |       67 |      9224 | 11811 |  2453 | 104.656678010738 | 2289.22165522421
 113 |       68 |      9224 |  1550 | 19237 | 53.3042387365226 | 2393.87833323495
 114 |       69 |      9224 |   505 | 19236 | 44.5745770966455 | 2447.18257197148
 115 |       70 |      9224 | 13224 |    -1 |                0 | 2491.75714906812
(115 rows)

12.1.3. Solution to Exercise 3

Exercise 3

 seq | path_seq | end_vid | node  | edge  |       cost       |     agg_cost     
-----+----------+---------+-------+-------+------------------+------------------
   1 |        1 |    1458 | 13224 | 19236 | 34.2881362281889 |                0
   2 |        2 |    1458 |   505 | 19237 | 41.0032605665559 | 34.2881362281889
   3 |        3 |    1458 |  1550 |   850 | 42.8455117819296 | 75.2913967947447
   4 |        4 |    1458 |  8663 |   851 | 16.4791192084346 | 118.136908576674
   5 |        5 |    1458 |  6843 |   852 | 8.95717020422545 | 134.616027785109
   6 |        6 |    1458 |  5650 |  5150 | 114.324986792963 | 143.573197989334
   7 |        7 |    1458 |  4506 |  7329 | 7.99060651926608 | 257.898184782297
   8 |        8 |    1458 |  6510 |  7020 | 6.17978906498578 | 265.888791301563
   9 |        9 |    1458 |  7089 |  5565 | 7.17751346475173 | 272.068580366549
  10 |       10 |    1458 | 13024 |  8750 | 8.79876186542804 | 279.246093831301
  11 |       11 |    1458 |  6624 | 20080 | 15.3957935477721 | 288.044855696729
  12 |       12 |    1458 | 15949 |  1477 |  51.738946011487 | 303.440649244501
  13 |       13 |    1458 | 15366 |  1476 | 13.7209541040273 | 355.179595255988
  14 |       14 |    1458 | 13617 |  1475 | 22.7754635654335 | 368.900549360015
  15 |       15 |    1458 |  1378 |  6681 | 5.06086163107774 | 391.676012925449
  16 |       16 |    1458 |   427 | 19125 | 8.09357916215779 | 396.736874556526
  17 |       17 |    1458 |  9285 | 19126 | 75.5114762936174 | 404.830453718684
  18 |       18 |    1458 |  6752 | 19243 | 34.1797743478905 | 480.341930012301
  19 |       19 |    1458 | 10545 | 19242 | 101.394692997563 | 514.521704360192
  20 |       20 |    1458 |  5817 | 19241 | 7.79797705613788 | 615.916397357755
  21 |       21 |    1458 |  7508 | 19248 | 7.18477702088377 | 623.714374413892
  22 |       22 |    1458 | 10074 | 19133 | 4.88430206466937 | 630.899151434776
  23 |       23 |    1458 |  1575 |  5653 | 66.9043211927399 | 635.783453499445
  24 |       24 |    1458 | 14787 |  5652 | 5.99282361875801 | 702.687774692185
  25 |       25 |    1458 | 13428 | 14423 | 6.69286400681673 | 708.680598310944
  26 |       26 |    1458 |  2530 | 14424 | 201.943587700405 |  715.37346231776
  27 |       27 |    1458 |  8322 | 19259 | 144.317717517644 | 917.317050018165
  28 |       28 |    1458 |  1911 | 19103 | 8.21819590424307 | 1061.63476753581
  29 |       29 |    1458 |  8850 | 19113 | 10.7972647438228 | 1069.85296344005
  30 |       30 |    1458 |  8421 |   402 |  13.697201363779 | 1080.65022818388
  31 |       31 |    1458 |  6588 |  9581 | 3.34542374164179 | 1094.34742954765
  32 |       32 |    1458 |   341 |  9580 | 5.24276934308748 |  1097.6928532893
  33 |       33 |    1458 | 15780 |  9579 | 94.4081169243771 | 1102.93562263238
  34 |       34 |    1458 |  1458 |    -1 |                0 | 1197.34373955676
  35 |        1 |    6549 | 13224 |   815 | 122.603330927938 |                0
  36 |        2 |    6549 |  3495 |   820 | 108.873256142959 | 122.603330927938
  37 |        3 |    6549 |   905 | 19177 | 6.69426733935636 | 231.476587070897
  38 |        4 |    6549 |  6893 | 19178 | 5.70936684444834 | 238.170854410253
  39 |        5 |    6549 |  7753 | 19191 | 32.7605982468217 | 243.880221254702
  40 |        6 |    6549 |  8159 |  7015 | 33.7611443217917 | 276.640819501523
  41 |        7 |    6549 |  2477 |  7016 | 6.03595481331128 | 310.401963823315
  42 |        8 |    6549 | 11902 |  7017 |  6.3758555438943 | 316.437918636626
  43 |        9 |    6549 |  2042 |  7018 | 7.99482329223677 | 322.813774180521
  44 |       10 |    6549 |  4004 |  7019 | 67.5830026742709 | 330.808597472757
  45 |       11 |    6549 |  6549 |    -1 |                0 | 398.391600147028
  46 |        1 |    9224 | 13224 | 19236 | 34.2881362281889 |                0
  47 |        2 |    9224 |   505 | 19237 | 41.0032605665559 | 34.2881362281889
  48 |        3 |    9224 |  1550 |  2453 | 80.5051369313371 | 75.2913967947447
  49 |        4 |    9224 | 11811 |  2452 | 25.2517632320277 | 155.796533726082
  50 |        5 |    9224 |   107 |  2451 | 11.6401585942618 |  181.04829695811
  51 |        6 |    9224 |    72 |  2450 | 7.87686325157605 | 192.688455552371
  52 |        7 |    9224 |  5870 |  4638 | 7.01219046590498 | 200.565318803947
  53 |        8 |    9224 |  4835 |  4639 | 10.1148055346673 | 207.577509269852
  54 |        9 |    9224 |  4237 |  4640 | 7.59311019656177 |  217.69231480452
  55 |       10 |    9224 |  6985 |  4641 | 7.36464784212053 | 225.285425001082
  56 |       11 |    9224 |  6229 |  4642 | 21.2289553250381 | 232.650072843202
  57 |       12 |    9224 |  2423 |  4643 | 1.26130287196517 |  253.87902816824
  58 |       13 |    9224 |  2632 |  4644 | 18.9325123493666 | 255.140331040205
  59 |       14 |    9224 |  1390 |  4645 | 2.58468763369201 | 274.072843389572
  60 |       15 |    9224 |   660 |  4646 | 11.1153490120191 | 276.657531023264
  61 |       16 |    9224 |  7472 |  8306 | 9.41644722856957 | 287.772880035283
  62 |       17 |    9224 | 10632 |  8312 | 6.01403012804675 | 297.189327263853
  63 |       18 |    9224 | 13696 |  8325 | 21.3771218114931 | 303.203357391899
  64 |       19 |    9224 |   658 |  8326 | 18.0591922185045 | 324.580479203393
  65 |       20 |    9224 |  7225 |  8327 |  16.620613953415 | 342.639671421897
  66 |       21 |    9224 |  9454 |  8315 | 26.3973116183559 | 359.260285375312
  67 |       22 |    9224 | 11977 | 19152 | 20.2516261472536 | 385.657596993668
  68 |       23 |    9224 | 16021 | 18830 | 97.5014751942106 | 405.909223140922
  69 |       24 |    9224 | 14235 | 19309 | 26.0131000911547 | 503.410698335132
  70 |       25 |    9224 | 11615 | 19308 | 8.24984162613557 | 529.423798426287
  71 |       26 |    9224 |  2778 | 19307 | 15.8946341946029 | 537.673640052422
  72 |       27 |    9224 |  2964 | 19306 | 12.2308502253616 | 553.568274247025
  73 |       28 |    9224 |  7869 | 19088 | 86.6549427874448 | 565.799124472387
  74 |       29 |    9224 |  9990 | 20393 | 79.9569750653582 | 652.454067259832
  75 |       30 |    9224 |  6992 | 20392 |  94.710541979303 |  732.41104232519
  76 |       31 |    9224 |    94 | 13470 | 19.4254829439341 | 827.121584304493
  77 |       32 |    9224 |  1007 | 19179 |   80.66085913057 | 846.547067248427
  78 |       33 |    9224 |   174 | 20384 | 29.5030049764708 | 927.207926378997
  79 |       34 |    9224 |   199 |  6301 | 72.3251075980845 | 956.710931355468
  80 |       35 |    9224 |  9153 |  6300 | 11.1676877043869 | 1029.03603895355
  81 |       36 |    9224 |  3338 |  6299 |  76.375819556296 | 1040.20372665794
  82 |       37 |    9224 | 13203 |  6298 | 25.6366908933222 | 1116.57954621424
  83 |       38 |    9224 | 10104 |  6297 |  7.4406678952637 | 1142.21623710756
  84 |       39 |    9224 |  4096 |  6296 | 28.7594299002777 | 1149.65690500282
  85 |       40 |    9224 | 15346 | 20388 | 11.7225119918359 |  1178.4163349031
  86 |       41 |    9224 | 15694 |  4562 | 67.6205287123165 | 1190.13884689493
  87 |       42 |    9224 | 12284 |  4561 | 6.61662323402174 | 1257.75937560725
  88 |       43 |    9224 | 11204 |  4560 | 13.3944947746719 | 1264.37599884127
  89 |       44 |    9224 | 12838 |  4558 | 38.1245758535969 | 1277.77049361594
  90 |       45 |    9224 |  2595 |  4559 | 42.6336813256604 | 1315.89506946954
  91 |       46 |    9224 |  4676 |  8168 | 15.3929714640095 |  1358.5287507952
  92 |       47 |    9224 |  3456 |  8167 | 11.8683693296658 | 1373.92172225921
  93 |       48 |    9224 |  3477 |  8166 | 7.37672299929922 | 1385.79009158888
  94 |       49 |    9224 |  4551 |  1071 | 63.0504906386191 | 1393.16681458818
  95 |       50 |    9224 |  5894 |  1074 | 16.2923546318245 |  1456.2173052268
  96 |       51 |    9224 |    97 |  1075 | 7.30158662947286 | 1472.50965985862
  97 |       52 |    9224 |  9981 | 17566 | 8.55925772954955 | 1479.81124648809
  98 |       53 |    9224 |  7365 | 17567 | 88.7191194949846 | 1488.37050421764
  99 |       54 |    9224 |  9783 |  3750 |  23.652887417845 | 1577.08962371263
 100 |       55 |    9224 |  9765 | 18292 | 12.5706394548025 | 1600.74251113047
 101 |       56 |    9224 | 10042 |  5746 | 5.73746869512169 | 1613.31315058527
 102 |       57 |    9224 | 13899 | 14574 | 13.0763121697071 |  1619.0506192804
 103 |       58 |    9224 |  8935 | 18562 | 5.33004026537109 |  1632.1269314501
 104 |       59 |    9224 | 12237 | 18563 | 32.8216394322923 | 1637.45697171547
 105 |       60 |    9224 | 13998 | 18561 | 41.8365160140774 | 1670.27861114777
 106 |       61 |    9224 |  7908 | 10969 | 8.03935226621607 | 1712.11512716184
 107 |       62 |    9224 | 13281 | 10968 | 9.49874224132999 | 1720.15447942806
 108 |       63 |    9224 | 11139 |  6491 | 9.26511765704051 | 1729.65322166939
 109 |       64 |    9224 |  5874 | 18336 | 5.69731564310177 | 1738.91833932643
 110 |       65 |    9224 |  8016 | 18305 | 7.08599261079426 | 1744.61565496953
 111 |       66 |    9224 | 16045 | 18790 | 37.7884594503012 | 1751.70164758033
 112 |       67 |    9224 | 15391 | 18791 | 66.8980879911976 | 1789.49010703063
 113 |       68 |    9224 |  5214 |  6710 | 13.9262578014744 | 1856.38819502183
 114 |       69 |    9224 |  4540 |  6711 |  46.421815690639 |  1870.3144528233
 115 |       70 |    9224 |  9224 |    -1 |                0 | 1916.73626851394
(115 rows)

12.1.4. Solution to Exercise 4

Exercise 4

 seq | path_seq | start_vid | end_vid | node  | edge  |        cost        |     agg_cost      
-----+----------+-----------+---------+-------+-------+--------------------+-------------------
   1 |        1 |      1458 |    6963 |  1458 |  9579 |   1.57346861540628 |                 0
   2 |        2 |      1458 |    6963 | 15780 |  9580 | 0.0873794890514581 |  1.57346861540628
   3 |        3 |      1458 |    6963 |   341 |  9581 | 0.0557570623606965 |  1.66084810445774
   4 |        4 |      1458 |    6963 |  6588 |   402 |  0.228286689396317 |  1.71660516681844
   5 |        5 |      1458 |    6963 |  8421 |   403 |  0.179286801853948 |  1.94489185621476
   6 |        6 |      1458 |    6963 |  8537 |  6732 |    0.2444324092704 |   2.1241786580687
   7 |        7 |      1458 |    6963 |  3142 |  6733 |   1.51823979755031 |   2.3686110673391
   8 |        8 |      1458 |    6963 |  9004 |  8621 |  0.190804676475657 |  3.88685086488942
   9 |        9 |      1458 |    6963 |  6073 | 19134 |  0.313172480834778 |  4.07765554136507
  10 |       10 |      1458 |    6963 | 13088 | 19135 | 0.0890299107621897 |  4.39082802219985
  11 |       11 |      1458 |    6963 | 15790 | 19142 |   1.48580800731769 |  4.47985793296204
  12 |       12 |      1458 |    6963 | 12232 | 20397 | 0.0114205119654465 |  5.96566594027973
  13 |       13 |      1458 |    6963 | 12578 | 20391 |  0.101231599197813 |  5.97708645224518
  14 |       14 |      1458 |    6963 |  1389 | 20390 | 0.0736208919353656 |  6.07831805144299
  15 |       15 |      1458 |    6963 | 13133 | 11440 |  0.114722156383355 |  6.15193894337835
  16 |       16 |      1458 |    6963 |  9162 |  8210 |  0.035500305294526 |  6.26666109976171
  17 |       17 |      1458 |    6963 |  4797 |  8211 | 0.0517756657826458 |  6.30216140505624
  18 |       18 |      1458 |    6963 |   798 |  8212 |  0.092282586740909 |  6.35393707083888
  19 |       19 |      1458 |    6963 | 10037 |  8213 | 0.0780167141573164 |  6.44621965757979
  20 |       20 |      1458 |    6963 |  7434 |   425 |  0.323540394709221 |  6.52423637173711
  21 |       21 |      1458 |    6963 | 14760 |  1330 | 0.0841669138789044 |  6.84777676644633
  22 |       22 |      1458 |    6963 |    94 |  1329 |   3.79483755698699 |  6.93194368032523
  23 |       23 |      1458 |    6963 |  6069 |   904 |  0.132997584588892 |  10.7267812373122
  24 |       24 |      1458 |    6963 |  6047 |  3027 |   1.25335196283187 |  10.8597788219011
  25 |       25 |      1458 |    6963 |  7709 |  3829 |  0.246166449837467 |   12.113130784733
  26 |       26 |      1458 |    6963 |  4692 |  1864 |  0.160168148628724 |  12.3592972345705
  27 |       27 |      1458 |    6963 | 11169 |  1865 |  0.302681773365452 |  12.5194653831992
  28 |       28 |      1458 |    6963 | 16263 |  3831 |  0.597477583175007 |  12.8221471565646
  29 |       29 |      1458 |    6963 |  8341 |  3834 |  0.134288073415925 |  13.4196247397396
  30 |       30 |      1458 |    6963 |  6963 |    -1 |                  0 |  13.5539128131556
  31 |        1 |      1458 |   13224 |  1458 |  9579 |   1.57346861540628 |                 0
  32 |        2 |      1458 |   13224 | 15780 |  9580 | 0.0873794890514581 |  1.57346861540628
  33 |        3 |      1458 |   13224 |   341 |  9581 | 0.0557570623606965 |  1.66084810445774
  34 |        4 |      1458 |   13224 |  6588 |   402 |  0.228286689396317 |  1.71660516681844
  35 |        5 |      1458 |   13224 |  8421 | 19113 |  0.179954412397046 |  1.94489185621476
  36 |        6 |      1458 |   13224 |  8850 | 19103 |  0.136969931737385 |   2.1248462686118
  37 |        7 |      1458 |   13224 |  1911 | 19259 |   2.40529529196073 |  2.26181620034919
  38 |        8 |      1458 |   13224 |  8322 | 14424 |   3.36572646167342 |  4.66711149230992
  39 |        9 |      1458 |   13224 |  2530 | 14423 |  0.111547733446946 |  8.03283795398334
  40 |       10 |      1458 |   13224 | 13428 |  5652 | 0.0998803936459669 |  8.14438568743028
  41 |       11 |      1458 |   13224 | 14787 |  5653 |     1.115072019879 |  8.24426608107625
  42 |       12 |      1458 |   13224 |  1575 | 19133 | 0.0814050344111562 |  9.35933810095525
  43 |       13 |      1458 |   13224 | 10074 | 19248 |  0.119746283681396 |  9.44074313536641
  44 |       14 |      1458 |   13224 |  7508 | 19241 |  0.129966284268965 |   9.5604894190478
  45 |       15 |      1458 |   13224 |  5817 | 19242 |   1.68991154995938 |  9.69045570331677
  46 |       16 |      1458 |   13224 | 10545 | 19243 |  0.569662905798174 |  11.3803672532761
  47 |       17 |      1458 |   13224 |  6752 | 19126 |   1.25852460489362 |  11.9500301590743
  48 |       18 |      1458 |   13224 |  9285 | 19125 |  0.134892986035963 |  13.2085547639679
  49 |       19 |      1458 |   13224 |   427 |  6681 | 0.0843476938512957 |  13.3434477500039
  50 |       20 |      1458 |   13224 |  1378 |  1475 |  0.379591059423892 |  13.4277954438552
  51 |       21 |      1458 |   13224 | 13617 |  1476 |  0.228682568400454 |  13.8073865032791
  52 |       22 |      1458 |   13224 | 15366 |  1477 |  0.862315766858117 |  14.0360690716796
  53 |       23 |      1458 |   13224 | 15949 | 20080 |  0.256596559129536 |  14.8983848385377
  54 |       24 |      1458 |   13224 |  6624 |  8750 |  0.146646031090467 |  15.1549813976672
  55 |       25 |      1458 |   13224 | 13024 |  5565 |  0.119625224412529 |  15.3016274287577
  56 |       26 |      1458 |   13224 |  7089 |  7020 |   0.10299648441643 |  15.4212526531702
  57 |       27 |      1458 |   13224 |  6510 |  7329 |  0.133176775321101 |  15.5242491375866
  58 |       28 |      1458 |   13224 |  4506 |  5150 |   1.90541644654938 |  15.6574259129077
  59 |       29 |      1458 |   13224 |  5650 |   852 |  0.149286170070424 |  17.5628423594571
  60 |       30 |      1458 |   13224 |  6843 |   851 |  0.274651986807244 |  17.7121285295275
  61 |       31 |      1458 |   13224 |  8663 |   850 |  0.714091863032161 |  17.9867805163348
  62 |       32 |      1458 |   13224 |  1550 | 19237 |  0.683387676109264 |  18.7008723793669
  63 |       33 |      1458 |   13224 |   505 | 19236 |  0.571468937136481 |  19.3842600554762
  64 |       34 |      1458 |   13224 | 13224 |    -1 |                  0 |  19.9557289926127
  65 |        1 |      6549 |    6963 |  6549 |  5660 |  0.856236728735746 |                 0
  66 |        2 |      6549 |    6963 |  7070 |  5661 |   0.18543632496964 | 0.856236728735746
  67 |        3 |      6549 |    6963 |   426 |  5662 |   1.22432099182122 |  1.04167305370539
  68 |        4 |      6549 |    6963 | 10096 |  5663 |  0.240812864742167 |  2.26599404552661
  69 |        5 |      6549 |    6963 |  4569 |  5664 |  0.509024186920151 |  2.50680691026878
  70 |        6 |      6549 |    6963 |  4805 |  5642 |   0.24583236679844 |  3.01583109718893
  71 |        7 |      6549 |    6963 | 15283 |  3024 |   0.41220319337299 |  3.26166346398737
  72 |        8 |      6549 |    6963 | 12972 |   334 |  0.079787419303827 |  3.67386665736036
  73 |        9 |      6549 |    6963 | 12557 |   335 |   0.32821634495476 |  3.75365407666418
  74 |       10 |      6549 |    6963 |  1663 |   336 |   0.26912469116213 |  4.08187042161894
  75 |       11 |      6549 |    6963 |  4337 |   337 |  0.271106952505498 |  4.35099511278107
  76 |       12 |      6549 |    6963 | 15036 |   338 |  0.210400135656938 |  4.62210206528657
  77 |       13 |      6549 |    6963 | 16202 |   339 |  0.372184280461411 |  4.83250220094351
  78 |       14 |      6549 |    6963 |  9160 |   340 |  0.378482125906236 |  5.20468648140492
  79 |       15 |      6549 |    6963 | 14494 |   341 |  0.278790857180833 |  5.58316860731116
  80 |       16 |      6549 |    6963 | 12260 |   342 |  0.319993852882897 |  5.86195946449199
  81 |       17 |      6549 |    6963 |  4544 |   869 |  0.117725426174845 |  6.18195331737489
  82 |       18 |      6549 |    6963 | 12332 |   870 |  0.798268469610074 |  6.29967874354973
  83 |       19 |      6549 |    6963 |  2479 |   871 |  0.192201284358209 |  7.09794721315981
  84 |       20 |      6549 |    6963 | 10803 |   749 |  0.162628256488273 |  7.29014849751801
  85 |       21 |      6549 |    6963 |   350 |   840 |  0.580025721045009 |  7.45277675400629
  86 |       22 |      6549 |    6963 | 13661 |  3832 |  0.167447948694977 |   8.0328024750513
  87 |       23 |      6549 |    6963 |  2736 |  3835 |  0.142495300911802 |  8.20025042374628
  88 |       24 |      6549 |    6963 |  6963 |    -1 |                  0 |  8.34274572465808
  89 |        1 |      6549 |   13224 |  6549 |  7019 |   1.12638337790452 |                 0
  90 |        2 |      6549 |   13224 |  4004 |  7018 |  0.133247054870613 |  1.12638337790452
  91 |        3 |      6549 |   13224 |  2042 |  7017 |  0.106264259064905 |  1.25963043277513
  92 |        4 |      6549 |   13224 | 11902 |  7016 |  0.100599246888521 |  1.36589469184003
  93 |        5 |      6549 |   13224 |  2477 |  7015 |  0.562685738696528 |  1.46649393872855
  94 |        6 |      6549 |   13224 |  8159 | 19191 |  0.546009970780361 |  2.02917967742508
  95 |        7 |      6549 |   13224 |  7753 | 19178 |  0.095156114074139 |  2.57518964820544
  96 |        8 |      6549 |   13224 |  6893 | 19177 |  0.111571122322606 |  2.67034576227958
  97 |        9 |      6549 |   13224 |   905 |   820 |   1.81455426904932 |  2.78191688460219
  98 |       10 |      6549 |   13224 |  3495 |   815 |   2.04338884879897 |  4.59647115365151
  99 |       11 |      6549 |   13224 | 13224 |    -1 |                  0 |  6.63986000245047
 100 |        1 |      9224 |    6963 |  9224 |  6711 |  0.773696928177316 |                 0
 101 |        2 |      9224 |    6963 |  4540 |  6710 |  0.232104296691239 | 0.773696928177316
 102 |        3 |      9224 |    6963 |  5214 |  6709 | 0.0706150934847376 |  1.00580122486856
 103 |        4 |      9224 |    6963 | 15275 | 18557 |  0.978833365836443 |  1.07641631835329
 104 |        5 |      9224 |    6963 |  8576 | 10912 |  0.534652025142967 |  2.05524968418974
 105 |        6 |      9224 |    6963 | 13002 | 10940 |  0.754355406473535 |   2.5899017093327
 106 |        7 |      9224 |    6963 |  4734 |  5196 |  0.122070875539987 |  3.34425711580624
 107 |        8 |      9224 |    6963 |  9409 | 18621 |  0.651775735966076 |  3.46632799134622
 108 |        9 |      9224 |    6963 | 12005 | 18620 |  0.924386265472568 |   4.1181037273123
 109 |       10 |      9224 |    6963 |    58 |  9757 | 0.0974486858022987 |  5.04248999278487
 110 |       11 |      9224 |    6963 | 15849 | 14510 |     0.105947279089 |  5.13993867858717
 111 |       12 |      9224 |    6963 | 14083 | 14509 | 0.0851922029461005 |  5.24588595767617
 112 |       13 |      9224 |    6963 |  2592 | 14514 | 0.0531023411166572 |  5.33107816062227
 113 |       14 |      9224 |    6963 |  7902 | 18324 |  0.112388719540531 |  5.38418050173892
 114 |       15 |      9224 |    6963 |  7188 | 18325 |  0.602672154364066 |  5.49656922127946
 115 |       16 |      9224 |    6963 | 10691 |  7398 |  0.675677318680876 |  6.09924137564352
 116 |       17 |      9224 |    6963 |  3795 |  7396 |  0.572249268348016 |   6.7749186943244
 117 |       18 |      9224 |    6963 |   420 |  7397 |  0.625345079853931 |  7.34716796267241
 118 |       19 |      9224 |    6963 | 10227 | 14557 |  0.187346129253984 |  7.97251304252634
 119 |       20 |      9224 |    6963 |  3365 |  4910 |   2.71898528812772 |  8.15985917178033
 120 |       21 |      9224 |    6963 | 14964 | 14567 |  0.919723500053188 |  10.8788444599081
 121 |       22 |      9224 |    6963 | 14556 | 14566 |  0.421393042915545 |  11.7985679599612
 122 |       23 |      9224 |    6963 |  5739 | 14565 | 0.0874785875266396 |  12.2199610028768
 123 |       24 |      9224 |    6963 |  8234 |  5072 |  0.101564572624929 |  12.3074395904034
 124 |       25 |      9224 |    6963 |  1790 | 18229 |  0.936340300859038 |  12.4090041630284
 125 |       26 |      9224 |    6963 |  3786 |   898 |   1.01060126254594 |  13.3453444638874
 126 |       27 |      9224 |    6963 |  1777 |   900 | 0.0868146142138172 |  14.3559457264333
 127 |       28 |      9224 |    6963 |  4761 |   897 |  0.153033494566707 |  14.4427603406471
 128 |       29 |      9224 |    6963 |  8645 |   877 |  0.441176097084315 |  14.5957938352139
 129 |       30 |      9224 |    6963 |  7036 |   876 |   0.38256066668352 |  15.0369699322982
 130 |       31 |      9224 |    6963 |  5046 |   875 |   2.28587451856933 |  15.4195305989817
 131 |       32 |      9224 |    6963 |  1398 |   874 |  0.532328474203955 |   17.705405117551
 132 |       33 |      9224 |    6963 |  3940 |   873 |  0.164923762476395 |   18.237733591755
 133 |       34 |      9224 |    6963 |  6362 |  3833 |  0.826788500281132 |  18.4026573542314
 134 |       35 |      9224 |    6963 |  2736 |  3835 |  0.142495300911802 |  19.2294458545125
 135 |       36 |      9224 |    6963 |  6963 |    -1 |                  0 |  19.3719411554243
 136 |        1 |      9224 |   13224 |  9224 |  6711 |  0.773696928177316 |                 0
 137 |        2 |      9224 |   13224 |  4540 |  6710 |  0.232104296691239 | 0.773696928177316
 138 |        3 |      9224 |   13224 |  5214 | 18791 |   1.11496813318663 |  1.00580122486856
 139 |        4 |      9224 |   13224 | 15391 | 18790 |  0.629807657505021 |  2.12076935805518
 140 |        5 |      9224 |   13224 | 16045 | 18305 |  0.118099876846571 |   2.7505770155602
 141 |        6 |      9224 |   13224 |  8016 | 18336 | 0.0949552607183629 |  2.86867689240677
 142 |        7 |      9224 |   13224 |  5874 |  6491 |  0.154418627617342 |  2.96363215312514
 143 |        8 |      9224 |   13224 | 11139 | 10968 |  0.158312370688833 |  3.11805078074248
 144 |        9 |      9224 |   13224 | 13281 | 10969 |  0.133989204436935 |  3.27636315143131
 145 |       10 |      9224 |   13224 |  7908 | 18561 |  0.697275266901291 |  3.41035235586825
 146 |       11 |      9224 |   13224 | 13998 | 18563 |  0.547027323871538 |  4.10762762276954
 147 |       12 |      9224 |   13224 | 12237 | 18562 | 0.0888340044228515 |  4.65465494664107
 148 |       13 |      9224 |   13224 |  8935 | 14574 |  0.217938536161786 |  4.74348895106393
 149 |       14 |      9224 |   13224 | 13899 |  5746 | 0.0956244782520282 |  4.96142748722571
 150 |       15 |      9224 |   13224 | 10042 | 18292 |  0.209510657580041 |  5.05705196547774
 151 |       16 |      9224 |   13224 |  9765 |  3750 |  0.394214790297416 |  5.26656262305778
 152 |       17 |      9224 |   13224 |  9783 | 17567 |   1.47865199158308 |   5.6607774133552
 153 |       18 |      9224 |   13224 |  7365 | 17566 |  0.142654295492492 |  7.13942940493827
 154 |       19 |      9224 |   13224 |  9981 |  1075 |  0.121693110491214 |  7.28208370043077
 155 |       20 |      9224 |   13224 |    97 |  1074 |  0.271539243863741 |  7.40377681092198
 156 |       21 |      9224 |   13224 |  5894 |  1071 |   1.05084151064365 |  7.67531605478572
 157 |       22 |      9224 |   13224 |  4551 |  8166 |  0.122945383321654 |  8.72615756542937
 158 |       23 |      9224 |   13224 |  3477 |  8167 |   0.19780615549443 |  8.84910294875103
 159 |       24 |      9224 |   13224 |  3456 |  8168 |  0.256549524400158 |  9.04690910424546
 160 |       25 |      9224 |   13224 |  4676 |  4559 |  0.710561355427673 |  9.30345862864561
 161 |       26 |      9224 |   13224 |  2595 |  4558 |  0.635409597559948 |  10.0140199840733
 162 |       27 |      9224 |   13224 | 12838 |  4560 |  0.223241579577864 |  10.6494295816332
 163 |       28 |      9224 |   13224 | 11204 |  4561 |  0.110277053900362 |  10.8726711612111
 164 |       29 |      9224 |   13224 | 12284 |  4562 |   1.12700881187194 |  10.9829482151115
 165 |       30 |      9224 |   13224 | 15694 | 20388 |  0.195375199863932 |  12.1099570269834
 166 |       31 |      9224 |   13224 | 15346 |  6296 |  0.479323831671295 |  12.3053322268473
 167 |       32 |      9224 |   13224 |  4096 |  6297 |  0.124011131587728 |  12.7846560585186
 168 |       33 |      9224 |   13224 | 10104 |  6298 |   0.42727818155537 |  12.9086671901064
 169 |       34 |      9224 |   13224 | 13203 |  6299 |   1.27293032593827 |  13.3359453716617
 170 |       35 |      9224 |   13224 |  3338 |  6300 |  0.186128128406448 |     14.6088756976
 171 |       36 |      9224 |   13224 |  9153 |  6301 |   1.20541845996808 |  14.7950038260064
 172 |       37 |      9224 |   13224 |   199 | 20384 |  0.491716749607846 |  16.0004222859745
 173 |       38 |      9224 |   13224 |   174 | 19179 |   1.34434765217617 |  16.4921390355824
 174 |       39 |      9224 |   13224 |  1007 | 13470 |  0.323758049065568 |  17.8364866877585
 175 |       40 |      9224 |   13224 |    94 | 20392 |   1.57850903298838 |  18.1602447368241
 176 |       41 |      9224 |   13224 |  6992 | 20393 |    1.3326162510893 |  19.7387537698125
 177 |       42 |      9224 |   13224 |  9990 | 19088 |   1.44424904645741 |  21.0713700209018
 178 |       43 |      9224 |   13224 |  7869 | 19306 |  0.203847503756027 |  22.5156190673592
 179 |       44 |      9224 |   13224 |  2964 | 19307 |  0.264910569910049 |  22.7194665711152
 180 |       45 |      9224 |   13224 |  2778 | 19308 |  0.137497360435593 |  22.9843771410253
 181 |       46 |      9224 |   13224 | 11615 | 19309 |  0.433551668185912 |  23.1218745014609
 182 |       47 |      9224 |   13224 | 14235 | 18830 |   1.62502458657018 |  23.5554261696468
 183 |       48 |      9224 |   13224 | 16021 | 19152 |  0.337527102454226 |   25.180450756217
 184 |       49 |      9224 |   13224 | 11977 |  8315 |  0.439955193639265 |  25.5179778586712
 185 |       50 |      9224 |   13224 |  9454 |  8327 |  0.277010232556917 |  25.9579330523105
 186 |       51 |      9224 |   13224 |  7225 |  8326 |  0.300986536975075 |  26.2349432848674
 187 |       52 |      9224 |   13224 |   658 |  8325 |  0.356285363524885 |  26.5359298218424
 188 |       53 |      9224 |   13224 | 13696 |  8312 |  0.100233835467446 |  26.8922151853673
 189 |       54 |      9224 |   13224 | 10632 |  8306 |  0.156940787142826 |  26.9924490208348
 190 |       55 |      9224 |   13224 |  7472 |  4646 |  0.185255816866985 |  27.1493898079776
 191 |       56 |      9224 |   13224 |   660 |  4645 | 0.0430781272282002 |  27.3346456248446
 192 |       57 |      9224 |   13224 |  1390 |  4644 |  0.315541872489444 |  27.3777237520728
 193 |       58 |      9224 |   13224 |  2632 |  4643 | 0.0210217145327529 |  27.6932656245622
 194 |       59 |      9224 |   13224 |  2423 |  4642 |  0.353815922083968 |   27.714287339095
 195 |       60 |      9224 |   13224 |  6229 |  4641 |  0.122744130702009 |   28.068103261179
 196 |       61 |      9224 |   13224 |  6985 |  4640 |  0.126551836609363 |   28.190847391881
 197 |       62 |      9224 |   13224 |  4237 |  4639 |  0.168580092244456 |  28.3173992284903
 198 |       63 |      9224 |   13224 |  4835 |  4638 |  0.116869841098416 |  28.4859793207348
 199 |       64 |      9224 |   13224 |  5870 |  2450 |  0.131281054192934 |  28.6028491618332
 200 |       65 |      9224 |   13224 |    72 |  2451 |  0.194002643237697 |  28.7341302160261
 201 |       66 |      9224 |   13224 |   107 |  2452 |  0.420862720533796 |  28.9281328592638
 202 |       67 |      9224 |   13224 | 11811 |  2453 |   1.34175228218895 |  29.3489955797976
 203 |       68 |      9224 |   13224 |  1550 | 19237 |  0.683387676109264 |  30.6907478619866
 204 |       69 |      9224 |   13224 |   505 | 19236 |  0.571468937136481 |  31.3741355380958
 205 |       70 |      9224 |   13224 | 13224 |    -1 |                  0 |  31.9456044752323
(205 rows)

12.1.5. Solution to Exercise 5

Exercise 5

 start_vid | end_vid |     agg_cost     
-----------+---------+------------------
      1458 |    6963 | 13.5539128131556
      6549 |    6963 | 8.34274572465808
      9224 |    6963 | 19.3719411554243
      1458 |   13224 | 19.9557289926127
      6549 |   13224 | 6.63986000245047
      9224 |   13224 | 31.9456044752323
(6 rows)

12.1.6. Solution to Exercise 6

Exercise 6

 seq | node  | edge  |         cost         
-----+-------+-------+----------------------
   0 | 13224 |   815 |  0.00177810584893137
   1 |  3495 |   820 |  0.00179225967147818
   2 |   905 | 19177 | 0.000102092605022171
   3 |  6893 | 19178 | 8.66225143958747e-05
   4 |  7753 | 19191 |  0.00047705096163826
   5 |  8159 |  7015 | 0.000513853140499986
   6 |  2477 |  7016 | 9.12382595170489e-05
   7 | 11902 |  7017 | 9.71560600269149e-05
   8 |  2042 |  7018 | 0.000120258430056735
   9 |  4004 |  7019 |  0.00102611053011065
  10 |  6549 |    -1 |                    0
(11 rows)

BEGIN

12.2. Advanced Routing Queries Solutions

12.2.1. Solution to Exercise 7

Exercise 7

 seq | path_seq | node  | edge  |       cost        |     agg_cost     
-----+----------+-------+-------+-------------------+------------------
   1 |        1 | 13224 | 19236 |  5.57182213708069 |                0
   2 |        2 |   505 | 19237 |  6.66302984206533 | 5.57182213708069
   3 |        3 |  1550 |  2454 | 0.678269603711311 |  12.234851979146
   4 |        4 |  3912 |  9773 |  4.28726495803698 | 12.9131215828573
   5 |        5 |  5484 | 19302 | 0.453562668313021 | 17.2003865408943
   6 |        6 |  6769 | 19198 |  1.29729350245085 | 17.6539492092073
   7 |        7 |   248 | 19199 | 0.421429419306211 | 18.9512427116582
   8 |        8 |  2741 | 18024 | 0.597971461086073 | 19.3726721309644
   9 |        9 |  6843 | 18023 |  5.46158224174097 | 19.9706435920505
  10 |       10 |  3986 | 18022 |  3.97827696652654 | 25.4322258337914
  11 |       11 | 11907 | 18021 |  1.88946212222989 |  29.410502800318
  12 |       12 |  9476 | 18020 | 0.890793524893943 | 31.2999649225479
  13 |       13 |  9911 | 18019 |  1.02544844872492 | 32.1907584474418
  14 |       14 |  9710 | 13478 |  1.02341600240761 | 33.2162068961667
  15 |       15 | 16314 | 13477 |  1.24960907383209 | 34.2396228985743
  16 |       16 |  2793 | 18822 |  7.04906959908907 | 35.4892319724064
  17 |       17 | 13888 | 18823 |  5.78359258512173 | 42.5383015714955
  18 |       18 |  6887 | 19097 |  9.78950308437746 | 48.3218941566172
  19 |       19 |  2185 | 19096 |  3.72160974357092 | 58.1113972409947
  20 |       20 |  5723 | 18364 |  1.70159294499613 | 61.8330069845656
  21 |       21 |  7421 | 18814 |  2.55067544929402 | 63.5345999295618
  22 |       22 | 10611 | 18815 |  6.28024488985007 | 66.0852753788558
  23 |       23 |  5458 | 18816 |  3.71826690986161 | 72.3655202687058
  24 |       24 | 14373 | 18824 |  2.98521776926893 | 76.0837871785674
  25 |       25 | 15388 | 18825 |  11.7495133585327 | 79.0690049478364
  26 |       26 |   670 | 18826 | 0.398358466430553 | 90.8185183063691
  27 |       27 | 11896 |  6751 | 0.837746076712271 | 91.2168767727996
  28 |       28 |  6210 |  6752 | 0.255329438423506 | 92.0546228495119
  29 |       29 |  1389 |  6753 | 0.783619203312067 | 92.3099522879354
  30 |       30 |   912 |  6754 |   3.2425587441558 | 93.0935714912475
  31 |       31 | 10098 |  6755 |  2.63371669177485 | 96.3361302354033
  32 |       32 | 14098 |  6756 |  1.77951960289969 | 98.9698469271781
  33 |       33 | 15603 |  6757 |  3.24568448358097 | 100.749366530078
  34 |       34 |  3931 |  6758 |  3.04856034692038 | 103.995051013659
  35 |       35 | 13624 |  6759 |  3.77794278764274 | 107.043611360579
  36 |       36 | 10999 |  6760 | 0.751733402129401 | 110.821554148222
  37 |       37 |  5042 |  6761 |  2.14000806157837 | 111.573287550351
  38 |       38 |  3496 |  6762 |  8.98425436379907 |  113.71329561193
  39 |       39 | 15063 |  6763 |  2.48246793843341 | 122.697549975729
  40 |       40 |  8809 |   409 |  2.94785206024908 | 125.180017914162
  41 |       41 | 14558 |   410 | 0.967628330903848 | 128.127869974411
  42 |       42 |  4468 |   411 |  2.19980052564804 | 129.095498305315
  43 |       43 | 15820 |   412 |   5.3577280770342 | 131.295298830963
  44 |       44 |  6388 |   413 | 0.656576736380796 | 136.653026907997
  45 |       45 |    47 |   414 |  1.80202776516093 | 137.309603644378
  46 |       46 |  8383 |   349 |  1.19715001612563 | 139.111631409539
  47 |       47 | 11145 |   415 |  2.95402628867348 | 140.308781425665
  48 |       48 |  9508 |   416 | 0.964202251525239 | 143.262807714338
  49 |       49 | 12841 | 10967 |  0.72090542218561 | 144.227009965863
  50 |       50 | 15231 |  4657 | 0.636480094206681 | 144.947915388049
  51 |       51 |  1499 |  4658 | 0.332359538896821 | 145.584395482256
  52 |       52 |   956 |  4659 | 0.721349979408134 | 145.916755021153
  53 |       53 |   682 |  4654 | 0.790028942546533 | 146.638105000561
  54 |       54 |  7348 |  4655 |  1.50565798580178 | 147.428133943107
  55 |       55 |  4367 | 18566 | 0.426099157483539 | 148.933791928909
  56 |       56 | 10294 | 18757 |  4.95270745419416 | 149.359891086393
  57 |       57 |  4697 | 18788 |  6.35004451061804 | 154.312598540587
  58 |       58 |  7826 | 18308 |  1.08235846879132 | 160.662643051205
  59 |       59 | 13257 | 18307 | 0.920968079054278 | 161.745001519996
  60 |       60 | 13205 | 18306 | 0.333126239689007 |  162.66596959905
  61 |       61 |  8016 | 18305 | 0.708599261079426 | 162.999095838739
  62 |       62 | 16045 | 18790 |  3.77884594503012 | 163.707695099819
  63 |       63 | 15391 | 18791 |  6.68980879911976 | 167.486541044849
  64 |       64 |  5214 |  6710 |  1.39262578014744 | 174.176349843969
  65 |       65 |  4540 |  6711 |   4.6421815690639 | 175.568975624116
  66 |       66 |  9224 |    -1 |                 0 |  180.21115719318
(66 rows)

12.2.2. Solution to Exercise 8

Exercise 8

 seq | path_seq | node  | edge  |        cost         |     agg_cost      
-----+----------+-------+-------+---------------------+-------------------
   1 |        1 | 13224 | 19236 |    0.15477283714113 |                 0
   2 |        2 |   505 | 19237 |   0.185084162279592 |  0.15477283714113
   3 |        3 |  1550 |  2454 |  0.0188408223253142 | 0.339856999420723
   4 |        4 |  3912 |  9773 |   0.119090693278805 | 0.358697821746037
   5 |        5 |  5484 | 19302 |   0.012598963008695 | 0.477788515024842
   6 |        6 |  6769 | 19198 |  0.0360359306236348 | 0.490387478033537
   7 |        7 |   248 | 19199 |  0.0117063727585059 | 0.526423408657172
   8 |        8 |  2741 | 18024 |   0.016610318363502 | 0.538129781415678
   9 |        9 |  6843 | 18023 |   0.151710617826138 |  0.55474009977918
  10 |       10 |  3986 | 18022 |   0.110507693514626 | 0.706450717605318
  11 |       11 | 11907 | 18021 |  0.0524850589508304 | 0.816958411119944
  12 |       12 |  9476 | 18020 |  0.0247442645803873 | 0.869443470070774
  13 |       13 |  9911 | 18019 |  0.0284846791312478 | 0.894187734651161
  14 |       14 |  9710 | 13478 |  0.0284282222891003 | 0.922672413782409
  15 |       15 | 16314 | 13477 |  0.0347113631620025 | 0.951100636071509
  16 |       16 |  2793 | 18822 |   0.195807488863585 | 0.985811999233512
  17 |       17 | 13888 | 18823 |   0.160655349586715 |   1.1816194880971
  18 |       18 |  6887 | 19097 |   0.271930641232707 |  1.34227483768381
  19 |       19 |  2185 | 19096 |   0.103378048432526 |  1.61420547891652
  20 |       20 |  5723 | 18364 |  0.0472664706943368 |  1.71758352734904
  21 |       21 |  7421 | 18814 |  0.0708520958137228 |  1.76484999804338
  22 |       22 | 10611 | 18815 |    0.17445124694028 |   1.8357020938571
  23 |       23 |  5458 | 18816 |     0.1032851919406 |  2.01015334079738
  24 |       24 | 14373 | 18824 |  0.0829227158130259 |  2.11343853273798
  25 |       25 | 15388 | 18825 |   0.326375371070353 |  2.19636124855101
  26 |       26 |   670 | 18826 |  0.0110655129564042 |  2.52273661962136
  27 |       27 | 11896 |  6751 |  0.0232707243531186 |  2.53380213257777
  28 |       28 |  6210 |  6752 | 0.00709248440065293 |  2.55707285693089
  29 |       29 |  1389 |  6753 |  0.0217672000920019 |  2.56416534133154
  30 |       30 |   912 |  6754 |  0.0900710762265499 |  2.58593254142354
  31 |       31 | 10098 |  6755 |  0.0731587969937459 |  2.67600361765009
  32 |       32 | 14098 |  6756 |  0.0494311000805468 |  2.74916241464384
  33 |       33 | 15603 |  6757 |  0.0901579023216935 |  2.79859351472438
  34 |       34 |  3931 |  6758 |  0.0846822318588993 |  2.88875141704608
  35 |       35 | 13624 |  6759 |   0.104942855212298 |  2.97343364890498
  36 |       36 | 10999 |  6760 |  0.0208814833924834 |  3.07837650411728
  37 |       37 |  5042 |  6761 |  0.0594446683771771 |  3.09925798750976
  38 |       38 |  3496 |  6762 |   0.249562621216641 |  3.15870265588694
  39 |       39 | 15063 |  6763 |  0.0689574427342613 |  3.40826527710358
  40 |       40 |  8809 |   409 |  0.0818847794513632 |  3.47722271983784
  41 |       41 | 14558 |   410 |  0.0268785647473291 |   3.5591074992892
  42 |       42 |  4468 |   411 |  0.0611055701568899 |  3.58598606403653
  43 |       43 | 15820 |   412 |   0.148825779917617 |  3.64709163419342
  44 |       44 |  6388 |   413 |  0.0182382426772443 |  3.79591741411104
  45 |       45 |    47 |   414 |  0.0500563268100258 |  3.81415565678828
  46 |       46 |  8383 |   349 |   0.033254167114601 |  3.86421198359831
  47 |       47 | 11145 |   415 |  0.0820562857964855 |  3.89746615071291
  48 |       48 |  9508 |   416 |  0.0267833958757011 |  3.97952243650939
  49 |       49 | 12841 | 10967 |  0.0200251506162669 |   4.0063058323851
  50 |       50 | 15231 |  4657 |  0.0176800026168523 |  4.02633098300136
  51 |       51 |  1499 |  4658 | 0.00923220941380058 |  4.04401098561821
  52 |       52 |   956 |  4659 |  0.0200374994280037 |  4.05324319503201
  53 |       53 |   682 |  4654 |  0.0219452484040704 |  4.07328069446002
  54 |       54 |  7348 |  4655 |  0.0418238329389385 |  4.09522594286409
  55 |       55 |  4367 | 18566 |  0.0118360877078761 |  4.13704977580303
  56 |       56 | 10294 | 18757 |   0.137575207060949 |   4.1488858635109
  57 |       57 |  4697 | 18788 |   0.176390125294945 |  4.28646107057185
  58 |       58 |  7826 | 18308 |  0.0300655130219811 |   4.4628511958668
  59 |       59 | 13257 | 18307 |  0.0255824466403966 |  4.49291670888878
  60 |       60 | 13205 | 18306 | 0.00925350665802798 |  4.51849915552918
  61 |       61 |  8016 | 18305 |  0.0196833128077618 |   4.5277526621872
  62 |       62 | 16045 | 18790 |   0.104967942917503 |  4.54743597499496
  63 |       63 | 15391 | 18791 |   0.185828022197771 |  4.65240391791247
  64 |       64 |  5214 |  6710 |  0.0386840494485399 |  4.83823194011024
  65 |       65 |  4540 |  6711 |   0.128949488029553 |  4.87691598955878
  66 |       66 |  9224 |    -1 |                   0 |  5.00586547758833
(66 rows)

12.2.3. Solution to Exercise 9

Exercise 9

 seq | path_seq | node  | edge  |       cost        |     agg_cost     
-----+----------+-------+-------+-------------------+------------------
   1 |        1 | 13224 | 19236 |  5.57182213708069 |                0
   2 |        2 |   505 | 19237 |  6.66302984206533 | 5.57182213708069
   3 |        3 |  1550 |  2453 |  13.0820847513423 |  12.234851979146
   4 |        4 | 11811 |  2452 |  4.10341152520451 | 25.3169367304883
   5 |        5 |   107 |  2451 |  1.89152577156755 | 29.4203482556928
   6 |        6 |    72 |  2450 |  1.27999027838111 | 31.3118740272604
   7 |        7 |  5870 |  1470 |  9.45396899233208 | 32.5918643056415
   8 |        8 |  9911 |  1471 |  1.56584704878802 | 42.0458332979735
   9 |        9 |  6510 |   329 | 0.929528750890085 | 43.6116803467616
  10 |       10 |  7890 |   330 | 0.630377814496658 | 44.5412090976517
  11 |       11 |  6577 |  4314 | 0.391089758215698 | 45.1715869121483
  12 |       12 | 13024 | 18821 | 0.562099221869422 |  45.562676670364
  13 |       13 |  2793 | 18822 |  4.22944175945344 | 46.1247758922334
  14 |       14 | 13888 | 18823 |  3.47015555107304 | 50.3542176516869
  15 |       15 |  6887 | 19097 |  5.87370185062647 | 53.8243732027599
  16 |       16 |  2185 | 19096 |  2.23296584614255 | 59.6980750533864
  17 |       17 |  5723 | 18364 |  1.02095576699768 | 61.9310408995289
  18 |       18 |  7421 | 18814 |  1.53040526957641 | 62.9519966665266
  19 |       19 | 10611 | 18815 |  3.76814693391004 |  64.482401936103
  20 |       20 |  5458 | 18816 |  2.23096014591697 | 68.2505488700131
  21 |       21 | 14373 | 18824 |  1.79113066156136 |   70.48150901593
  22 |       22 | 15388 | 18825 |  7.04970801511962 | 72.2726396774914
  23 |       23 |   670 | 18826 | 0.239015079858332 |  79.322347692611
  24 |       24 | 11896 |  6751 | 0.502647646027362 | 79.5613627724694
  25 |       25 |  6210 |  6752 | 0.153197663054103 | 80.0640104184967
  26 |       26 |  1389 |  6753 |  0.47017152198724 | 80.2172080815508
  27 |       27 |   912 |  6754 |  1.94553524649348 |  80.687379603538
  28 |       28 | 10098 |  6755 |  1.58023001506491 | 82.6329148500315
  29 |       29 | 14098 |  6756 |  1.06771176173981 | 84.2131448650964
  30 |       30 | 15603 |  6757 |  1.94741069014858 | 85.2808566268363
  31 |       31 |  3931 |  6758 |  1.82913620815223 | 87.2282673169848
  32 |       32 | 13624 |  6759 |  2.26676567258564 | 89.0574035251371
  33 |       33 | 10999 |  6760 | 0.451040041277641 | 91.3241691977227
  34 |       34 |  5042 |  6761 |  1.28400483694702 | 91.7752092390003
  35 |       35 |  3496 |  6762 |  5.39055261827944 | 93.0592140759474
  36 |       36 | 15063 |  6763 |  1.48948076306004 | 98.4497666942268
  37 |       37 |  8809 |   409 |  1.76871123614945 | 99.9392474572869
  38 |       38 | 14558 |   410 | 0.580576998542309 | 101.707958693436
  39 |       39 |  4468 |   411 |  1.31988031538882 | 102.288535691979
  40 |       40 | 15820 |   412 |  3.21463684622052 | 103.608416007367
  41 |       41 |  6388 |   413 | 0.393946041828477 | 106.823052853588
  42 |       42 |    47 |   414 |  1.08121665909656 | 107.216998895416
  43 |       43 |  8383 |   349 | 0.718290009675381 | 108.298215554513
  44 |       44 | 11145 |   415 |  1.77241577320409 | 109.016505564188
  45 |       45 |  9508 |   416 | 0.578521350915144 | 110.788921337392
  46 |       46 | 12841 | 10967 | 0.432543253311366 | 111.367442688308
  47 |       47 | 15231 |  4657 | 0.509184075365345 | 111.799985941619
  48 |       48 |  1499 |  4658 | 0.265887631117457 | 112.309170016984
  49 |       49 |   956 |  4659 | 0.577079983526507 | 112.575057648102
  50 |       50 |   682 |  4654 | 0.632023154037226 | 113.152137631628
  51 |       51 |  7348 |  4655 |  1.20452638864143 | 113.784160785665
  52 |       52 |  4367 |  4656 |  3.54808613080014 | 114.988687174307
  53 |       53 |  6266 | 18558 | 0.897700123698223 | 118.536773305107
  54 |       54 |  3799 | 18559 |  4.81435744955728 | 119.434473428805
  55 |       55 |  7033 | 18560 | 0.874950823815008 | 124.248830878363
  56 |       56 | 11139 |  6491 | 0.741209412563241 | 125.123781702178
  57 |       57 |  5874 | 10944 | 0.801491047925414 | 125.864991114741
  58 |       58 |  9090 | 10945 |  3.56198970170045 | 126.666482162666
  59 |       59 | 15967 | 10946 |  4.94211690709793 | 130.228471864367
  60 |       60 | 15275 |  6709 | 0.423690560908426 | 135.170588771465
  61 |       61 |  5214 |  6710 |  1.39262578014744 | 135.594279332373
  62 |       62 |  4540 |  6711 |   4.6421815690639 |  136.98690511252
  63 |       63 |  9224 |    -1 |                 0 | 141.629086681584
(63 rows)

12.2.4. Solution to Exercise 10

Exercise 10

 seq | path_seq | node  | edge  |        cost        |     agg_cost     
-----+----------+-------+-------+--------------------+------------------
   1 |        1 | 13224 | 19236 |   2.78591106854035 |                0
   2 |        2 |   505 | 19237 |   3.33151492103266 | 2.78591106854035
   3 |        3 |  1550 |  2454 | 0.0678269603711311 | 6.11742598957301
   4 |        4 |  3912 |  9773 |  0.428726495803698 | 6.18525294994414
   5 |        5 |  5484 | 19302 | 0.0453562668313021 | 6.61397944574784
   6 |        6 |  6769 | 19198 |  0.129729350245085 | 6.65933571257914
   7 |        7 |   248 | 19199 | 0.0421429419306211 | 6.78906506282423
   8 |        8 |  2741 | 18024 | 0.0597971461086073 | 6.83120800475485
   9 |        9 |  6843 | 18023 |  0.546158224174098 | 6.89100515086346
  10 |       10 |  3986 | 18022 |  0.397827696652654 | 7.43716337503755
  11 |       11 | 11907 | 18021 |  0.188946212222989 | 7.83499107169021
  12 |       12 |  9476 | 18020 | 0.0890793524893943 |  8.0239372839132
  13 |       13 |  9911 | 18019 |  0.102544844872492 | 8.11301663640259
  14 |       14 |  9710 | 18018 |  0.155387073771394 | 8.21556148127508
  15 |       15 | 15452 | 18832 |  0.155723239649382 | 8.37094855504647
  16 |       16 | 13516 | 18831 |   1.11924403732928 | 8.52667179469586
  17 |       17 | 16021 | 18830 |  0.975014751942106 | 9.64591583202513
  18 |       18 | 14235 | 19309 |  0.260131000911547 | 10.6209305839672
  19 |       19 | 11615 | 19308 | 0.0824984162613557 | 10.8810615848788
  20 |       20 |  2778 | 19307 |  0.158946341946029 | 10.9635600011401
  21 |       21 |  2964 | 19306 |  0.122308502253616 | 11.1225063430862
  22 |       22 |  7869 | 19088 |  0.866549427874448 | 11.2448148453398
  23 |       23 |  9990 | 20393 |  0.799569750653582 | 12.1113642732142
  24 |       24 |  6992 | 20392 |   0.94710541979303 | 12.9109340238678
  25 |       25 |    94 | 13470 |  0.194254829439341 | 13.8580394436608
  26 |       26 |  1007 | 19179 |    0.8066085913057 | 14.0522942731002
  27 |       27 |   174 | 18323 | 0.0730450068489668 | 14.8589028644059
  28 |       28 |  8543 | 18322 |  0.246255236621709 | 14.9319478712549
  29 |       29 |  9066 | 20363 |   0.50236810854033 | 15.1782031078766
  30 |       30 | 10257 | 20362 |  0.242035047945409 | 15.6805712164169
  31 |       31 |  3030 | 20361 | 0.0415220838681793 | 15.9226062643623
  32 |       32 | 10887 | 20360 |   0.47113047603107 | 15.9641283482305
  33 |       33 | 13148 | 20359 | 0.0826779111871476 | 16.4352588242615
  34 |       34 |  6972 | 20358 |  0.268684376604592 | 16.5179367354487
  35 |       35 |  5305 | 20357 |  0.225803739392425 | 16.7866211120533
  36 |       36 |  6598 | 20356 | 0.0578960034006048 | 17.0124248514457
  37 |       37 |  4215 |  8151 | 0.0693427396722224 | 17.0703208548463
  38 |       38 |  5222 |  8150 |  0.398459034167599 | 17.1396635945185
  39 |       39 | 15694 |  4562 |  0.676205287123166 | 17.5381226286861
  40 |       40 | 12284 |  4561 | 0.0661662323402174 | 18.2143279158093
  41 |       41 | 11204 |  4560 |  0.133944947746719 | 18.2804941481495
  42 |       42 | 12838 |  4558 |  0.381245758535969 | 18.4144390958962
  43 |       43 |  2595 |  4559 |  0.426336813256604 | 18.7956848544322
  44 |       44 |  4676 |  8168 |  0.153929714640095 | 19.2220216676888
  45 |       45 |  3456 |  8167 |  0.118683693296658 | 19.3759513823289
  46 |       46 |  3477 |  8166 | 0.0737672299929922 | 19.4946350756256
  47 |       47 |  4551 |  1071 |  0.630504906386191 | 19.5684023056186
  48 |       48 |  5894 |  1074 |  0.162923546318245 | 20.1989072120048
  49 |       49 |    97 |  1075 | 0.0730158662947286 |  20.361830758323
  50 |       50 |  9981 | 17566 | 0.0855925772954955 | 20.4348466246177
  51 |       51 |  7365 | 17567 |  0.887191194949847 | 20.5204392019132
  52 |       52 |  9783 |  3750 |   0.23652887417845 | 21.4076303968631
  53 |       53 |  9765 | 18292 |  0.125706394548025 | 21.6441592710415
  54 |       54 | 10042 | 18291 |  0.259309010522501 | 21.7698656655895
  55 |       55 |  7650 | 18331 | 0.0539777510905859 |  22.029174676112
  56 |       56 |  9758 | 18330 |  0.131535256659738 | 22.0831524272026
  57 |       57 | 12998 | 18329 | 0.0523316716539607 | 22.2146876838624
  58 |       58 | 15081 | 18333 | 0.0342743422558721 | 22.2670193555163
  59 |       59 |  2015 | 18332 |  0.751666879171886 | 22.3012936977722
  60 |       60 |   595 | 18316 |  0.095061913736187 | 23.0529605769441
  61 |       61 |  4514 | 18317 | 0.0913594559604046 | 23.1480224906803
  62 |       62 |  9090 | 18318 | 0.0338909729891768 | 23.2393819466407
  63 |       63 | 16045 | 18790 |  0.377884594503012 | 23.2732729196299
  64 |       64 | 15391 | 18791 |  0.668980879911976 | 23.6511575141329
  65 |       65 |  5214 |  6710 |  0.696312890073718 | 24.3201383940448
  66 |       66 |  4540 |  6711 |   2.32109078453195 | 25.0164512841186
  67 |       67 |  9224 |    -1 |                  0 | 27.3375420686505
(67 rows)

12.3. Writing a pl/pgsql Wrapper Solutions

12.3.1. Solution to Exercise 11

Exercise 11

 seq | path_seq | node  | edge  |       cost        |     agg_cost     |                                            st_astext                                            
-----+----------+-------+-------+-------------------+------------------+-------------------------------------------------------------------------------------------------
   1 |        1 | 13224 |   815 |  19.9230412757899 |                0 | LINESTRING(7.1234212 50.7172365,7.1220583 50.7183785)
   2 |        2 |  3495 |   820 |  10.8873256142959 | 19.9230412757899 | LINESTRING(7.1250564 50.7179702,7.1244554 50.7176698,7.1235463 50.7172858,7.1234212 50.7172365)
   3 |        3 |   905 |   819 |  1.62841081775502 | 30.8103668900858 | LINESTRING(7.1252835 50.7180941,7.1251813 50.7180326,7.1250564 50.7179702)
   4 |        4 |  4973 |   331 |  1.09464370028738 | 32.4387777078408 | LINESTRING(7.1252835 50.7180941,7.1253634 50.7180339)
   5 |        5 |  8783 |  7014 |  1.85980318726536 | 33.5334214081282 | LINESTRING(7.1253634 50.7180339,7.1255128 50.7179396)
   6 |        6 | 12792 |  8077 | 0.387128281146154 | 35.3932245953936 | LINESTRING(7.1255128 50.7179396,7.125566 50.7179697)
   7 |        7 | 10537 |  8078 | 0.691584902562495 | 35.7803528765397 | LINESTRING(7.125566 50.7179697,7.125661 50.7180235)
   8 |        8 |  3323 |  8070 |  4.74670060391361 | 36.4719377791022 | LINESTRING(7.125661 50.7180235,7.126268 50.7176245)
   9 |        9 |  1515 | 19175 | 0.434844038482694 | 41.2186383830159 | LINESTRING(7.126268 50.7176245,7.1263232 50.7175877)
  10 |       10 |  7787 | 19176 |  1.50706950320129 | 41.6534824214985 | LINESTRING(7.1263232 50.7175877,7.1265154 50.7174607)
  11 |       11 | 15950 | 19186 |  6.87047357229535 | 43.1605519246998 | LINESTRING(7.1265154 50.7174607,7.1273927 50.7168824)
  12 |       12 |  6062 |  7889 |  1.29886576975074 | 50.0310254969952 | LINESTRING(7.1273927 50.7168824,7.1272155 50.7167805)
  13 |       13 |  6549 |    -1 |                 0 | 51.3298912667459 | 
(13 rows)

12.3.2. Solution to Exercise 12

Exercise 12

 seq | path_seq | node  | edge  |       cost        |     agg_cost     |                                                                          the_geom                                                                          
-----+----------+-------+-------+-------------------+------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 |        1 | 13224 |   815 |  19.9230412757899 |                0 | 0102000020E61000000200000045888620627E1C40AE7FD767CE5B494049D2DAD9FC7C1C4024D3A1D3F35B4940
   2 |        2 |  3495 |   820 |  10.8873256142959 | 19.9230412757899 | 0102000020E6100000040000003A9FF0C80E801C4055409072E65B49400E3E833C717F1C40D729A09ADC5B4940CF2AD8EB827E1C404E716605D05B494045888620627E1C40AE7FD767CE5B4940
   3 |        3 |   905 |   819 |  1.62841081775502 | 30.8103668900858 | 0102000020E610000003000000E6E95C514A801C40AC79E981EA5B49407748D6862F801C401E3B037EE85B49403A9FF0C80E801C4055409072E65B4940
   4 |        4 |  4973 |   331 |  1.09464370028738 | 32.4387777078408 | 0102000020E610000002000000E6E95C514A801C40AC79E981EA5B494023765C435F801C40ADF5EA88E85B4940
   5 |        5 |  8783 |  7014 |  1.85980318726536 | 33.5334214081282 | 0102000020E61000000200000023765C435F801C40ADF5EA88E85B4940E5EA6C6D86801C406D40DF71E55B4940
   6 |        6 | 12792 |  8077 | 0.387128281146154 | 35.3932245953936 | 0102000020E610000002000000E5EA6C6D86801C406D40DF71E55B494049F59D5F94801C406C825E6EE65B4940
   7 |        7 | 10537 |  8078 | 0.691584902562495 | 35.7803528765397 | 0102000020E61000000200000049F59D5F94801C406C825E6EE65B4940D787F546AD801C403621AD31E85B4940
   8 |        8 |  3323 |  8070 |  4.74670060391361 | 36.4719377791022 | 0102000020E610000002000000D787F546AD801C403621AD31E85B494014200A664C811C4078279F1EDB5B4940
   9 |        9 |  1515 | 19175 | 0.434844038482694 | 41.2186383830159 | 0102000020E61000000200000014200A664C811C4078279F1EDB5B49407EE772DE5A811C4085C1EBE9D95B4940
  10 |       10 |  7787 | 19176 |  1.50706950320129 | 41.6534824214985 | 0102000020E6100000020000007EE772DE5A811C4085C1EBE9D95B4940EDC2C5408D811C40275591C0D55B4940
  11 |       11 | 15950 | 19186 |  6.87047357229535 | 43.1605519246998 | 0102000020E610000002000000EDC2C5408D811C40275591C0D55B49401EFF603B73821C40FC896FCDC25B4940
  12 |       12 |  6062 |  7889 |  1.29886576975074 | 50.0310254969952 | 0102000020E6100000020000001EFF603B73821C40FC896FCDC25B49405A2DB0C744821C408CF4A276BF5B4940
  13 |       13 |  6549 |    -1 |                 0 | 51.3298912667459 | 
(13 rows)

12.3.3. Solution to Exercise 13

Exercise 13

 seq | path_seq | node  | edge  |       cost        |     agg_cost     |                                           route_geom                                            
-----+----------+-------+-------+-------------------+------------------+-------------------------------------------------------------------------------------------------
   1 |        1 | 13224 |   815 |  19.9230412757899 |                0 | LINESTRING(7.1220583 50.7183785,7.1234212 50.7172365)
   2 |        2 |  3495 |   820 |  10.8873256142959 | 19.9230412757899 | LINESTRING(7.1234212 50.7172365,7.1235463 50.7172858,7.1244554 50.7176698,7.1250564 50.7179702)
   3 |        3 |   905 |   819 |  1.62841081775502 | 30.8103668900858 | LINESTRING(7.1250564 50.7179702,7.1251813 50.7180326,7.1252835 50.7180941)
   4 |        4 |  4973 |   331 |  1.09464370028738 | 32.4387777078408 | LINESTRING(7.1252835 50.7180941,7.1253634 50.7180339)
   5 |        5 |  8783 |  7014 |  1.85980318726536 | 33.5334214081282 | LINESTRING(7.1253634 50.7180339,7.1255128 50.7179396)
   6 |        6 | 12792 |  8077 | 0.387128281146154 | 35.3932245953936 | LINESTRING(7.1255128 50.7179396,7.125566 50.7179697)
   7 |        7 | 10537 |  8078 | 0.691584902562495 | 35.7803528765397 | LINESTRING(7.125566 50.7179697,7.125661 50.7180235)
   8 |        8 |  3323 |  8070 |  4.74670060391361 | 36.4719377791022 | LINESTRING(7.125661 50.7180235,7.126268 50.7176245)
   9 |        9 |  1515 | 19175 | 0.434844038482694 | 41.2186383830159 | LINESTRING(7.126268 50.7176245,7.1263232 50.7175877)
  10 |       10 |  7787 | 19176 |  1.50706950320129 | 41.6534824214985 | LINESTRING(7.1263232 50.7175877,7.1265154 50.7174607)
  11 |       11 | 15950 | 19186 |  6.87047357229535 | 43.1605519246998 | LINESTRING(7.1265154 50.7174607,7.1273927 50.7168824)
  12 |       12 |  6062 |  7889 |  1.29886576975074 | 50.0310254969952 | LINESTRING(7.1273927 50.7168824,7.1272155 50.7167805)
(12 rows)

12.3.4. Solution to Exercise 14

Exercise 14

 seq |       cost        |          name          |                                           route_geom                                            
-----+-------------------+------------------------+-------------------------------------------------------------------------------------------------
   1 |  19.9230412757899 | Karl-Carstens-Straße   | LINESTRING(7.1220583 50.7183785,7.1234212 50.7172365)
   2 |  10.8873256142959 | Heussallee             | LINESTRING(7.1234212 50.7172365,7.1235463 50.7172858,7.1244554 50.7176698,7.1250564 50.7179702)
   3 |  1.62841081775502 | Heussallee             | LINESTRING(7.1250564 50.7179702,7.1251813 50.7180326,7.1252835 50.7180941)
   4 |  1.09464370028738 | Kurt-Schumacher-Straße | LINESTRING(7.1252835 50.7180941,7.1253634 50.7180339)
   5 |  1.85980318726536 | Kurt-Schumacher-Straße | LINESTRING(7.1253634 50.7180339,7.1255128 50.7179396)
   6 | 0.387128281146154 |                        | LINESTRING(7.1255128 50.7179396,7.125566 50.7179697)
   7 | 0.691584902562495 |                        | LINESTRING(7.125566 50.7179697,7.125661 50.7180235)
   8 |  4.74670060391361 |                        | LINESTRING(7.125661 50.7180235,7.126268 50.7176245)
   9 | 0.434844038482694 |                        | LINESTRING(7.126268 50.7176245,7.1263232 50.7175877)
  10 |  1.50706950320129 |                        | LINESTRING(7.1263232 50.7175877,7.1265154 50.7174607)
  11 |  6.87047357229535 |                        | LINESTRING(7.1265154 50.7174607,7.1273927 50.7168824)
  12 |  1.29886576975074 |                        | LINESTRING(7.1273927 50.7168824,7.1272155 50.7167805)
(12 rows)

12.3.5. Solution to Exercise 15

Exercise 15

CREATE VIEW
 count 
-------
 21086
(1 row)

 count 
-------
  4302
(1 row)

12.3.6. Solution to Exercise 16

Exercise 16

 seq |       cost        |          name          |                                           route_geom                                            
-----+-------------------+------------------------+-------------------------------------------------------------------------------------------------
   1 |  19.9230412757899 | Karl-Carstens-Straße   | LINESTRING(7.1220583 50.7183785,7.1234212 50.7172365)
   2 |  10.8873256142959 | Heussallee             | LINESTRING(7.1234212 50.7172365,7.1235463 50.7172858,7.1244554 50.7176698,7.1250564 50.7179702)
   3 |  1.62841081775502 | Heussallee             | LINESTRING(7.1250564 50.7179702,7.1251813 50.7180326,7.1252835 50.7180941)
   4 |  1.09464370028738 | Kurt-Schumacher-Straße | LINESTRING(7.1252835 50.7180941,7.1253634 50.7180339)
   5 |  1.85980318726536 | Kurt-Schumacher-Straße | LINESTRING(7.1253634 50.7180339,7.1255128 50.7179396)
   6 | 0.387128281146154 |                        | LINESTRING(7.1255128 50.7179396,7.125566 50.7179697)
   7 | 0.691584902562495 |                        | LINESTRING(7.125566 50.7179697,7.125661 50.7180235)
   8 |  4.74670060391361 |                        | LINESTRING(7.125661 50.7180235,7.126268 50.7176245)
   9 | 0.434844038482694 |                        | LINESTRING(7.126268 50.7176245,7.1263232 50.7175877)
  10 |  1.50706950320129 |                        | LINESTRING(7.1263232 50.7175877,7.1265154 50.7174607)
  11 |  6.87047357229535 |                        | LINESTRING(7.1265154 50.7174607,7.1273927 50.7168824)
  12 |  1.29886576975074 |                        | LINESTRING(7.1273927 50.7168824,7.1272155 50.7167805)
(12 rows)

12.3.7. Solution to Exercise 17

Exercise 17

CREATE FUNCTION
 seq |       cost        |          name          |                                            st_astext                                            
-----+-------------------+------------------------+-------------------------------------------------------------------------------------------------
   1 |  19.9230412757899 | Karl-Carstens-Straße   | LINESTRING(7.1220583 50.7183785,7.1234212 50.7172365)
   2 |  10.8873256142959 | Heussallee             | LINESTRING(7.1234212 50.7172365,7.1235463 50.7172858,7.1244554 50.7176698,7.1250564 50.7179702)
   3 |  1.62841081775502 | Heussallee             | LINESTRING(7.1250564 50.7179702,7.1251813 50.7180326,7.1252835 50.7180941)
   4 |  1.09464370028738 | Kurt-Schumacher-Straße | LINESTRING(7.1252835 50.7180941,7.1253634 50.7180339)
   5 |  1.85980318726536 | Kurt-Schumacher-Straße | LINESTRING(7.1253634 50.7180339,7.1255128 50.7179396)
   6 | 0.387128281146154 |                        | LINESTRING(7.1255128 50.7179396,7.125566 50.7179697)
   7 | 0.691584902562495 |                        | LINESTRING(7.125566 50.7179697,7.125661 50.7180235)
   8 |  4.74670060391361 |                        | LINESTRING(7.125661 50.7180235,7.126268 50.7176245)
   9 | 0.434844038482694 |                        | LINESTRING(7.126268 50.7176245,7.1263232 50.7175877)
  10 |  1.50706950320129 |                        | LINESTRING(7.1263232 50.7175877,7.1265154 50.7174607)
  11 |  6.87047357229535 |                        | LINESTRING(7.1265154 50.7174607,7.1273927 50.7168824)
  12 |  1.29886576975074 |                        | LINESTRING(7.1273927 50.7168824,7.1272155 50.7167805)
(12 rows)

12.3.8. Solution to Exercise 18

Exercise 18

CREATE FUNCTION
 seq |       cost        |          name          |     heading      |                                            st_astext                                            
-----+-------------------+------------------------+------------------+-------------------------------------------------------------------------------------------------
   1 |  19.9230412757899 | Karl-Carstens-Straße   | 2.26823488590015 | LINESTRING(7.1220583 50.7183785,7.1234212 50.7172365)
   2 |  10.8873256142959 | Heussallee             | 1.14903125649754 | LINESTRING(7.1234212 50.7172365,7.1235463 50.7172858,7.1244554 50.7176698,7.1250564 50.7179702)
   3 |  1.62841081775502 | Heussallee             | 1.07135705537504 | LINESTRING(7.1250564 50.7179702,7.1251813 50.7180326,7.1252835 50.7180941)
   4 |  1.09464370028738 | Kurt-Schumacher-Straße | 2.21649655239403 | LINESTRING(7.1252835 50.7180941,7.1253634 50.7180339)
   5 |  1.85980318726536 | Kurt-Schumacher-Straße | 2.13383552417012 | LINESTRING(7.1253634 50.7180339,7.1255128 50.7179396)
   6 | 0.387128281146154 |                        | 1.05591155044059 | LINESTRING(7.1255128 50.7179396,7.125566 50.7179697)
   7 | 0.691584902562495 |                        | 1.05551295177301 | LINESTRING(7.125566 50.7179697,7.125661 50.7180235)
   8 |  4.74670060391361 |                        | 2.15230799439581 | LINESTRING(7.125661 50.7180235,7.126268 50.7176245)
   9 | 0.434844038482694 |                        | 2.15879893029791 | LINESTRING(7.126268 50.7176245,7.1263232 50.7175877)
  10 |  1.50706950320129 |                        | 2.15470552678966 | LINESTRING(7.1263232 50.7175877,7.1265154 50.7174607)
  11 |  6.87047357229535 |                        | 2.15359902999596 | LINESTRING(7.1265154 50.7174607,7.1273927 50.7168824)
  12 |  1.29886576975074 |                        | 4.19051229038139 | LINESTRING(7.1273927 50.7168824,7.1272155 50.7167805)
(12 rows)

12.3.9. Solution to Exercise 19

Exercise 19

 seq |       cost       |            name             |      heading      |                                                                                                st_astext                                                                                                
-----+------------------+-----------------------------+-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | 7.23806223185627 |                             |  5.47524812984737 | LINESTRING(7.1187971 50.7149767,7.1187404 50.7150309)
   2 | 42.5250082283043 |                             |  4.33276222953596 | LINESTRING(7.1187404 50.7150309,7.1182306 50.7148275)
   3 |  9.2908824699497 |                             |  4.52416747510972 | LINESTRING(7.1182306 50.7148275,7.1181046 50.7148035)
   4 | 106.843572939635 | Joseph-Beuys-Allee          |  5.49920628270578 | LINESTRING(7.1181046 50.7148035,7.1172954 50.715615)
   5 | 61.6198657678989 | Joseph-Beuys-Allee          |  5.44223604171501 | LINESTRING(7.1172954 50.715615,7.1171851 50.7157579,7.1168464 50.7160422,7.1167952 50.7160625)
   6 | 3.20694890824723 | Rheinweg                    |  4.80786617276356 | LINESTRING(7.1167952 50.7160625,7.1167503 50.7160668)
   7 |     3.8074320844 | Rheinweg                    |  4.52692424889154 | LINESTRING(7.1167503 50.7160668,7.1166986 50.7160571)
   8 | 1136.37890032744 |                             |  5.49729972389679 | LINESTRING(7.1166986 50.7160571,7.1149061 50.7178493,7.1147497 50.7180781,7.1146719 50.718165,7.1145112 50.7182509,7.1135093 50.7192668,7.1134434 50.7193114,7.1134087 50.7193349,7.1080776 50.7246697)
   9 | 4.88786325760668 | Lessingstraße               |  1.04892542359734 | LINESTRING(7.1080776 50.7246697,7.1081289 50.7246992)
  10 | 202.234633418538 | Kaiserstraße                |   5.4898652315813 | LINESTRING(7.1081289 50.7246992,7.1080866 50.72474,7.1080589 50.7247667,7.1078678 50.724951,7.1065767 50.726227)
  11 | 108.068852543753 | Kaiserstraße                |  5.49231341180503 | LINESTRING(7.1065767 50.726227,7.1057501 50.7270446)
  12 | 17.8011896534849 | Kaiserstraße                |  5.49261732279518 | LINESTRING(7.1057501 50.7270446,7.105614 50.7271793)
  13 | 208.481084554304 | Kaiserstraße                |  5.57179478843925 | LINESTRING(7.105614 50.7271793,7.1055095 50.7272826,7.1053634 50.7274362,7.1049418 50.7279276,7.1043373 50.7286612,7.1041973 50.7288229)
  14 | 41.2306261017116 | Kaiserstraße                |  5.61021695440483 | LINESTRING(7.1041973 50.7288229,7.1041442 50.7288932,7.1039337 50.7291536)
  15 | 146.167599369216 | Kaiserstraße                |  5.57605828430552 | LINESTRING(7.1039337 50.7291536,7.1029922 50.730254,7.1029467 50.7303086)
  16 | 64.0037638100452 | Kaiserstraße                |  5.57028082970214 | LINESTRING(7.1029467 50.7303086,7.1025106 50.730813)
  17 | 44.3680301760183 | Kaiserstraße                |  5.59381475599874 | LINESTRING(7.1025106 50.730813,7.1022193 50.7311664)
  18 | 52.2387322440832 | Hans-Iwand-Straße           | 0.948215303718884 | LINESTRING(7.1022193 50.7311664,7.1027094 50.7315182)
  19 | 66.8124834896632 | An der Evangelischen Kirche |   5.1976140184811 | LINESTRING(7.1027094 50.7315182,7.1019815 50.731902)
  20 | 43.0593467919035 | An der Evangelischen Kirche |   5.1668076171977 | LINESTRING(7.1019815 50.731902,7.1014982 50.7321381)
  21 | 46.2298956871004 | Kaiserplatz                 | 0.896594694200448 | LINESTRING(7.1014982 50.7321381,7.101799 50.7323745,7.1019054 50.7324635)
  22 | 43.5878508555243 | Am Neutor                   |  5.16575734617977 | LINESTRING(7.1019054 50.7324635,7.1017062 50.7325747,7.1014165 50.7327017)
  23 | 42.3158201638911 | Am Neutor                   |  5.14942434972155 | LINESTRING(7.1014165 50.7327017,7.1009338 50.7329272)
  24 | 7.68669989160877 | Am Neutor                   |  5.17510157330919 | LINESTRING(7.1009338 50.7329272,7.1008482 50.7329699)
  25 | 27.1576709815517 | Martinsplatz                |  5.48732269248256 | LINESTRING(7.1008482 50.7329699,7.1007809 50.733012,7.1006406 50.7331732)
  26 | 12.0881718148334 | Martinsplatz                |  5.78056661352778 | LINESTRING(7.1006406 50.7331732,7.1005842 50.7332758)
  27 | 5.61017957171694 |                             |  5.91683226658509 | LINESTRING(7.1005842 50.7332758,7.1005654 50.7333248)
  28 | 49.9882137762625 |                             |  5.25568418446752 | LINESTRING(7.1005654 50.7333248,7.1004814 50.7333844,7.1002964 50.7335171,7.1000549 50.7336331)
  29 | 62.2655406576079 |                             |  4.91250708492959 | LINESTRING(7.1000549 50.7336331,7.0992148 50.7338035)
  30 | 7.86669095707821 | Münsterplatz                | 0.518011776679894 | LINESTRING(7.0992148 50.7338035,7.0992527 50.73387)
  31 | 61.6681820931258 | Münsterplatz                |  5.10393673173242 | LINESTRING(7.0992527 50.73387,7.0985205 50.7341723)
  32 | 9.23425169096536 |                             |  5.15291932102226 | LINESTRING(7.0985205 50.7341723,7.0984155 50.7342218)
  33 | 42.6506675393865 | Windeckstraße               |  5.11858322613311 | LINESTRING(7.0984155 50.7342218,7.0979154 50.7344369)
  34 | 8.60423401974624 | Windeckstraße               |  5.19160772141209 | LINESTRING(7.0979154 50.7344369,7.0978211 50.7344859)
(34 rows)

ROLLBACK