[pgrouting] 01/07: Imported Upstream version 2.3.0

Bas Couwenberg sebastic at debian.org
Mon Sep 26 16:50:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository pgrouting.

commit 03f3118a51ec549184f9632b3d856b7f58f48f05
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Mon Sep 26 17:27:34 2016 +0200

    Imported Upstream version 2.3.0
---
 .gitignore                                         |    4 +-
 .travis.yml                                        |   29 +-
 CMakeLists.txt                                     |  523 +-
 NEWS                                               |   85 +-
 README.md                                          |   41 +-
 VERSION                                            |    2 +-
 appveyor.yml                                       |  102 +-
 ci/appveyor/install-CGAL.bat                       |  211 +
 ci/appveyor/install-boost.bat                      |  149 +
 ci/appveyor/install.bat                            |  176 +
 ci/appveyor/msbuild_pgrouting.bat                  |   55 +
 cmake/FindPostgreSQL.cmake                         |    3 +-
 doc/CMakeLists.txt                                 |   18 +-
 doc/conf.py.in                                     |   12 +-
 doc/deprecated.rst                                 |   97 +-
 doc/i18n/pot/src/index.pot                         |    2 +-
 doc/index.html.in                                  |   84 -
 doc/index.rst                                      |   33 +-
 doc/src/changelog/1_x.rst                          |   79 -
 doc/src/changelog/2_0.rst                          |   52 -
 doc/src/changelog/2_1_0.rst                        |   71 -
 doc/src/changelog/2_2_0.rst                        |   59 -
 doc/src/changelog/2_2_1.rst                        |   30 -
 doc/src/changelog/2_2_2.rst                        |   28 -
 doc/src/changelog/2_2_3.rst                        |   28 -
 doc/src/changelog/2_2_4.rst                        |   31 -
 doc/src/changelog/index.rst                        |   35 -
 doc/src/changelog/release_notes.rst                |  359 +
 doc/src/developer/developer_guide.rst              |   16 +-
 doc/src/developer/sampledata.rst                   |   33 +-
 doc/src/installation/install-dependencies.rst      |    2 -
 doc/src/installation/installation.rst              |   49 +-
 doc/src/introduction/introduction.rst              |    4 +-
 doc/src/introduction/support.rst                   |    9 +-
 doc/src/recipes/index.rst                          |    8 +-
 doc/src/tutorial/analytics.rst                     |    2 +-
 doc/src/tutorial/custom_query.rst                  |   49 +-
 doc/src/tutorial/topology.rst                      |    2 +-
 doc/src/tutorial/tutorial.rst                      |    2 +-
 doc/test/utilities-any.result                      |    2 +-
 doc/test/utilities-any.test.sql                    |    2 +-
 doxygen/CMakeLists.txt                             |   23 +
 tools/doxygen/Doxyfile => doxygen/Doxyfile.in      |   43 +-
 {tools/doxygen => doxygen}/DoxygenLayout.xml       |    0
 src/CMakeLists.txt                                 |    3 +
 src/allpairs/doc/allpairs.rst                      |   17 +-
 src/allpairs/doc/pgr_floydWarshall.rst             |  108 +-
 src/allpairs/doc/pgr_johnson.rst                   |  117 +-
 src/allpairs/src/floydWarshall.c                   |   34 +-
 src/allpairs/src/floydWarshall_driver.cpp          |  118 +-
 src/allpairs/src/floydWarshall_driver.h            |    5 +-
 src/allpairs/src/johnson.c                         |   17 +-
 src/allpairs/src/johnson_driver.cpp                |   95 +-
 src/allpairs/src/johnson_driver.h                  |    4 +
 src/allpairs/src/pgr_allpairs.hpp                  |   43 +-
 src/allpairs/test/test.conf                        |    2 +-
 src/alpha_shape/doc/doc-pgr_alphashape.queries     |   15 +-
 src/alpha_shape/src/CMakeLists.txt                 |    2 +-
 src/alpha_shape/src/alpha.c                        |  211 +-
 src/alpha_shape/src/alpha_drivedist.cpp            |  301 -
 src/alpha_shape/src/alpha_driver.cpp               |  279 +
 src/alpha_shape/src/{alpha.h => alpha_driver.h}    |   25 +-
 src/apsp_johnson/doc/doc-apspJohnson.queries       |    2 +
 src/apsp_johnson/doc/pgr_apspJohnson.rst           |   11 +-
 src/apsp_johnson/test/doc-apspJohnson.test.sql     |    1 +
 src/apsp_warshall/doc/doc-apspWarshall.queries     |    2 +
 src/apsp_warshall/doc/pgr_apspWarshall.rst         |   13 +-
 src/apsp_warshall/test/doc-apspWarshall.test.sql   |    1 +
 src/astar/CMakeLists.txt                           |    5 -
 .../{doc-astar.queries => doc-astar-v2.queries}    |   20 +-
 src/astar/doc/doc-astar.queries                    |   74 +-
 src/astar/doc/{pgr_astar.rst => pgr_astar-v2.rst}  |   25 +-
 src/astar/doc/pgr_astar.rst                        |  232 +-
 src/astar/sql/CMakeLists.txt                       |   10 +-
 src/astar/sql/_astar.sql                           |  108 +
 src/astar/sql/astar.sql                            |  124 +-
 src/astar/sql/astarCost.sql                        |  120 +
 .../sql/astarOneToOne.sql}                         |   56 +-
 .../sql/astarV2.0.sql}                             |   50 +-
 src/astar/src/CMakeLists.txt                       |   13 +-
 src/astar/src/astar.c                              |  504 -
 src/astar/src/astar.h                              |   41 -
 .../src/astarManyToMany.c}                         |  178 +-
 src/astar/src/astarManyToMany_driver.cpp           |  172 +
 .../src/astarManyToMany_driver.h}                  |   45 +-
 .../src/astarManyToOne.c}                          |  181 +-
 .../src/astarOneToMany.c}                          |  178 +-
 src/astar/src/astarOneToMany_driver.cpp            |  182 +
 .../src/astarOneToMany_driver.h}                   |   48 +-
 .../src/astarOneToOne.c}                           |  160 +-
 src/astar/src/astarOneToOne_driver.cpp             |  167 +
 .../src/astarOneToOne_driver.h}                    |   44 +-
 src/astar/src/astar_boost_wrapper.cpp              |  313 -
 src/astar/src/pgr_astar.hpp                        |  567 ++
 src/astar/test/doc-astar-v2.result                 |   15 +
 src/astar/test/doc-astar-v2.test.sql               |   13 +
 src/astar/test/doc-astar.result                    |   32 +-
 src/astar/test/doc-astar.test.sql                  |   28 +-
 .../test/pgtap/astarV2.0-compare-dijkstra.test.sql |  121 +
 ...r-types-check.sql => astarV2.0-types-check.sql} |  202 +-
 src/astar/test/pgtap/astarV2.0-types-check2.sql    |  223 +
 .../pgtap/astar_oneToOne-compare-dijkstra.test.sql |  112 +
 .../astar_oneToOne-compare-dijkstra1.test.sql      |  143 +
 .../test/pgtap/astar_oneToOne-types-check.sql      |  216 +
 src/astar/test/spas-any-00.result                  |    5 -
 src/astar/test/spas-any-01.result                  |    2 -
 src/astar/test/spas-any-01.test.sql                |   32 -
 src/astar/test/test.conf                           |   10 +-
 src/bd_astar/CMakeLists.txt                        |    6 -
 src/bd_astar/doc/pgr_bdAstar.rst                   |    4 +-
 src/bd_astar/src/BiDirAStar.cpp                    |  793 +-
 src/bd_astar/src/BiDirAStar.h                      |  132 +-
 src/bd_astar/src/CMakeLists.txt                    |    3 +-
 src/bd_astar/src/MinHeap.cpp                       |  220 +-
 src/bd_astar/src/MinHeap.h                         |   58 +-
 src/bd_astar/src/bdastar.c                         |  151 +-
 .../src/{bdastar_core.cpp => bdastar_driver.cpp}   |   25 +-
 src/bd_astar/src/{bdastar.h => bdastar_driver.h}   |    8 +-
 src/bd_astar/tester/BiDirAStar.cpp                 |    8 +-
 src/bd_dijkstra/CMakeLists.txt                     |    6 -
 src/bd_dijkstra/doc/doc-bdDijkstra.queries         |   10 +-
 src/bd_dijkstra/doc/pgr_bdDijkstra.rst             |    5 +-
 src/bd_dijkstra/src/BiDirDijkstra.cpp              |  720 +-
 src/bd_dijkstra/src/BiDirDijkstra.h                |  113 +-
 src/bd_dijkstra/src/CMakeLists.txt                 |    2 +-
 src/bd_dijkstra/src/bdsp.c                         |  174 +-
 .../src/{bdsp_core.cpp => bdsp_driver.cpp}         |   40 +-
 src/bd_dijkstra/src/{bdsp.h => bdsp_driver.h}      |   36 +-
 src/bd_dijkstra/test/doc-bdDijkstra.result         |   20 +-
 src/common/CMakeLists.txt                          |    5 -
 src/common/doc/types/cost_result.rst               |    2 -
 src/common/doc/types/geom_result.rst               |    1 -
 src/common/doc/utilities/end_point.rst             |   11 +-
 src/common/doc/utilities/get_column_name.rst       |   16 +-
 src/common/doc/utilities/get_table_name.rst        |   15 +-
 src/common/doc/utilities/index.rst                 |   44 -
 src/common/doc/utilities/is_column_in_table.rst    |   14 +-
 src/common/doc/utilities/is_column_indexed.rst     |   15 +-
 src/common/doc/utilities/point_to_id.rst           |   18 +-
 src/common/doc/utilities/quote_ident.rst           |   12 +-
 src/common/doc/utilities/start_point.rst           |   11 +-
 src/common/doc/utilities/versionless.rst           |   11 +-
 src/common/sql/CMakeLists.txt                      |    1 +
 src/common/sql/pgRouting-header.sql                |   37 +
 src/common/sql/pgr_parameter_check.sql             |   28 +-
 src/common/sql/pgrouting_utilities.sql             |   10 +-
 src/common/sql/utilities_pgr.sql                   |    4 +-
 src/common/src/CMakeLists.txt                      |   12 +
 src/common/src/arrays_input.c                      |   99 +-
 src/common/src/arrays_input.h                      |    7 +
 src/common/src/baseGraph.hpp                       |  564 --
 src/common/src/basePath_SSEC.cpp                   |   35 +-
 src/common/src/basePath_SSEC.hpp                   |   85 +-
 .../src/{postgres_connection.h => basic_edge.cpp}  |   28 +-
 .../customers_input.h => common/src/basic_edge.h}  |   43 +-
 src/common/src/basic_vertex.cpp                    |  146 +
 src/common/src/basic_vertex.h                      |   79 +
 src/common/src/ch_edge.cpp                         |  124 +
 src/common/src/ch_edge.h                           |   75 +
 src/common/src/ch_vertex.cpp                       |  120 +
 src/common/src/ch_vertex.h                         |   76 +
 .../src/coordinates_input.c}                       |   85 +-
 .../src/coordinates_input.h}                       |   20 +-
 src/common/src/debug_macro.h                       |   10 +-
 src/common/src/edges_input.c                       |  423 +-
 src/common/src/edges_input.h                       |  229 +-
 src/common/src/get_check_data.c                    |    9 +-
 src/common/src/get_check_data.h                    |    6 +
 src/common/src/identifiers.hpp                     |  350 +
 .../src/matrixRows_input.c}                        |   49 +-
 .../src/matrixRows_input.h}                        |    8 +-
 src/common/src/{memory_func.hpp => pgr_alloc.hpp}  |   40 +-
 src/common/src/pgr_assert.cpp                      |   43 +-
 src/common/src/pgr_assert.h                        |   99 +-
 src/common/src/pgr_base_graph.hpp                  |  843 ++
 src/common/src/pgr_logger.h                        |    2 +-
 src/common/src/pgr_types.h                         |  127 +-
 src/common/src/points_input.c                      |   16 +-
 src/common/src/points_input.h                      |   51 +
 src/common/src/postgres_connection.c               |    8 +-
 src/common/src/postgres_connection.h               |    8 +-
 src/common/src/restrictions_input.c                |   27 +-
 src/common/src/restrictions_input.h                |    4 +
 src/common/src/signalhandler.h                     |    4 +-
 src/common/src/time_msg.c                          |   34 +-
 src/common/src/time_msg.h                          |   30 +
 src/common/src/xy_vertex.cpp                       |  147 +
 src/common/src/xy_vertex.h                         |   95 +
 src/contraction/demo/dead_end_demo.sql             |   56 +
 src/contraction/demo/linear_demo.sql               |   44 +
 src/contraction/doc/contraction.rst                |  630 +-
 src/contraction/doc/doc-contractGraph.queries      |   56 +
 src/contraction/doc/doc-contraction.queries        |  354 +
 src/contraction/doc/pgr_contractGraph.rst          |  175 +
 src/contraction/doc/proof_of_concept.queries       |  106 +
 src/{astar => contraction}/sql/CMakeLists.txt      |    3 +-
 .../sql/contractGraph.sql}                         |   38 +-
 src/contraction/src/CMakeLists.txt                 |    4 +
 src/contraction/src/contractGraph.c                |  267 +
 src/contraction/src/contractGraph_driver.cpp       |  278 +
 .../contraction/src/contractGraph_driver.h         |   43 +-
 src/contraction/src/contraction.dox                |  579 ++
 src/contraction/src/pgr_contract.hpp               |  444 +
 src/contraction/src/pgr_contractionGraph.hpp       |  530 ++
 src/contraction/src/pgr_deadEndContraction.hpp     |  229 +
 src/contraction/src/pgr_linearContraction.hpp      |  259 +
 .../src/structs.h}                                 |   33 +-
 src/contraction/test/directed-development.result   |   50 +
 src/contraction/test/directed-development.test.sql |  107 +
 src/contraction/test/doc-contractGraph.result      |   28 +
 src/contraction/test/doc-contractGraph.test.sql    |   21 +
 src/contraction/test/doc-contraction.result        |  128 +
 src/contraction/test/doc-contraction.test.sql      |  212 +
 src/contraction/test/expand_graph.result           |   78 +
 src/contraction/test/expand_graph.test.sql         |  220 +
 .../test/expand_graph_without_function.result      |   78 +
 .../test/expand_graph_without_function.test.sql    |   86 +
 .../test/pgtap/contraction-types-check.sql         |  237 +
 .../test/pgtap/contraction_cycle_directed.sql      |  228 +
 .../test/pgtap/contraction_cycle_undirected.sql    |  265 +
 src/contraction/test/pgtap/directed_dead_end.sql   |  440 +
 src/contraction/test/pgtap/directed_linear.sql     |  178 +
 src/contraction/test/pgtap/undirected_dead_end.sql |  301 +
 src/contraction/test/pgtap/undirected_linear.sql   |  185 +
 src/contraction/test/proof_of_concept.result       |   47 +
 src/contraction/test/proof_of_concept.test.sql     |   90 +
 src/contraction/test/proof_of_concept_1.result     |   68 +
 src/contraction/test/proof_of_concept_1.test.sql   |   70 +
 src/contraction/test/return_types.result           |   43 +
 src/contraction/test/return_types.test.sql         |   71 +
 src/contraction/test/sampleData.result             |    6 +
 src/contraction/test/sampleData.test.sql           |    6 +
 src/contraction/test/test.conf                     |   32 +
 .../doc/doc-conversion.queries                     |    5 +
 .../doc/doc-matrix.queries                         |   20 +-
 .../doc/pgr_flipEdges.rst                          |   19 +-
 .../doc/pgr_pointToEdgeNode.rst                    |   14 +-
 .../doc/pgr_pointsToDMatrix.rst                    |   26 +-
 .../doc/pgr_pointsToVids.rst                       |   16 +-
 .../doc/pgr_textToPoints.rst                       |   22 +-
 .../doc/pgr_vidsToDMatrix.rst                      |   26 +-
 .../doc/pgr_vidsToDMatrix2.rst                     |   28 +-
 .../sql/CMakeLists.txt                             |    3 +-
 src/convenience/sql/pgr_fakeContraction.sql        |   56 +
 src/convenience/sql/pgr_vidsToDMatrix.sql          |   92 +
 .../sql/pgrouting_conversion_tools.sql             |    2 +
 .../sql/pgrouting_dmatrix_tools.sql                |    8 +-
 .../test/doc-conversion.result                     |    3 +
 .../test/doc-conversion.test.sql                   |    1 +
 src/convenience/test/doc-matrix.result             |   39 +
 .../test/doc-matrix.test.sql                       |    2 +
 .../test/pgtap/flipEdges-types-check.sql           |    0
 .../test/pgtap/pointToEdgeNode-types-check.sql     |    0
 .../test/pgtap/pointsToDMatrix-types-check.sql     |    0
 .../test/pgtap/pointsToVids-types-check.sql        |    0
 .../test/pgtap/textToPoints-types-check.sql        |    0
 .../test/pgtap/vidsToDMatrix-types-check.sql       |    0
 src/{convinience => convenience}/test/test.conf    |    1 -
 src/convenience/test/vidstodmatrix-any-01.result   |    4 +
 .../test/vidstodmatrix-any-01.test.sql             |    3 +-
 src/convinience/doc/convenience.rst                |   61 -
 src/convinience/sql/pgr_vidsToDMatrix_dir.sql      |   29 -
 src/convinience/test/doc-matrix.result             |   25 -
 src/convinience/test/vidstodmatrix-any-01.result   |    2 -
 src/costMatrix/doc/costMatrix.rst                  |   94 +
 src/costMatrix/doc/dmatrix_return_values.txt       |   23 +
 src/costMatrix/doc/doc-pgr_fooDmatrix.queries      |  132 +
 src/costMatrix/doc/pgr_dijkstraCostMatrix.rst      |  144 +
 src/costMatrix/doc/pgr_withPointsCostMatrix.rst    |  161 +
 src/costMatrix/sql/CMakeLists.txt                  |   14 +
 .../sql/astarCostMatrix.sql}                       |   44 +-
 .../sql/dijkstraCostMatrix.sql}                    |   39 +-
 src/costMatrix/sql/eucledianCostMatrix.sql         |   92 +
 .../sql/withPointsCostMatrix.sql}                  |   44 +-
 src/costMatrix/test/doc-pgr_fooDmatrix-mac.result  |   66 +
 .../test/doc-pgr_fooDmatrix-mac.test.sql           |   51 +
 .../test/doc-pgr_fooDmatrix-windows.result         |   66 +
 .../test/doc-pgr_fooDmatrix-windows.test.sql       |   51 +
 src/costMatrix/test/doc-pgr_fooDmatrix.result      |   66 +
 src/costMatrix/test/doc-pgr_fooDmatrix.test.sql    |   51 +
 src/costMatrix/test/test.conf                      |   28 +
 src/dijkstra/demo/boost_demo.sql                   |    2 +-
 src/dijkstra/demo/hanoslav_demo.sql                |    2 +-
 src/dijkstra/doc/CMakeLists.txt                    |    0
 src/dijkstra/doc/dijkstra.rst                      |   20 +-
 src/dijkstra/doc/doc-pgr_dijkstra.queries          |   10 +
 src/dijkstra/doc/doc-pgr_dijkstraVia.queries       |    4 +-
 src/dijkstra/doc/pgr_dijkstra.rst                  |  115 +-
 src/dijkstra/doc/pgr_dijkstraCost.rst              |  127 +-
 src/dijkstra/doc/pgr_dijkstraVia.rst               |   72 +-
 src/dijkstra/doc/pgr_dijkstra_v2.rst               |   19 +-
 src/dijkstra/sql/dijkstra.sql                      |   28 +
 src/dijkstra/sql/dijkstraVia.sql                   |   25 +
 src/dijkstra/src/dijkstraVia.c                     |   15 +-
 src/dijkstra/src/dijkstraVia_driver.cpp            |   43 +-
 src/dijkstra/src/many_to_many_dijkstra.c           |   19 +-
 src/dijkstra/src/many_to_many_dijkstra_driver.cpp  |   19 +-
 src/dijkstra/src/many_to_one_dijkstra.c            |   16 +-
 src/dijkstra/src/many_to_one_dijkstra_driver.cpp   |   19 +-
 src/dijkstra/src/one_to_many_dijkstra.c            |   15 +-
 src/dijkstra/src/one_to_many_dijkstra_driver.cpp   |   20 +-
 src/dijkstra/src/one_to_one_dijkstra.c             |   19 +-
 src/dijkstra/src/one_to_one_dijkstra_driver.cpp    |   17 +-
 src/dijkstra/src/pgr_dijkstra.hpp                  |   47 +-
 src/dijkstra/test/dijkstra-v2.test.sql             |    2 +
 src/dijkstra/test/doc-pgr_dijkstra.test.sql        |    5 +
 src/dijkstra/test/doc-pgr_dijkstraVia.result       |    4 +-
 src/driving_distance/CMakeLists.txt                |    4 -
 .../doc/doc-pgr_drivingDistance.queries            |    2 +
 .../doc/doc-pgr_drivingdistance-v2.queries         |    2 +
 src/driving_distance/doc/drivingDistance.rst       |   17 +-
 src/driving_distance/doc/pgr_drivingDistance.rst   |  118 +-
 .../doc/pgr_drivingDistance_v2.rst                 |   20 +-
 src/driving_distance/sql/routing_dd.sql            |    2 +-
 src/driving_distance/src/CMakeLists.txt            |    1 -
 .../src/boost_interface_drivedist.cpp              |   51 +-
 .../src/boost_interface_drivedist.h                |    3 +-
 src/driving_distance/src/drivedist.c               |   15 +-
 .../src/many_to_dist_driving_distance.c            |    4 +-
 .../src/many_to_dist_withPointsDD.c                |   21 +-
 src/driving_distance/src/withPoints_dd.c           |   19 +-
 src/driving_distance/src/withPoints_dd_driver.cpp  |   42 +-
 src/driving_distance/src/withPoints_dd_driver.h    |    2 +-
 .../test/doc-pgr_drivingDistance.test.sql          |    1 +
 .../test/doc-pgr_drivingdistance-v2.test.sql       |    1 +
 .../test/drivingdistance-any-00.test.sql           |    3 +-
 src/internalQueryTests/sql/CMakeLists.txt          |    9 +
 .../sql/testXYedges.sql}                           |   17 +-
 .../sql/test_ch_edges.sql}                         |   14 +-
 .../sql/test_matrixRows.sql}                       |   14 +-
 src/internalQueryTests/src/CMakeLists.txt          |   11 +
 src/internalQueryTests/src/testXYedges.c           |  118 +
 src/internalQueryTests/src/testXYedges_driver.cpp  |  208 +
 .../src/testXYedges_driver.h}                      |   28 +-
 src/internalQueryTests/src/test_c_edges.c          |  113 +
 src/internalQueryTests/src/test_c_edges_driver.cpp |  381 +
 .../src/test_c_edges_driver.h}                     |   30 +-
 src/internalQueryTests/src/test_matrixRows.c       |  120 +
 .../src/test_matrixRows_driver.cpp                 |   80 +
 .../src/test_matrixRows_driver.h}                  |   23 +-
 src/internalQueryTests/test/XYedge.result          |    1 +
 src/internalQueryTests/test/XYedge.test.sql        |    4 +
 .../test/pgtap/matrixRows_types_check.sql          |   94 +
 .../test/pgtap/testXYedges_types_check.sql         |  133 +
 .../test/test.conf                                 |   19 +-
 src/internalQueryTests/test/testCHedges.result     |  682 ++
 src/internalQueryTests/test/testCHedges.test.sql   |    5 +
 src/kdijkstra/CMakeLists.txt                       |    4 -
 src/kdijkstra/doc/CMakeLists.txt                   |    0
 src/kdijkstra/doc/doc-kdijkstra.queries            |    2 +
 src/kdijkstra/doc/pgr_kDijkstra.rst                |   17 +-
 src/kdijkstra/src/CMakeLists.txt                   |    3 -
 src/kdijkstra/src/k_targets_boost_wrapper.cpp      |  250 -
 src/kdijkstra/src/k_targets_boost_wrapper.h        |   98 -
 src/kdijkstra/src/k_targets_sp.c                   |  486 -
 src/kdijkstra/test/doc-kdijkstra.test.sql          |    1 +
 src/ksp/CMakeLists.txt                             |    4 -
 src/ksp/doc/CMakeLists.txt                         |    0
 src/ksp/doc/doc-ksp-v2.queries                     |    2 +
 src/ksp/doc/doc-ksp.queries                        |    2 +
 src/ksp/doc/pgr_ksp.rst                            |  109 +-
 src/ksp/doc/pgr_ksp_v2.rst                         |   23 +-
 src/ksp/src/CMakeLists.txt                         |    1 -
 src/ksp/src/ksp.c                                  |   22 +-
 src/ksp/src/ksp.h                                  |   41 -
 src/ksp/src/ksp_driver.cpp                         |   34 +-
 src/ksp/src/ksp_driver.h                           |    4 +-
 src/ksp/src/pgr_ksp.cpp                            |   23 +-
 src/ksp/src/pgr_ksp.hpp                            |    9 +-
 src/ksp/src/withPoints_ksp.c                       |   19 +-
 src/ksp/src/withPoints_ksp_driver.cpp              |   26 +-
 src/ksp/src/withPoints_ksp_driver.h                |    4 +-
 src/ksp/test/doc-ksp-v2.test.sql                   |    2 +
 src/ksp/test/doc-ksp.test.sql                      |    1 +
 src/ksp/test/ksp-network.test.sql                  |    1 +
 src/label_graph/CMakeLists.txt                     |    4 -
 src/label_graph/doc/CMakeLists.txt                 |    0
 src/label_graph/doc/pgr_labelGraph.rst             |   18 +-
 src/label_graph/src/CMakeLists.txt                 |    0
 src/linecommand/src/dijkstra.hpp                   |   84 +-
 src/linecommand/src/driving.cpp                    |   12 +-
 src/linecommand/src/ksp.cpp                        |   61 +-
 src/linecommand/src/pgRouting.cpp                  |  367 +-
 src/linecommand/src/warshall.hpp                   |    6 +-
 src/mainpage.dox                                   |   73 +-
 src/max_flow/demo/slide_demo.sql                   |   45 +
 src/{allpairs => max_flow}/doc/CMakeLists.txt      |    0
 src/max_flow/doc/doc-pgr_edgeDisjointPaths.queries |   91 +
 .../doc/doc-pgr_maxFlowBoykovKolmogorov.queries    |  107 +
 .../doc/doc-pgr_maxFlowEdmondsKarp.queries         |  107 +
 .../doc/doc-pgr_maxFlowPushRelabel.queries         |  114 +
 .../doc/doc-pgr_maximumCardinalityMatching.queries |   40 +
 src/max_flow/doc/maxFlow.rst                       |   90 +
 src/max_flow/doc/maxFlowApplications.rst           |   60 +
 src/max_flow/doc/pgr_edgeDisjointPaths.rst         |  225 +
 src/max_flow/doc/pgr_maxFlowBoykovKolmogorov.rst   |  219 +
 src/max_flow/doc/pgr_maxFlowEdmondsKarp.rst        |  209 +
 src/max_flow/doc/pgr_maxFlowPushRelabel.rst        |  213 +
 .../doc/pgr_maximumCardinalityMatching.rst         |  171 +
 src/max_flow/sql/CMakeLists.txt                    |    9 +
 src/max_flow/sql/edge_disjoint_paths.sql           |  102 +
 src/max_flow/sql/max_flow.sql                      |  361 +
 .../sql/maximum_cardinality_matching.sql}          |   36 +-
 src/max_flow/src/CMakeLists.txt                    |   25 +
 .../src/edge_disjoint_paths_many_to_many.c}        |  156 +-
 .../edge_disjoint_paths_many_to_many_driver.cpp    |  106 +
 .../src/edge_disjoint_paths_many_to_many_driver.h} |   45 +-
 .../src/edge_disjoint_paths_many_to_one.c}         |  154 +-
 .../src/edge_disjoint_paths_many_to_one_driver.cpp |  103 +
 .../src/edge_disjoint_paths_many_to_one_driver.h}  |   44 +-
 .../src/edge_disjoint_paths_one_to_many.c}         |  153 +-
 .../src/edge_disjoint_paths_one_to_many_driver.cpp |  104 +
 .../src/edge_disjoint_paths_one_to_many_driver.h}  |   44 +-
 .../src/edge_disjoint_paths_one_to_one.c}          |  142 +-
 .../src/edge_disjoint_paths_one_to_one_driver.cpp  |   99 +
 .../src/edge_disjoint_paths_one_to_one_driver.h}   |   35 +-
 .../src/max_flow_many_to_many.c}                   |  164 +-
 src/max_flow/src/max_flow_many_to_many_driver.cpp  |  116 +
 .../src/max_flow_many_to_many_driver.h}            |   35 +-
 .../src/max_flow_many_to_one.c}                    |  158 +-
 src/max_flow/src/max_flow_many_to_one_driver.cpp   |  117 +
 .../src/max_flow_many_to_one_driver.h}             |   34 +-
 .../src/max_flow_one_to_many.c}                    |  158 +-
 src/max_flow/src/max_flow_one_to_many_driver.cpp   |  117 +
 .../src/max_flow_one_to_many_driver.h}             |   34 +-
 .../src/max_flow_one_to_one.c}                     |  144 +-
 src/max_flow/src/max_flow_one_to_one_driver.cpp    |  114 +
 .../src/max_flow_one_to_one_driver.h}              |   34 +-
 .../src/maximum_cardinality_matching.c}            |  128 +-
 .../src/maximum_cardinality_matching_driver.cpp    |   98 +
 .../src/maximum_cardinality_matching_driver.h}     |   31 +-
 src/max_flow/src/pgr_edgedisjointpaths.hpp         |  269 +
 src/max_flow/src/pgr_maxflow.hpp                   |  262 +
 .../src/pgr_maximumcardinalitymatching.hpp         |  170 +
 src/{astar/doc => max_flow/test}/CMakeLists.txt    |    0
 src/max_flow/test/doc-pgr_edgeDisjointPaths.result |   44 +
 .../test/doc-pgr_edgeDisjointPaths.test.sql        |   38 +
 .../test/doc-pgr_maxFlowBoykovKolmogorov.result    |   41 +
 .../test/doc-pgr_maxFlowBoykovKolmogorov.test.sql  |   60 +
 .../test/doc-pgr_maxFlowEdmondsKarp.result         |   41 +
 .../test/doc-pgr_maxFlowEdmondsKarp.test.sql       |   60 +
 .../test/doc-pgr_maxFlowPushRelabel.result         |   48 +
 .../test/doc-pgr_maxFlowPushRelabel.test.sql       |   62 +
 .../test/doc-pgr_maximumCardinalityMatching.result |   19 +
 .../doc-pgr_maximumCardinalityMatching.test.sql    |   18 +
 src/max_flow/test/pgtap/flow-types-check.sql       | 1368 +++
 .../test/pgtap/flowapplications-types-check.sql    |  740 ++
 src/max_flow/test/sample_data_categories.sql       |   33 +
 src/max_flow/test/test.conf                        |   24 +
 src/pickDeliver/CMakeLists.txt                     |    5 -
 src/pickDeliver/doc/doc-pickDeliver.queries        |  245 +
 src/pickDeliver/doc/index.rst                      |   85 -
 src/pickDeliver/doc/pgr_pickDeliver.rst            |  229 +
 src/pickDeliver/sql/CMakeLists.txt                 |    5 +-
 .../sql/pickDeliver.sql}                           |   38 +-
 src/pickDeliver/sql/routing_vrppdtw.sql            |   43 -
 src/pickDeliver/src/CMakeLists.txt                 |   23 +-
 src/pickDeliver/src/Route.h                        |  257 -
 src/pickDeliver/src/Solution.h                     |  140 -
 src/pickDeliver/src/customers_input.c              |   74 +-
 src/pickDeliver/src/customers_input.h              |   28 +-
 src/pickDeliver/src/initial_solution.cpp           |  559 ++
 src/pickDeliver/src/initial_solution.h             |   77 +
 src/pickDeliver/src/node.cpp                       |   81 +
 src/pickDeliver/src/node.h                         |   80 +
 src/pickDeliver/src/optimize.cpp                   |  497 +
 src/pickDeliver/src/optimize.h                     |   76 +
 src/pickDeliver/src/order.cpp                      |  190 +
 src/pickDeliver/src/order.h                        |  106 +
 src/pickDeliver/src/pdp.c                          |  170 -
 src/pickDeliver/src/pdp.h                          |   69 -
 src/pickDeliver/src/pdp.hpp                        |   69 -
 src/pickDeliver/src/pdp_solver.cpp                 |  355 -
 src/pickDeliver/src/pgr_pickDeliver.cpp            |  357 +
 src/pickDeliver/src/pgr_pickDeliver.h              |  108 +
 .../src/pickDeliver.c}                             |  192 +-
 src/pickDeliver/src/pickDeliver_driver.cpp         |  127 +
 .../src/pickDeliver_driver.h}                      |   51 +-
 src/pickDeliver/src/solution.cpp                   |  225 +
 src/pickDeliver/src/solution.h                     |  125 +
 src/pickDeliver/src/tw_node.cpp                    |  279 +
 src/pickDeliver/src/tw_node.h                      |  299 +
 src/pickDeliver/src/vehicle.cpp                    |  516 +
 src/pickDeliver/src/vehicle.h                      |  325 +
 src/pickDeliver/src/vehicle_node.cpp               |  154 +
 src/pickDeliver/src/vehicle_node.h                 |  183 +
 src/pickDeliver/src/vehicle_pickDeliver.cpp        |  352 +
 src/pickDeliver/src/vehicle_pickDeliver.h          |  155 +
 src/pickDeliver/test/CMakeLists.txt                |    0
 .../test/bencharkTest/README.vrpdptw-testdata      |   33 +
 src/pickDeliver/test/bencharkTest/lc101_test.sql   |    9 +
 .../test/bencharkTest/vrpdptw-testdata.sql.gz      |  Bin 0 -> 1996513 bytes
 src/pickDeliver/test/doc-pickDeliver.result        |  233 +
 src/pickDeliver/test/doc-pickDeliver.test.sql      |    8 +
 src/pickDeliver/test/pdp-any-01.result             |    3 -
 .../test/pgtap/pickDeliver_types_check.sql         |   39 +
 src/pickDeliver/test/pgtap/wrong_data.sql          |  130 +
 .../test/{pdp-any-00.data => pickDeliver.data}     |   26 +-
 src/{allpairs => pickDeliver}/test/test.conf       |   18 +-
 src/proposed.rst                                   |   96 +-
 src/proposedNext.rst                               |   67 +-
 src/routingFunctions.rst                           |   68 +-
 src/shooting_star/CMakeLists.txt                   |    5 -
 src/shooting_star/doc/CMakeLists.txt               |    0
 src/shooting_star/doc/index.rst                    |  155 -
 src/shooting_star/sql/CMakeLists.txt               |    8 -
 src/shooting_star/sql/shooting_star.sql            |   51 -
 src/shooting_star/src/CMakeLists.txt               |   13 -
 src/shooting_star/src/edge_visitors.hpp            |   66 -
 src/shooting_star/src/shooting_star.c              |  574 --
 src/shooting_star/src/shooting_star.h              |   88 -
 .../src/shooting_star_boost_wrapper.cpp            |  456 -
 src/shooting_star/src/shooting_star_relax.hpp      |  197 -
 src/shooting_star/src/shooting_star_search.hpp     |  643 --
 src/shooting_star/test/CMakeLists.txt              |    0
 src/shooting_star/test/spss-any-00.data            |  212 -
 src/topology/doc/doc-pgr_analyzeGraph.queries      |    2 +
 src/topology/doc/doc-pgr_createTopology.queries    |    2 +
 src/topology/doc/pgr_analyzeGraph.rst              |   10 +-
 src/topology/doc/pgr_analyzeOneWay.rst             |    6 +-
 src/topology/doc/pgr_createTopology.rst            |   11 +-
 src/topology/doc/pgr_createVerticesTable.rst       |   13 +-
 src/topology/doc/pgr_nodeNetwork.rst               |   14 +-
 src/topology/sql/create_vertices_table.sql         |    6 +-
 src/topology/sql/nodeNetwork.sql                   |    4 +-
 src/topology/sql/pgrouting_analytics.sql           |    4 +-
 src/topology/sql/pgrouting_topology.sql            |   10 +-
 src/topology/test/analyzeOneway-any.test.sql       |    3 +
 src/topology/test/createVertTab-any.test.sql       |    1 +
 src/topology/test/doc-pgr_analyzeGraph.test.sql    |    1 +
 src/topology/test/doc-pgr_createTopology.test.sql  |    2 +
 src/topology/test/nodeNetwork-any.result           |    2 +-
 src/topology/test/nodeNetwork-any.test.sql         |    2 +
 src/trsp/CMakeLists.txt                            |    4 -
 src/trsp/doc/CMakeLists.txt                        |    0
 src/trsp/doc/pgr_trsp.rst                          |   13 +-
 src/trsp/sql/trsp_V2.2.sql                         |    4 +-
 src/trsp/src/CMakeLists.txt                        |    2 +-
 src/trsp/src/GraphDefinition.cpp                   |   16 +-
 src/trsp/src/GraphDefinition.h                     |   20 +-
 src/trsp/src/trsp.c                                |   20 +-
 src/trsp/src/{trsp_core.cpp => trsp_driver.cpp}    |    3 +-
 src/trsp/src/{trsp.h => trsp_driver.h}             |   10 -
 src/tsp/CMakeLists.txt                             |    4 -
 src/tsp/doc/CMakeLists.txt                         |    0
 src/tsp/doc/doc-pgr_TSP.queries                    |   73 +
 src/tsp/doc/doc-pgr_eucledianTSP.queries           |   94 +
 src/tsp/doc/doc-tsp.queries                        |  118 +
 src/tsp/doc/pgr_eucledianTSP.rst                   |  148 +
 src/tsp/doc/{pgr_tsp.rst => pgr_tsp-V2.0.rst}      |   27 +-
 src/tsp/doc/pgr_tsp.rst                            |  260 +-
 src/tsp/doc/tsp.rst                                |  277 +
 src/tsp/doc/tsp_parameters.txt                     |   34 +
 src/tsp/doc/tsp_return_values.txt                  |   27 +
 src/tsp/sql/CMakeLists.txt                         |   11 +
 src/tsp/sql/TSP.sql                                |   26 +
 src/tsp/sql/_makeMatrix.sql                        |   69 +
 src/tsp/sql/eucledianTSP.sql                       |   27 +
 src/tsp/sql/routing_tsp_wrappers.sql               |    4 +-
 src/tsp/sql/tsp_v2.0_coordinates.sql               |   72 +
 src/tsp/sql/xyd_tsp.sql                            |   11 -
 src/tsp/src/CMakeLists.txt                         |   19 +-
 src/tsp/src/Dmatrix.cpp                            |  176 +-
 src/tsp/src/Dmatrix.h                              |  125 +
 src/tsp/src/Dmatrix.hpp                            |   39 -
 src/tsp/src/OBSOLETE/tsp.c                         |  545 --
 src/tsp/src/eucledianDmatrix.cpp                   |  169 +
 src/tsp/src/eucledianDmatrix.h                     |  124 +
 src/tsp/src/{xyd_tsp.c => eucledianTSP.c}          |  155 +-
 src/tsp/src/eucledianTSP_driver.cpp                |  207 +
 .../src/{tsp_driver.h => eucledianTSP_driver.h}    |   24 +-
 src/tsp/src/{xyd_tsp.c => newTSP.c}                |  138 +-
 src/tsp/src/newTSP_driver.cpp                      |  223 +
 src/tsp/src/{tsp_driver.h => newTSP_driver.h}      |   19 +-
 src/tsp/src/pgr_tsp.cpp                            |  720 +-
 src/tsp/src/pgr_tsp.hpp                            |  153 +-
 src/tsp/src/tour.cpp                               |  100 +
 src/tsp/src/tour.h                                 |  160 +
 src/tsp/src/tsp.h                                  |   18 +-
 src/tsp/src/tsp2.c                                 |   79 +-
 src/tsp/src/tsp_driver.cpp                         |  234 -
 src/tsp/src/tsplib.c                               |  331 +-
 src/tsp/test/CMakeLists.txt                        |    0
 src/tsp/test/development/gr9882-tsp.test.sql       | 9903 ++++++++++++++++++++
 .../test/development/qa194-tsp.result}             |    0
 src/tsp/test/development/qa194-tsp.test.sql        |  272 +
 src/tsp/test/development/wi29-tsp.result           |  226 +
 src/tsp/test/development/wi29-tsp.test.sql         |   75 +
 src/tsp/test/doc-pgr_TSP-mac.result                |   25 +
 src/tsp/test/doc-pgr_TSP-mac.test.sql              |   41 +
 src/tsp/test/doc-pgr_TSP-windows.result            |   25 +
 src/tsp/test/doc-pgr_TSP-windows.test.sql          |   41 +
 src/tsp/test/doc-pgr_TSP.result                    |   25 +
 src/tsp/test/doc-pgr_TSP.test.sql                  |   41 +
 src/tsp/test/doc-pgr_eucledianTSP.result           |   50 +
 src/tsp/test/doc-pgr_eucledianTSP.test.sql         |   35 +
 src/tsp/test/doc-tsp-mac.result                    |   68 +
 src/tsp/test/doc-tsp-mac.test.sql                  |   40 +
 src/tsp/test/doc-tsp-windows.result                |   68 +
 src/tsp/test/doc-tsp-windows.test.sql              |   40 +
 src/tsp/test/doc-tsp.result                        |   68 +
 src/tsp/test/doc-tsp.test.sql                      |   40 +
 src/tsp/test/performance/dj38.sql                  |   84 +
 src/tsp/test/performance/qa194.sql                 |  239 +
 src/tsp/test/performance/wi29.sql                  |   71 +
 src/tsp/test/pgtap/pgr_TSP_types_check.sql         |  213 +
 .../test/pgtap/pgr_eucledianTSP_types_check.sql    |  210 +
 src/tsp/test/test.conf                             |   33 +-
 src/tsp/test/tsp-any-00.data                       |   32 -
 src/tsp/test/tsp-any-00.result                     |    1 -
 src/tsp/test/tsp-any-00.test.sql                   |   23 -
 src/tsp/test/tsp-any-01.result                     |    1 -
 src/tsp/test/tsp-any-01.test.sql                   |   23 -
 src/tsp/test/tsp-any-03.test.sql                   |   62 -
 src/tsp/test/tsp-any-04.result                     |   11 -
 src/tsp/test/tsp-any-04.test.sql                   |   23 -
 src/tsp/test/tsp-any-05.result                     |   34 -
 src/tsp/test/tsp-any-05.test.sql                   |   39 -
 src/tsp/test/tsp-any.result                        |    7 -
 src/tsp/test/tsp-any.test.sql                      |   14 -
 .../test/{tsp-any-03.result => tsp-v2-0.result}    |   59 +
 src/tsp/test/tsp-v2-0.test.sql                     |  137 +
 src/tsp/test/tsp.data                              |   12 -
 src/vrp_basic/CMakeLists.txt                       |    6 -
 src/vrp_basic/doc/pgr_vrpOneDepot.rst              |   10 +-
 src/vrp_basic/src/Orders.txt                       |  102 -
 src/vrp_basic/src/Tester.cpp                       |  432 +-
 src/vrp_basic/src/Utils.h                          |  140 +-
 src/vrp_basic/src/VRP.c                            | 1242 ++-
 src/vrp_basic/src/VRP.h                            |   80 +-
 src/vrp_basic/src/VRP_Solver.cpp                   | 1608 ++--
 src/vrp_basic/src/VRP_Solver.h                     |  643 +-
 src/vrp_basic/src/VRP_core.cpp                     |  332 +-
 src/vrp_basic/src/Vehicles.txt                     |   21 -
 src/vrppdtw/CMakeLists.txt                         |    5 -
 src/vrppdtw/doc/CMakeLists.txt                     |    0
 src/vrppdtw/doc/doc-gsoc_vrppdtw.queries           |   76 +
 src/vrppdtw/doc/index.rst                          |   84 -
 src/vrppdtw/doc/pgr_gsoc_vrppdtw.rst               |  134 +
 src/vrppdtw/sql/CMakeLists.txt                     |    3 +-
 src/vrppdtw/sql/gsoc_vrppdtw.sql                   |   19 +
 src/vrppdtw/sql/routing_vrppdtw.sql                |   41 -
 src/vrppdtw/src/CMakeLists.txt                     |    6 -
 src/vrppdtw/src/Route.h                            |  348 -
 src/vrppdtw/src/Solution.h                         |  185 -
 src/vrppdtw/src/pdp.c                              |  478 -
 src/vrppdtw/src/pdp.h                              |  191 -
 src/vrppdtw/src/pdp_solver.cpp                     |  445 -
 src/vrppdtw/test/CMakeLists.txt                    |    0
 src/vrppdtw/test/doc-gsoc_vrppdtw.result           |   56 +
 src/vrppdtw/test/doc-gsoc_vrppdtw.test.sql         |   14 +
 src/vrppdtw/test/pdp-any-01.result                 |  146 -
 src/vrppdtw/test/pdp-any-01.test.sql               |    3 -
 src/vrppdtw/test/pdp-any-02.result                 |  114 +
 src/vrppdtw/test/pdp-any-02.test.sql               |    3 +
 src/vrppdtw/test/test.conf                         |   27 +-
 src/withPoints/doc/CMakeLists.txt                  |    0
 src/withPoints/doc/pgr_withPoints.rst              |   56 +-
 src/withPoints/doc/pgr_withPointsCost.rst          |   54 +-
 src/withPoints/doc/pgr_withPointsDD.rst            |   42 +-
 src/withPoints/doc/pgr_withPointsKSP.rst           |   38 +-
 src/withPoints/doc/pgr_withPointsVia.rst           |   36 +-
 src/withPoints/doc/withPoints.rst                  |   43 +-
 src/withPoints/doc/withPoints_queries.txt          |   51 -
 src/withPoints/src/get_new_queries.cpp             |   11 +-
 src/withPoints/src/get_new_queries.h               |    9 +-
 src/withPoints/src/many_to_many_withPoints.c       |   54 +-
 .../src/many_to_many_withPoints_driver.cpp         |   74 +-
 .../src/many_to_many_withPoints_driver.h           |   30 +-
 src/withPoints/src/many_to_one_withPoints.c        |   42 +-
 .../src/many_to_one_withPoints_driver.cpp          |   44 +-
 src/withPoints/src/many_to_one_withPoints_driver.h |   28 +-
 src/withPoints/src/msg_logger.hpp                  |    6 +-
 src/withPoints/src/one_to_many_withPoints.c        |   90 +-
 .../src/one_to_many_withPoints_driver.cpp          |  113 +-
 src/withPoints/src/one_to_many_withPoints_driver.h |   31 +-
 src/withPoints/src/one_to_one_withPoints.c         |   81 +-
 .../src/one_to_one_withPoints_driver.cpp           |  113 +-
 src/withPoints/src/one_to_one_withPoints_driver.h  |   34 +-
 src/withPoints/src/pgr_withPoints.cpp              |  179 +-
 src/withPoints/src/pgr_withPoints.hpp              |   11 +-
 src/withPoints/test/doc-pgr_withPoints.test.sql    |    1 -
 src/withPoints/test/test.conf                      |    2 +-
 tools/clean/clean.sh                               |   66 +
 tools/doxygen/Makefile                             |    5 -
 tools/{ => git-tools}/pre-commit                   |    6 +-
 tools/licences/GNU_license.txt                     |    4 +-
 tools/licences/README.md                           |    9 +
 tools/licences/add-licenses                        |   19 +-
 tools/scripts/fix_typos.sh                         |   73 +
 tools/scripts/typos_whitelist.txt                  |   39 +
 tools/sigs/pgrouting--2.0.0.sig                    |    1 +
 tools/sigs/pgrouting--2.0.1.sig                    |    1 +
 tools/sigs/pgrouting--2.2.4.sig                    |  109 +
 tools/template/create.sh                           |   31 +-
 tools/template/src/function1.c                     |   65 +-
 tools/template/src/function1_driver.cpp            |  110 +-
 tools/template/src/function1_driver.h              |   22 +-
 tools/template/test/pgtap/types-check.sql          |   79 +-
 tools/testers/algorithm-tester.pl                  |  245 +-
 tools/testers/contraction_data.sql                 |   61 +
 tools/testers/pg_prove_tests.sh                    |   26 +-
 .../testers/pickDeliver_pgtap_data.sql             |   27 +-
 tools/testers/sampledata.sql                       |  109 +-
 .../{setup_db.sql => setup_contraction_db.sql}     |    2 +-
 tools/testers/setup_db.sql                         |    1 +
 tools/testers/update-tester.sh                     |  113 +
 tools/travis/install-postgres9.5.sh                |   19 -
 ...stall-postgres9.5.sh => install-postgres9.6.sh} |   25 +-
 tools/travis/pgrouting_build.sh                    |    5 +-
 tools/travis/pgrouting_test.sh                     |    2 +-
 tools/windows/makepgroutingw32.sh                  |    2 +-
 tools/windows/makepgroutingw64.sh                  |    2 +-
 tools/windows/msbuild_pgrouting.bat                |  210 +
 tools/winnie/build_pgrouting.sh                    |  207 +-
 715 files changed, 55153 insertions(+), 20675 deletions(-)

diff --git a/.gitignore b/.gitignore
index f685e80..7e6c836 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,9 @@
 # default build directory
 build
-src/turnRestricted
+fix_typos
+
 .DS_Store
 .vagrant
-issues
 tools/vagrant/packaging.sh
 *.mo
 .directory
diff --git a/.travis.yml b/.travis.yml
index 4935a62..4f629fc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,10 +7,10 @@
 
 #choose precise or trusty
 
-group: edge
-3dist: trusty    
+#group: edge
+#dist: trusty    
 
-#dist: precise
+dist: precise
 
 sudo: required
 
@@ -27,6 +27,7 @@ branches:
   only:
     - master
     - develop
+    - release/2.3.0
 
 env:
   - POSTGRESQL_VERSION=9.1
@@ -34,9 +35,10 @@ env:
   - POSTGRESQL_VERSION=9.3
   - POSTGRESQL_VERSION=9.4
   - POSTGRESQL_VERSION=9.5
+  #- POSTGRESQL_VERSION=9.6
 
 
-# excecuted. So things have to be tested oe by one.
+# executed. So things have to be tested oe by one.
 addons:
   apt:
     sources:
@@ -53,24 +55,36 @@ addons:
       - libcgal-dev
       - postgresql-server-dev-all
       - postgresql-common
+      - python-sphinx
 
 
 install:
   - sudo /etc/init.d/postgresql stop
   - sudo /etc/init.d/postgresql stop
+
   - sudo ./tools/travis/install-postgres9.5.sh $POSTGRESQL_VERSION postgres
+  #- sudo ./tools/travis/install-postgres9.6.sh $POSTGRESQL_VERSION postgres
 
 before_script:
+  ## Install doxygen
+  #- sudo add-apt-repository ppa:libreoffice/libreoffice-4-4 -y && sudo apt-get -qq update &&
+  #  sudo apt-get --no-install-suggests --no-install-recommends -qq install doxygen  &&
+  #  doxygen --version ;
+
   # Add our chosen PG version to the path
   - export PATH=/usr/lib/postgresql/$POSTGRESQL_VERSION/bin:$PATH
+
   # Stop whichever version of PG that travis started
   - sudo /etc/init.d/postgresql stop
+
   # Start the version of PG that we want to test
   - sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION
+
   # Install pgtap and pg_prove
   # pgtap has to be installed after postgres has started
   - ./tools/travis/install_pgtap.sh $POSTGRESQL_VERSION
   - sudo apt-get install -y libtap-parser-sourcehandler-pgtap-perl
+
   # initialize databases
   - createdb  -U postgres ___pgr___test___
   - createdb  -U postgres pgr_test__db__test
@@ -78,12 +92,15 @@ before_script:
 
 script: 
   - ./tools/travis/pgrouting_build.sh $POSTGRESQL_VERSION $POSTGIS_VERSION
+  # tests as part of script so if a test fails the build fails
   - ./tools/travis/pgrouting_test.sh $POSTGRESQL_VERSION postgres
   - ./tools/testers/pg_prove_tests.sh postgres
 
 after_script: 
-  # nothing
+  # blank
 
 #after_success:
-  #- ./tools/travis/pgrouting_deploy.sh $POSTGRESQL_VERSION $POSTGIS_VERSION
+  - make doc
+  # - doxygen -v
+  - make doxy
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ab540a..c10af4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,36 +2,182 @@
 # Format convention
 # - command (lower case)
 # - VARIABLE (upper case)
-# (http://www.cmake.org/cmake/help/v2.8.10/cmake.html)
+# (http://www.cmake.org/cmake/help/v2.8.12/cmake.html)
 #
 
-cmake_minimum_required(VERSION 2.8./ FATAL_ERROR)
+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+
+#---------------------------------------------
+# Setting kind of build
+#---------------------------------------------
+#
+# On Master cmake -DMAKE_BUILD_TYPE=Release
+#----------------------
+
+
+message(STATUS "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
+if(NOT CMAKE_BUILD_TYPE)
+    if (UNIX)
+        set(CMAKE_BUILD_TYPE Release CACHE STRING
+            "Choose the type of build, options are: None Debug Release RelWithDebInfo
+            MinSizeRel."
+            FORCE)
+        message("Running as: Debug")
+    else()
+        set(CMAKE_BUILD_TYPE Release CACHE STRING
+            "Choose the type of build, options are: None Debug Release RelWithDebInfo
+            MinSizeRel."
+            FORCE)
+        message("Running as: Release")
+    endif()
+endif()
+message(STATUS "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
+
+
+#---------------------------------------------
+#---------------------------------------------
+#---------------------------------------------
+
 project(PGROUTING)
 
-#set(CMAKE_VERBOSE_MAKEFILE 1)
+#---------------------------------------------
+#---------------------------------------------
+#---------------------------------------------
+
+if(POLICY CMP0046)
+   cmake_policy(SET CMP0046 OLD)
+endif()
+
+if(MSVC)
+    cmake_policy(SET CMP0046 OLD)
+endif()
+
+#=============================================
+# Set the working directories
+#=============================================
 
-# Configure options
+#---------------------------------------------
+#  PgRouting_SOURCE_NAMES
+#---------------------------------------------
+#
+# Name of the directories that have C/C++ code
+#  - <directory>/src/CMakelists.txt must exist
+#  - <directory>/sql/CMakeLists.txt  must exist
+#----------------------
+
+set(PgRouting_SOURCE_NAMES
+
+    #----------------------
+    # "common" must be first can not be removed
+    #----------------------
+    "common"
 
-option(WITH_DOC
-    "Set ON|OFF (default=OFF) to build Documentation library tree" OFF)
+    #----------------------
+    # "dijkstra" can not be removed 
+    #   Has the command needed to link with prostgresl
+    #----------------------
+    "dijkstra" 
 
-option(BUILD_LATEX
-    "Set ON|OFF (default=OFF) to build Documentation library tree as PDF" OFF)
+    #----------------------
+    # Directories that have being rewritten
+    #----------------------
+    "allpairs"
+    "astar"
+    "driving_distance"
+    "ksp"
+    "tsp"
+
+    #----------------------
+    # Code needs to be rewritten
+    #----------------------
+    "alpha_shape"
+    "bd_astar"
+    "bd_dijkstra"
+    "trsp"
+
+    #----------------------
+    # Proposed
+    #  - Not officially on the release
+    #  - number indicates version when was propsosed with code
+    #----------------------
+    "max_flow"    # 2.3
+    "contraction" # 2.3
+    "pickDeliver" # 2.3
+    "vrp_basic"   # 2.0 
+    "withPoints"  # 2.2
+
+    # template generated name
+    #"funnyDijkstra"
 
-option(BUILD_HTML
-    "Set ON|OFF (default=ON) to build Documentation library tree as HTML" ON)
+    )
 
-option(BUILD_MAN
-    "Set ON|OFF (default=ON) to build Documentation library tree as MAN page" OFF)
+#-----------------------------------------------------------------------------
+# Name of the directories containing only SQL files
+#
+#  - <directory>/sql/CMakeLists.txt  must exist
+#-----------------------------------------------------------------------------
+set(PgRouting_SQL_DIRECTORIES 
+
+    "topology"     # needs to be revised
+
+    #----------------------
+    # Proposed
+    #  Not officially on the release
+    #----------------------
+    "convenience"  # most are deprecated
+    "label_graph"  # needs to be rewritten using Boost
+    "costMatrix"   # proposed on 2.3
+
+    #----------------------
+    # Wrappers for backwards compatibility 
+    #----------------------
+    "apsp_johnson"  # 2.0 wrap of pgr_johnson
+    "apsp_warshall" # 2.0 wrap of pgr_warshall
+    "kdijkstra"     # 2.0 wrap of pgr_dijkstra & pgr_dijkstraCost
+    "vrppdtw"       # 2.1 wraps of _pgr_pickDeliver 
 
-SET(POSTGRESQL_BIN "" CACHE STRING "Define optional path to PostgreSQL binaries an a non-standard location.")
+    )
 
+#---------------------------------------------
+# minimum versions
+#---------------------------------------------
+set(DOXYGEN_MINIMUM_VERSION "1.8.6")
+set(SPHINX_MINIMUM_VERSION "1.1")
+
+message(STATUS "DOXYGEN_MINIMUM_VERSION=${DOXYGEN_MINIMUM_VERSION}")
+message(STATUS "SPHINX_MINIMUM_VERSION=${SPHINX_MINIMUM_VERSION}")
+
+
+#---------------------------------------------
+# C++ Compiler requirements
+#---------------------------------------------
+
+
+include(CheckCXXCompilerFlag)
+
+if (NOT MSVC) 
+    CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+    message(STATUS "COMPILER_SUPPORTS_CXX0X= ${COMPILER_SUPPORTS_CXX0X}")
+    message(STATUS "CMAKE_CXX_COMPILER= ${CMAKE_CXX_COMPILER}")
+    if(COMPILER_SUPPORTS_CXX0X)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+    else()
+        CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+        message(STATUS "COMPILER_SUPPORTS_CXX11= ${COMPILER_SUPPORTS_CXX11}")
+        if(COMPILER_SUPPORTS_CXX11)
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+        else()
+            message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++0x nor C++11 support.
+            Please use a different C++ compiler.")
+        endif()
+    endif()
+endif()
 
 #-----------------------------------------------------------------------------
 # PGROUTING version number.
 set(PGROUTING_VERSION_MAJOR "2")
-set(PGROUTING_VERSION_MINOR "2")
-set(PGROUTING_VERSION_PATCH "4")
+set(PGROUTING_VERSION_MINOR "3")
+set(PGROUTING_VERSION_PATCH "0")
 
 set(PGROUTING_VERSION_STRING "${PGROUTING_VERSION_MAJOR}.${PGROUTING_VERSION_MINOR}.${PGROUTING_VERSION_PATCH}")
 set(PGROUTING_VERSION "${PGROUTING_VERSION_MAJOR}.${PGROUTING_VERSION_MINOR}")
@@ -41,8 +187,9 @@ set(POSTGIS_MINIMUM_VERSION "2.0.0")
 
 file(STRINGS "${PGROUTING_SOURCE_DIR}/VERSION" PGROUTING_BUILD_STRING)
 
-set(PGROUTING_GIT_TAG "pgrouting-2.2.4")
-#string(REGEX REPLACE "^(.+)-([0-9]+)-([0-9a-f]+) (.*)$" "\\1" PGROUTING_GIT_TAG ${PGROUTING_BUILD_STRING})
+set(PGROUTING_GIT_TAG "pgrouting-2.3.0")
+
+#string(REGEX REPLACE "^(.+)-([0-9]+)-g([0-9a-f]+) (.*)$" "\\1" PGROUTING_GIT_TAG ${PGROUTING_BUILD_STRING})
 string(REGEX REPLACE "^(.+)-([^-]+)-[0-9]+-([0-9a-f]+) (.*)$" "\\2" PGROUTING_GIT_BUILD ${PGROUTING_BUILD_STRING})
 string(REGEX REPLACE "^(.+)-([0-9]+)-([0-9a-f]+) (.*)$" "\\3" PGROUTING_GIT_HASH ${PGROUTING_BUILD_STRING})
 string(REGEX REPLACE "^(.+)-([0-9]+)-([0-9a-f]+) (.*)$" "\\4" PGROUTING_GIT_BRANCH ${PGROUTING_BUILD_STRING})
@@ -51,6 +198,7 @@ set(PGROUTING_VERSION_REVISION_NAME "${PGROUTING_GIT_HASH} ${PGROUTING_GIT_BRANC
 set(PGROUTING_VERSION_REVISION_HASH "${PGROUTING_GIT_HASH}")
 
 message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
+message(STATUS "PGROUTING_BUILD_STRING: ${PGROUTING_BUILD_STRING}")
 message(STATUS "PGROUTING_GIT_TAG: ${PGROUTING_GIT_TAG}")
 message(STATUS "PGROUTING_GIT_BUILD: ${PGROUTING_GIT_BUILD}")
 message(STATUS "PGROUTING_GIT_HASH: ${PGROUTING_GIT_HASH}")
@@ -63,6 +211,8 @@ message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
 message(STATUS "PGROUTING_VERSION_REVISION_HASH: ${PGROUTING_VERSION_REVISION_HASH}")
 message(STATUS "POSTGRESQL_BIN: ${POSTGRESQL_BIN}")
 
+
+
 #-----------------------------------------------------------------------------
 # CMAKE configuration
 # This is for my mingw64 environment, it should go away
@@ -76,58 +226,58 @@ set(CMAKE_MODULE_PATH "${PGROUTING_SOURCE_DIR}/cmake")
 include(MacroLibrary)
 include(TargetDistclean)
 
-message(STATUS "UNIX=${UNIX}")
-message(STATUS "WIN32=${WIN32}")
-if(WIN32)
-  set(OS_BUILD  $ENV{OS_BUILD})
-  if(NOT OS_BUILD)
-    set(OS_BUILD "64")
-  endif(NOT OS_BUILD)
-  set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:/c/ming${OS_BUILD}/projects/pgx${OS_BUILD}/pg92)
-  if (NOT BOOST_ROOT)
-    set(BOOST_ROOT c:/ming${OS_BUILD}/msys/local)
-  endif(NOT BOOST_ROOT)
-   
-  if (NOT CGAL_ROOT)
-    set(CGAL_ROOT c:/ming${OS_BUILD}/msys/local)
-  endif(NOT CGAL_ROOT)
-  
-  if (NOT GMP_ROOT)
-    set(GMP_ROOT c:/ming${OS_BUILD}/mingw${OS_BUILD})
-  endif(NOT GMP_ROOT)
-  message(STATUS "OS_BUILD=${OS_BUILD}")
-  message(STATUS "CGAL_ROOT=${CGAL_ROOT}")
-  message(STATUS "GMP_ROOT=${GMP_ROOT}")
-  message(STATUS "BOOST_ROOT=${BOOST_ROOT}")
-  message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
-endif(WIN32)
+if(WIN32 AND NOT MSVC)
+    set(OS_BUILD  $ENV{OS_BUILD})
+    if(NOT OS_BUILD)
+        set(OS_BUILD "64")
+    endif(NOT OS_BUILD)
+    set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:/c/ming${OS_BUILD}/projects/pgx${OS_BUILD}/pg92)
+    if (NOT BOOST_ROOT)
+        set(BOOST_ROOT c:/ming${OS_BUILD}/msys/local)
+    endif(NOT BOOST_ROOT)
+
+    if (NOT CGAL_ROOT)
+        set(CGAL_ROOT c:/ming${OS_BUILD}/msys/local)
+    endif(NOT CGAL_ROOT)
+
+    if (NOT GMP_ROOT)
+        set(GMP_ROOT c:/ming${OS_BUILD}/mingw${OS_BUILD})
+    endif(NOT GMP_ROOT)
+    message(STATUS "OS_BUILD=${OS_BUILD}")
+    message(STATUS "CGAL_ROOT=${CGAL_ROOT}")
+    message(STATUS "GMP_ROOT=${GMP_ROOT}")
+    message(STATUS "BOOST_ROOT=${BOOST_ROOT}")
+    message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
+endif(WIN32 AND NOT MSVC)
 
 
 include(FindPerl)
 if(NOT PERL_EXECUTABLE)
-  message(FATAL_ERROR " Please check your Perl installation.")
+    message(FATAL_ERROR " Please check your Perl installation.")
 endif(NOT PERL_EXECUTABLE)
 
 find_package(PostgreSQL)
 if(NOT POSTGRESQL_FOUND)
-  message(FATAL_ERROR " Please check your PostgreSQL installation.") 
+    message(FATAL_ERROR " Please check your PostgreSQL installation.") 
 endif(NOT POSTGRESQL_FOUND)
 
 #set(Boost_DEBUG ON)
 find_package(Boost)
 if(Boost_INCLUDE_DIRS)
-  message(STATUS "Boost headers were found here: ${Boost_INCLUDE_DIR}")
+    message(STATUS "Boost headers were found here: ${Boost_INCLUDE_DIRS}")
+    #find_file(MYVAR geometry.hpp)
+    #message(STATUS "geometry.hpp  found here: ${MYVAR}")
 else(Boost_INCLUDE_DIRS)
-  message(FATAL_ERROR " Please check your Boost installation ") 
+    message(FATAL_ERROR " Please check your Boost installation ") 
 endif(Boost_INCLUDE_DIRS)
 
 find_package(CGAL)
 if(NOT CGAL_FOUND)
-   message(FATAL_ERROR " Please check your CGAL installation, or set correct path to CGAL_INCLUDE_DIR and CGAL_LIBRARIES.")
+    message(FATAL_ERROR " Please check your CGAL installation, or set correct path to CGAL_INCLUDE_DIR and CGAL_LIBRARIES.")
 endif(NOT CGAL_FOUND)
 
 if(NOT POSTGRESQL_VERSION_STRING)
-  message(FATAL_ERROR "pg_config was not found. Please check your PostgreSQL installation!")
+    message(FATAL_ERROR "pg_config was not found. Please check your PostgreSQL installation!")
 endif(NOT POSTGRESQL_VERSION_STRING)
 
 message(STATUS "POSTGRESQL_VERSION_STRING is ${POSTGRESQL_VERSION_STRING}")
@@ -138,141 +288,147 @@ message(STATUS "PGSQL_VERSION is ${PGSQL_VERSION}")
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPGSQL_VERSION=${PGSQL_VERSION}")
 
+#TODO maybe needs a wrapper for visual studio
+if(WIN32 AND MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_DEPRECATE")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SCL_SECURE_NO_DEPRECATE")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_NONSTDC_NO_DEPRECATE")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -EHsc")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
+endif()
+
 if("${POSTGRESQL_VERSION}" VERSION_LESS "${POSTGRESQL_MINIMUM_VERSION}")
-  message(FATAL_ERROR " PostgreSQL ${POSTGRESQL_MINIMUM_VERSION} or greater is required.")
+    message(FATAL_ERROR " PostgreSQL ${POSTGRESQL_MINIMUM_VERSION} or greater is required.")
 endif("${POSTGRESQL_VERSION}" VERSION_LESS "${POSTGRESQL_MINIMUM_VERSION}")
 
 
 execute_process(
-  COMMAND ${POSTGRESQL_PG_CONFIG} --pkglibdir
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-  OUTPUT_VARIABLE LIB_DIR)
+    COMMAND ${POSTGRESQL_PG_CONFIG} --pkglibdir
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    OUTPUT_VARIABLE LIB_DIR)
 
 if(LIB_DIR)
-  message(STATUS "Install directory for libraries is set to ${LIB_DIR}")
+    message(STATUS "Install directory for libraries is set to ${LIB_DIR}")
 else(LIB_DIR)
-  message(FATAL_ERROR "pg_config --pkglibdir failed to return a value. Please check your PostgreSQL installation!")
+    message(FATAL_ERROR "pg_config --pkglibdir failed to return a value. Please check your PostgreSQL installation!")
 endif(LIB_DIR)
 
 set(LIBRARY_INSTALL_PATH ${LIB_DIR})
 
 execute_process(
-  COMMAND ${POSTGRESQL_PG_CONFIG} --sharedir
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-  OUTPUT_VARIABLE SHARE_DIR)
+    COMMAND ${POSTGRESQL_PG_CONFIG} --sharedir
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    OUTPUT_VARIABLE SHARE_DIR)
 
 if(SHARE_DIR)
-  set(SHARE_DIR "${SHARE_DIR}/extension")
-  message(STATUS "Extension directory for SQL files is set to ${SHARE_DIR}")
+    set(SHARE_DIR "${SHARE_DIR}/extension")
+    message(STATUS "Extension directory for SQL files is set to ${SHARE_DIR}")
 else(SHARE_DIR)
-  message(FATAL_ERROR "pg_config --sharedir failed to return a value. Please check your PostgreSQL installation!")
+    message(FATAL_ERROR "pg_config --sharedir failed to return a value. Please check your PostgreSQL installation!")
 endif(SHARE_DIR)
 
+#-------------------------------------
 # Handles documentation
+#-------------------------------------
+set(PROJECT_NAME  "pgRouting")
+set(PROJECT_BRIEF "pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.")
+set(PROJECT_NUMBER  "${PGROUTING_GIT_TAG}")
+add_subdirectory(doxygen)
 add_subdirectory(doc)
+#-------------------------------------
 
 #include directories: files in alphabetical order
 set(PGROUTING_INCLUDE_DIRECTORIES
-    ${PGROUTING_SOURCE_DIR}/src/apsp_johnson/src
-    ${PGROUTING_SOURCE_DIR}/src/apsp_warshall/src
-    ${PGROUTING_SOURCE_DIR}/src/allpairs/src
-    ${PGROUTING_SOURCE_DIR}/src/astar/src
-    ${PGROUTING_SOURCE_DIR}/src/bd_astar/src
-    ${PGROUTING_SOURCE_DIR}/src/bd_dijkstra/src
     ${PGROUTING_SOURCE_DIR}/src/common/src
     ${PGROUTING_SOURCE_DIR}/src/dijkstra/src
-    ${PGROUTING_SOURCE_DIR}/src/driving_distance/src
-    ${PGROUTING_SOURCE_DIR}/src/kdijkstra/src
-    ${PGROUTING_SOURCE_DIR}/src/ksp/src
-    ${PGROUTING_SOURCE_DIR}/src/trsp/src
-    ${PGROUTING_SOURCE_DIR}/src/tsp/src
-    ${PGROUTING_SOURCE_DIR}/src/vrp_basic/src
-    ${PGROUTING_SOURCE_DIR}/src/vrppdtw/src
-
-# not using C/C++
-    ${PGROUTING_SOURCE_DIR}/src/label_graph/src
+    )
 
+include_directories(${PGROUTING_INCLUDE_DIRECTORIES} ${POSTGRESQL_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${CGAL_INCLUDE_DIR})
+message(STATUS "PGROUTING_INCLUDE_DIRECTORIES = ${PGROUTING_INCLUDE_DIRECTORIES}")
+message(STATUS "POSTGRESQL_INCLUDE_DIR = ${POSTGRESQL_INCLUDE_DIR}")
+message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
 
-#not suported but directory exists
-#    ${PGROUTING_SOURCE_DIR}/src/shooting_star/src
-    )
+get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
+foreach(dir ${dirs})
+    message(STATUS "dir='${dir}'")
+endforeach()
 
-include_directories(${PGROUTING_INCLUDE_DIRECTORIES} ${POSTGRESQL_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
 
 
 if(WIN32)
-  include_directories(${POSTGRESQL_INCLUDE_DIR}/port/win32)
+    include_directories(${POSTGRESQL_INCLUDE_DIR}/port/win32)
+    if(MSVC)
+        include_directories(${POSTGRESQL_INCLUDE_DIR}/port/win32_msvc/)
+    endif(MSVC)
 endif(WIN32)
 
 # we need link libpostgres.a on win32 env
 if(WIN32)
-  message(STATUS "LINK_DIRECTORIES = ${POSTGRESQL_LIBRARIES}")
-  link_directories(${POSTGRESQL_LIBRARIES} ${LIB_DIR})
-  link_libraries(postgres)
+    message(STATUS "LINK_DIRECTORIES = ${POSTGRESQL_LIBRARIES}")
+    link_directories(${POSTGRESQL_LIBRARIES} ${LIB_DIR})
+    link_libraries(postgres)
 endif(WIN32)
 
-# TODO default compilation with -dNDEBUG 
+# TODO default compilation with -DNDEBUG 
 
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 #compiler directives
-if(APPLE)
-  # support GNU(Xcode<4) and Clang(Xcode>=4)
-  if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
-    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -fPIC -O2 -g -frounding-math")
-  else()
-    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -fPIC -O2 -g")
-  endif()
-  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -O2 -g -frounding-math -Wno-deprecated")
-  else()
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -O2 -std=c++0x -g -Wno-deprecated")
-  endif()
-
-elseif(UNIX) # UNIX system variable include UNIX like system(i.e. APPLE and CYGWIN)
-    #set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -std=gnu99 -fPIC -O2 -g -Wall -Wconversion -pedantic -fmax-errors=10  -Wmissing-prototypes -frounding-math")
-    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fPIC -O2 -g -Wall -Wconversion -pedantic -fmax-errors=10 -Wextra  -frounding-math -Wno-deprecated")
-
-    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -fPIC -O2 -g  -frounding-math")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -O2 -g -std=c++0x -frounding-math -Wno-deprecated")
-
-elseif(WIN32)
-    # currently, support MinGW only
-    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -O2  -frounding-math")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2  -std=c++0x -frounding-math -Wno-deprecated")
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+if(UNIX OR (WIN32 AND NOT MSVC))
+    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}  -std=gnu99 ")
 endif()
 
-# List variable to collect module SQL file names
-set(PACKAGE_SQL_FILES "")
-set(L_PACKAGE_SQL_FILES "")
 
-#==========================
-#  PgRouting_SOURCE_NAMES
-#==========================
+CHECK_C_COMPILER_FLAG("-frounding-math" C_COMPILER_SUPPORTS_ROUNDING_MATH)
+CHECK_CXX_COMPILER_FLAG("-frounding-math" CXX_COMPILER_SUPPORTS_ROUNDING_MATH)
+if(C_COMPILER_SUPPORTS_ROUNDING_MATH)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -frounding-math")
+endif()
+if(CXX_COMPILER_SUPPORTS_ROUNDING_MATH)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frounding-math")
+endif()
 
-set(PgRouting_SOURCE_NAMES
-    "common"
 
-    #to be deprecated
-    "kdijkstra"
+if(NOT WIN32)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC ")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ")
+endif()
 
-    "dijkstra"
-    "driving_distance"
-    "ksp"
-    "allpairs"
-    "withPoints"
 
-    #"funnyDijkstra"
+set(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}  -Wall -Wconversion -pedantic -fmax-errors=10  -Wmissing-prototypes")
+#TODO remove the optimizer flag when pgr_bdijkstra gets fixed
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O1 -fno-implicit-inline-templates -Wconversion -pedantic -fmax-errors=10 -Wunused -Wuninitialized -Wextra")
 
-    "alpha_shape"
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-    "astar" "bd_astar"
-    "bd_dijkstra"
-    "trsp" #2.0
-    "tsp"
+#if(CDEBUG)
+message(STATUS "CMAKE_CXX_FLAGS_DEBUG= ${CMAKE_CXX_FLAGS_DEBUG}")
+message(STATUS "CMAKE_CXX_FLAGS_RELEASE= ${CMAKE_CXX_FLAGS_RELEASE}")
+message(STATUS "CMAKE_CXX_FLAGS= ${CMAKE_CXX_FLAGS}")
 
-    "vrp_basic"
-    "vrppdtw"
+message(STATUS "CMAKE_C_FLAGS_DEBUG= ${CMAKE_C_FLAGS_DEBUG}")
+message(STATUS "CMAKE_C_FLAGS_RELEASE= ${CMAKE_C_FLAGS_RELEASE}")
+message(STATUS "CMAKE_C_FLAGS= ${CMAKE_C_FLAGS}")
+
+message(STATUS "UNIX=${UNIX}")
+message(STATUS "WIN32=${WIN32}")
+message(STATUS "MSVC=${MSVC}")
+#endif()
+
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-    )
+
+#====================================================================
+# Include the working directories
+#====================================================================
+
+if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
+    message("Including InternalQueryTests")
+    set(PgRouting_SOURCE_NAMES ${PgRouting_SOURCE_NAMES} "internalQueryTests")
+endif()
 
 #-------------------
 # add the subdirectories that have the C/C++ code 
@@ -282,35 +438,9 @@ foreach (subdir ${PgRouting_SOURCE_NAMES})
     add_subdirectory("${PGROUTING_SOURCE_DIR}/src/${subdir}/src")
 endforeach()
 
-#-----------------------------------------------------------------------------
-# List variable to collect module SQL file names
-#-----------------------------------------------------------------------------
-set(PgRouting_SQL_DIRECTORIES ${PgRouting_SOURCE_NAMES}
-    "apsp_johnson"  #V2.0
-    "apsp_warshall" #V2.0
-    "convinience"
-    "topology"
-    "label_graph")
-
-
-set(PACKAGE_SQL_FILES "")
-set(LIST_PACKAGE_SQL_FILES "")
-
-foreach (subdir ${PgRouting_SQL_DIRECTORIES})
-    add_subdirectory("${PGROUTING_SOURCE_DIR}/src/${subdir}/sql")
-endforeach()
-
-list(APPEND LIST_PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}")
-
-#if (CDEBUG)
-    foreach (files ${LIST_PACKAGE_SQL_FILES})
-        message("${files}")
-    endforeach()
-#endif()
 
+#====================================================================
 
-#add_subdirectory(src)
-#list(APPEND L_PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}")
 
 
 # assemble the object files from the src functions into
@@ -365,31 +495,78 @@ if(APPLE)
         PROPERTIES
         LINK_FLAGS "-bundle_loader ${POSTGRESQL_EXECUTABLE} -bundle")
 endif(APPLE)
+if(WIN32 AND MSVC)
+    set_target_properties(${PGROUTING_LIB_NAME} PROPERTIES PREFIX "lib")
+endif(WIN32 AND MSVC)
+
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#
+# Handling SQL files
+#
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#
+add_custom_target(build-time-sql-directory ALL
+    COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/sql_queries")
 
+set(TEMP_LIB_FILENAME "${CMAKE_BINARY_DIR}/sql_queries/lib-pgrouting--version.sql.in")
+file(WRITE ${TEMP_LIB_FILENAME} "")
 
-file(WRITE "${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql.in"
-    "-- pgRouting version '${PGROUTING_VERSION_STRING}' extension for postgresql\n")
+#-------------------
+# add the subdirectories that have the SQL files
+#-------------------
 
-file(APPEND "${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql.in"
-    "-- Complain if script is sourced in pgsql, rather than CREATE EXTENSION\n")
-#file(APPEND "${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql.in"
-#    "\\echo Use \"CREATE EXTENSION pgrouting\" to load this file. \\quit")
+set(PgRouting_SQL_DIRECTORIES
+    ${PgRouting_SOURCE_NAMES}
+    ${PgRouting_SQL_DIRECTORIES})
+
+set(PACKAGE_SQL_FILES "")
+
+foreach (subdir ${PgRouting_SQL_DIRECTORIES})
+    add_subdirectory("${PGROUTING_SOURCE_DIR}/src/${subdir}/sql")
+endforeach()
 
 
+if (CDEBUG)
+    foreach (files ${PACKAGE_SQL_FILES})
+        message("${files}")
+    endforeach()
+endif()
 
-foreach(PACKAGE_SQL_FILE ${LIST_PACKAGE_SQL_FILES})
-    cat(${PACKAGE_SQL_FILE} "${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql.in")
+ADD_CUSTOM_TARGET(ProcessSQLFiles ALL)
+foreach(file_in ${PACKAGE_SQL_FILES})
+    get_filename_component(file_name ${file_in} NAME)
+    set(file_out "${CMAKE_BINARY_DIR}/sql_queries/${file_name}")
+    configure_file(${file_in} ${file_out})
+
+    add_dependencies(ProcessSQLFiles ${file_in})
+    file(READ "${file_out}" CONTENTS)
+    string(REGEX REPLACE "/\\*PGR-(GNU|MIT).*PGR-(GNU|MIT)\\*/" "" STRIP_CONTENTS "${CONTENTS}")
+    string(REGEX REPLACE "/\\*/*FOR.*FOR-USER\\*/" "" CONTENTS "${STRIP_CONTENTS}")
+    file(APPEND ${TEMP_LIB_FILENAME} "${CONTENTS}")
 endforeach()
 
-# copy our temporary file into a final file
-# this extra set will allow us to place variables in the sql file
-# that will get substituted in this step before they are installed
-configure_file("${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql.in"
-    "${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql")
+configure_file("${TEMP_LIB_FILENAME}"
+    "${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql"
+    )
+message(STATUS "Created ${CMAKE_BINARY_DIR}/lib/pgrouting--${PGROUTING_VERSION_STRING}.sql")
+#
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
 
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+# Handling pgrouting.control.in files
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#
 configure_file("${PGROUTING_SOURCE_DIR}/src/common/sql/pgrouting.control.in"
     "${CMAKE_BINARY_DIR}/lib/pgrouting.control")
 
+message(STATUS "Created ${CMAKE_BINARY_DIR}/lib/pgrouting.control")
+#
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+
 # create the signature file for this release
 message(STATUS "Creating lib/pgrouting--${PGROUTING_VERSION_STRING}.sig")
 execute_process(
diff --git a/NEWS b/NEWS
index eab0552..daad8dd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,42 @@
-hanges for 2.2.4
+
+Changes for 2.3.0
+-------------------------------------------------------------------------------
+
+- New Signatures:
+
+  * pgr_TSP
+  * pgr_aStar
+
+* New Functions:
+
+  * pgr_eucledianTSP
+
+* New Proposed functions
+
+  * pgr_dijkstraCostMatrix
+  * pgr_withPointsCostMatrix
+  * pgr_maxFlowPushRelabel
+  * pgr_maxFlowEdmondsKarp
+  * pgr_maxFlowBoykovKolmogorov
+  * pgr_maximumCardinalityMatching
+  * pgr_edgeDisjointPaths
+  * pgr_contractGraph
+
+
+* Deprecated Signatures
+
+  * pgr_tsp - use pgr_TSP or pgr_eucledianTSP instead
+  * pgr_astar - use pgr_aStar instead
+
+
+* Deprecated functions
+
+  * pgr_flip_edges
+  * pgr_vidsToDmatrix
+  * pgr_pointsToDMatrix
+  * pgr_textToPoints
+
+Changes for 2.2.4
 -------------------------------------------------------------------------------
 
 - Bogus uses of extern "C"
@@ -12,7 +50,6 @@ Changes for 2.2.3
 
 - Fixed  compatibility issues with PostgreSQL 9.6.
 
-
 Changes for 2.2.2
 -------------------------------------------------------------------------------
 
@@ -27,31 +64,31 @@ Changes for 2.2.1
 Changes for 2.2.0
 -------------------------------------------------------------------------------
 
-  - Improved:
-    - pgr_nodeNetwork
-      - Adding a row_where and outall optional parameters
+- Improved:
+  - pgr_nodeNetwork
+    - Adding a row_where and outall optional parameters
 
-  - Signature fix
-    - pgr_dijkstra  -- to match what was documented (the pgr_dijkstra from V2.0)
+- Signature fix
+  - pgr_dijkstra  -- to match what was documented (the pgr_dijkstra from V2.0)
 
-  - New functions
-    - pgr_floydWarshall
-    - pgr_Johnson
-    - pgr_DijkstraCost
+- New functions
+  - pgr_floydWarshall
+  - pgr_Johnson
+  - pgr_DijkstraCost
 
-  - New Proposed functions
-    - pgr_withPoints
-    - pgr_withPointsCost
-    - pgr_withPointsDD
-    - pgr_withPointsKSP
-    - pgr_dijkstraVia
+- New Proposed functions
+  - pgr_withPoints
+  - pgr_withPointsCost
+  - pgr_withPointsDD
+  - pgr_withPointsKSP
+  - pgr_dijkstraVia
 
 
-  - Deprecated functions:
-    - pgr_apspWarshall  use pgr_floydWarshall instead
-    - pgr_apspJohnson   use pgr_Johnson instead
-    - pgr_kDijkstraCost use pgr_dijkstraCost instead
-    - pgr_kDijkstraPath use pgr_dijkstra instead
+- Deprecated functions:
+  - pgr_apspWarshall  use pgr_floydWarshall instead
+  - pgr_apspJohnson   use pgr_Johnson instead
+  - pgr_kDijkstraCost use pgr_dijkstraCost instead
+  - pgr_kDijkstraPath use pgr_dijkstra instead
 
 
 
@@ -69,7 +106,7 @@ Changes for 2.1.0
    - allow any-integer in the id's
    - allow any-numerical on the cost/reverse_cost columns
 
- - Three Functions where completly re-factored using the developers library and functionality was added.
+ - Three Functions where completely re-factored using the developers library and functionality was added.
 
    - pgr_dijkstra
    - pgr_ksp
@@ -83,7 +120,7 @@ Changes for 2.1.0
    - The library has a the prefix 2-1-0
 
  - Added proposed functions to be evaluated:
-   - Proposed functions from Steve Woodbridge, (Classified as Convinience by the author.)
+   - Proposed functions from Steve Woodbridge, (Classified as Convenience by the author.)
       - pgr_pointToEdgeNode - convert a point geometry to a vertex_id based on closest edge.
       - pgr_flipEdges - flip the edges in an array of geometries so the connect end to end.
       - pgr_textToPoints - convert a string of x,y;x,y;... locations into point geometries.
diff --git a/README.md b/README.md
index 3e2734c..c5f94ec 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,11 @@
 
 ### Branches
 
-The *master* branch reflects the current 2.2.4 release.
-The *develop* branch reflects the 2.3.0-dev
+* The *master* branch has the latest minor release. (2.3.0)
+* The *develop* branch has the next minor release. (2.4.0)
 
+For the complete list of releases go to:
+https://github.com/pgRouting/pgrouting/releases
 
 
 ## LINKS
@@ -20,26 +22,43 @@ The *develop* branch reflects the 2.3.0-dev
 <table>
 	<tr>
 		<td>Branch</td>
-		<td>Status</td>
-		<td>Comment</td>
+		<td>Travis</td>
+		<td>Appveyor</td>
+		<td>Jenkins</td>
+		<td>Comments</td>
 	</tr>
 	<tr>
 		<td>master</td>
 		<td><img src="https://travis-ci.org/pgRouting/pgrouting.png?branch=master" alt="Build Status"/></td>
+		<td><img src="https://ci.appveyor.com/api/projects/status/github/pgRouting/pgrouting?branch=master&svg=true" alt="Appveyor Status"/></td>
+        <td><img src="http://winnie.postgis.net:1500/buildStatus/icon?job=pgRouting_matrix_master" alt="Jenkins Status"/></td>
+		<td></td>
 	</tr>
 	<tr>
 		<td>develop</td>
 		<td><img src="https://travis-ci.org/pgRouting/pgrouting.png?branch=develop" alt="Build Status"/></td>
+		<td><img src="https://ci.appveyor.com/api/projects/status/github/pgRouting/pgrouting?branch=develop&svg=true" alt="Appveyor Status"/></td>
+        <td><img src="http://winnie.postgis.net:1500/buildStatus/icon?job=pgRouting_matrix_branch_develop" alt="Jenkins Status"/></td>
 		<td></td>
 	</tr>
 
 	<tr>
 		<td>gh-pages</td>
 		<td><img src="https://travis-ci.org/pgRouting/pgrouting.png?branch=gh-pages" alt="Build Status"/></td>
+		<td></td>
+		<td></td>
 		<td>not enabled</td>
 	</tr>
 </table>
 
+* travis: Postgis 2.2 for  Postgres 9.1, 9.2, 9.3, 9.4, 9.5
+  * precise
+* jenkins: g++ 4.8 on 32 & 64 bits for Postgis 2.3.0dev and Postgres 9.4, 9.5, 9.6
+* appveyor: vs1013 Postgis 2.2 Postgres 9.4
+
+
+
+
 ## INTRODUCTION
 
 pgRouting extends the PostGIS/PostgreSQL geospatial database to provide geospatial routing and other network analysis functionality.
@@ -58,7 +77,7 @@ This library contains following features:
 * Traveling Sales Person
 * Turn Restriction Shortest Path (TRSP)
 
-Additionaly, ready for testing and to be part of 2.3 official version:
+Additionally, ready for testing and to be part of 2.3 official version:
 
 * Shortest Path Dijkstra With Points Family of functions
 * Shortest Path Dijkstra Cost With Points Family of functions
@@ -73,21 +92,23 @@ Family of functions include:
 * many to one
 * many to many
 
-
 ## REQUIREMENTS
 
 * C and C++ compilers
+  * g++ >= 4.6
 * Postgresql version >= 9.1
 * PostGIS version >= 2.0
 * The Boost Graph Library (BGL).
   * Version >= 1.46
+* Version >= 1.55 for linux
+* Version >= 1.58 for MAC
 * CMake >= 2.8.8
 * CGAL >= 4.4
 * Sphinx >= 1.2
 
 ## INSTALLATION
 
-See online documentation: http://docs.pgrouting.org/latest/en/doc/src/installation/installation.html
+See online documentation: http://docs.pgrouting.org/
 
 ## COMPILATION
 
@@ -121,11 +142,13 @@ Postgresql 9.1+
 
 ## USAGE
 
-See online documentation: http://docs.pgrouting.org/latest/en/doc/index.html
-
+See online documentation: http://docs.pgrouting.org/2.3/en/doc/index.html
 
 ## LICENSE
 
 * Most features are available under GPLv2.
 * Some Boost extensions are available under Boost license (see LICENSE_1_0.txt)
 * Some code contributed by iMaptools.com is available under MIT-X license.
+
+
+
diff --git a/VERSION b/VERSION
index 0e4885d..38edf79 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-pgrouting-2.2.4-2524-3d5c321 master
+pgrouting-2.3.0-3977-8c86efd master
diff --git a/appveyor.yml b/appveyor.yml
index b4b1534..c0c4f6d 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -5,72 +5,56 @@
 # Main configuration
 # ------------------------------------------------------------------------------
 
-
-
-
-
-notifications:
-  email:
-    on_failure: vicky_vergara at hotmail.com
+version: 2.3.{build}
 
 branches:
   only:
     - master
     - develop
-    - dev-2.2
-
-    
-
-services:
-  - postgresql
-
-environment:
-  POSTGRESQL_VERSION: 9.4
 
-# excecuted. So things have to be tested oe by one.
-#addons:
-#  apt:
-#    sources:
-# For gcc >= 4.8
-# - ubuntu-toolchain-r-test
-# For cmake >= 2.8.8 (for CMakePackageConfigHelpers)
-#- kubuntu-backports
-#      - boost-latest
-#    packages:
-#- cmake
-#      - libboost-thread-dev
-#- libboost-graph-dev
-#- libcgal-dev
-#- postgresql-server-dev-all
-#- postgresql-common
+image: Visual Studio 2013
+configuration: Release
+platform: x64
 
+clone_depth: 1
+clone_folder: c:\build\pgrouting
 
-#- export PATH=/usr/lib/postgresql/$POSTGRESQL_VERSION/bin:$PATH # Add our chosen PG version to the path
-#- sudo /etc/init.d/postgresql stop                      # Stop whichever version of PG that travis started
-#- sudo apt-get install -y postgresql-9.5
-#- sudo apt-get install -y postgresql-9.5-postgis
-#- sudo /etc/init.d/postgresql stop                      # Stop whichever version of PG that travis started
-#- sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION # Start the version of PG that we want to test
-#before_script:
-    
-# - ./tools/travis/install_pgtap.sh $POSTGRESQL_VERSION   # pgtap has to be installed after postgres has started
-#- sudo apt-get install -y libtap-parser-sourcehandler-pgtap-perl
-#- createdb  ___pgr___test___
-#- createdb  pgr_test__db__test
-#- ./tools/travis/check-extensions.sh $POSTGRESQL_VERSION ___pgr___test___
+cache:
+  - downloads -> appveyor.yml
+  - c:\build\local\msvc120\x64 -> appveyor
 
+services:
+  - postgresql94
 
-#before_install:
-
-#before_script:
-
-#script: 
-
-#- ./tools/travis/pgrouting_build.sh $POSTGRESQL_VERSION $POSTGIS_VERSION
-#- ./tools/travis/pgrouting_test.sh $POSTGRESQL_VERSION
-
-#after_script: 
-
-#- ./tools/travis/pg_prove_tests.sh postgres
-
-#after_success:
+environment:
+  CONFIGURATION: Release
+  MSVC_VER: 12.0
+  BUILD_ROOT_DIR: c:\build
+
+init:
+  - git config --global core.autocrlf false
+
+install:
+  # Install pgRouting prerequisites:
+  # cmake
+  # postGIS
+  # CGAL
+  - call ci\appveyor\install.bat
+
+
+build_script:
+  - cd c:\build\pgrouting\ci\appveyor
+  - msbuild_pgrouting.bat 9.4 
+  - cd %PGROUTING_BUILD_DIR%
+  - msbuild PGROUTING.sln /target:Build /property:Configuration=%CONFIGURATION%
+  - msbuild INSTALL.vcxproj /target:Build /property:Configuration=%CONFIGURATION%
+  - copy c:\build\gmp\x64\lib\*.dll C:\Progra~1\PostgreSQL\9.4\bin\
+
+test_script:
+  - set PGUSER=postgres
+  - set PGPASSWORD=Password12!
+  - set PGHOME=C:\Progra~1\PostgreSQL\9.4
+  - set PGPORT=5432
+  - set PATH=%PATH%;%PGHOME%\bin
+  # Execute algorithm test by Cygwin
+  - C:\cygwin\bin\bash -lc "cd /cygdrive/c/build/pgrouting && tools/testers/algorithm-tester.pl -psql \"/cygdrive/c/Progra~1/PostgreSQL/9.4/bin/psql\""
diff --git a/ci/appveyor/install-CGAL.bat b/ci/appveyor/install-CGAL.bat
new file mode 100644
index 0000000..b3e45a0
--- /dev/null
+++ b/ci/appveyor/install-CGAL.bat
@@ -0,0 +1,211 @@
+ at echo off
+
+Setlocal EnableDelayedExpansion EnableExtensions
+
+if defined CGAL_LOCAL_DEBUG echo APPVEYOR_BUILD_FOLDER %APPVEYOR_BUILD_FOLDER%
+
+:: =========================================================
+:: Set some defaults. Infer some variables.
+::
+
+if not defined BUILD_ROOT_DIR goto _error
+if not defined COMMON_INSTALL_DIR goto _error
+if not defined PLATFORM goto _error
+if not defined DOWNLOADS_DIR goto _error
+if not defined CGAL_VERSION goto _error
+if not defined RUNTIME goto _error
+if not defined CMAKE_GENERATOR goto _error
+if not defined BOOST_INCLUDE_DIR goto _error
+if not defined BOOST_LIBRARY_DIR goto _error
+
+if defined CGAL_LOCAL_DEBUG (
+    echo BUILD_ROOT_DIR %BUILD_ROOT_DIR%
+    echo COMMON_INSTALL_DIR %COMMON_INSTALL_DIR%
+    echo PLATFORM %PLATFORM%
+    echo DOWNLOADS_DIR %DOWNLOADS_DIR%
+    echo CGAL_VERSION %CGAL_VERSION%
+    echo RUNTIME %RUNTIME%
+    echo CMAKE_GENERATOR %CMAKE_GENERATOR%
+    echo BOOST_INCLUDE_DIR %BOOST_INCLUDE_DIR%
+    echo BOOST_LIBRARY_DIR %BOOST_LIBRARY_DIR%
+)
+
+set MSBUILD_CONFIGURATION=RelWithDebInfo
+
+::
+:: =========================================================
+
+:: create a download directory:
+mkdir %DOWNLOADS_DIR% 2>NUL
+mkdir %COMMON_INSTALL_DIR% 2>NUL
+
+if defined CGAL_LOCAL_DEBUG dir %DOWNLOADS_DIR%
+if defined CGAL_LOCAL_DEBUG dir %COMMON_INSTALL_DIR%
+
+
+if not defined GMP_SRC_DIR set GMP_SRC_DIR=%BUILD_ROOT_DIR%\gmp\%PLATFORM%
+pushd %BUILD_ROOT_DIR%
+mkdir gmp\%PLATFORM% 2>NUL
+popd
+if defined CGAL_LOCAL_DEBUG (
+    echo GMP_SRC_DIR %GMP_SRC_DIR%
+    dir %GMP_SRC_DIR%
+)
+
+
+echo ----------------------------------- GMP
+if not exist %GMP_SRC_DIR%\gmp.COPYING (
+    if not exist %DOWNLOADS_DIR%\gmp-all-CGAL-3.9.zip (
+        echo Downloading gmp-all-CGAL-3.9.zip
+        pushd %DOWNLOADS_DIR%
+        curl -L -O -S -s http://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/%PLATFORM%/GMP/5.0.1/gmp-all-CGAL-3.9.zip
+        if not exist %DOWNLOADS_DIR%\gmp-all-CGAL-3.9.zip (
+            echo Something went wrong Downloading gmp-all-CGAL-3.9.zip
+        )
+        popd
+    )
+
+    echo Extracting gmp-all-CGAL-3.9.zip
+    pushd %DOWNLOADS_DIR%
+    7z x -o%GMP_SRC_DIR% gmp-all-CGAL-3.9.zip
+    popd
+) else (
+    echo GMP already installed at %GMP_SRC_DIR%
+)
+set GMP_LIBRARIES=%GMP_SRC_DIR%\lib\libgmp-10.lib
+set GMP_INCLUDE_DIR=%GMP_SRC_DIR%\include
+if defined CGAL_LOCAL_DEBUG (
+    echo GMP_LIBRARIES %GMP_LIBRARIES%
+    dir %GMP_SRC_DIR%
+)
+echo -----------------------------------
+
+echo ----------------------------------- MPFR
+if not exist %GMP_SRC_DIR%\mpfr.COPYING (
+    if not exist %DOWNLOADS_DIR%\mpfr-all-CGAL-3.9.zip (
+        echo Downloading mpfr-all-CGAL-3.9.zip
+        pushd %DOWNLOADS_DIR%
+        curl -L -O -S -s http://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/%PLATFORM%/MPFR/3.0.0/mpfr-all-CGAL-3.9.zip
+        if not exist %DOWNLOADS_DIR%\mpfr-all-CGAL-3.9.zip (
+            echo Something went wrong Downloading mpfr-all-CGAL-3.9.zip
+        )
+        popd
+    )
+    echo Extracting mpfr-all-CGAL-3.9.zip
+    pushd %DOWNLOADS_DIR%
+    7z x -o%GMP_SRC_DIR% mpfr-all-CGAL-3.9.zip
+    popd
+) else (
+    echo MPFR already installed at %GMP_SRC_DIR%
+)
+set MPFR_LIBRARIES=%GMP_SRC_DIR%\lib\libmpfr-4.lib
+
+if defined CGAL_LOCAL_DEBUG (
+    dir %GMP_SRC_DIR%
+)
+echo -----------------------------------
+
+echo ==================================== CGAL
+
+if exist %COMMON_INSTALL_DIR%/include/CGAL (
+    echo CGAL already installed
+    goto _ExitCGAL
+)
+
+if not exist %BUILD_ROOT_DIR%\CGAL-%CGAL_VERSION%\ (
+    if not exist %DOWNLOADS_DIR%\CGAL-%CGAL_VERSION%.zip (
+        echo Downloading CGAL-%CGAL_VERSION%.zip
+        pushd %DOWNLOADS_DIR%
+        curl -L -O -S -s http://github.com/CGAL/cgal/releases/download/releases/CGAL-%CGAL_VERSION%/CGAL-%CGAL_VERSION%.zip
+        if not exist %DOWNLOADS_DIR%\CGAL-%CGAL_VERSION%.zip (
+            echo Something went wrong Downoading CGAL-%CGAL_VERSION%.zip
+        )
+        popd
+    )
+    echo Extracting CGAL-%CGAL_VERSION%.zip
+    pushd %DOWNLOADS_DIR%
+    7z x -o%BUILD_ROOT_DIR% CGAL-%CGAL_VERSION%.zip
+    popd
+)
+
+set CGAL_SRC_DIR=%BUILD_ROOT_DIR%\CGAL-%CGAL_VERSION%
+set CGAL_BUILD_DIR=%CGAL_SRC_DIR%\build\%RUNTIME%\%PLATFORM%
+
+if defined CGAL_LOCAL_DEBUG (
+    echo CGAL_SRC_DIR %CGAL_SRC_DIR%
+    dir %CGAL_SRC_DIR%
+
+    echo CGAL_BUILD_DIR %CGAL_BUILD_DIR%
+)
+
+
+
+set PROJ_EXT=vcxproj
+echo PROJ_EXT %PROJ_EXT%
+
+mkdir %CGAL_BUILD_DIR% %2>null
+pushd %CGAL_BUILD_DIR%
+cmake -G "%CMAKE_GENERATOR%" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=%COMMON_INSTALL_DIR% ^
+    -DBoost_USE_MULTITHREADED=ON ^
+    -DCGAL_Boost_USE_STATIC_LIBS=ON -DBoost_USE_STATIC_RUNTIME=OFF ^
+    -DBoost_INCLUDE_DIR:PATH=%BOOST_INCLUDE_DIR% ^
+    -DBOOST_LIBRARYDIR=%BOOST_LIBRARY_DIR% ^
+    -DGMP_INCLUDE_DIR=%GMP_SRC_DIR%\include ^
+    -DMPFR_INCLUDE_DIR=%GMP_SRC_DIR%\include ^
+    -DGMP_LIBRARIES=%GMP_LIBRARIES% ^
+    -DMPFR_LIBRARIES=%MPFR_LIBRARIES%  ..\..\..\
+msbuild CGAL.sln /target:Build /property:Configuration=%MSBUILD_CONFIGURATION%
+msbuild INSTALL.%PROJ_EXT% /target:Build /property:Configuration=%MSBUILD_CONFIGURATION%
+popd
+
+if defined CGAL_LOCAL_DEBUG (
+    echo DOWNLOADS_DIR %DOWNLOADS_DIR%
+    dir %DOWNLOADS%
+
+    echo BUILD_ROOT_DIR %BUILD_ROOT_DIR%
+    dir %BUILD_ROOT_DIR%
+
+    echo GMP_SRC_DIR %GMP_SRC_DIR%
+    dir %GMP_SRC_DIR%
+    
+    dir C:/build/local/msvc120/x64/include/CGAL
+)
+:_ExitCGAL
+echo --------------------------------
+set CGAL_LIBRARIES=%COMMON_INSTALL_DIR%\lib\libCGAL-vc%MSVC_VER:.=%-mt-%CGAL_VERSION%.lib&
+set CGAL_INCLUDE_DIR=%COMMON_INSTALL_DIR%\include
+echo Installation of CGAL done.
+echo Environment variables set:
+
+echo GMP_LIBRARIES %GMP_LIBRARIES%
+echo MPFR_LIBRARIES %MPFR_LIBRARIES%
+echo CGAL_LIBRARIES %CGAL_LIBRARIES%
+echo CGAL_INCLUDE_DIR %CGAL_INCLUDE_DIR%
+echo GMP_INCLUDE_DIR %GMP_INCLUDE_DIR%
+
+echo ======================================================
+
+endlocal & (
+    set GMP_LIBRARIES=%GMP_LIBRARIES%
+    set MPFR_LIBRARIES=%MPFR_LIBRARIES%
+    set CGAL_LIBRARIES=%CGAL_LIBRARIES%
+    set CGAL_INCLUDE_DIR=%CGAL_INCLUDE_DIR%
+    set GMP_INCLUDE_DIR=%GMP_INCLUDE_DIR%
+)
+
+goto :eof
+
+:_error
+echo an environment variable is missing:
+echo BUILD_ROOT_DIR %BUILD_ROOT_DIR%
+echo COMMON_INSTALL_DIR %COMMON_INSTALL_DIR%
+echo PLATFORM %PLATFORM%
+echo DOWNLOADS_DIR %DOWNLOADS_DIR%
+echo CGAL_VERSION %CGAL_VERSION%
+echo RUNTIME %RUNTIME%
+echo CMAKE_GENERATOR %CMAKE_GENERATOR%
+echo BOOST_INCLUDE_DIR %BOOST_INCLUDE_DIR%
+echo BOOST_LIBRARY_DIR %BOOST_LIBRARY_DIR%
+echo MSBUILD_CONFIGURATION %MSBUILD_CONFIGURATION%
+
+
diff --git a/ci/appveyor/install-boost.bat b/ci/appveyor/install-boost.bat
new file mode 100644
index 0000000..cdfae85
--- /dev/null
+++ b/ci/appveyor/install-boost.bat
@@ -0,0 +1,149 @@
+ at echo off
+
+
+Setlocal EnableDelayedExpansion EnableExtensions
+
+
+if not defined BOOST_VERSION goto _error
+if not defined COMMON_INSTALL_DIR goto _error
+if not defined MSVC_VER goto _error
+if not defined ARCH goto _error
+if not defined BUILD_ROOT_DIR goto _error
+if not defined CONFIGURATION goto _error
+    
+if defined BOOST_LOCAL_DEBUG (
+    echo "install-boost.bat"
+    echo received environment
+    echo BOOST_VERSION %BOOST_VERSION%
+    echo COMMON_INSTALL_DIR %COMMON_INSTALL_DIR%
+    echo MSVC_VER %MSVC_VER%
+    echo ARCH %ARCH%
+    echo BUILD_ROOT_DIR %BUILD_ROOT_DIR%
+    echo CONFIGURATION %CONFIGURATION%
+)
+:: create a download & install directories:
+mkdir %APPVEYOR_BUILD_FOLDER%\downloads 2>NUL
+mkdir %COMMON_INSTALL_DIR% 2>NUL
+if defined BOOST_LOCAL_DEBUG dir %DOWNLOADS_DIR%
+if defined BOOST_LOCAL_DEBUG dir %COMMON_INSTALL_DIR%
+
+echo ==================================== BOOST
+
+
+:: deducing variables
+set BOOST_VER_USC=%BOOST_VERSION:.=_%
+set BOOST_SHORT_VER=%BOOST_VER_USC:_0=%
+
+set BOOST_INSTALL_DIR=%COMMON_INSTALL_DIR%
+set BOOST_INCLUDE_DIR=%BOOST_INSTALL_DIR%\include\boost-%BOOST_SHORT_VER%
+set BOOST_LIBRARY_DIR=%BOOST_INSTALL_DIR%\lib
+set BOOST_THREAD_LIB=%BOOST_INSTALL_DIR%\lib\libboost_thread-vc%MSVC_VER:.=%-mt-%BOOST_SHORT_VER%.lib
+set BOOST_SYSTEM_LIB=%BOOST_INSTALL_DIR%\lib\libboost_system-vc%MSVC_VER:.=%-mt-%BOOST_SHORT_VER%.lib
+set BOOST_ADDRESS_MODEL=%ARCH%
+set BOOST_TOOLSET=msvc-%MSVC_VER%
+set BOOST_SRC_DIR=%BUILD_ROOT_DIR%\boost_%BOOST_VER_USC%
+set MSBUILD_CONFIGURATION=%CONFIGURATION%
+
+if defined BOOST_LOCAL_DEBUG (
+    echo BOOST_VERSION %BOOST_VERSION%
+    echo BOOST_VER_USC %BOOST_VER_USC%
+    echo BOOST_SHORT_VER %BOOST_SHORT_VER%
+    echo BOOST_INSTALL_DIR %BOOST_INSTALL_DIR%
+    echo BOOST_INCLUDE_DIR %BOOST_INCLUDE_DIR%
+    echo BOOST_LIBRARY_DIR %BOOST_LIBRARY_DIR%
+    echo BOOST_THREAD_LIB %BOOST_THREAD_LIB%
+    echo BOOST_SYSTEM_LIB %BOOST_SYSTEM_LIB%
+    echo BOOST_ADDRESS_MODEL %BOOST_ADDRESS_MODEL%
+    echo BOOST_TOOLSET %BOOST_TOOLSET%
+)
+
+:: check that everything needed from boost is there
+set BOOST_INSTALL_FLAG=10
+if not exist %BOOST_INCLUDE_DIR%\ ( set BOOST_INSTALL_FLAG=1 )
+if not exist %BOOST_LIBRARY_DIR%\ ( set BOOST_INSTALL_FLAG=2 )
+if not exist %BOOST_THREAD_LIB% ( set BOOST_INSTALL_FLAG=3 )
+if not exist %BOOST_SYSTEM_LIB% ( set BOOST_INSTALL_FLAG=4 )
+
+
+if defined BOOST_LOCAL_DEBUG echo BOOST_INSTALL_FLAG %BOOST_INSTALL_FLAG%
+
+
+if not "%BOOST_INSTALL_FLAG%"=="10" (
+
+    :: download if needed
+    if not exist %DOWNLOADS_DIR%\boost_%BOOST_VER_USC%.zip (
+        echo ***** Downloading Boost %BOOST_VERSION% ...
+        pushd %DOWNLOADS_DIR%
+        curl -L -O -S -s http://downloads.sourceforge.net/project/boost/boost/%BOOST_VERSION%/boost_%BOOST_VER_USC%.zip
+        popd
+        if not exist %DOWNLOADS_DIR%\boost_%BOOST_VER_USC%.zip (
+            echo something went wrong on boost %BOOST_VERSION% download !!!!!!!!!
+            if defined BOOST_LOCAL_DEBUG dir %DOWNLOADS_DIR%
+            Exit \B 1
+        )
+    ) else (
+        echo **** Boost_%BOOST_VER_USC%  already downloaded
+    )
+
+    echo **** Extracting Boost_%BOOST_VERSION%.zip ...
+    pushd %DOWNLOADS_DIR%
+    7z x -o%BUILD_ROOT_DIR%\ boost_%BOOST_VER_USC%.zip
+    popd
+    if not exist %BOOST_SRC_DIR% (
+        echo something went wrong on boost extraction!!!!!!!!!
+        if defined BOOST_LOCAL_DEBUG dir %BOOST_SRC_DIR%
+        Exit \B 1
+    )
+
+    echo **** Executing bootstrap.bat...
+    if not exist "%BOOST_SRC_DIR%\b2.exe" (
+        pushd %BOOST_SRC_DIR%
+        call "bootstrap.bat"
+        popd
+        if not exist "%BOOST_SRC_DIR%\b2.exe" (
+            echo something went wrong on booststrap.bat execution!!!!!!!!!
+            if defined BOOST_LOCAL_DEBUG dir %BOOST_SRC_DIR%
+            Exit \B 1
+        )
+    )
+
+    echo **** Executing  %BOOST_SRC_DIR%\b2.exe ...
+    pushd %BOOST_SRC_DIR%
+    if defined BOOST_LOCAL_DEBUG @echo on
+    b2 toolset=%BOOST_TOOLSET% variant=release link=static threading=multi address-model=%BOOST_ADDRESS_MODEL% ^
+        --with-thread --with-system --prefix=%BOOST_INSTALL_DIR% -d0 install
+    if defined BOOST_LOCAL_DEBUG @echo off
+    popd
+) else (
+    echo Boost_%BOOST_VERSION% already installed
+)
+
+echo ------------------------------
+echo Environment variables set:
+
+echo BOOST_INCLUDE_DIR %BOOST_INCLUDE_DIR%
+echo BOOST_LIBRARY_DIR %BOOST_LIBRARY_DIR%
+echo BOOST_THREAD_LIB %BOOST_THREAD_LIB%
+echo BOOST_SYSTEM_LIB %BOOST_SYSTEM_LIB%
+echo ======================================================
+
+
+endlocal & (
+    set BOOST_INCLUDE_DIR=%BOOST_INCLUDE_DIR%
+    set BOOST_LIBRARY_DIR=%BOOST_LIBRARY_DIR%
+    set BOOST_THREAD_LIB=%BOOST_THREAD_LIB%
+    set BOOST_SYSTEM_LIB=%BOOST_SYSTEM_LIB%
+)
+
+goto :eof
+
+:_error
+echo an environment variable is missing:
+echo --  BOOST_VERSION
+echo --  COMMON_INSTALL_DIR
+echo --  MSVC_VER
+echo --  ARCH
+echo --  BUILD_ROOT_DIR
+echo --  CONFIGURATION
+echo --  BOOST_LOCAL_DEBUG  (if defined will print debug information)
+
diff --git a/ci/appveyor/install.bat b/ci/appveyor/install.bat
new file mode 100644
index 0000000..aa83bdd
--- /dev/null
+++ b/ci/appveyor/install.bat
@@ -0,0 +1,176 @@
+ at echo off
+
+::set LOCAL_DEBUG=1
+
+Setlocal EnableDelayedExpansion EnableExtensions
+
+if defined LOCAL_DEBUG echo APPVEYOR_BUILD_FOLDER %APPVEYOR_BUILD_FOLDER%
+echo platform %platform%
+
+:: =========================================================
+:: Set some defaults. Infer some variables.
+::
+
+if not defined MSVC_VER set MSVC_VER=12.0
+if not defined RUNTIME set RUNTIME=msvc%MSVC_VER:.=%
+if not defined MSVC_YEAR set MSVC_YEAR=2013
+if not defined BUILD_ROOT_DIR set BUILD_ROOT_DIR=c:\build
+if not defined DOWNLOADS_DIR set DOWNLOADS_DIR=%APPVEYOR_BUILD_FOLDER%\downloads
+if not defined COMMON_INSTALL_DIR set COMMON_INSTALL_DIR=%BUILD_ROOT_DIR%\local\%RUNTIME%\%PLATFORM%
+
+:: for cmake its the min version
+if not defined CMAKE_VERSION set CMAKE_VERSION=3.5.2
+if not defined PG_VERSION set PG_VERSION=2.2.2
+if not defined BOOST_VERSION set BOOST_VERSION=1.58.0
+if not defined CGAL_VERSION set CGAL_VERSION=4.8.1
+
+
+set CMAKE_GENERATOR=Visual Studio %MSVC_VER:.0=% %MSVC_YEAR%
+if "%platform%"=="x64" (
+    set CMAKE_GENERATOR=%CMAKE_GENERATOR% Win64
+)
+
+:: Determine if arch is 32/64 bits
+if /I "%platform%"=="x86" ( set arch=32) else ( set arch=64)
+
+::
+:: =========================================================
+
+:: create a download directory:
+pushd %APPVEYOR_BUILD_FOLDER%
+mkdir downloads 2>NUL
+popd
+mkdir %COMMON_INSTALL_DIR% 2>NUL
+if defined LOCAL_DEBUG dir %DOWNLOADS_DIR%
+if defined LOCAL_DEBUG dir %COMMON_INSTALL_DIR%
+
+
+:: =========================================================
+:: Download and install cmake
+::
+
+echo ==================================== CMAKE
+for /f "tokens=*  delims=" %%a in ('cmake --version') do (
+    set CURR_CMAKE=%%a& goto _ExitForLoop1
+)
+:_ExitForLoop1
+set CURR_CMAKE=%CURR_CMAKE:~14%
+
+if "%CURR_CMAKE%" GTR "%CMAKE_VERSION%" (
+    echo cmake %CMAKE_VERSION% already installed
+) else (
+    echo Downloading cmake %CMAKE_VERSION%
+    pushd %DOWNLOADS_DIR%
+    curl -L -O -S -s https://cmake.org/files/v3.5/cmake-%CMAKE_VERSION%-win32-%platform%.msi
+    popd
+
+    echo Installing cmake %CMAKE_VERSION%
+    pushd %DOWNLOADS_DIR%
+    start /wait msiexec /i cmake-%CMAKE_VERSION%-win32-%platform%.msi /qn
+    popd
+
+    for /f "tokens=*  delims=" %%a in ('cmake --version') do (
+        set CURR_CMAKE=%%a& goto _ExitForLoop2
+    )
+    :_ExitForLoop2
+    set CURR_CMAKE=%CURR_CMAKE:~14%
+    if "%CURR_CMAKE%" == "%CMAKE_VERSION%" (
+        echo cmake %CMAKE_VERSION% installed
+    ) else (
+        echo something went wrong on cmake installation!!!!!!!!!
+        Exit \B 1
+    )
+)
+echo ====================================
+
+::
+:: =========================================================
+
+
+
+:: =========================================================
+:: Download and install Postgis
+::
+
+echo ==================================== POSTGIS
+if not exist "C:\Progra~1\PostgreSQL\9.4\makepostgisdb_using_extensions.bat" (
+    cd %APPVEYOR_BUILD_FOLDER%
+    if not exist %DOWNLOADS_DIR%\postgis-pg94-binaries-%PG_VERSION%w%arch%gcc48.zip (
+        echo Downloading PostGIS %PG_VERSION%
+        pushd %DOWNLOADS_DIR%
+        curl -L -O -S -s http://winnie.postgis.net/download/windows/pg94/buildbot/postgis-pg94-binaries-%PG_VERSION%w%arch%gcc48.zip
+        popd
+        if not exist %DOWNLOADS_DIR%\postgis-pg94-binaries-%PG_VERSION%w%arch%gcc48.zip (
+            echo something went wrong on PostGIS %PG_VERSION% download !!!!!!!!!
+            if defined LOCAL_DEBUG dir %DOWNLOADS_DIR%
+            Exit \B 1
+        )
+    )
+
+    echo Extracting PostGIS %PG_VERSION%
+    pushd %DOWNLOADS_DIR%
+    7z x -o%BUILD_ROOT_DIR%\ postgis-pg94-binaries-%PG_VERSION%w%arch%gcc48.zip
+    popd
+
+    echo **** Installing postGIS %PG_VERSION%
+    xcopy /e /y /q %BUILD_ROOT_DIR%\postgis-pg94-binaries-%PG_VERSION%w%arch%gcc48 C:\Progra~1\PostgreSQL\9.4
+
+    if not exist "C:\Progra~1\PostgreSQL\9.4\makepostgisdb_using_extensions.bat" (
+        echo something went wrong on PostGIS %PG_VERSION% installation !!!!!!!!!
+        if defined LOCAL_DEBUG dir %DOWNLOADS_DIR%
+        if defined LOCAL_DEBUG dir C:\Progra~1\PostgreSQL\9.4\
+        Exit \B 1
+    ) else (
+        echo **** PostGIS %PG_VERSION% %arch% installed
+    )
+) else (
+    echo PostGIS %PG_VERSION% %arch% already installed
+)
+echo ====================================
+
+
+:: =========================================================
+:: Download and install Boost
+::
+
+:: set BOOST_LOCAL_DEBUG=1
+call ci/appveyor/install-boost.bat
+
+::
+:: CGAL & GMP & MPFR
+::
+::
+set CGAL_LOCAL_DEBUG=1
+call ci/appveyor/install-CGAL.bat
+
+
+echo ======================================================
+echo Installation of Prerequisites done.
+echo Environment variables set:
+
+echo BOOST_THREAD_LIB %BOOST_THREAD_LIB%
+echo BOOST_SYSTEM_LIB %BOOST_SYSTEM_LIB%
+echo BOOST_INCLUDE_DIR %BOOST_INCLUDE_DIR%
+echo GMP_LIBRARIES %GMP_LIBRARIES%
+echo MPFR_LIBRARIES %MPFR_LIBRARIES%
+echo CGAL_LIBRARIES %CGAL_LIBRARIES%
+echo CGAL_INCLUDE_DIR %CGAL_INCLUDE_DIR%
+echo GMP_INCLUDE_DIR %GMP_INCLUDE_DIR%
+echo CMAKE_GENERATOR %CMAKE_GENERATOR%
+
+echo ======================================================
+echo.
+
+endlocal & (
+    set BOOST_THREAD_LIB=%BOOST_THREAD_LIB%
+    set BOOST_SYSTEM_LIB=%BOOST_SYSTEM_LIB%
+    set BOOST_INCLUDE_DIR=%BOOST_INCLUDE_DIR%
+    set GMP_LIBRARIES=%GMP_LIBRARIES%
+    set MPFR_LIBRARIES=%MPFR_LIBRARIES%
+    set CGAL_LIBRARIES=%CGAL_LIBRARIES%
+    set CGAL_INCLUDE_DIR=%CGAL_INCLUDE_DIR%
+    set GMP_INCLUDE_DIR=%GMP_INCLUDE_DIR%
+    set CMAKE_GENERATOR=%CMAKE_GENERATOR%
+)
+
+goto :eof
diff --git a/ci/appveyor/msbuild_pgrouting.bat b/ci/appveyor/msbuild_pgrouting.bat
new file mode 100644
index 0000000..13ed787
--- /dev/null
+++ b/ci/appveyor/msbuild_pgrouting.bat
@@ -0,0 +1,55 @@
+ at echo off
+
+set PG_VER=%1
+
+echo MSVC_VER %MSVC_VER%
+echo BUILD_ROOT_DIR %BUILD_ROOT_DIR%
+echo CGAL_LIBRARIES %CGAL_LIBRARIES%
+echo GMP_LIBRARIES %GMP_LIBRARIES%
+echo MPFR_LIBRARIES %MPFR_LIBRARIES%
+echo CMAKE_GENERATOR %CMAKE_GENERATOR%
+echo BOOST_THREAD_LIB %BOOST_THREAD_LIB%
+echo BOOST_SYSTEM_LIB %BOOST_SYSTEM_LIB%
+echo BOOST_INCLUDE_DIR %BOOST_INCLUDE_DIR%
+echo PLATFORM %PLATFORM%
+echo GMP_INCLUDE_DIR %GMP_INCLUDE_DIR%
+echo CGAL_INCLUDE_DIR %CGAL_INCLUDE_DIR%
+echo PG_VER %PG_VER%
+echo PROGRAMFILES %PROGRAMFILES%
+
+set POSTGRESQL_DIR=%PROGRAMFILES%\PostgreSQL\%PG_VER%
+
+set PGROUTING_SRC_DIR=%~dp0..\..\
+echo PGROUTING_SRC_DIR %PGROUTING_SRC_DIR%
+
+path %PATH%;%PROGRAMFILES% (x86)\CMake\bin
+
+set PGROUTING_BUILD_DIR=%PGROUTING_SRC_DIR%build\pg%PG_VER:.=%\%PLATFORM%
+set PGROUTING_INSTALL_DIR=%PGROUTING_SRC_DIR%lib\pg%PG_VER:.=%\%PLATFORM%
+
+
+echo PGROUTING_BUILD_DIR %PGROUTING_BUILD_DIR%
+echo PGROUTING_INSTALL_DIR %PGROUTING_INSTALL_DIR%
+echo POSTGRESQL_DIR %POSTGRESQL_DIR%
+
+rem ### pgRouting ###
+
+if exist %PGROUTING_BUILD_DIR% (
+    rmdir /S /Q %PGROUTING_BUILD_DIR%
+)
+
+mkdir %PGROUTING_BUILD_DIR%
+pushd %PGROUTING_BUILD_DIR%
+ at echo on
+cmake -G "%CMAKE_GENERATOR%" -DPOSTGRESQL_INCLUDE_DIR:PATH="%POSTGRESQL_DIR%\include;%POSTGRESQL_DIR%\include\server;%POSTGRESQL_DIR%\include\server\port;%POSTGRESQL_DIR%\include\server\port\win32;%POSTGRESQL_DIR%\include\server\port\win32_msvc" ^
+    -DPOSTGRESQL_LIBRARIES:FILEPATH="%POSTGRESQL_DIR%\lib\postgres.lib" ^
+    -DPOSTGRESQL_EXECUTABLE:FILEPATH="%POSTGRESQL_DIR%\bin\postgres.exe" ^
+    -DPOSTGRESQL_PG_CONFIG:FILEPATH="%POSTGRESQL_DIR%\bin\pg_config.exe" ^
+    -DBoost_INCLUDE_DIR:PATH=%BOOST_INCLUDE_DIR% ^
+    -DBOOST_THREAD_LIBRARIES:FILEPATH="%BOOST_THREAD_LIB%;%BOOST_SYSTEM_LIB%" ^
+    -DCGAL_INCLUDE_DIR:PATH="%CGAL_INCLUDE_DIR%;%GMP_INCLUDE_DIR%" ^
+    -DCGAL_LIBRARIES:FILEPATH=%CGAL_LIBRARIES% ^
+    -DGMP_LIBRARIES:FILEPATH="%GMP_LIBRARIES%;%MPFR_LIBRARIES%"  ..\..\..\
+ at echo off
+popd
+
diff --git a/cmake/FindPostgreSQL.cmake b/cmake/FindPostgreSQL.cmake
index 9e48037..4180559 100644
--- a/cmake/FindPostgreSQL.cmake
+++ b/cmake/FindPostgreSQL.cmake
@@ -16,8 +16,7 @@
 
 # A check condition to see if those variables are set
 
-#POSTGRESQL_BIN ia an optional commandline argument to specify a non-standard path to the postgresql program executables
-SET(POSTGRESQL_BIN "" CACHE STRING "Some user-specified option")    
+SET(POSTGRESQL_BIN "" CACHE STRING "non-standard path to the postgresql program executables")    
 
 if(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES AND POSTGRESQL_EXECUTABLE AND POSTGRESQL_VERSION_STRING)
     set(POSTGRESQL_FOUND TRUE)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 4a8e6d5..031f160 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -6,12 +6,24 @@
 # Daniel Kastl 03/2013
 #
 
+option(WITH_DOC
+     "Set ON|OFF (default=OFF) to build Documentation library tree" OFF)
+
+option(BUILD_LATEX
+    "Set ON|OFF (default=OFF) to build Documentation library tree as PDF" OFF)
+
+option(BUILD_HTML
+    "Set ON|OFF (default=ON) to build Documentation library tree as HTML" ON)
+
+option(BUILD_MAN
+    "Set ON|OFF (default=ON) to build Documentation library tree as MAN page" OFF)
+
 set(SPHINX_THEME "haiku")
 #set(SPHINX_THEME_DIR "_themes")
 
 if(WITH_DOC)
 
-    find_package(Sphinx)
+    find_package(Sphinx "${SPHINX_MINIMUM_VERSION}")
 
     if (NOT SPHINX_FOUND)
         message(WARNING "Sphinx not found. Cannot generate documentation!")
@@ -45,10 +57,6 @@ if(WITH_DOC)
         file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/CNAME" DESTINATION "${PGROUTING_BINARY_DIR}")
 
         configure_file(
-            "${CMAKE_CURRENT_SOURCE_DIR}/index.html.in"
-            "${PGROUTING_BINARY_DIR}/doc/html/index.html")
-
-        configure_file(
             "${CMAKE_CURRENT_SOURCE_DIR}/forward.html"
             "${PGROUTING_BINARY_DIR}/doc/html/en/index.html")
 
diff --git a/doc/conf.py.in b/doc/conf.py.in
index 32608af..9f5da17 100644
--- a/doc/conf.py.in
+++ b/doc/conf.py.in
@@ -26,7 +26,7 @@ needs_sphinx = '1.1'
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 mathjax_path="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
-extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
+extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.graphviz']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['doc/templates']
@@ -42,7 +42,7 @@ master_doc = 'doc/index'
 
 # General information about the project.
 project = u'pgRouting'
-copyright = u'pgRouting Contributors - Version @PGROUTING_VERSION_STRING@ (@PGROUTING_GIT_TAG@)'
+copyright = u'pgRouting Contributors - Version @PGROUTING_VERSION_STRING@'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -51,8 +51,8 @@ copyright = u'pgRouting Contributors - Version @PGROUTING_VERSION_STRING@ (@PGRO
 # The short X.Y version.
 version = '@PGROUTING_VERSION_STRING@'
 # The full version, including alpha/beta/rc tags.
-#release = '@PGROUTING_VERSION_STRING@ (@PGROUTING_GIT_BRANCH@)'
-release = '@PGROUTING_VERSION_STRING@ (@PGROUTING_GIT_TAG@)'
+release = '@PGROUTING_VERSION_STRING@ (@PGROUTING_GIT_BRANCH@)'
+#release = '@PGROUTING_VERSION_STRING@ (@PGROUTING_GIT_TAG@)'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -72,7 +72,6 @@ exclude_patterns = [
     'doc/build',
     'src/shooting_star/doc/index.rst',
     'src/withPoints/doc/pgr_withPointsVia.rst',
-    'src/pickDeliver/*',
     'src/travelingSalesPerson',
     '*/notUsed',
     'tools/template'
@@ -115,8 +114,11 @@ html_theme_path = ['@SPHINX_THEME_DIR@']
 
 # The name for this set of Sphinx documents.  If None, it defaults to
 # "<project> v<release> documentation".
+
+#html_title = "pgRouting Manual (@PGROUTING_VERSION_STRING@) (@PGROUTING_GIT_BRANCH@)"
 html_title = "pgRouting Manual (@PGROUTING_VERSION@)"
 
+
 # A shorter title for the navigation bar.  Default is the same as html_title.
 #html_short_title = None
 
diff --git a/doc/deprecated.rst b/doc/deprecated.rst
index 56c1511..27948fa 100644
--- a/doc/deprecated.rst
+++ b/doc/deprecated.rst
@@ -12,19 +12,53 @@
 Deprecated Functions
 ====================
 
-.. warning:: This functions have being deprecated
+.. warning:: These functions are deprecated!!!
 
+    * That means they have been replaced by new functions or are no longer supported, and may be removed from future versions.
+    * All code that uses the functions should be converted to use its replacement if one exists. 
 
 
-Deprecated Routing Functions
+Deprecated on version 2.3
 ----------------------------
 
+Routing functions
+...................
+
+- :ref:`pgr_astar-V2.0` - See new signatures of :ref:`pgr_aStar`
+- :ref:`pgr_tsp-V2.0` - See new signatures of :ref:`tsp`
+
+
+Auxiliary functions
+...................
+
+- :ref:`pgr_flip_edges`
+- :ref:`pgr_vids_to_dmatrix`
+- :ref:`pgr_vids_to_dmatrix2`
+- :ref:`pgr_points_to_dmatrix`
+- :ref:`pgr_text_to_points`
+
+
+.. toctree::
+   :hidden:
+
+   ../src/astar/doc/pgr_astar-v2
+   ../src/tsp/doc/pgr_tsp-V2.0
+   ../src/convenience/doc/pgr_flipEdges
+   ../src/convenience/doc/pgr_vidsToDMatrix
+   ../src/convenience/doc/pgr_vidsToDMatrix2
+   ../src/convenience/doc/pgr_pointsToDMatrix
+   ../src/convenience/doc/pgr_textToPoints
+
+
 Deprecated on version 2.2
+----------------------------
 
-  - :ref:`pgr_apspJohnson<pgr_apsp_johnson>` - Replaced with :ref:`pgr_johnson` 
-  - :ref:`pgr_apspWarshall<pgr_apsp_warshall>` - Replaced with :ref:`pgr_floydWarshall`
-  - :ref:`pgr_kDijkstra<pgr_kdijkstra>` - Replaced with :ref:`pgr_dijkstraCost`
-  - :ref:`pgr_drivingDistance<pgr_driving_distance_v2>` - Driving Distance (V2.0 signature). See new signature :ref:`pgr_drivingDistance`
+Routing functions
+...................
+
+- :ref:`pgr_apsp_johnson` - Replaced with :ref:`pgr_johnson` 
+- :ref:`pgr_apsp_warshall` - Replaced with :ref:`pgr_floydWarshall`
+- :ref:`pgr_kdijkstra` - Replaced with :ref:`pgr_dijkstraCost` and :ref:`pgr_dijkstra` (one to many)
 
 .. toctree::
    :hidden: 
@@ -32,38 +66,47 @@ Deprecated on version 2.2
    ../src/apsp_johnson/doc/pgr_apspJohnson
    ../src/apsp_warshall/doc/pgr_apspWarshall
    ../src/kdijkstra/doc/pgr_kDijkstra
-   ../src/driving_distance/doc/pgr_drivingDistance_v2
 
-Deprecated on version 2.1
 
- - :ref:`pgr_dijkstra<pgr_dijkstra_v2>` - Mutliple destination Shortest Path Dijkstra (V2.0 signature)
- - :ref:`pgr_ksp<pgr_ksp_v2>` - K shortest paths (V2.0 signature)
+Deprecated on version 2.1
+------------------------------------------
 
-.. toctree::
-   :hidden: 
+Routing functions
+...................
 
-   ../src/dijkstra/doc/pgr_dijkstra_v2
-   ../src/ksp/doc/pgr_ksp_v2
+- :ref:`pgr_dijkstra_v2` - See new signature in :ref:`pgr_dijkstra` (one to one)
+- :ref:`pgr_ksp_v2` - See new signature in :ref:`pgr_ksp`
+- :ref:`pgr_driving_distance_v2` - See new signature in :ref:`pgr_drivingDistance`
 
-Deprecated Developer's Auxiliary Functions
-------------------------------------------
 
+Auxiliary functions
+...................
 
-Deprecated on version 2.1
-
-  -  :ref:`pgr_get_column_name` - to get the name of the column as is stored in the postgres administration tables.
-  -  :ref:`pgr_get_table_name` - to retrieve the name of the table as is stored in the postgres administration tables.
-  -  :ref:`pgr_is_column_indexed` - to check if the column is indexed.
-  -  :ref:`pgr_is_column_in_table` - to check only for the existance of the column.
-  -  :ref:`pgr_quote_ident` - to quotes the input text to be used as an identifier in an SQL statement string.
-  -  :ref:`pgr_versionless` - to compare two version numbers.
-  -  :ref:`pgr_start_point` - to get the start point of a (multi)linestring.
-  -  :ref:`pgr_end_point` - to get the end point of a (multi)linestring.
+-  :ref:`pgr_get_column_name`
+-  :ref:`pgr_get_table_name`
+-  :ref:`pgr_is_column_indexed`
+-  :ref:`pgr_is_column_in_table`
+-  :ref:`pgr_quote_ident`
+-  :ref:`pgr_versionless`
+-  :ref:`pgr_start_point`
+-  :ref:`pgr_end_point`
 
 
 
 .. toctree::
    :hidden: 
 
-   ../src/common/doc/utilities/index
+   ../src/dijkstra/doc/pgr_dijkstra_v2
+   ../src/ksp/doc/pgr_ksp_v2
+   ../src/driving_distance/doc/pgr_drivingDistance_v2
+   ../src/common/doc/utilities/get_column_name
+   ../src/common/doc/utilities/get_table_name
+   ../src/common/doc/utilities/is_column_indexed
+   ../src/common/doc/utilities/is_column_in_table
+   ../src/common/doc/utilities/point_to_id
+   ../src/common/doc/utilities/quote_ident
+   ../src/common/doc/utilities/versionless
+   ../src/common/doc/utilities/start_point
+   ../src/common/doc/utilities/end_point
+
 
diff --git a/doc/i18n/pot/src/index.pot b/doc/i18n/pot/src/index.pot
index dee4f39..92063df 100644
--- a/doc/i18n/pot/src/index.pot
+++ b/doc/i18n/pot/src/index.pot
@@ -53,7 +53,7 @@ msgstr ""
 
 #: ../../../src/index.rst:21
 # 969c1456730541eab216fd6f9256a548
-msgid ":ref:`pgr_kDijkstra<pgr_kdijkstra>` - Mutliple destination Shortest Path Dijkstra"
+msgid ":ref:`pgr_kDijkstra<pgr_kdijkstra>` - Multiple destination Shortest Path Dijkstra"
 msgstr ""
 
 #: ../../../src/index.rst:22
diff --git a/doc/index.html.in b/doc/index.html.in
deleted file mode 100644
index 4ff3b79..0000000
--- a/doc/index.html.in
+++ /dev/null
@@ -1,84 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    
-    <title>Documentation — pgRouting</title>
-    
-    <link rel="stylesheet" href="dev/_static/haiku.css" type="text/css" />
-    <link rel="stylesheet" href="dev/_static/pygments.css" type="text/css" />
-    <link rel="stylesheet" href="dev/_static/print.css" type="text/css" />
-    
-    <script type="text/javascript" src="dev/_static/jquery.js"></script>
-    <script type="text/javascript" src="dev/_static/underscore.js"></script>
-    <script type="text/javascript" src="dev/_static/doctools.js"></script>
-    <script type="text/javascript" src="dev/_static/theme_extras.js"></script>
-    <link rel="shortcut icon" href="dev/_static/favicon.ico"/>
-  </head>
-  <body>
-    <div class="header"><img class="rightlogo" src="dev/_static/pgrouting.png" alt="Logo"/><h1 class="heading"><a href="./index.html">
-          <span>pgRouting</span></a></h1>
-        <h2 class="heading"><span>Documentation</span></h2>
-      </div>
-      <div class="topnav"><p><a class="uplink" href="#"></a></p></div>
-      <div class="content">
-
-        <div class="section">
-          <h2>Stable Release Documentation<a class="headerlink" title="Permalink to this headline">¶</a></h2>
-          <p>This documentation is for the released versions and will contain corrections and errata as they are available.</p>
-          <div class="toctree-wrapper compound">
-            <ul>
-              <li class="toctree-l1">
-                <b>pgRouting 2.0</b>
-                <ul>
-                  <li><a class="reference internal" href="2.0/en/doc/index.html">English</a> [ <a class="reference internal" href="2.0/en/pgRoutingDocumentation.pdf">PDF</a> | <a class="reference internal" href="2.0/en/pgrouting.7.gz">MAN</a> | Transifex ]</li>
-                  <li><a class="reference internal" href="2.0/fr/doc/index.html">French</a> [ <a class="reference internal" href="2.0/fr/pgRoutingDocumentation.pdf">PDF</a> | MAN | <a href="https://www.transifex.com/projects/p/pgrouting/language/fr/">Transifex</a> ]</li>
-                  <li><a class="reference internal" href="2.0/es/doc/index.html">Spanish</a> [ <a class="reference internal" href="/2.0/es/pgRoutingDocumentation.pdf">PDF</a> | MAN | <a href="https://www.transifex.com/projects/p/pgrouting/language/es/">Transifex</a> ]</li>
-                  <li><a class="reference internal" href="2.0/ja/doc/index.html">Japanese</a> [ <a class="reference internal" href="/2.0/ja/pgRoutingDocumentation.pdf">PDF</a> | MAN | <a href="https://www.transifex.com/projects/p/pgrouting/language/ja/">Transifex</a> ]</li>
-                  <li><a class="reference internal" href="2.0/de/doc/index.html">German</a> [ <a class="reference internal" href="/2.0/ja/pgRoutingDocumentation.pdf">PDF</a> | MAN | <a href="https://www.transifex.com/projects/p/pgrouting/language/de/">Transifex</a> ]</li>
-                </ul>
-              </li>
-              <li class="toctree-l1"><a class="reference internal" href="http://pgrouting.org/docs/1.x/index.html">pgRouting 1.0</a></li>
-            </ul>
-          </div>
-        </div>
-
-        <div class="section">
-          <h2>Betas and Release Candidates<a class="headerlink" title="Permalink to this headline">¶</a></h2>
-          <p>This documentation is for the alpha, beta and release candidate versions. Releases in this section are known to be unstable.</p>
-          <div class="toctree-wrapper compound">
-            <!--
-            <ul>
-                <li class="toctree-l1"><a class="reference internal" href="v2.0.0-rc1/doc/index.html">pgRouting v2.0.0-rc1</a> [<a class="reference external" href="v2.0.0-rc1/pgRoutingDocumentation.pdf">PDF</a> | <a class="reference external" href="v2.0.0-rc1/pgrouting.7.gz">MAN</a>]</li>
-            </ul>
-            <ul>
-                <li class="toctree-l1"><a class="reference internal" href="v2.0.0-beta/doc/index.html">pgRouting v2.0.0-beta</a> [PDF | MAN]</li>
-            </ul>
-            -->
-            <ul>
-                <li class="toctree-l1"><a class="reference internal" href="v2.1.0-alpha/doc/index.html">v2.1.0-alpha</a> [PDF | MAN]</li>
-                <li class="toctree-l1"><a class="reference internal" href="v2.1.0-beta/doc/index.html">v2.1.0-beta</a> [PDF | MAN]</li>
-            </ul>
-          </div> 
-        </div>
-
-        <div class="section">
-          <h2>In Development Documentation<a class="headerlink" title="Permalink to this headline">¶</a></h2>
-          <p>This documentation is for the unreleased version currently under development, and is frequently updated and changed.</p>
-          <div class="toctree-wrapper compound">
-            <ul>
-              <li class="toctree-l1"><a class="reference internal" href="dev/en/doc/index.html">develop ${PGROUTING_VERSION_REVISION_NAME}</a> [
-            </ul>
-          </div>
-        </div>
-
-      </div>
-      <div class="bottomnav"><p><a class="uplink" href="#"></a></p></div>
-
-    <div class="footer">
-        © Copyright <a href="http://www.pgrouting.org">pgRouting</a> Contributors.
-    </div>
-  </body>
-</html>
diff --git a/doc/index.rst b/doc/index.rst
index a3ea1e5..857aede 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -105,8 +105,9 @@ Data Types
    ../src/common/doc/types/index
 
 
+*******************************************************************************
 Topology functions
-===============================================================================
+*******************************************************************************
 
 :ref:`topology_functions`
 
@@ -121,30 +122,32 @@ Topology functions
 
    ../src/topology/doc/topology
 
+
+*******************************************************************************
+Routing Functions
+*******************************************************************************
+
 ..
     ROUTING FUNCTIONS SECTION
-
+    :hidden:
+    :maxdepth: 0
+    
 .. toctree::
-   :hidden:
-   :maxdepth: 0
-
-   ../src/routingFunctions
 
-Routing Functions
-=================
+    ../src/routingFunctions
 
 .. include:: ../src/routingFunctions.rst
    :start-after: from-here
    :end-before: to-here
-
+    
 
 
 *******************************************************************************
 Available Functions but not official pgRouting functions
 *******************************************************************************
 
-  - :ref:`proposedNext`
-  - :ref:`proposed`
+- :ref:`proposedNext`
+- :ref:`proposed`
 
 .. toctree::
     :hidden:
@@ -153,8 +156,6 @@ Available Functions but not official pgRouting functions
     ../src/proposed
 
 
-
-
 *******************************************************************************
 Discontinued & Deprecated Functions
 *******************************************************************************
@@ -177,19 +178,21 @@ Change Log
 
 :ref:`change_log`
 
+   - :ref:`changelog_2_3_0`
    - :ref:`changelog_2_2_4`
    - :ref:`changelog_2_2_3`
    - :ref:`changelog_2_2_2`
    - :ref:`changelog_2_2_1`
    - :ref:`changelog_2_2_0`
    - :ref:`changelog_2_1_0`
-   - :ref:`changelog_2_0`
+   - :ref:`changelog_2_0_1`
+   - :ref:`changelog_2_0_0`
    - :ref:`changelog_1_x`
 
 .. toctree::
     :hidden:
 
-    src/changelog/index
+    src/changelog/release_notes
 
 
 .. rubric:: Indices and tables
diff --git a/doc/src/changelog/1_x.rst b/doc/src/changelog/1_x.rst
deleted file mode 100644
index 387f1b1..0000000
--- a/doc/src/changelog/1_x.rst
+++ /dev/null
@@ -1,79 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share  
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_1_x:
-
-pgRouting 1.x Release Notes
-===============================================================================
-
-The following release notes have been copied from the previous ``RELEASE_NOTES`` file and are kept as a reference.
-Release notes starting with :ref:`version 2.0.0 <changelog_2_0>` will follow a different schema.
-
-
-Changes for release 1.05
--------------------------------------------------------------------------------
-
-* Bugfixes
-
-
-Changes for release 1.03
--------------------------------------------------------------------------------
-
-* Much faster topology creation
-* Bugfixes
-
-
-Changes for release 1.02
--------------------------------------------------------------------------------
-
-* Shooting* bugfixes
-* Compilation problems solved
-
-
-Changes for release 1.01
--------------------------------------------------------------------------------
-
-* Shooting* bugfixes
-
-
-Changes for release 1.0
--------------------------------------------------------------------------------
-
-* Core and extra functions are separated
-* Cmake build process
-* Bugfixes
-
-
-Changes for release 1.0.0b
--------------------------------------------------------------------------------
-
-* Additional SQL file with more simple names for wrapper functions
-* Bugfixes
-
-
-Changes for release 1.0.0a
--------------------------------------------------------------------------------
-
-* Shooting* shortest path algorithm for real road networks
-* Several SQL bugs were fixed
-
-
-Changes for release 0.9.9
--------------------------------------------------------------------------------
-
-* PostgreSQL 8.2 support
-* Shortest path functions return empty result if they couldn’t find any path
-
-
-Changes for release 0.9.8
--------------------------------------------------------------------------------
-
-* Renumbering scheme was added to shortest path functions
-* Directed shortest path functions were added
-* routing_postgis.sql was modified to use dijkstra in TSP search
diff --git a/doc/src/changelog/2_0.rst b/doc/src/changelog/2_0.rst
deleted file mode 100644
index 5ccc462..0000000
--- a/doc/src/changelog/2_0.rst
+++ /dev/null
@@ -1,52 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share  
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_2_0:
-
-pgRouting 2.0 Release Notes
-===============================================================================
-
-With the release of pgRouting 2.0 the library has abandoned backwards compatibility to :ref:`pgRouting 1.x <changelog_1_x>` releases. We did this so we could restructure pgRouting, standardize the function naming, and prepare the project for future development. As a result of this effort, we have been able to simplify pgRouting, add significant new functionality, integrate documentation and testing into the source tree and make it easier for multiple developers to make contribution.
-
-For important changes see the following release notes. To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
-
-
-..
-	Changes for 2.0.1
-	-------------------------------------------------------------------------------
-
-	* [TBD]
-
-
-Changes for 2.0.0
--------------------------------------------------------------------------------
-
-* Graph Analytics - tools for detecting and fixing connection some problems in a graph
-* A collection of useful utility functions
-* Two new All Pairs Short Path algorithms (pgr_apspJohnson, pgr_apspWarshall)
-* Bi-directional Dijkstra and A-star search algorithms (pgr_bdAstar, pgr_bdDijkstra)
-* One to many nodes search (pgr_kDijkstra)
-* K alternate paths shortest path (pgr_ksp)
-* New TSP solver that simplifies the code and the build process (pgr_tsp), dropped "Gaul Library" dependency
-* Turn Restricted shortest path (pgr_trsp) that replaces Shooting Star
-* Dropped support for Shooting Star
-* Built a test infrastructure that is run before major code changes are checked in
-* Tested and fixed most all of the outstanding bugs reported against 1.x that existing in the 2.0-dev code base.
-* Improved build process for Windows
-* Automated testing on Linux and Windows platforms trigger by every commit
-* Modular library design
-* Compatibility with PostgreSQL 9.1 or newer 
-* Compatibility with PostGIS 2.0 or newer 
-* Installs as PostgreSQL EXTENSION
-* Return types refactored and unified
-* Support for table SCHEMA in function parameters
-* Support for ``st_`` PostGIS function prefix
-* Added ``pgr_`` prefix to functions and types
-* Better documentation: http://docs.pgrouting.org
-
diff --git a/doc/src/changelog/2_1_0.rst b/doc/src/changelog/2_1_0.rst
deleted file mode 100644
index e658de7..0000000
--- a/doc/src/changelog/2_1_0.rst
+++ /dev/null
@@ -1,71 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share  
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_2_1_0:
-
-pgRouting 2.1.0 Release Notes
-===============================================================================
-
-With the release of pgRouting 2.1.0 fixes some bugs and issues.
-
- - To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
- - To see the issues closed by this release see the `Git closed issues <https://github.com/pgRouting/pgrouting/issues?q=is%3Aissue+milestone%3A%22Release+2.1.0%22+is%3Aclosed>`_ on Github.
- - For important changes see the following release notes.
-
-..
-
-
-
-Release Notes
--------------------------------------------------------------------------------
-
- - A C and C++ library for developer was created
-
-   - encapsulates postgreSQL related functions
-   - encapsulates Boost.Graph graphs
-
-     - Directed Boost.Graph
-     - Undirected Boost.graph.
-
-   - allow any-integer in the id's
-   - allow any-numerical on the cost/reverse_cost columns
-
- - Three Functions where completly re-factored using the developers library and functionality was added.
-
-   - pgr_dijkstra
-   - pgr_ksp
-   - pgr_drivingDistance
-
- - Improved
-   - Alphashape function now can generate better (multi)polygon with holes and alpha parameter.
-
- - Instead of generating many libraries:
-   - All functions are encapsulated in one library
-   - The library has a the prefix 2-1-0
-
- - Added proposed functions to be evaluated:
-
-   - Proposed functions from Steve Woodbridge, (Classified as Convinience by the author.)
-
-      - pgr_pointToEdgeNode - convert a point geometry to a vertex_id based on closest edge.
-      - pgr_flipEdges - flip the edges in an array of geometries so the connect end to end.
-      - pgr_textToPoints - convert a string of x,y;x,y;... locations into point geometries.
-      - pgr_pointsToVids - convert an array of point geometries into vertex ids.
-      - pgr_pointsToDMatrix - Create a distance matrix from an array of points.
-      - pgr_vidsToDMatrix - Create a distance matrix from an array of vertix_id.
-      - pgr_vidsToDMatrix - Create a distance matrix from an array of vertix_id.
-
- - Added proposed functions from GSoc Projects:
-
-   - pgr_vrppdtw
-
- - Removed the 1.x legacy functions
-
- - Some bug fixes in other functions
-
diff --git a/doc/src/changelog/2_2_0.rst b/doc/src/changelog/2_2_0.rst
deleted file mode 100644
index 25221c5..0000000
--- a/doc/src/changelog/2_2_0.rst
+++ /dev/null
@@ -1,59 +0,0 @@
-..
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_2_2_0:
-
-pgRouting 2.2.0 Release Notes
-===============================================================================
-
-With the release of pgRouting 2.2.0 fixes some bugs and issues.
-
- - To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
- - To see the issues closed by this release see the `Git closed issues <https://github.com/pgRouting/pgrouting/issues?utf8=%E2%9C%93&q=is%3Aissue+milestone%3A%22Release+2.2.0%22+is%3Aclosed>`_ on Github.
- - For important changes see the following release notes.
-
-
-Release Notes
--------------------------------------------------------------------------------
-
-
-Changes for release 2.2.0
-
-
-  - Improved:
-
-    - pgr_nodeNetwork
-
-     - Adding a row_where and outall optional parameters
-
-  - Signature fix
-
-    - pgr_dijkstra  -- to match what was documented
-
-  - New functions
-
-    - pgr_floydWarshall
-    - pgr_Johnson
-    - pgr_DijkstraCost
-
-  - New Proposed functions
-
-    - pgr_withPoints
-    - pgr_withPointsCost
-    - pgr_withPointsDD
-    - pgr_withPointsKSP
-    - pgr_dijkstraVia
-
-
-  - Deprecated functions:
-
-    - pgr_apspWarshall  use pgr_floydWarshall instead
-    - pgr_apspJohnson   use pgr_Johnson instead
-    - pgr_kDijkstraCost use pgr_dijkstraCost instead
-    - pgr_kDijkstraPath use pgr_dijkstra instead
diff --git a/doc/src/changelog/2_2_1.rst b/doc/src/changelog/2_2_1.rst
deleted file mode 100644
index e7aa654..0000000
--- a/doc/src/changelog/2_2_1.rst
+++ /dev/null
@@ -1,30 +0,0 @@
-..
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_2_2_1:
-
-pgRouting 2.2.1 Release Notes
-===============================================================================
-
-With the release of pgRouting 2.2.1 fixes some bugs and issues.
-
- - To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
- - To see the issues closed by this release see the `Git closed issues <https://github.com/pgRouting/pgrouting/issues?q=milestone%3A2.2.1+is%3Aclosed>`_ on Github.
- - For important changes see the following release notes.
-
-
-Release Notes
--------------------------------------------------------------------------------
-
-
-Changes for release 2.2.1
-
-* Server crash fix on pgr_alphaShape
-* Bug fix on With Points family of functions
-
diff --git a/doc/src/changelog/2_2_2.rst b/doc/src/changelog/2_2_2.rst
deleted file mode 100644
index a10be50..0000000
--- a/doc/src/changelog/2_2_2.rst
+++ /dev/null
@@ -1,28 +0,0 @@
-..
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_2_2_2:
-
-pgRouting 2.2.2 Release Notes
-===============================================================================
-
-With the release of pgRouting 2.2.2 fixes a regression bug.
-
- - To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
- - To see the issues closed by this release see the `Git closed issues <https://github.com/pgRouting/pgrouting/issues?q=milestone%3ARelease-2.2.2+is%3Aclosed>`_ on Github.
- - For important changes see the following release notes.
-
-
-Release Notes
--------------------------------------------------------------------------------
-
-
-Changes for release 2.2.2
-
-* Fixed regression error on pgr_drivingDistance
diff --git a/doc/src/changelog/2_2_3.rst b/doc/src/changelog/2_2_3.rst
deleted file mode 100644
index 18d599a..0000000
--- a/doc/src/changelog/2_2_3.rst
+++ /dev/null
@@ -1,28 +0,0 @@
-..
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_2_2_3:
-
-pgRouting 2.2.3 Release Notes
-===============================================================================
-
-With the release of pgRouting 2.2.e fixes  compatibility issues with PostgreSQL 9.6.
-
- - To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
- - To see the issues closed by this release see the `Git closed issues <https://github.com/pgRouting/pgrouting/issues?q=milestone%3ARelease-2.2.3+is%3Aclosed>`_ on Github.
- - For important changes see the following release notes.
-
-
-Release Notes
--------------------------------------------------------------------------------
-
-
-Changes for release 2.2.3
-
-* Fixed  compatibility issues with PostgreSQL 9.6.
diff --git a/doc/src/changelog/2_2_4.rst b/doc/src/changelog/2_2_4.rst
deleted file mode 100644
index cc4e8ab..0000000
--- a/doc/src/changelog/2_2_4.rst
+++ /dev/null
@@ -1,31 +0,0 @@
-..
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _changelog_2_2_4:
-
-pgRouting 2.2.4 Release Notes
-===============================================================================
-
-With the release of pgRouting 2.2.4 fixes compatibility errors with Fedora
-
- - To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
- - To see the issues closed by this release see the `Git closed issues <https://github.com/pgRouting/pgrouting/issues?q=is%3Aissue+milestone%3A%22Release+2.2.4%22+is%3Aclosed>`_ on Github.
- - For important changes see the following release notes.
-
-
-Release Notes
--------------------------------------------------------------------------------
-
-
-Changes for release 2.2.4
-
-
-- Bogus uses of extern "C"
-- Build error on Fedora 24 + GCC 6.0
-- Regression error pgr_nodeNetwork
diff --git a/doc/src/changelog/index.rst b/doc/src/changelog/index.rst
deleted file mode 100644
index 18f771f..0000000
--- a/doc/src/changelog/index.rst
+++ /dev/null
@@ -1,35 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share  
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _change_log:
-
-Release Notes
-===============================================================================
-
-   - :ref:`changelog_2_2_4`
-   - :ref:`changelog_2_2_3`
-   - :ref:`changelog_2_2_2`
-   - :ref:`changelog_2_2_1`
-   - :ref:`changelog_2_2_0`  
-   - :ref:`changelog_2_1_0`  
-   - :ref:`changelog_2_0`  
-   - :ref:`changelog_1_x`  
-
-.. toctree::
-   :hidden: 
-
-   2_2_4
-   2_2_3
-   2_2_2
-   2_2_1
-   2_2_0
-   2_1_0
-   2_0
-   1_x
-
diff --git a/doc/src/changelog/release_notes.rst b/doc/src/changelog/release_notes.rst
new file mode 100644
index 0000000..0f6afa3
--- /dev/null
+++ b/doc/src/changelog/release_notes.rst
@@ -0,0 +1,359 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _change_log:
+
+Release Notes
+===============================================================================
+
+To see the full list of changes check the list of `Git commits <https://github.com/pgRouting/pgrouting/commits>`_ on Github.
+
+Table of contents
+--------------------------
+
+   - :ref:`changelog_2_3_0`
+   - :ref:`changelog_2_2_4`
+   - :ref:`changelog_2_2_3`
+   - :ref:`changelog_2_2_2`
+   - :ref:`changelog_2_2_1`
+   - :ref:`changelog_2_2_0`
+   - :ref:`changelog_2_1_0`
+   - :ref:`changelog_2_0_1`
+   - :ref:`changelog_2_0_0`
+   - :ref:`changelog_1_x`
+
+.. _changelog_2_3_0:
+
+pgRouting 2.3.0 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.3.0 <https://github.com/pgRouting/pgrouting/issues?q=is%3Aissue+milestone%3A%22Release+2.3.0%22+is%3Aclosed>`_ on Github.
+
+.. rubric:: New Signatures
+
+Indentifiers can be `ANY-INTEGER` and costs can be `ANY-NUMERICAL`
+
+* pgr_TSP
+* pgr_aStar
+
+.. rubric:: New Functions
+
+* pgr_eucledianTSP
+
+
+.. rubric:: New Proposed functions
+
+* pgr_dijkstraCostMatrix
+* pgr_withPointsCostMatrix
+* pgr_maxFlowPushRelabel
+* pgr_maxFlowEdmondsKarp
+* pgr_maxFlowBoykovKolmogorov 
+* pgr_maximumCardinalityMatching
+* pgr_edgeDisjointPaths
+* pgr_contractGraph
+
+
+.. rubric:: Deprecated Signatures
+
+* pgr_tsp - use pgr_TSP or pgr_eucledianTSP instead
+* pgr_astar - use pgr_aStar instead
+
+
+.. rubric:: Deprecated Functions
+
+* pgr_flip_edges
+* pgr_vidsToDmatrix
+* pgr_pointsToDMatrix
+* pgr_textToPoints
+
+
+
+.. _changelog_2_2_4:
+
+pgRouting 2.2.4 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.2.4 <https://github.com/pgRouting/pgrouting/issues?q=is%3Aissue+milestone%3A%22Release+2.2.4%22+is%3Aclosed>`_ on Github.
+
+.. rubric:: Bug Fixes
+
+* Bogus uses of extern "C"
+* Build error on Fedora 24 + GCC 6.0
+* Regression error pgr_nodeNetwork
+
+.. _changelog_2_2_3:
+
+pgRouting 2.2.3 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.2.3 <https://github.com/pgRouting/pgrouting/issues?q=milestone%3A%22Release+2.2.3%22+is%3Aclosed>`_ on Github.
+
+.. rubric:: Bug Fixes
+
+* Fixed compatibility issues with PostgreSQL 9.6.
+
+.. _changelog_2_2_2:
+
+pgRouting 2.2.2 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.2.2 <https://github.com/pgRouting/pgrouting/issues?q=milestone%3A%22Release+2.2.2%22+is%3Aclosed>`_ on Github.
+
+.. rubric:: Bug Fixes
+
+* Fixed regression error on pgr_drivingDistance
+
+
+.. _changelog_2_2_1:
+
+pgRouting 2.2.1 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.2.1 <https://github.com/pgRouting/pgrouting/issues?q=milestone%3A2.2.1+is%3Aclosed>`_ on Github.
+
+.. rubric:: Bug Fixes
+
+* Server crash fix on pgr_alphaShape
+* Bug fix on With Points family of functions
+
+
+.. _changelog_2_2_0:
+
+pgRouting 2.2.0 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.2.0 <https://github.com/pgRouting/pgrouting/issues?utf8=%E2%9C%93&q=is%3Aissue+milestone%3A%22Release+2.2.0%22+is%3Aclosed>`_ on Github.
+
+
+.. rubric:: Improvements
+
+- pgr_nodeNetwork
+
+  - Adding a row_where and outall optional parameters
+
+- Signature fix
+
+  - pgr_dijkstra  -- to match what is documented
+
+
+.. rubric:: New Functions
+
+- pgr_floydWarshall
+- pgr_Johnson
+- pgr_DijkstraCost
+
+.. rubric:: Proposed functionality
+
+- pgr_withPoints
+- pgr_withPointsCost
+- pgr_withPointsDD
+- pgr_withPointsKSP
+- pgr_dijkstraVia
+
+
+.. rubric:: Deprecated functions:
+
+- pgr_apspWarshall  use pgr_floydWarshall instead
+- pgr_apspJohnson   use pgr_Johnson instead
+- pgr_kDijkstraCost use pgr_dijkstraCost instead
+- pgr_kDijkstraPath use pgr_dijkstra instead
+
+
+.. _changelog_2_1_0:
+
+pgRouting 2.1.0 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.1.0 <https://github.com/pgRouting/pgrouting/issues?q=is%3Aissue+milestone%3A%22Release+2.1.0%22+is%3Aclosed>`_ on Github.
+
+.. rubric:: Refactored
+
+- pgr_dijkstra
+- pgr_ksp
+- pgr_drivingDistance
+
+.. rubric:: Improvements
+
+- Alphashape function now can generate better (multi)polygon with holes and alpha parameter.
+
+.. rubric:: Proposed functionality
+
+- Proposed functions from Steve Woodbridge, (Classified as Convenience by the author.)
+
+  - pgr_pointToEdgeNode - convert a point geometry to a vertex_id based on closest edge.
+  - pgr_flipEdges - flip the edges in an array of geometries so the connect end to end.
+  - pgr_textToPoints - convert a string of x,y;x,y;... locations into point geometries.
+  - pgr_pointsToVids - convert an array of point geometries into vertex ids.
+  - pgr_pointsToDMatrix - Create a distance matrix from an array of points.
+  - pgr_vidsToDMatrix - Create a distance matrix from an array of vertix_id.
+  - pgr_vidsToDMatrix - Create a distance matrix from an array of vertix_id.
+
+- Added proposed functions from GSoc Projects:
+
+  - pgr_vrppdtw
+
+.. rubric:: No longer supported
+
+- Removed the 1.x legacy functions
+
+.. rubric:: Bug Fixes
+
+- Some bug fixes in other functions
+
+
+.. rubric:: Refactoring Internal Code
+
+- A C and C++ library for developer was created
+
+  - encapsulates postgreSQL related functions
+  - encapsulates Boost.Graph graphs
+
+    - Directed Boost.Graph
+    - Undirected Boost.graph.
+
+  - allow any-integer in the id's
+  - allow any-numerical on the cost/reverse_cost columns
+
+- Instead of generating many libraries:
+  - All functions are encapsulated in one library
+  - The library has a the prefix 2-1-0
+
+
+
+.. _changelog_2_0_1:
+
+pgRouting 2.0.1 Release Notes
+===============================================================================
+
+Minor bug fixes.
+
+.. rubric:: Bug Fixes
+
+* No track of the bug fixes were kept.
+
+
+.. _changelog_2_0_0:
+
+pgRouting 2.0.0 Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 2.0.0 <https://github.com/pgRouting/pgrouting/issues?q=milestone%3A%22Release+2.0.0%22+is%3Aclosed>`_ on Github.
+
+With the release of pgRouting 2.0.0 the library has abandoned backwards compatibility to :ref:`pgRouting 1.x <changelog_1_x>` releases.
+The main Goals for this release are:
+
+* Major restructuring of pgRouting.
+* Standardiziation of the function naming
+* Prepararation of the project for future development.
+ 
+As a result of this effort:
+
+* pgRouting has a simplified structure
+* Significant new functionality has being added
+* Documentation has being integrated
+* Testing has being integrated
+* And made it easier for multiple developers to make contributions.
+
+
+.. rubric:: Important Changes
+
+* Graph Analytics - tools for detecting and fixing connection some problems in a graph
+* A collection of useful utility functions
+* Two new All Pairs Short Path algorithms (pgr_apspJohnson, pgr_apspWarshall)
+* Bi-directional Dijkstra and A-star search algorithms (pgr_bdAstar, pgr_bdDijkstra)
+* One to many nodes search (pgr_kDijkstra)
+* K alternate paths shortest path (pgr_ksp)
+* New TSP solver that simplifies the code and the build process (pgr_tsp), dropped "Gaul Library" dependency
+* Turn Restricted shortest path (pgr_trsp) that replaces Shooting Star
+* Dropped support for Shooting Star
+* Built a test infrastructure that is run before major code changes are checked in
+* Tested and fixed most all of the outstanding bugs reported against 1.x that existing in the 2.0-dev code base.
+* Improved build process for Windows
+* Automated testing on Linux and Windows platforms trigger by every commit
+* Modular library design
+* Compatibility with PostgreSQL 9.1 or newer
+* Compatibility with PostGIS 2.0 or newer
+* Installs as PostgreSQL EXTENSION
+* Return types refactored and unified
+* Support for table SCHEMA in function parameters
+* Support for ``st_`` PostGIS function prefix
+* Added ``pgr_`` prefix to functions and types
+* Better documentation: http://docs.pgrouting.org
+
+
+.. _changelog_1_x:
+
+pgRouting 1.x Release Notes
+===============================================================================
+
+To see the issues closed by this release see the `Git closed issues for 1.x <https://github.com/pgRouting/pgrouting/issues?q=milestone%3A%22Release+1.x%22+is%3Aclosed>`_ on Github.
+The following release notes have been copied from the previous ``RELEASE_NOTES`` file and are kept as a reference.
+
+
+Changes for release 1.05
+-------------------------------------------------------------------------------
+
+* Bugfixes
+
+
+Changes for release 1.03
+-------------------------------------------------------------------------------
+
+* Much faster topology creation
+* Bugfixes
+
+
+Changes for release 1.02
+-------------------------------------------------------------------------------
+
+* Shooting* bugfixes
+* Compilation problems solved
+
+
+Changes for release 1.01
+-------------------------------------------------------------------------------
+
+* Shooting* bugfixes
+
+
+Changes for release 1.0
+-------------------------------------------------------------------------------
+
+* Core and extra functions are separated
+* Cmake build process
+* Bugfixes
+
+
+Changes for release 1.0.0b
+-------------------------------------------------------------------------------
+
+* Additional SQL file with more simple names for wrapper functions
+* Bugfixes
+
+
+Changes for release 1.0.0a
+-------------------------------------------------------------------------------
+
+* Shooting* shortest path algorithm for real road networks
+* Several SQL bugs were fixed
+
+
+Changes for release 0.9.9
+-------------------------------------------------------------------------------
+
+* PostgreSQL 8.2 support
+* Shortest path functions return empty result if they couldn’t find any path
+
+
+Changes for release 0.9.8
+-------------------------------------------------------------------------------
+
+* Renumbering scheme was added to shortest path functions
+* Directed shortest path functions were added
+* routing_postgis.sql was modified to use dijkstra in TSP search
diff --git a/doc/src/developer/developer_guide.rst b/doc/src/developer/developer_guide.rst
index 45d3ce2..a49fa80 100644
--- a/doc/src/developer/developer_guide.rst
+++ b/doc/src/developer/developer_guide.rst
@@ -48,7 +48,7 @@ pre-commit
 
 To keep version/branch/commit up to date install pelase do the following:
 
-.. code::
+.. code-block:: bash
 
   cp tools/pre-commit .git/hooks/pre-commit
 
@@ -59,12 +59,10 @@ After each commit a the file **VERSION** will remain. (The hash number will be o
 doxygen
 *******
 
-.. warning:: :ref:`developer_functions` documentation is going to be deleted from the pgRouting documentation and included in the doxygen documentation.
-
 To use doxygen:
 
 
-.. code::
+.. code-block:: bash
 
   cd tools/doxygen/
   make
@@ -72,7 +70,7 @@ To use doxygen:
 The code's documentation can be found in:
 
 
-.. code::
+.. code-block:: bash
 
   build/doxy/html/index.html
 
@@ -86,7 +84,7 @@ https://google-styleguide.googlecode.com/svn/trunk/cppguide.html
 
 Sample use:
 
-.. code::
+.. code-block:: bash
 
   python cpplint.py ../src/dijkstra/src/dijkstra_driver.h
   ../src/dijkstra/src/dijkstra_driver.h:34:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
@@ -99,7 +97,7 @@ Sample use:
 - Delete whitespace at end of line is easy fix.
 - Use your judgement!!!
 
-Some files like ``postgres.h`` are system dependant so don't include the directory.
+Some files like ``postgres.h`` are system dependent so don't include the directory.
 
 
 Other tools
@@ -148,9 +146,9 @@ Tests are part of the tree layout:
 
   - ``src/dijkstra/test``  Dijkstra's tests.
 
-    - ``test.conf``  Configuraton file.
+    - ``test.conf``  Configuration file.
     - ``<name>.test.sql``  Test file
-    - ``<name>.result``  Results file
+    - ``<name>.result``  Results file bash
 
   - ``src/dijkstra/test/pgtap``  Dijkstra's pgTaptests.
 
diff --git a/doc/src/developer/sampledata.rst b/doc/src/developer/sampledata.rst
index 0ba515b..2c143a8 100644
--- a/doc/src/developer/sampledata.rst
+++ b/doc/src/developer/sampledata.rst
@@ -30,7 +30,9 @@ To be able to execute the sample queries, run the following SQL commands to crea
    :end-before: --EDGE TABLE TOPOLOGY
 
 
-Before you test a routing function use this query to fill the source and target columns.
+.. rubric:: Topology
+
+- Before you test a routing function use this query to create a topology (fills the ``source`` and ``target`` columns).
 
 .. literalinclude:: ../../../tools/testers/sampledata.sql
    :start-after: --EDGE TABLE TOPOLOGY
@@ -38,7 +40,8 @@ Before you test a routing function use this query to fill the source and target
 
 .. rubric:: Points of interest
 
-When points outside of the graph
+- When points outside of the graph.
+- Used with the :ref:`withPoints` functions.
 
 .. literalinclude:: ../../../tools/testers/sampledata.sql
    :start-after: --POINTS CREATE
@@ -46,10 +49,28 @@ When points outside of the graph
 
 .. rubric:: Restrictions
 
+- Used with the :ref:`trsp` functions.
+
 .. literalinclude:: ../../../tools/testers/sampledata.sql
    :start-after: --RESTRICTIONS CREATE
    :end-before: --RESTRICTIONS END
 
+.. rubric:: Categories
+
+- Used with the :ref:`maxFlow` functions.
+
+.. literalinclude:: ../../../tools/testers/sampledata.sql
+   :start-after: --RESTRICTIONS END
+   :end-before: --CATEGORIES END
+
+.. rubric:: Vertex table
+
+- Used in some deprecated signatures or deprecated functions.
+
+.. literalinclude:: ../../../tools/testers/sampledata.sql
+   :start-after: --CATEGORIES END
+   :end-before: --VERTEX TABLE END
+
 
 Images
 ------
@@ -105,3 +126,11 @@ When working with city networks, this is recommended for point of view of pedest
    **Graph 4: Undirected, with cost**
 
 
+.. _pickdeliverdata:
+
+Pick & Deliver Data
+.........................
+
+.. literalinclude:: ../../../src/pickDeliver/test/pickDeliver.data
+
+
diff --git a/doc/src/installation/install-dependencies.rst b/doc/src/installation/install-dependencies.rst
index eb3ebcf..d501097 100644
--- a/doc/src/installation/install-dependencies.rst
+++ b/doc/src/installation/install-dependencies.rst
@@ -124,8 +124,6 @@ pgTap & pg_prove & perl for tests
 
 .. warning:: cmake does not test for this packages.
 
-Installing the tests dependencies:
-
 .. code-block:: none
 
     sudo apt-get install -y perl
diff --git a/doc/src/installation/installation.rst b/doc/src/installation/installation.rst
index c39dbe2..84d8ef8 100644
--- a/doc/src/installation/installation.rst
+++ b/doc/src/installation/installation.rst
@@ -14,10 +14,17 @@ Installation
 
 This is a basic guide to download and install pgRouting.
 
-Additional notes can be found in `Installation Notes <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__
+The specific instructions for any given OS distribution may vary depending on the various package maintainers.
+Contact the specific OS package maintainer for details.
+
+.. note:: The following are only general instructions.
+
+Additional notes and corrections can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__
 
 Also PostGIS provides some information about installation in this `Install Guide <http://www.postgis.us/presentations/postgis_install_guide_22.html>`__
 
+
+
 Download
 --------
 
@@ -29,7 +36,7 @@ Windows
 
 Winnie Bot Builds:
 
-* `Winnie PostgreSQL 9.2-9.5 32-bit/64-bit <http://postgis.net/windows_downloads>`_
+* `Winnie Bot Builds <http://postgis.net/windows_downloads>`_
 
 Production Builds:
 
@@ -37,28 +44,41 @@ Production Builds:
 * Can also get PostGIS Bundle from http://download.osgeo.org/postgis/windows/
 
 
-Ubuntu/Debian
+Ubuntu
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-Ubuntu packages are available in postgreSQL repositories.
+pgRouting on Ubuntu can be installed using packages from a PostgreSQL repository:
 
 Using a terminal window:
 
+* Create /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg.
+
 .. code-block:: bash
 
-    # Create /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg.
-    sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
+   sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
 
-    # Import the repository key, update the package lists
-    sudo apt-get install wget ca-certificates
+* Import the repository key, update the package lists
+
+.. code-block:: bash
+
+    sudo apt install wget ca-certificates
     wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
-    sudo apt-get update
+    sudo apt update
 
-    # Install pgrouting based on your postgres Installation: for this example is 9.3
-    sudo apt-get install postgresql-9.3-pgrouting
+* Install pgrouting based on your postgres Installation: for this example is 9.3
 
-This will also install all required packages such as postgreSQL and postGIS if not installed yet.
+.. code-block:: bash
 
+sudo apt install postgresql-9.3-pgrouting
+
+This will also install all required packages such as PostgreSQL and PostGIS if not installed yet.
+
+* To be up-to-date with changes and improvements
+
+
+.. code-block:: bash
+
+sudo apt-get update & sudo apt-get upgrade
 
 
 RHEL/CentOS
@@ -166,9 +186,10 @@ To upgrade pgRouting to version 2.x.y use the following command:
 
    ALTER EXTENSION pgrouting UPDATE TO "2.x.y";
 
-For example to upgrade to 2.2.3
+   For example to upgrade to 2.2.3
 
-.. code-block:: sql
+   .. code-block:: sql
 
    ALTER EXTENSION pgrouting UPDATE TO "2.2.3";
 
+
diff --git a/doc/src/introduction/introduction.rst b/doc/src/introduction/introduction.rst
index 7f1b736..9cdb097 100644
--- a/doc/src/introduction/introduction.rst
+++ b/doc/src/introduction/introduction.rst
@@ -50,7 +50,7 @@ This Release Contributors
 Individuals (in alphabetical order)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-Daniel Kastl, Ko Nagase, Mario Basa, Regina Obe, Stephen Woodbridge, Virginia Vergara
+Andrea Nardellli, Daniel Kastl, Ko Nagase, Mario Basa, Regina Obe, Rohith Reddy, Stephen Woodbridge, Virginia Vergara
 
 And all the people that gives us a little of their time making comments, finding issues, making pull requests etc.
 
@@ -70,7 +70,7 @@ Contributors Past & Present:
 Individuals (in alphabetical order)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-Akio Takubo, Anton Patrushev, Ashraf Hossain, Christian Gonzalez, Daniel Kastl, Dave Potts, David Techer, Denis Rykov, Ema Miyawaki, Florian Thurkow, Frederic Junod, Gerald Fenoy, Jay Mahadeokar, Jinfu Leng, Kai Behncke, Kishore Kumar, Ko Nagase, Manikata Kondeti, Mario Basa, Martin Wiesenhaan,  Maxim Dubinin, Mohamed Zia, Mukul Priya, Razequl Islam, Sarthak Agarwal, Stephen Woodbridge, Sylvain Housseman, Sylvain Pasche, Virginia Vergara
+Akio Takubo, Andrea Nardelli, Anton Patrushev, Ashraf Hossain, Christian Gonzalez, Daniel Kastl, Dave Potts, David Techer, Denis Rykov, Ema Miyawaki, Florian Thurkow, Frederic Junod, Gerald Fenoy, Jay Mahadeokar, Jinfu Leng, Kai Behncke, Kishore Kumar, Ko Nagase, Manikata Kondeti, Mario Basa, Martin Wiesenhaan,  Maxim Dubinin, Mohamed Zia, Mukul Priya, Razequl Islam, Regina Obe, Rohith Reddy, Sarthak Agarwal, Stephen Woodbridge, Sylvain Housseman, Sylvain Pasche, Virginia Vergara
 
 Corporate Sponsors (in alphabetical order)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/doc/src/introduction/support.rst b/doc/src/introduction/support.rst
index 0719297..cd1da04 100644
--- a/doc/src/introduction/support.rst
+++ b/doc/src/introduction/support.rst
@@ -63,16 +63,13 @@ For users who require professional support, development and consulting services,
      - **Website**
    * - Georepublic
      - Germany, Japan
-     - http://georepublic.info
+     - https://georepublic.info
    * - iMaptools
      - United States
      - http://imaptools.com
-   * - Paaragon Corporation
+   * - Paragon Corporation
      - United States
-     - http://www.paragoncorporation.com/
-   * - Orkney Inc.
-     - Japan
-     - http://www.orkney.co.jp
+     - http://www.paragoncorporation.com
    * - Camptocamp
      - Switzerland, France
      - http://www.camptocamp.com
diff --git a/doc/src/recipes/index.rst b/doc/src/recipes/index.rst
index 44a3c1f..50ed137 100644
--- a/doc/src/recipes/index.rst
+++ b/doc/src/recipes/index.rst
@@ -33,7 +33,7 @@ The first steps are:
   - Create a branch for your recipe or wrapper
   - Create your recipe file
 
-.. code::
+.. code-block:: bash
 
     cd doc/src/recipes/
     vi myrecipe.rst
@@ -43,7 +43,7 @@ The first steps are:
 
 .. rubric:: To create the test file of your recipe
 
-.. code::
+.. code-block:: bash
 
     cd test
     cp myrecipe.rst myrecipe.sql.test
@@ -66,7 +66,7 @@ Leave only the SQL code on ``myrecipe.sql.test`` by deleting lines or by comment
 
 From the root directory execute:
 
-.. code::
+.. code-block:: bash
 
     tools/test-runner.pl -alg recipes -ignorenotice
 
@@ -74,7 +74,7 @@ Copy the results of your recipe and paste them in the file ``myrecipe.result``,
 
 .. rubric::  make a pull request.
 
-.. code::
+.. code-block:: bash
 
     git commit -a -m 'myrecipe is for this and that'
     git push
diff --git a/doc/src/tutorial/analytics.rst b/doc/src/tutorial/analytics.rst
index 1128c80..97ff85e 100644
--- a/doc/src/tutorial/analytics.rst
+++ b/doc/src/tutorial/analytics.rst
@@ -52,7 +52,7 @@ With :ref:`pgr_analyze_graph` the graph can be checked for errors. For example f
 
 In the vertices table "mytab_vertices_pgr":
 
-  - Deadends are indentified by ``cnt=1`` 
+  - Deadends are identified by ``cnt=1`` 
   - Potencial gap problems are identified with ``chk=1``.
 
 .. code-block:: sql
diff --git a/doc/src/tutorial/custom_query.rst b/doc/src/tutorial/custom_query.rst
index 0887289..559f5d9 100644
--- a/doc/src/tutorial/custom_query.rst
+++ b/doc/src/tutorial/custom_query.rst
@@ -14,6 +14,47 @@ Dictionary of columns & Custom Query
 
 :path: a sequence of vertices/edges from A to B.
 :route: a sequence of paths. 
+:ANY-INTEGER: Any of the following types: SMALLINT, INTEGER, BIGINT
+:ANY-NUMERICAL: Any of the following types: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+
+
+
+Custom Queries
+===============================================================================
+
+
+
+Edges queries
+-------------------------------------------------------------------------------
+
+
+Columns of the edges_sql queries
+...............................................................................
+
+
+Depending on the function used the following columns are expected
+
+================  ===================   ======== =================================================
+Column            Type                  Default  Description
+================  ===================   ======== =================================================
+**id**            ``ANY-INTEGER``                Identifier of the edge.
+**source**        ``ANY-INTEGER``                Identifier of the first end point vertex of the edge.
+**target**        ``ANY-INTEGER``                Identifier of the second end point vertex of the edge.
+**cost**          ``ANY-NUMERICAL``              Weight of the edge  `(source, target)`
+                                                   - When negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
+**reverse_cost**  ``ANY-NUMERICAL``       -1     Weight of the edge `(target, source)`,
+                                                   - When negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
+================  ===================   ======== =================================================
+
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+
+
+
+
 
 Description of the edges_sql query
 -------------------------------------------------------------------------------
@@ -35,7 +76,7 @@ Where:
 Description of the parameters of the signatures
 -------------------------------------------------------------------------------
 
-:edges_sql: ``TEXT`` SQL query as decribed above.
+:edges_sql: ``TEXT`` SQL query as described above.
 :start_vid: ``BIGINT`` identifier of the starting vertex of the path.
 :start_vids: ``array[ANY-INTEGER]`` array of identifiers of starting vertices.
 :end_vid: ``BIGINT`` identifier of the ending vertex of the path.
@@ -49,9 +90,9 @@ Description of the return values
 Returns set of ``(seq [, start_vid] [, end_vid] , node, edge, cost, agg_cost)``
 
 :seq: ``INTEGER``  is a sequential value starting from **1**.
-:route_seq: ``INTEGER``  relative position in the route. Has value **1** for the begining of a route.
+:route_seq: ``INTEGER``  relative position in the route. Has value **1** for the beginning of a route.
 :route_id: ``INTEGER`` id of the route.
-:path_seq: ``INTEGER``  relative position in the path. Has value **1** for the begining of a path.
+:path_seq: ``INTEGER``  relative position in the path. Has value **1** for the beginning of a path.
 :path_id: ``INTEGER`` id of the path.
 :start_vid: ``BIGINT`` id of the starting vertex. Used when multiple starting vetrices are in the query.
 :end_vid: ``BIGINT`` id of the ending vertex. Used when multiple ending vertices are in the query.
@@ -127,7 +168,7 @@ When the columns required have the default names this can be used (pgr_func is t
 	SELECT pgr_analyzeOneway('edge_table', ARRAY['', 'B', 'TF'], ARRAY['', 'B', 'FT'], 
 					       ARRAY['', 'B', 'FT'], ARRAY['', 'B', 'TF']) 
 
-When the columns required do not have the default names its strongly recomended to use the *named notation*.
+When the columns required do not have the default names its strongly recommended to use the *named notation*.
 
 .. code-block:: sql
 
diff --git a/doc/src/tutorial/topology.rst b/doc/src/tutorial/topology.rst
index 1cf8f91..86cbe16 100644
--- a/doc/src/tutorial/topology.rst
+++ b/doc/src/tutorial/topology.rst
@@ -92,7 +92,7 @@ The function :ref:`pgr_createTopology() <pgr_create_topology>` will create the `
                        WHEN fcc='A69' THEN 15
                        ELSE null END;
 
-    -- UPDATE the cost infomation based on oneway streets
+    -- UPDATE the cost information based on oneway streets
 
     UPDATE edge_table SET
         cost_time = CASE
diff --git a/doc/src/tutorial/tutorial.rst b/doc/src/tutorial/tutorial.rst
index 59874f4..a496fed 100644
--- a/doc/src/tutorial/tutorial.rst
+++ b/doc/src/tutorial/tutorial.rst
@@ -113,7 +113,7 @@ network. The general form of a route query is:
 
 .. code-block:: sql
 
-    select pgr_<algorithm>(<SQL for edges>, start, end, <additonal options>)
+    select pgr_<algorithm>(<SQL for edges>, start, end, <additional options>)
 
 As you can see this is fairly straight forward and you can look and the 
 specific algorithms for the details of the signatures and how to use them.
diff --git a/doc/test/utilities-any.result b/doc/test/utilities-any.result
index 530cdd9..276cbf9 100644
--- a/doc/test/utilities-any.result
+++ b/doc/test/utilities-any.result
@@ -1 +1 @@
-2.2.4
+2.3.0
diff --git a/doc/test/utilities-any.test.sql b/doc/test/utilities-any.test.sql
index b8a7225..32455ae 100644
--- a/doc/test/utilities-any.test.sql
+++ b/doc/test/utilities-any.test.sql
@@ -3,6 +3,6 @@ BEGIN;
 --------------------------------------------------------------------------------
 --                pgr_version
 --------------------------------------------------------------------------------
--- SELECT pgr_version(); -- DONT USE THIS IT CHANGES WITH EVERY COMMIT
+-- SELECT pgr_version(); -- DON'T USE THIS IT CHANGES WITH EVERY COMMIT
 SELECT version FROM pgr_version(); -- This changes infrequently
 ROLLBACK;
diff --git a/doxygen/CMakeLists.txt b/doxygen/CMakeLists.txt
new file mode 100644
index 0000000..b463d34
--- /dev/null
+++ b/doxygen/CMakeLists.txt
@@ -0,0 +1,23 @@
+#
+# Based on:
+# https://majewsky.wordpress.com/2010/08/14/tip-of-the-day-cmake-and-doxygen/
+#
+
+option(BUILD_DOXY
+    "Set ON|OFF (default=OFF) to build Developers Documentation" OFF)
+
+if (BUILD_DOXY)
+    message(STATUS "Developers documentation.")
+    find_package(Doxygen ${DOXYGEN_MINIMUM_VERSION})
+
+    if(DOXYGEN_FOUND)
+        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
+        add_custom_target(doxy
+            ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+            COMMENT "Generating API documentation with Doxygen" VERBATIM
+            )
+        message(".....OK")
+    endif()
+
+endif()
diff --git a/tools/doxygen/Doxyfile b/doxygen/Doxyfile.in
similarity index 99%
rename from tools/doxygen/Doxyfile
rename to doxygen/Doxyfile.in
index ab48741..98fa2af 100644
--- a/tools/doxygen/Doxyfile
+++ b/doxygen/Doxyfile.in
@@ -32,33 +32,33 @@ DOXYFILE_ENCODING      = UTF-8
 # title of most generated pages and in a few other places.
 # The default value is: My Project.
 
-PROJECT_NAME           = "pgRouting"
+PROJECT_NAME           = "@PROJECT_NAME@"
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = 2.2
+PROJECT_NUMBER         = @PGROUTING_NUMBER@
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a
 # quick idea about the purpose of the project. Keep the description short.
 
-PROJECT_BRIEF          = "pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality."
+PROJECT_BRIEF          = "@PROJECT_BRIEF@"
 
 # With the PROJECT_LOGO tag one can specify an logo or icon that is included in
 # the documentation. The maximum height of the logo should not exceed 55 pixels
 # and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
 # to the output directory.
 
-PROJECT_LOGO           = "../../doc/static/images/pgrouting-logo.png"
+PROJECT_LOGO           = @CMAKE_CURRENT_SOURCE_DIR@/../doc/static/images/pgrouting-logo.png
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
 # into which the generated documentation will be written. If a relative path is
 # entered, it will be relative to the location where doxygen was started. If
 # left blank the current directory will be used.
 
-OUTPUT_DIRECTORY       = ../../build/doxy/
+OUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_DIR@
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
 # directories (in 2 levels) under the output directory of each output format and
@@ -76,7 +76,7 @@ CREATE_SUBDIRS         = NO
 # U+3044.
 # The default value is: NO.
 
-ALLOW_UNICODE_NAMES    = NO
+#ALLOW_UNICODE_NAMES    = NO
 
 # The OUTPUT_LANGUAGE tag is used to specify the language in which all
 # documentation generated by doxygen is written. Doxygen will use this
@@ -409,7 +409,7 @@ LOOKUP_CACHE_SIZE      = 0
 # normally produced when WARNINGS is set to YES.
 # The default value is: NO.
 
-EXTRACT_ALL            = NO
+EXTRACT_ALL            = YES
 
 # If the EXTRACT_PRIVATE tag is set to YES all private members of a class will
 # be included in the documentation.
@@ -452,7 +452,7 @@ EXTRACT_LOCAL_METHODS  = NO
 # are hidden.
 # The default value is: NO.
 
-EXTRACT_ANON_NSPACES   = NO
+EXTRACT_ANON_NSPACES   = YES
 
 # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
 # undocumented members inside documented classes or files. If set to NO these
@@ -460,7 +460,7 @@ EXTRACT_ANON_NSPACES   = NO
 # section is generated. This option has no effect if EXTRACT_ALL is enabled.
 # The default value is: NO.
 
-HIDE_UNDOC_MEMBERS     = YES
+HIDE_UNDOC_MEMBERS     = NO
 
 # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
 # undocumented classes that are normally visible in the class hierarchy. If set
@@ -515,7 +515,7 @@ SHOW_INCLUDE_FILES     = YES
 
 # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
 # grouped member an include statement to the documentation, telling the reader
-# which file to include in order to use the member.
+
 # The default value is: NO.
 
 SHOW_GROUPED_MEMB_INC  = YES
@@ -694,7 +694,7 @@ CITE_BIB_FILES         =
 # messages are off.
 # The default value is: NO.
 
-QUIET                  = NO
+QUIET                  = YES
 
 # The WARNINGS tag can be used to turn on/off the warning messages that are
 # generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
@@ -710,7 +710,7 @@ WARNINGS               = YES
 # will automatically be disabled.
 # The default value is: YES.
 
-WARN_IF_UNDOCUMENTED   = NO
+WARN_IF_UNDOCUMENTED   = YES
 
 # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
 # potential errors in the documentation, such as not documenting some parameters
@@ -742,7 +742,7 @@ WARN_FORMAT            = "$file:$line: $text"
 # messages should be written. If left blank the output is written to standard
 # error (stderr).
 
-WARN_LOGFILE           =
+WARN_LOGFILE           = ./LOG
 
 #---------------------------------------------------------------------------
 # Configuration options related to the input files
@@ -754,7 +754,7 @@ WARN_LOGFILE           =
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = ../../src ../../doc
+INPUT                  = @CMAKE_CURRENT_SOURCE_DIR@/../src @CMAKE_CURRENT_SOURCE_DIR@/../doc
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -789,7 +789,8 @@ RECURSIVE              = YES
 # Note that relative paths are relative to the directory from which doxygen is
 # run.
 
-EXCLUDE                = ../../tools ../../doc ../../build ../../cmake ../../.tx 
+EXCLUDE                =
+# ../../tools ../../doc ../../build ../../cmake ../../.tx 
 
 # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
 # directories that are symbolic links (a Unix file system feature) are excluded
@@ -842,7 +843,9 @@ EXAMPLE_RECURSIVE      = NO
 # that contain images that are to be included in the documentation (see the
 # \image command).
 
-IMAGE_PATH             = ../../doc/static/images/developers/
+IMAGE_PATH             = @CMAKE_CURRENT_SOURCE_DIR@/../doc/static/images/developers \
+                         @CMAKE_CURRENT_SOURCE_DIR@/../src/contraction/doc/images
+                        
 
 # The INPUT_FILTER tag can be used to specify a program that doxygen should
 # invoke to filter for each input file. Doxygen will invoke the filter program
@@ -1399,7 +1402,7 @@ EXT_LINKS_IN_WINDOW    = YES
 
 FORMULA_FONTSIZE       = 10
 
-# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
 # generated for formulas are transparent PNGs. Transparent PNGs are not
 # supported properly for IE 6.0, but are supported on all modern browsers.
 #
@@ -1779,7 +1782,7 @@ MAN_EXTENSION          = .3
 # MAN_EXTENSION with the initial . removed.
 # This tag requires that the tag GENERATE_MAN is set to YES.
 
-MAN_SUBDIR             =
+#MAN_SUBDIR             =
 
 # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
 # will generate one additional man file for each entity documented in the real
@@ -2056,7 +2059,7 @@ HIDE_UNDOC_RELATIONS   = YES
 # set to NO
 # The default value is: YES.
 
-HAVE_DOT               = YES
+HAVE_DOT               = NO
 
 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
 # to run in parallel. When set to 0 doxygen will base this on the number of
@@ -2237,7 +2240,7 @@ DOT_PATH               =
 # command).
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-DOTFILE_DIRS           = ../doc/images/
+DOTFILE_DIRS           = 
 
 # The MSCFILE_DIRS tag can be used to specify one or more directories that
 # contain msc files that are included in the documentation (see the \mscfile
diff --git a/tools/doxygen/DoxygenLayout.xml b/doxygen/DoxygenLayout.xml
similarity index 100%
rename from tools/doxygen/DoxygenLayout.xml
rename to doxygen/DoxygenLayout.xml
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dd572dc..d7ec5e3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -55,5 +55,8 @@ LIST(APPEND L_PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}")
 #ADD_SUBDIRECTORY(shooting_star)
 #LIST(APPEND L_PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}")
 
+#ADD_SUBDIRECTORY(contraction)
+#LIST(APPEND L_PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}")
+
 # Make sure this is after all the ADD_SUBDIRECTORY
 SET(PACKAGE_SQL_FILES "${L_PACKAGE_SQL_FILES}" PARENT_SCOPE)
diff --git a/src/allpairs/doc/allpairs.rst b/src/allpairs/doc/allpairs.rst
index d0d4eb9..fa51059 100644
--- a/src/allpairs/doc/allpairs.rst
+++ b/src/allpairs/doc/allpairs.rst
@@ -20,14 +20,14 @@ The following functions work an all vertices pair combinations
 
      
 .. toctree::
-    :hidden: 
+    :hidden:
 
     ./pgr_floydWarshall
     ./pgr_johnson
 
 
 Performance
-===============================================================================
+------------------------------------------------------------------------------
 
 The following tests:
  - non server computer
@@ -37,7 +37,7 @@ The following tests:
  - posgreSQL version 9.3
 
 Data
-----
+.........................................
 
 The following data was used
 
@@ -60,10 +60,9 @@ Data processing was done with osm2pgrouting-alpha
 
 
 Results
------------
+.........................................
 
-Test One
-.........
+:Test: One
 
 This test is not with a bounding box
 The density of the passed graph is extremely low.
@@ -113,8 +112,8 @@ The results of this tests are presented as:
  10000  10000     3.52E-7    38491  23.26         6.51
 ====== ======  ========== ======== ============== =============
 
-Test Two
-.........
+
+:Test: Two
 
 This test is with a bounding box
 The density of the passed graph higher than of the Test One.
@@ -169,7 +168,7 @@ The results of this tests are presented as:
 
 
 See Also
--------------------------------------------------------------------------------
+.........................................
 
 * :ref:`pgr_johnson`
 * :ref:`pgr_floydWarshall`
diff --git a/src/allpairs/doc/pgr_floydWarshall.rst b/src/allpairs/doc/pgr_floydWarshall.rst
index b3195a6..8f413fc 100644
--- a/src/allpairs/doc/pgr_floydWarshall.rst
+++ b/src/allpairs/doc/pgr_floydWarshall.rst
@@ -29,28 +29,8 @@ is a good choice to calculate the sum of the costs of the shortest path for each
 pair of nodes in the graph, for *dense graphs*. We make use of the  Boost's
 implementation which runs in :math:`\Theta(V^3)` time,
 
-    
-Signature
-===============================================================================
 
-
-.. index::
-    single: floydWarshall(edges_sql, directed)
-
-.. code-block:: none
-   
-    pgr_floydWarshall(edges_sql, directed:=true)
-         RETURNS SET OF (start_vid, end_vid,  agg_cost) or EMPTY SET
-
-Example
--------
-.. code-block:: none
-   
-    pgr_floydWarshall(
-       'SELECT source, target, cost, reverse_cost FROM edge_table WHERE city_code = 304'
-    );
-
-Characteristics:
+Characteristics
 ----------------
 
 The main Characteristics are:
@@ -71,35 +51,66 @@ The main Characteristics are:
 
   - When  `start_vid` = `end_vid`, the `agg_cost` = 0.
 
-  - **Recomended, use a bounding box of no more than 3500 edges.**
+  - **Recommended, use a bounding box of no more than 3500 edges.**
+
+Signature Summary
+--------------------------------------------
+    
+.. code-block:: none
+   
+    pgr_floydWarshall(edges_sql)
+    pgr floydWarshall(edges_sql, directed)
+    RETURNS SET OF (start_vid, end_vid,  agg_cost) or EMPTY SET
+
+Signatures
+--------------------------------------------
 
 
+.. index::
+    single: floydWarshall(Minimal Signature)
 
-Description of the Signature
-============================
+Minimal Signature
+...................
 
-Description of the SQL query
--------------------------------------------------------------------------------
+.. code-block:: none
+   
+    pgr_floydWarshall(edges_sql)
+    RETURNS SET OF (start_vid, end_vid,  agg_cost) or EMPTY SET
+
+:Example 1: On a directed graph.
+
+.. literalinclude:: doc-floydWarshall.queries
+   :start-after: -- q1
+   :end-before: -- q2
 
-:edges_sql: is an SQL query, which should return a set of rows with the following columns:
 
-================  ===================   =================================================
-Column            Type                      Description
-================  ===================   =================================================
-**source**        ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
-**target**        ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
-**cost**          ``ANY-NUMERICAL``     Weight of the edge `(source, target)`, if negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
-**reverse_cost**  ``ANY-NUMERICAL``     (optional) Weight of the edge `(target, source)`, if negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
-================  ===================   =================================================
+.. index::
+    single: floydWarshall(Complete Signature)
 
-Where:
+Complete Signature
+...................
 
-:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
-:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+.. code-block:: none
+   
+    pgr_floydWarshall(edges_sql, directed)
+    RETURNS SET OF (start_vid, end_vid,  agg_cost) or EMPTY SET
+
+
+:Example 2: On an undirected graph.
+
+.. literalinclude:: doc-floydWarshall.queries
+   :start-after: -- q2
+
+Description of the Signatures
+------------------------------
+
+.. include:: ../../common/src/edges_input.h
+    :start-after: no_id_edges_sql_start
+    :end-before: no_id_edges_sql_end
 
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+................................................
 
 Receives  ``(edges_sql, directed)``
 
@@ -112,7 +123,7 @@ Parameter     Type          Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+..................................
 
 Returns set of ``(start_vid, end_vid, agg_cost)``
 
@@ -126,22 +137,6 @@ Column        Type          Description
 
 
 
-Examples
-============================
-
-:Example 1: On a directed graph.
-
-.. literalinclude:: doc-floydWarshall.queries
-   :start-after: -- q1
-   :end-before: -- q2
-
-:Example 2: On an undirected graph.
-
-.. literalinclude:: doc-floydWarshall.queries
-   :start-after: -- q2
-
-
-These queries uses the :ref:`sampledata` network.
 
 
 .. rubric:: History
@@ -153,6 +148,7 @@ See Also
 
 * :ref:`pgr_johnson`
 * `Boost floyd-Warshall <http://www.boost.org/libs/graph/doc/floyd_warshall_shortest.html>`_ algorithm
+* Queries uses the :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
diff --git a/src/allpairs/doc/pgr_johnson.rst b/src/allpairs/doc/pgr_johnson.rst
index 38cb014..5e66170 100644
--- a/src/allpairs/doc/pgr_johnson.rst
+++ b/src/allpairs/doc/pgr_johnson.rst
@@ -16,7 +16,7 @@ Synopsis
 -------------------------------------------------------------------------------
 
 ``pgr_johnson`` - Returns the sum of the costs of the shortest path for each
-pair of nodes in the graph using Johnson's algorithm.
+pair of nodes in the graph using Floyd-Warshall algorithm.
 
 .. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
    :target: http://www.boost.org/libs/graph/doc/johnson_all_pairs_shortest.html
@@ -26,30 +26,10 @@ pair of nodes in the graph using Johnson's algorithm.
 
 The Johnson algorithm, is a good choice to calculate the sum of the costs
 of the shortest path for each pair of nodes in the graph, for *sparse graphs*.
-We make use of the  Boost's implementation which runs in :math:`O(V E \log V)` time,
+It usees the Boost's implementation which runs in :math:`O(V E \log V)` time,
 
-    
-Signature
-===============================================================================
-
-
-.. index::
-    single: johnson(edges_sql, directed)
-
-.. code-block:: none
-   
-    pgr_johnson(edges_sql, directed:=true)
-         RETURNS SET OF (start_vid, end_vid, agg_cost) or EMPTY SET
-
-Example
--------
-.. code-block:: none
-   
-    pgr_johnson(
-       'SELECT source, target, cost, reverse_cost FROM edge_table WHERE city_code = 304'
-    );
 
-Characteristics:
+Characteristics
 ----------------
 
 The main Characteristics are:
@@ -71,31 +51,65 @@ The main Characteristics are:
   - When  `start_vid` = `end_vid`, the `agg_cost` = 0.
 
 
-Description of the Signature
-============================
 
-Description of the SQL query
--------------------------------------------------------------------------------
+Signature Summary
+--------------------------------------------
+    
+.. code-block:: none
+   
+    pgr_johnson(edges_sql)
+    pgr johnson(edges_sql, directed)
+    RETURNS SET OF (start_vid, end_vid,  agg_cost) or EMPTY SET
+
+Signatures
+--------------------------------------------
+
+
+.. index::
+    single: johnson(Minimal Signature)
+
+Minimal Signature
+...................
+
+.. code-block:: none
+   
+    pgr_johnson(edges_sql)
+    RETURNS SET OF (start_vid, end_vid,  agg_cost) or EMPTY SET
 
-:edges_sql: is an SQL query, which should return a set of rows with the following columns:
+:Example 1: On a directed graph.
 
-================  ===================   =================================================
-Column            Type                      Description
-================  ===================   =================================================
-**source**        ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
-**target**        ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
-**cost**          ``ANY-NUMERICAL``     Weight of the edge `(source, target)`, If negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
-**reverse_cost**  ``ANY-NUMERICAL``     (optional) Weight of the edge `(target, source)`, if negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
-================  ===================   =================================================
+.. literalinclude:: doc-johnson.queries
+   :start-after: -- q1
+   :end-before: -- q2
 
-Where:
 
-:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
-:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+.. index::
+    single: johnson(Complete Signature)
+
+Complete Signature
+...................
+
+.. code-block:: none
+   
+    pgr_johnson(edges_sql, directed)
+    RETURNS SET OF (start_vid, end_vid,  agg_cost) or EMPTY SET
+
+
+:Example 2: On an undirected graph.
+
+.. literalinclude:: doc-johnson.queries
+   :start-after: -- q2
+
+Description of the Signatures
+------------------------------
+
+.. include:: ../../common/src/edges_input.h
+    :start-after: no_id_edges_sql_start
+    :end-before: no_id_edges_sql_end
 
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+................................................
 
 Receives  ``(edges_sql, directed)``
 
@@ -108,7 +122,7 @@ Parameter     Type          Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+..................................
 
 Returns set of ``(start_vid, end_vid, agg_cost)``
 
@@ -122,33 +136,18 @@ Column        Type          Description
 
 
 
-Examples
-============================
-
-:Example 1: On a directed graph.
-
-.. literalinclude:: doc-johnson.queries
-   :start-after: -- q1
-   :end-before: -- q2
-
-:Example 2: On an undirected graph.
-
-.. literalinclude:: doc-johnson.queries
-   :start-after: -- q2
-
-
-These queries uses the :ref:`sampledata` network.
 
 
 .. rubric:: History
 
-* Re-design of pgr_apspJohnson in version 2.2.0
+* Re-design of pgr_apspJohnson in Version 2.2.0
 
 See Also
 -------------------------------------------------------------------------------
 
 * :ref:`pgr_floydWarshall`
-* `Boost Jhonson <http://www.boost.org/libs/graph/doc/johnson_all_pairs_shortest.html>`_ algorithm implementation.
+* `Boost Johnson <http://www.boost.org/libs/graph/doc/johnson_all_pairs_shortest.html>`_ algorithm implementation.
+* Queries uses the :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
diff --git a/src/allpairs/src/floydWarshall.c b/src/allpairs/src/floydWarshall.c
index 97a0ee3..7ce4c40 100644
--- a/src/allpairs/src/floydWarshall.c
+++ b/src/allpairs/src/floydWarshall.c
@@ -27,14 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include <unistd.h>
-
 #include "postgres.h"
+#include "fmgr.h"
 #include "funcapi.h"
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
-#include "fmgr.h"
 
 // #define DEBUG
 
@@ -45,13 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/edges_input.h"
 #include "./floydWarshall_driver.h"
 
-PG_FUNCTION_INFO_V1(floydWarshall);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-floydWarshall(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum floydWarshall(PG_FUNCTION_ARGS);
 
 static
 void
@@ -65,7 +57,7 @@ process(
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
     size_t total_tuples = 0;
-    pgr_get_data_4_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges_no_id(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -78,29 +70,37 @@ process(
 
     clock_t start_t = clock();
     PGR_DBG("Starting processing");
-    char *err_msg = (char *)"";
+    char *err_msg = NULL;
+    char *log_msg = NULL;
     do_pgr_floydWarshall(
             edges,
             total_tuples,
             directed,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
     time_msg(" processing FloydWarshall", start_t, clock());
 
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+
+    if (log_msg) {
+        PGR_DBG("LOG = %s\n", log_msg);
+        free(log_msg);
+    }
+
+    if (err_msg) {
+       if (*result_tuples) free(*result_tuples);
+       elog(ERROR, " %s\n", err_msg);
+    }
 
     pfree(edges);
     pgr_SPI_finish();
 }
 
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(floydWarshall);
 PGDLLEXPORT Datum
-#endif
 floydWarshall(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
diff --git a/src/allpairs/src/floydWarshall_driver.cpp b/src/allpairs/src/floydWarshall_driver.cpp
index 9fe1824..36e2040 100644
--- a/src/allpairs/src/floydWarshall_driver.cpp
+++ b/src/allpairs/src/floydWarshall_driver.cpp
@@ -27,9 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#ifdef open
+#undef open
+#endif
 #endif
 
 
@@ -38,62 +41,71 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <vector>
 #include "./pgr_allpairs.hpp"
 #include "./floydWarshall_driver.h"
-
-extern "C" {
+#include "./../../common/src/pgr_assert.h"
 #include "./../../common/src/pgr_types.h"
-}
 
 
 void
 do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
-
-    // return values
-    Matrix_cell_t **postgres_rows,
-    size_t *result_tuple_count,
-    char ** err_msg) {
-// function starts
-  std::ostringstream log;
-  try {
-    graphType gType = directedFlag? DIRECTED: UNDIRECTED;
-    const size_t initial_size = total_tuples;
-
-
-    if (directedFlag) {
-      log << "Processing Directed graph\n";
-      Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
-      digraph.graph_insert_data(data_edges, total_tuples);
-      pgr_floydWarshall(digraph, *result_tuple_count, postgres_rows);
-    } else {
-      log << "Processing Undirected graph\n";
-      Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
-      undigraph.graph_insert_data(data_edges, total_tuples);
-      pgr_floydWarshall(undigraph, *result_tuple_count, postgres_rows);
+        pgr_edge_t  *data_edges,
+        size_t total_tuples,
+        bool directedFlag,
+
+        // return values
+        Matrix_cell_t **return_tuples,
+        size_t *return_count,
+        char ** log_msg,
+        char ** err_msg) {
+    // function starts
+    std::ostringstream log;
+    try {
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+        pgassert(!(*return_tuples));
+        pgassert(*return_count == 0);
+
+        graphType gType = directedFlag? DIRECTED: UNDIRECTED;
+
+
+        if (directedFlag) {
+            log << "Processing Directed graph\n";
+            pgrouting::DirectedGraph digraph(gType);
+            digraph.graph_insert_data(data_edges, total_tuples);
+            log << digraph;
+            pgr_floydWarshall(digraph, *return_count, return_tuples);
+        } else {
+            log << "Processing Undirected graph\n";
+            pgrouting::UndirectedGraph undigraph(gType);
+            undigraph.graph_insert_data(data_edges, total_tuples);
+            log << undigraph;
+            pgr_floydWarshall(undigraph, *return_count, return_tuples);
+        }
+
+
+        if (*return_count == 0) {
+            log <<  "NOTICE: No Vertices found??? wiered error\n";
+            *err_msg = strdup(log.str().c_str());
+            *return_tuples = NULL;
+            *return_count = 0;
+            return;
+        }
+
+        *log_msg = strdup(log.str().c_str());
+        return;
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
     }
-
-
-    if (*result_tuple_count == 0) {
-      log <<  "NOTICE: No Vertices found??? wiered error\n";
-      *err_msg = strdup(log.str().c_str());
-      *postgres_rows = NULL;
-      *result_tuple_count = 0;
-      return;
-    }
-#ifndef DEBUG
-    *err_msg = strdup("OK");
-#else
-    *err_msg = strdup(log.str().c_str());
-#endif
-    return;
-  } catch ( ... ) {
-    log << "Caught unknown expection!\n";
-    *err_msg = strdup(log.str().c_str());
-    *postgres_rows = NULL;
-    *result_tuple_count = 0;
-    return;
-  }
 }
-
-
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/allpairs/src/floydWarshall_driver.h
index 801bb6c..252e6ce 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/allpairs/src/floydWarshall_driver.h
@@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
 #define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
 
+#pragma once
+
 #include "./../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
@@ -45,7 +47,8 @@ do_pgr_floydWarshall(
     // return values
     Matrix_cell_t **ret_matrix,
     size_t *return_tuple_count,
-    char ** err_msg); 
+    char ** log_msg,
+    char ** err_msg);
 
 #ifdef __cplusplus
 }
diff --git a/src/allpairs/src/johnson.c b/src/allpairs/src/johnson.c
index 6fd3d44..4afbe28 100644
--- a/src/allpairs/src/johnson.c
+++ b/src/allpairs/src/johnson.c
@@ -45,13 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/edges_input.h"
 #include "./johnson_driver.h"
 
-PG_FUNCTION_INFO_V1(johnson);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-johnson(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum johnson(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
@@ -66,7 +60,7 @@ void process(
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
     size_t total_tuples = 0;
-    pgr_get_data_4_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges_no_id(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,11 +92,8 @@ void process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(johnson);
 PGDLLEXPORT Datum
-#endif
 johnson(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
@@ -161,7 +152,7 @@ johnson(PG_FUNCTION_ARGS) {
         HeapTuple    tuple;
         Datum        result;
         Datum        *values;
-        bool*        nulls;
+        bool         *nulls;
 
         /*********************************************************************/
         /*                          MODIFY AS NEEDED                         */
diff --git a/src/allpairs/src/johnson_driver.cpp b/src/allpairs/src/johnson_driver.cpp
index 7425f12..4fe939d 100644
--- a/src/allpairs/src/johnson_driver.cpp
+++ b/src/allpairs/src/johnson_driver.cpp
@@ -27,9 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#ifdef open
+#undef open
+#endif
 #endif
 
 
@@ -38,12 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <vector>
 #include "./pgr_allpairs.hpp"
 #include "./johnson_driver.h"
-
-// #define DEBUG
-
-extern "C" {
 #include "./../../common/src/pgr_types.h"
-}
 
 // CREATE OR REPLACE FUNCTION pgr_johnson(edges_sql TEXT, directed BOOLEAN,
 void
@@ -54,48 +52,47 @@ do_pgr_johnson(
         Matrix_cell_t **return_tuples,
         size_t *return_count,
         char **err_msg) {
-  std::ostringstream log;
-  try {
-    if (total_tuples == 1) {
-      log << "Required: more than one tuple\n";
-      (*return_tuples) = NULL;
-      (*return_count) = 0;
-      *err_msg = strdup(log.str().c_str());
-      return;
-    }
-
-    graphType gType = directed? DIRECTED: UNDIRECTED;
-    const auto initial_size = total_tuples;
-
-    std::deque< Path >paths;
-
-    if (directed) {
-      log << "Working with directed Graph\n";
-      Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
-      digraph.graph_insert_data(data_edges, total_tuples);
-      pgr_johnson(digraph, *return_count, return_tuples);
-    } else {
-      log << "Working with Undirected Graph\n";
-      Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
-      undigraph.graph_insert_data(data_edges, total_tuples);
-      pgr_johnson(undigraph, *return_count, return_tuples);
-    }
-
-    if (*return_count == 0) {
-      log <<  "NOTICE: No Vertices found??? wiered error\n";
-      *err_msg = strdup(log.str().c_str());
-      (*return_tuples) = NULL;
-      (*return_count) = 0;
-      return;
+    std::ostringstream log;
+    try {
+        if (total_tuples == 1) {
+            log << "Required: more than one tuple\n";
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        graphType gType = directed? DIRECTED: UNDIRECTED;
+
+        std::deque< Path >paths;
+
+        if (directed) {
+            log << "Working with directed Graph\n";
+            pgrouting::DirectedGraph digraph(gType);
+            digraph.graph_insert_data(data_edges, total_tuples);
+            pgr_johnson(digraph, *return_count, return_tuples);
+        } else {
+            log << "Working with Undirected Graph\n";
+            pgrouting::UndirectedGraph undigraph(gType);
+            undigraph.graph_insert_data(data_edges, total_tuples);
+            pgr_johnson(undigraph, *return_count, return_tuples);
+        }
+
+        if (*return_count == 0) {
+            log <<  "NOTICE: No Vertices found??? wiered error\n";
+            *err_msg = strdup(log.str().c_str());
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            return;
+        }
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+    } catch ( ... ) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
     }
-
-    #ifndef DEBUG
-      *err_msg = strdup("OK");
-    #else
-      *err_msg = strdup(log.str().c_str());
-    #endif
-  } catch ( ... ) {
-    log << "Caught unknown expection!\n";
-    *err_msg = strdup(log.str().c_str());
-  }
 }
diff --git a/src/allpairs/src/johnson_driver.h b/src/allpairs/src/johnson_driver.h
index 8a64bf6..350d561 100644
--- a/src/allpairs/src/johnson_driver.h
+++ b/src/allpairs/src/johnson_driver.h
@@ -26,6 +26,8 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
+#ifndef SRC_ALLPAIRS_SRC_JOHNSON_DRIVER_H_
+#define SRC_ALLPAIRS_SRC_JOHNSON_DRIVER_H_
 
 #pragma once
 
@@ -49,3 +51,5 @@ do_pgr_johnson(
 #ifdef __cplusplus
 }
 #endif
+
+#endif  // SRC_ALLPAIRS_SRC_JOHNSON_DRIVER_H_
diff --git a/src/allpairs/src/pgr_allpairs.hpp b/src/allpairs/src/pgr_allpairs.hpp
index 3e79bff..3d9d1fe 100644
--- a/src/allpairs/src/pgr_allpairs.hpp
+++ b/src/allpairs/src/pgr_allpairs.hpp
@@ -26,28 +26,35 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #ifndef SRC_ALLPAIRS_SRC_PGR_ALLPAIRS_HPP_
 #define SRC_ALLPAIRS_SRC_PGR_ALLPAIRS_HPP_
-
-
-#include <deque>
-#include <vector>
-#include <set>
-#include <limits>
+#pragma once
+
+#if 0
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
+#endif
 
 #include <boost/config.hpp>
-
 #include <boost/graph/adjacency_list.hpp>
 #include <boost/property_map/property_map.hpp>
 #include <boost/graph/johnson_all_pairs_shortest.hpp>
 #include <boost/graph/floyd_warshall_shortest.hpp>
 
 
-extern "C" {
-#include "./../../common/src/pgr_types.h"
-}
+#include <deque>
+#include <vector>
+#include <set>
+#include <limits>
+
 
-#include "../../common/src/memory_func.hpp"
+#include "./../../common/src/pgr_types.h"
+#include "../../common/src/pgr_alloc.hpp"
 #include "./../../common/src/basePath_SSEC.hpp"
-#include "./../../common/src/baseGraph.hpp"
+#include "./../../common/src/pgr_base_graph.hpp"
 
 template < class G > class Pgr_allpairs;
 
@@ -92,7 +99,7 @@ pgr_floydWarshall(
 // template class
 template < class G >
 class Pgr_allpairs {
-    // defualt constructors and destructors
+    // default constructors and destructors
     /*
        Matrix_cell_t description:
        int64_t from_vid;
@@ -166,7 +173,7 @@ void Pgr_allpairs< G >::floydWarshall(
     boost::floyd_warshall_all_pairs_shortest_paths(
             graph.graph,
             matrix,
-            weight_map(get(&boost_edge_t::cost, graph.graph)).
+            weight_map(get(&pgrouting::Basic_edge::cost, graph.graph)).
             distance_combine(combine).
             distance_inf(std::numeric_limits<double>::max()).
             distance_zero(0));
@@ -185,7 +192,7 @@ void Pgr_allpairs< G >::floydWarshall(
     boost::floyd_warshall_all_pairs_shortest_paths(
             graph.graph,
             matrix,
-            weight_map(get(&boost_edge_t::cost, graph.graph)).
+            weight_map(get(&pgrouting::Basic_edge::cost, graph.graph)).
             distance_combine(combine).
             distance_inf(std::numeric_limits<double>::max()).
             distance_zero(0));
@@ -204,7 +211,7 @@ void Pgr_allpairs< G >::johnson(
     boost::johnson_all_pairs_shortest_paths(
             graph.graph,
             matrix,
-            weight_map(get(&boost_edge_t::cost, graph.graph)).
+            weight_map(get(&pgrouting::Basic_edge::cost, graph.graph)).
             distance_combine(combine).
             distance_inf(std::numeric_limits<double>::max()).
             distance_zero(0));
@@ -223,7 +230,7 @@ void Pgr_allpairs< G >::johnson(
     boost::johnson_all_pairs_shortest_paths(
             graph.graph,
             matrix,
-            weight_map(get(&boost_edge_t::cost, graph.graph)).
+            weight_map(get(&pgrouting::Basic_edge::cost, graph.graph)).
             distance_combine(combine).
             distance_inf(std::numeric_limits<double>::max()).
             distance_zero(0));
@@ -274,7 +281,7 @@ Pgr_allpairs< G >::make_result(
         size_t &result_tuple_count,
         Matrix_cell_t **postgres_rows) const {
     result_tuple_count = count_rows(graph, matrix);
-    *postgres_rows = get_memory(result_tuple_count, (*postgres_rows));
+    *postgres_rows = pgr_alloc(result_tuple_count, (*postgres_rows));
 
 
     size_t seq = 0;
diff --git a/src/allpairs/test/test.conf b/src/allpairs/test/test.conf
index 528a981..e004209 100644
--- a/src/allpairs/test/test.conf
+++ b/src/allpairs/test/test.conf
@@ -14,7 +14,7 @@
             doc-floydWarshall
             )]
     },
-# I dont know what this are for or how to use them.
+# I don't know what this are for or how to use them.
 #  TODO ask Steve 
 #    'vpg-vpgis' => {}, # for version specific tests
 #    '8-1' => {},       # for pg 8.x and postgis 1.x
diff --git a/src/alpha_shape/doc/doc-pgr_alphashape.queries b/src/alpha_shape/doc/doc-pgr_alphashape.queries
index ac290c7..54e10f7 100644
--- a/src/alpha_shape/doc/doc-pgr_alphashape.queries
+++ b/src/alpha_shape/doc/doc-pgr_alphashape.queries
@@ -5,16 +5,21 @@ FROM (SELECT ST_MakeLine(points ORDER BY id) AS openline FROM
 (SELECT ST_MakePoint(x, y) AS points, row_number() over() AS id
 FROM pgr_alphaShape('SELECT id, x, y FROM vertex_table')
 ) AS a) AS foo;
-ERROR:  relation "vertex_table" does not exist
-LINE 1: SELECT id, x, y FROM vertex_table
-                             ^
-QUERY:  SELECT id, x, y FROM vertex_table
+ st_area 
+---------
+   10.00
+(1 row)
+
 -----------------------------
 SELECT round(ST_Area(ST_MakePolygon(ST_AddPoint(foo.openline, ST_StartPoint(foo.openline))))::numeric, 2) AS st_area
 FROM (SELECT ST_MakeLine(points ORDER BY id) AS openline FROM
 (SELECT ST_MakePoint(x, y) AS points, row_number() over() AS id
 FROM pgr_alphaShape('SELECT id::integer, ST_X(the_geom)::float AS x, ST_Y(the_geom)::float AS y FROM edge_table_vertices_pgr')
 ) AS a) AS foo;
-ERROR:  current transaction is aborted, commands ignored until end of transaction block
+ st_area 
+---------
+   11.75
+(1 row)
+
 ROLLBACK;
 ROLLBACK
diff --git a/src/alpha_shape/src/CMakeLists.txt b/src/alpha_shape/src/CMakeLists.txt
index e11956d..4e67cb0 100644
--- a/src/alpha_shape/src/CMakeLists.txt
+++ b/src/alpha_shape/src/CMakeLists.txt
@@ -1,5 +1,5 @@
 ADD_LIBRARY(alpha_shape OBJECT
     alpha.c
-    alpha_drivedist.cpp
+    alpha_driver.cpp
  )
 
diff --git a/src/alpha_shape/src/alpha.c b/src/alpha_shape/src/alpha.c
index 108811e..4bebd1a 100644
--- a/src/alpha_shape/src/alpha.c
+++ b/src/alpha_shape/src/alpha.c
@@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "../../common/src/pgr_types.h"
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
@@ -31,106 +30,65 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "access/htup_details.h"
 #endif
 
-#include "alpha.h"
+#include "../../common/src/pgr_types.h"
+#include "alpha_driver.h"
 
 #include "fmgr.h"
 
 
-#ifndef PG_MODULE_MAGIC
-PG_MODULE_MAGIC;
-#endif
-
 /*
  * Define this to have profiling enabled
  */
-//#define PROFILE
-
-#ifdef PROFILE
-#include <sys/time.h>
-
-/*! \def MAX_NODES
-  \brief Maximal number of nodes in the path (to avoid infinite loops)
-*/
-#define MAX_NODES 1000000
-
-struct timeval prof_alpha, prof_store, prof_extract, prof_total;
-long proftime[5];
-long profipts1, profipts2, profopts;
-#define profstart(x) do { gettimeofday(&x, NULL); } while (0);
-#define profstop(n, x) do { struct timeval _profstop;   \
-        long _proftime;                         \
-        gettimeofday(&_profstop, NULL);                         \
-        _proftime = ( _profstop.tv_sec*1000000+_profstop.tv_usec) -     \
-                ( x.tv_sec*1000000+x.tv_usec); \
-        elog(NOTICE, \
-                "PRF(%s) %lu (%f ms)", \
-                (n), \
-             _proftime, _proftime / 1000.0);    \
-        } while (0);
-
-#else
-
-#define profstart(x) do { } while (0);
-#define profstop(n, x) do { } while (0);
-
-
-#endif // PROFILE
+// #define PROFILE
 
 
+PGDLLEXPORT
 Datum alphashape(PG_FUNCTION_ARGS);
 
 #undef DEBUG
-//#define DEBUG 1
 #include "../../common/src/debug_macro.h"
-    
+
 // The number of tuples to fetch from the SPI cursor at each iteration
 #define TUPLIMIT 1000
 
 static char *
-text2char(text *in)
-{
+text2char(text *in) {
   char *out = palloc(VARSIZE(in));
-    
+
   memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
   out[VARSIZE(in) - VARHDRSZ] = '\0';
   return out;
 }
 
 static int
-finish(int code, int ret)
-{
+finish(int code, int ret) {
   code = SPI_finish();
-  if (code  != SPI_OK_FINISH )
-  {
-    elog(ERROR,"couldn't disconnect from SPI");
-    return -1 ;
+  if (code  != SPI_OK_FINISH) {
+    elog(ERROR, "couldn't disconnect from SPI");
+    return -1;
   }
   return ret;
 }
-		  
 
-typedef struct vertex_columns 
-{
+
+typedef struct vertex_columns {
   int id;
   int x;
   int y;
-
 } vertex_columns_t;
 
 
 
 static int
-fetch_vertices_columns(SPITupleTable *tuptable, 
-                       vertex_columns_t *vertex_columns)
-{
+fetch_vertices_columns(SPITupleTable *tuptable,
+                       vertex_columns_t *vertex_columns) {
   vertex_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
   vertex_columns->x = SPI_fnumber(SPI_tuptable->tupdesc, "x");
   vertex_columns->y = SPI_fnumber(SPI_tuptable->tupdesc, "y");
 
   if (vertex_columns->id == SPI_ERROR_NOATTRIBUTE ||
       vertex_columns->x == SPI_ERROR_NOATTRIBUTE ||
-      vertex_columns->y == SPI_ERROR_NOATTRIBUTE) 
-    {
+      vertex_columns->y == SPI_ERROR_NOATTRIBUTE) {
       elog(ERROR, "Error, query must return columns "
            "'id', 'x' and 'y'");
       return -1;
@@ -138,20 +96,18 @@ fetch_vertices_columns(SPITupleTable *tuptable,
 
   if (SPI_gettypeid(SPI_tuptable->tupdesc, vertex_columns->id) != INT4OID ||
       SPI_gettypeid(SPI_tuptable->tupdesc, vertex_columns->x) != FLOAT8OID ||
-      SPI_gettypeid(SPI_tuptable->tupdesc, vertex_columns->y) != FLOAT8OID) 
-    {
-      elog(ERROR, 
+      SPI_gettypeid(SPI_tuptable->tupdesc, vertex_columns->y) != FLOAT8OID) {
+      elog(ERROR,
            "Error, column 'id' must be of type int4, 'x' and 'y' must be of type float8");
       return -1;
     }
-   
+
   return 0;
 }
 
 static void
-fetch_vertex(HeapTuple *tuple, TupleDesc *tupdesc, 
-             vertex_columns_t *vertex_columns, vertex_t *target_vertex)
-{
+fetch_vertex(HeapTuple *tuple, TupleDesc *tupdesc,
+             vertex_columns_t *vertex_columns, vertex_t *target_vertex) {
   Datum binval;
   bool isnull;
 
@@ -166,9 +122,7 @@ fetch_vertex(HeapTuple *tuple, TupleDesc *tupdesc,
   target_vertex->y = DatumGetFloat8(binval);
 }
 
-static int compute_alpha_shape(char* sql, float8 alpha, vertex_t **res, size_t *res_count)
-{
-
+static int compute_alpha_shape(char* sql, float8 alpha, vertex_t **res, size_t *res_count) {
   int SPIcode;
   void *SPIplan;
   Portal SPIportal;
@@ -176,40 +130,39 @@ static int compute_alpha_shape(char* sql, float8 alpha, vertex_t **res, size_t *
   uint32_t ntuples;
   vertex_t *vertices = NULL;
   uint32_t total_tuples = 0;
-  vertex_columns_t vertex_columns = {.id= -1, .x= -1, .y= -1};
+#ifndef _MSC_VER
+  vertex_columns_t vertex_columns = {.id = -1, .x = -1, .y = -1};
+#else   // _MSC_VER
+  vertex_columns_t vertex_columns = {-1, -1, -1};
+#endif  // _MSC_VER
   char *err_msg;
   int ret = -1;
 
   PGR_DBG("start alpha_shape\n");
-        
+
   SPIcode = SPI_connect();
-  if (SPIcode  != SPI_OK_CONNECT)
-    {
+  if (SPIcode  != SPI_OK_CONNECT) {
       elog(ERROR, "alpha_shape: couldn't open a connection to SPI");
       return -1;
     }
 
   SPIplan = SPI_prepare(sql, 0, NULL);
-  if (SPIplan  == NULL)
-    {
+  if (SPIplan  == NULL) {
       elog(ERROR, "alpha_shape: couldn't create query plan via SPI");
       return -1;
     }
 
-  if ((SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) 
-    {
+  if ((SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) {
       elog(ERROR, "alpha_shape: SPI_cursor_open('%s') returns NULL", sql);
       return -1;
     }
 
-  while (moredata == TRUE)
-    {
+  while (moredata == TRUE) {
       SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
 
-      if (vertex_columns.id == -1) 
-        {
+      if (vertex_columns.id == -1) {
           if (fetch_vertices_columns(SPI_tuptable, &vertex_columns) == -1)
-	    return finish(SPIcode, ret);
+        return finish(SPIcode, ret);
         }
 
       ntuples = SPI_processed;
@@ -219,99 +172,82 @@ static int compute_alpha_shape(char* sql, float8 alpha, vertex_t **res, size_t *
       else
         vertices = repalloc(vertices, total_tuples * sizeof(vertex_t));
 
-      if (vertices == NULL) 
-        {
+      if (vertices == NULL) {
           elog(ERROR, "Out of memory");
           return finish(SPIcode, ret);
         }
 
-      if (ntuples > 0) 
-        {
+      if (ntuples > 0) {
           uint32_t t;
           SPITupleTable *tuptable = SPI_tuptable;
           TupleDesc tupdesc = SPI_tuptable->tupdesc;
-                
-          for (t = 0; t < ntuples; t++) 
-            {
+
+          for (t = 0; t < ntuples; t++) {
               HeapTuple tuple = tuptable->vals[t];
-              fetch_vertex(&tuple, &tupdesc, &vertex_columns, 
+              fetch_vertex(&tuple, &tupdesc, &vertex_columns,
                            &vertices[total_tuples - ntuples + t]);
             }
           SPI_freetuptable(tuptable);
-        } 
-      else 
-        {
+        } else {
           moredata = FALSE;
         }
     }
 
 
   // if (total_tuples < 2) //this was the buggy code of the pgrouting project.
-  // TODO: report this as a bug to the pgrouting project
+  // TODO(someone): report this as a bug to the pgrouting project
   // the CGAL alpha-shape function crashes if called with less than three points!!!
 
   if (total_tuples < 3) {
-  	  elog(ERROR, "Less than 3 vertices. Alpha shape calculation needs at least 3 vertices.");
+      elog(ERROR, "Less than 3 vertices. Alpha shape calculation needs at least 3 vertices.");
       return finish(SPIcode, ret);
   }
   if (total_tuples == 1) {
-	  elog(ERROR, "Distance is too short. only 1 vertex for alpha shape calculation. alpha shape calculation needs at least 3 vertices.");
+      elog(ERROR, "Distance is too short. only 1 vertex for alpha shape calculation. alpha shape calculation needs at least 3 vertices.");
   }
   if (total_tuples == 2) {
-	  elog(ERROR, "Distance is too short. only 2 vertices for alpha shape calculation. alpha shape calculation needs at least 3 vertices.");
+      elog(ERROR, "Distance is too short. only 2 vertices for alpha shape calculation. alpha shape calculation needs at least 3 vertices.");
   }
-  if (total_tuples < 3)
-  {
+  if (total_tuples < 3) {
     // elog(ERROR, "Distance is too short ....");
     return finish(SPIcode, ret);
   }
 
   PGR_DBG("Calling CGAL alpha-shape\n");
-        
-  profstop("extract", prof_extract);
-  profstart(prof_alpha);
 
   ret = alpha_shape(vertices, total_tuples, alpha, res, res_count, &err_msg);
 
-  profstop("alpha", prof_alpha);
-  profstart(prof_store);
-
-  if (ret < 0)
-    {
-      //elog(ERROR, "Error computing shape: %s", err_msg);
+  if (ret < 0) {
+      // elog(ERROR, "Error computing shape: %s", err_msg);
       ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), errmsg("%s", err_msg)));
-    } 
-  
-  return finish(SPIcode, ret);    
+    }
+
+  return finish(SPIcode, ret);
 }
 
 PG_FUNCTION_INFO_V1(alphashape);
 
-Datum alphashape(PG_FUNCTION_ARGS)
-{
+PGDLLEXPORT
+Datum alphashape(PG_FUNCTION_ARGS) {
   FuncCallContext      *funcctx;
   uint32_t                  call_cntr;
   uint32_t                  max_calls;
   TupleDesc            tuple_desc;
   vertex_t     *res = 0;
-                    
+
   /* stuff done only on the first call of the function */
-  if (SRF_IS_FIRSTCALL())
-    {
+  if (SRF_IS_FIRSTCALL()) {
       MemoryContext   oldcontext;
       size_t res_count;
-                            
-      // XXX profiling messages are not thread safe
-      profstart(prof_total);
-      profstart(prof_extract);
-                                            
+
+
       /* create a function context for cross-call persistence */
       funcctx = SRF_FIRSTCALL_INIT();
-                                                                    
+
       /* switch to memory context appropriate for multiple function calls */
       oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
-      compute_alpha_shape(text2char(PG_GETARG_TEXT_P(0)), 
+      compute_alpha_shape(text2char(PG_GETARG_TEXT_P(0)),
                                 PG_GETARG_FLOAT8(1), &res, &res_count);
 
       /* total number of tuples to be returned */
@@ -319,7 +255,7 @@ Datum alphashape(PG_FUNCTION_ARGS)
       funcctx->max_calls = (uint32_t)res_count;
       funcctx->user_fctx = res;
 
-      PGR_DBG("Total count %i", res_count);
+      PGR_DBG("Total count %lu", res_count);
 
       if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
         ereport(ERROR,
@@ -343,16 +279,16 @@ Datum alphashape(PG_FUNCTION_ARGS)
 
   PGR_DBG("Trying to allocate some memory\n");
 
-  if (call_cntr < max_calls)    /* do when there is more left to send */
-    {
+  if (call_cntr < max_calls) {
+      /* do when there is more left to send */
       HeapTuple    tuple;
       Datum        result;
       Datum *values;
-      char* nulls;
+      bool* nulls;
       double x;
       double y;
 
-      /* This will work for some compilers. If it crashes with segfault, try to change the following block with this one    
+      /* This will work for some compilers. If it crashes with segfault, try to change the following block with this one
 
       values = palloc(3 * sizeof(Datum));
       nulls = palloc(3 * sizeof(char));
@@ -364,27 +300,24 @@ Datum alphashape(PG_FUNCTION_ARGS)
       values[2] = Float8GetDatum(res[call_cntr].y);
       nulls[2] = ' ';
       */
-    
+
       values = palloc(2 * sizeof(Datum));
       nulls = palloc(2 * sizeof(bool));
 
       x = res[call_cntr].x;
       y = res[call_cntr].y;
-      if (x == DBL_MAX && y == DBL_MAX)
-      {
+      if (x == DBL_MAX && y == DBL_MAX) {
         values[0] = 0;
         values[1] = 0;
         nulls[0] = true;
         nulls[1] = true;
-      }
-      else
-      {
+      } else {
         values[0] = Float8GetDatum(x);
         values[1] = Float8GetDatum(y);
         nulls[0] = false;
         nulls[1] = false;
       }
-	
+
       PGR_DBG("Heap making\n");
 
       tuple = heap_form_tuple(tuple_desc, values, nulls);
@@ -401,15 +334,9 @@ Datum alphashape(PG_FUNCTION_ARGS)
       pfree(nulls);
 
       SRF_RETURN_NEXT(funcctx, result);
-    }
-  else    /* do when there is no more left */
-    {
+    } else  {
+      /* do when there is no more left */
       if (res) free(res);
-      profstop("store", prof_store);
-      profstop("total", prof_total);
-#ifdef PROFILE
-      elog(NOTICE, "_________");
-#endif
       SRF_RETURN_DONE(funcctx);
     }
 }
diff --git a/src/alpha_shape/src/alpha_drivedist.cpp b/src/alpha_shape/src/alpha_drivedist.cpp
deleted file mode 100644
index 58046d5..0000000
--- a/src/alpha_shape/src/alpha_drivedist.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-/*PGR-GNU*****************************************************************
-File: alpha_drivedist.cpp 
-
-Copyright (c) 2006 Anton A. Patrushev, Orkney, Inc.
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-/*
- * As a special exception, you have permission to link this program
- * with the CGAL library and distribute executables, as long as you
- * follow the requirements of the GNU GPL in regard to all of the
- * software in the executable aside from CGAL.
- *
- */
-
-
-/***********************************************************************
-Takes a list of points and returns a list of segments 
-corresponding to the Alpha shape.
-************************************************************************/
-#ifdef __MINGW32__
-#include <winsock2.h>
-#include <windows.h>
-#endif
-#ifdef __MINGW64__
-namespace boost {
-  void tss_cleanup_implemented() { }
-}
-#endif
-#include <CGAL/Simple_cartesian.h>
-#include <CGAL/Filtered_kernel.h>
-#include <CGAL/algorithm.h>
-
-#include <vector>
-#include <list>
-#include <cmath>
-
-#include "alpha.h"
-
-#include <CGAL/Polygon_2.h>
-#include <CGAL/Delaunay_triangulation_2.h>
-#include <CGAL/Triangulation_2.h>
-#include <CGAL/Triangulation_hierarchy_vertex_base_2.h>
-#include <CGAL/Triangulation_hierarchy_2.h>
-#include <CGAL/Triangulation_face_base_2.h>
-#include <CGAL/Triangulation_euclidean_traits_2.h>
-#include <CGAL/Alpha_shape_2.h>
-#include <CGAL/Alpha_shape_face_base_2.h>
-#include <CGAL/Alpha_shape_vertex_base_2.h>
-
-
-typedef double coord_type;
-
-typedef CGAL::Simple_cartesian<coord_type>  SC;
-typedef CGAL::Filtered_kernel<SC> K;
-typedef K::Point_2  Point;
-typedef K::Segment_2  Segment;
-typedef K::Vector_2 Vector;
-typedef CGAL::Polygon_2<K> Polygon_2;
-
-typedef CGAL::Alpha_shape_vertex_base_2<K> Avb;
-typedef CGAL::Triangulation_hierarchy_vertex_base_2<Avb> Av;
-
-typedef CGAL::Triangulation_face_base_2<K> Tf;
-typedef CGAL::Alpha_shape_face_base_2<K,Tf> Af;
-
-typedef CGAL::Triangulation_default_data_structure_2<K,Av,Af> Tds;
-typedef CGAL::Delaunay_triangulation_2<K,Tds> Dt;
-typedef CGAL::Triangulation_hierarchy_2<Dt> Ht;
-typedef CGAL::Alpha_shape_2<Ht> Alpha_shape_2;
-
-typedef Alpha_shape_2::Face_circulator  Face_circulator;
-typedef Alpha_shape_2::Vertex_circulator  Vertex_circulator;
-
-typedef Alpha_shape_2::Alpha_iterator Alpha_iterator;
-typedef Alpha_shape_2::Alpha_shape_edges_iterator Alpha_shape_edges_iterator;
-
-//---------------------------------------------------------------------
-
-double get_angle(Point p, Point q, Point r)
-{
-  double m_pi(3.14159265358979323846);
-  Vector v1(q, p);
-  Vector v2(q, r);
-  double cross = v1.x() * v2.y() - v1.y() * v2.x();
-  double dot = v1.x() * v2.x() + v1.y() * v2.y();
-  double angle = atan2(cross, dot);
-  if (angle < 0.0) {
-    angle += 2 * m_pi;
-  }
-  return angle;
-}
-
-size_t prev_size = 0;
-void find_next_edge(Segment s, std::vector<Segment>& segments, 
-                    std::set<int>& unusedIndexes, std::vector<Polygon_2>& rings)
-{
-  if(unusedIndexes.empty()
-    || prev_size == unusedIndexes.size())
-  {
-    return;
-  }
-  
-  prev_size = unusedIndexes.size();
-  
-  Point start = s.source();
-  Point end = s.target();
-  rings.back().push_back(end);
-  
-  std::vector<int> nextIndexes;
-  for(unsigned int i = 0;i < segments.size(); i++)
-  {
-    if (unusedIndexes.find(i) != unusedIndexes.end())
-    {
-      Point source = segments.at(i).source();
-      if(source == end)
-      {
-        nextIndexes.push_back(i);
-      }
-    }
-  }
-  if (nextIndexes.size() == 1)
-  {
-    int i = nextIndexes.at(0);
-    unusedIndexes.erase(i);
-    find_next_edge(segments.at(i), segments, unusedIndexes, rings);
-  }
-  else if (nextIndexes.size() > 1)
-  {
-    std::vector< std::pair<double, int> > nextAngles;
-    for (unsigned int i = 0; i < nextIndexes.size(); i++)
-    {
-      int j = nextIndexes.at(i);
-      Point target = segments.at(j).target();
-      double angle = get_angle(start, end, target);
-      nextAngles.push_back(std::pair<double, int>(angle, j));
-    }
-    std::sort(nextAngles.begin(), nextAngles.end());
-    int i = nextAngles.begin()->second;
-    unusedIndexes.erase(i);
-    find_next_edge(segments.at(i), segments, unusedIndexes, rings);
-  }
-  
-  if (!unusedIndexes.empty())
-  {
-    for (unsigned int i = 0; i < segments.size(); i++)
-    {
-      if (unusedIndexes.find(i) != unusedIndexes.end())
-      {
-        Polygon_2 ring;
-        ring.push_back(segments.at(i).source());
-        rings.push_back(ring);
-        unusedIndexes.erase(i);
-        find_next_edge(segments.at(i), segments, unusedIndexes, rings);
-      }
-    }
-  }
-}
-
-template <class OutputIterator>
-void
-alpha_edges( const Alpha_shape_2&  A,
-             OutputIterator out)
-{ 
-
-  for(Alpha_shape_edges_iterator it =  A.alpha_shape_edges_begin();
-      it != A.alpha_shape_edges_end();
-      ++it){
-    *out++ = A.segment(*it);
-  }
-}
-
-
-int alpha_shape(vertex_t *vertices, size_t count, double alpha,
-                vertex_t **res, size_t *res_count, char **err_msg)
-{
-    try {
-  std::list<Point> points;
-
-  {
-    std::vector<Point> pv;
-
-    for (std::size_t j = 0; j < count; ++j) {
-        Point p(vertices[j].x, vertices[j].y);
-        pv.push_back(p);
-    }
-
-    std::sort(pv.begin(), pv.end(),
-        [](const Point &e1, const Point &e2)->bool {
-        return e2.y() < e1.y();
-        });
-    std::stable_sort(pv.begin(), pv.end(),
-        [](const Point &e1, const Point &e2)->bool {
-        return e2.x() < e1.x();
-        });
-    pv.erase(std::unique(pv.begin(), pv.end()), pv.end());
-    if (pv.size() != count &&  pv.size() < 3) {
-        *err_msg = strdup("After eliminating duplicated points, less than 3 points remain!!. Alpha shape calculation needs at least 3 vertices.");
-        return -1;
-    }
-    points.insert(points.begin(), pv.begin(), pv.end());
-  }
-
-  Alpha_shape_2 A(points.begin(), points.end(),
-                  coord_type(10000),
-                  Alpha_shape_2::REGULARIZED);
-  
-  std::vector<Segment> segments;
-//  std::vector<Segment> result;
-
-//  Alpha_shape_2::Alpha_shape_vertices_iterator vit;
-//  Alpha_shape_2::Vertex_handle vertex;
-//  Alpha_shape_2::Alpha_shape_edges_iterator eit;
-//  Alpha_shape_2::Edge edge;
-//  Alpha_shape_2::Face_iterator fit;
-//  Alpha_shape_2::Face_handle face;
-  
-  if (alpha <= 0.0)
-  {
-    alpha = *A.find_optimal_alpha(1);
-  }
-  A.set_alpha(alpha);
-
-  alpha_edges( A, std::back_inserter(segments));
-
-//  Segment s = segments.at(0);
-//  find_next_edge(s, segments, result);
-  if (segments.empty())
-  {
-    *res = NULL;
-    *res_count = 0;
-  }
-  else
-  {
-    std::set<int> unusedIndexes;
-    for (unsigned int i = 0; i < segments.size(); i++)
-    {
-      unusedIndexes.insert(i);
-    }
-    
-    std::vector<Polygon_2> rings;
-    Polygon_2 ring;
-    ring.push_back(segments.at(0).source());
-    rings.push_back(ring);
-    unusedIndexes.erase(0);
-    find_next_edge(segments.at(0), segments, unusedIndexes, rings);
-
-    size_t result_count = 0;
-    for (unsigned int i = 0; i < rings.size(); i++)
-    {
-      Polygon_2 ring = rings.at(i);
-      result_count += ring.size();
-    }
-    result_count += rings.size() - 1;
-    *res = (vertex_t *) malloc(sizeof(vertex_t) * result_count);
-    *res_count = result_count;
-
-    int idx = 0;
-    for (unsigned int i = 0; i < rings.size(); i++)
-    {
-      if (i > 0)
-      {
-        (*res)[idx].x = DBL_MAX;
-        (*res)[idx].y = DBL_MAX;
-        idx++;
-      }
-      Polygon_2 ring = rings.at(i);
-      for(unsigned int j = 0; j < ring.size(); j++)
-      {
-        Point point = ring.vertex(j);
-        (*res)[idx].x = point.x();
-        (*res)[idx].y = point.y();
-        idx++;
-      }
-    }
-  }
-  *err_msg = NULL;
-
-  return EXIT_SUCCESS;
-    } catch ( ... ) {
-        *err_msg = strdup("Caught unknown expection!");
-    }
-        return -1;
-
-}
diff --git a/src/alpha_shape/src/alpha_driver.cpp b/src/alpha_shape/src/alpha_driver.cpp
new file mode 100644
index 0000000..0e9e151
--- /dev/null
+++ b/src/alpha_shape/src/alpha_driver.cpp
@@ -0,0 +1,279 @@
+/*PGR-GNU*****************************************************************
+File: alpha_drivedist.cpp
+
+Copyright (c) 2006 Anton A. Patrushev, Orkney, Inc.
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+/*
+ * As a special exception, you have permission to link this program
+ * with the CGAL library and distribute executables, as long as you
+ * follow the requirements of the GNU GPL in regard to all of the
+ * software in the executable aside from CGAL.
+ *
+ */
+
+
+/***********************************************************************
+Takes a list of points and returns a list of segments
+corresponding to the Alpha shape.
+************************************************************************/
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+#ifdef __MINGW64__
+
+
+namespace boost {
+  void tss_cleanup_implemented() { }
+}
+#endif
+#include "./alpha_driver.h"
+
+#include <CGAL/Simple_cartesian.h>
+#include <CGAL/Filtered_kernel.h>
+#include <CGAL/algorithm.h>
+
+#include <CGAL/Polygon_2.h>
+#include <CGAL/Delaunay_triangulation_2.h>
+#include <CGAL/Triangulation_2.h>
+#include <CGAL/Triangulation_hierarchy_vertex_base_2.h>
+#include <CGAL/Triangulation_hierarchy_2.h>
+#include <CGAL/Triangulation_face_base_2.h>
+#include <CGAL/Triangulation_euclidean_traits_2.h>
+#include <CGAL/Alpha_shape_2.h>
+#include <CGAL/Alpha_shape_face_base_2.h>
+#include <CGAL/Alpha_shape_vertex_base_2.h>
+
+#include <vector>
+#include <list>
+#include <cmath>
+#include <utility>
+#include <algorithm>
+#include <set>
+
+
+typedef double coord_type;
+
+typedef CGAL::Simple_cartesian<coord_type>  SC;
+typedef CGAL::Filtered_kernel<SC> K;
+typedef K::Point_2  Point;
+typedef K::Segment_2  Segment;
+typedef K::Vector_2 Vector;
+typedef CGAL::Polygon_2<K> Polygon_2;
+
+typedef CGAL::Alpha_shape_vertex_base_2<K> Avb;
+typedef CGAL::Triangulation_hierarchy_vertex_base_2<Avb> Av;
+
+typedef CGAL::Triangulation_face_base_2<K> Tf;
+typedef CGAL::Alpha_shape_face_base_2<K, Tf> Af;
+
+typedef CGAL::Triangulation_default_data_structure_2<K, Av, Af> Tds;
+typedef CGAL::Delaunay_triangulation_2<K, Tds> Dt;
+typedef CGAL::Triangulation_hierarchy_2<Dt> Ht;
+typedef CGAL::Alpha_shape_2<Ht> Alpha_shape_2;
+
+typedef Alpha_shape_2::Face_circulator  Face_circulator;
+typedef Alpha_shape_2::Vertex_circulator  Vertex_circulator;
+
+typedef Alpha_shape_2::Alpha_iterator Alpha_iterator;
+typedef Alpha_shape_2::Alpha_shape_edges_iterator Alpha_shape_edges_iterator;
+
+// ---------------------------------------------------------------------
+
+double get_angle(Point p, Point q, Point r) {
+    double m_pi(3.14159265358979323846);
+    Vector v1(q, p);
+    Vector v2(q, r);
+    double cross = v1.x() * v2.y() - v1.y() * v2.x();
+    double dot = v1.x() * v2.x() + v1.y() * v2.y();
+    double angle = atan2(cross, dot);
+    if (angle < 0.0) {
+        angle += 2 * m_pi;
+    }
+    return angle;
+}
+
+size_t prev_size = 0;
+void find_next_edge(Segment s, std::vector<Segment>& segments,
+        std::set<int>& unusedIndexes, std::vector<Polygon_2>& rings) {
+    if (unusedIndexes.empty()
+            || prev_size == unusedIndexes.size()) {
+        return;
+    }
+
+    prev_size = unusedIndexes.size();
+
+    Point start = s.source();
+    Point end = s.target();
+    rings.back().push_back(end);
+
+    std::vector<int> nextIndexes;
+    for (unsigned int i = 0; i < segments.size(); i++) {
+        if (unusedIndexes.find(i) != unusedIndexes.end()) {
+            Point source = segments.at(i).source();
+            if (source == end) {
+                nextIndexes.push_back(i);
+            }
+        }
+    }
+    if (nextIndexes.size() == 1) {
+        int i = nextIndexes.at(0);
+        unusedIndexes.erase(i);
+        find_next_edge(segments.at(i), segments, unusedIndexes, rings);
+    } else if (nextIndexes.size() > 1) {
+        std::vector< std::pair<double, int> > nextAngles;
+        for (unsigned int i = 0; i < nextIndexes.size(); i++) {
+            int j = nextIndexes.at(i);
+            Point target = segments.at(j).target();
+            double angle = get_angle(start, end, target);
+            nextAngles.push_back(std::pair<double, int>(angle, j));
+        }
+        std::sort(nextAngles.begin(), nextAngles.end());
+        int i = nextAngles.begin()->second;
+        unusedIndexes.erase(i);
+        find_next_edge(segments.at(i), segments, unusedIndexes, rings);
+    }
+
+    if (!unusedIndexes.empty()) {
+        for (unsigned int i = 0; i < segments.size(); i++) {
+            if (unusedIndexes.find(i) != unusedIndexes.end()) {
+                Polygon_2 ring;
+                ring.push_back(segments.at(i).source());
+                rings.push_back(ring);
+                unusedIndexes.erase(i);
+                find_next_edge(segments.at(i), segments, unusedIndexes, rings);
+            }
+        }
+    }
+}
+
+template <class OutputIterator>
+void
+alpha_edges(const Alpha_shape_2& A,
+        OutputIterator out) {
+    for (Alpha_shape_edges_iterator it =  A.alpha_shape_edges_begin();
+            it != A.alpha_shape_edges_end();
+            ++it) {
+        *out++ = A.segment(*it);
+    }
+}
+
+
+int alpha_shape(vertex_t *vertices, size_t count, double alpha,
+        vertex_t **res, size_t *res_count, char **err_msg) {
+    try {
+        std::list<Point> points;
+        {
+            std::vector<Point> pv;
+
+            for (std::size_t j = 0; j < count; ++j) {
+                Point p(vertices[j].x, vertices[j].y);
+                pv.push_back(p);
+            }
+
+            std::sort(pv.begin(), pv.end(),
+                    [](const Point &e1, const Point &e2)->bool {
+                    return e2.y() < e1.y();
+                    });
+            std::stable_sort(pv.begin(), pv.end(),
+                    [](const Point &e1, const Point &e2)->bool {
+                    return e2.x() < e1.x();
+                    });
+            pv.erase(std::unique(pv.begin(), pv.end()), pv.end());
+            if (pv.size() != count &&  pv.size() < 3) {
+                *err_msg = strdup("After eliminating duplicated points, less than 3 points remain!!. Alpha shape calculation needs at least 3 vertices.");
+                return -1;
+            }
+            points.insert(points.begin(), pv.begin(), pv.end());
+        }
+
+        Alpha_shape_2 A(points.begin(), points.end(),
+                coord_type(10000),
+                Alpha_shape_2::REGULARIZED);
+
+        std::vector<Segment> segments;
+        //  std::vector<Segment> result;
+
+        //  Alpha_shape_2::Alpha_shape_vertices_iterator vit;
+        //  Alpha_shape_2::Vertex_handle vertex;
+        //  Alpha_shape_2::Alpha_shape_edges_iterator eit;
+        //  Alpha_shape_2::Edge edge;
+        //  Alpha_shape_2::Face_iterator fit;
+        //  Alpha_shape_2::Face_handle face;
+
+        if (alpha <= 0.0) {
+            alpha = *A.find_optimal_alpha(1);
+        }
+        A.set_alpha(alpha);
+
+        alpha_edges(A, std::back_inserter(segments));
+
+        //  Segment s = segments.at(0);
+        //  find_next_edge(s, segments, result);
+        if (segments.empty()) {
+            *res = NULL;
+            *res_count = 0;
+        } else {
+            std::set<int> unusedIndexes;
+            for (unsigned int i = 0; i < segments.size(); i++) {
+                unusedIndexes.insert(i);
+            }
+
+            std::vector<Polygon_2> rings;
+            Polygon_2 ring;
+            ring.push_back(segments.at(0).source());
+            rings.push_back(ring);
+            unusedIndexes.erase(0);
+            find_next_edge(segments.at(0), segments, unusedIndexes, rings);
+
+            size_t result_count = 0;
+            for (unsigned int i = 0; i < rings.size(); i++) {
+                Polygon_2 ring = rings.at(i);
+                result_count += ring.size();
+            }
+            result_count += rings.size() - 1;
+            *res = (vertex_t *) malloc(sizeof(vertex_t) * result_count);
+            *res_count = result_count;
+
+            int idx = 0;
+            for (unsigned int i = 0; i < rings.size(); i++) {
+                if (i > 0) {
+                    (*res)[idx].x = DBL_MAX;
+                    (*res)[idx].y = DBL_MAX;
+                    idx++;
+                }
+                Polygon_2 ring = rings.at(i);
+                for (unsigned int j = 0; j < ring.size(); j++) {
+                    Point point = ring.vertex(j);
+                    (*res)[idx].x = point.x();
+                    (*res)[idx].y = point.y();
+                    idx++;
+                }
+            }
+        }
+        *err_msg = NULL;
+
+        return EXIT_SUCCESS;
+    } catch ( ... ) {
+        *err_msg = strdup("Caught unknown exception!");
+    }
+    return -1;
+}
diff --git a/src/alpha_shape/src/alpha.h b/src/alpha_shape/src/alpha_driver.h
similarity index 82%
rename from src/alpha_shape/src/alpha.h
rename to src/alpha_shape/src/alpha_driver.h
index 259d0f5..38f23a5 100644
--- a/src/alpha_shape/src/alpha.h
+++ b/src/alpha_shape/src/alpha_driver.h
@@ -22,26 +22,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#define _ALPHA_H
+#ifndef SRC_ALPHA_SHAPE_SRC_ALPHA_DRIVER_H_
+#define SRC_ALPHA_SHAPE_SRC_ALPHA_DRIVER_H_
+#pragma once
+
+#include <stddef.h>
 
-#ifdef __MINGW64__
-#define ELOG_H
-#endif
-#include "postgres.h"
 #include "../../common/src/pgr_types.h"
 
-typedef struct vertex
-{
-  float8 x;
-  float8 y;
+typedef struct vertex {
+  double x;
+  double y;
 } vertex_t;
 
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
-                                                                     
+
   int alpha_shape(vertex_t *vertices, size_t count, double alpha,
                   vertex_t **res, size_t *res_count, char **err_msg);
 
@@ -49,4 +47,5 @@ extern "C"
 }
 #endif
 
-                                        
+
+#endif  // SRC_ALPHA_SHAPE_SRC_ALPHA_DRIVER_H_
diff --git a/src/apsp_johnson/doc/doc-apspJohnson.queries b/src/apsp_johnson/doc/doc-apspJohnson.queries
index 9b67e2d..27bce4b 100644
--- a/src/apsp_johnson/doc/doc-apspJohnson.queries
+++ b/src/apsp_johnson/doc/doc-apspJohnson.queries
@@ -1,3 +1,5 @@
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_apspJohnson(
         'SELECT source::INTEGER, target::INTEGER, cost FROM edge_table WHERE id < 5'
diff --git a/src/apsp_johnson/doc/pgr_apspJohnson.rst b/src/apsp_johnson/doc/pgr_apspJohnson.rst
index 24819ff..adbba2e 100644
--- a/src/apsp_johnson/doc/pgr_apspJohnson.rst
+++ b/src/apsp_johnson/doc/pgr_apspJohnson.rst
@@ -9,19 +9,20 @@
 
 .. _pgr_apsp_johnson:
 
-pgr_apspJohnson
+pgr_apspJohnson - Deprecated function
 ===============================================================================
 
-.. index::
-    single: pgr_apspJohnson(text) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * It has been replaced by a new functions, is no longer supported, and may be removed from future versions.
+    * All code that uses this function should be converted to use its replacement: :ref:`pgr_johnson`. 
+
 
 Name
 -------------------------------------------------------------------------------
 
 ``pgr_apspJohnson`` - Returns all costs for each pair of nodes in the graph.
 
-.. warning:: This function is deprecated in version 2.2
-             Use :ref:`pgr_johnson` instead
 
 Synopsis
 -------------------------------------------------------------------------------
diff --git a/src/apsp_johnson/test/doc-apspJohnson.test.sql b/src/apsp_johnson/test/doc-apspJohnson.test.sql
index 1d48764..6e471cf 100644
--- a/src/apsp_johnson/test/doc-apspJohnson.test.sql
+++ b/src/apsp_johnson/test/doc-apspJohnson.test.sql
@@ -3,6 +3,7 @@
 --              PGR_apspJohnson
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
+SET client_min_messages TO NOTICE;
 \echo --q1
 SELECT * FROM pgr_apspJohnson(
         'SELECT source::INTEGER, target::INTEGER, cost FROM edge_table WHERE id < 5'
diff --git a/src/apsp_warshall/doc/doc-apspWarshall.queries b/src/apsp_warshall/doc/doc-apspWarshall.queries
index 981e712..2352af3 100644
--- a/src/apsp_warshall/doc/doc-apspWarshall.queries
+++ b/src/apsp_warshall/doc/doc-apspWarshall.queries
@@ -1,3 +1,5 @@
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_apspWarshall(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table WHERE id < 5',
diff --git a/src/apsp_warshall/doc/pgr_apspWarshall.rst b/src/apsp_warshall/doc/pgr_apspWarshall.rst
index a0c2ea5..d246362 100644
--- a/src/apsp_warshall/doc/pgr_apspWarshall.rst
+++ b/src/apsp_warshall/doc/pgr_apspWarshall.rst
@@ -9,21 +9,20 @@
 
 .. _pgr_apsp_warshall:
 
-pgr_apspWarshall
+pgr_apspWarshall - Deprecated Function
 ===============================================================================
 
-.. index::
-    single: pgr_apspWarshall(text, boolean, boolean) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * It has been replaced by a new function, is no longer supported, and may be removed from future versions.
+    * All code that uses this function should be converted to use its replacement: :ref:`pgr_FloydWarshall`. 
+
 
 Name
 -------------------------------------------------------------------------------
 
 ``pgr_apspWarshall`` - Returns all costs for each pair of nodes in the graph.
 
-.. warning:: This function is deprecated in version 2.2
-             Use :ref:`pgr_floydWarshall` instead
-
-
 
 Synopsis
 -------------------------------------------------------------------------------
diff --git a/src/apsp_warshall/test/doc-apspWarshall.test.sql b/src/apsp_warshall/test/doc-apspWarshall.test.sql
index 892e55f..e6e8095 100644
--- a/src/apsp_warshall/test/doc-apspWarshall.test.sql
+++ b/src/apsp_warshall/test/doc-apspWarshall.test.sql
@@ -3,6 +3,7 @@
 --              PGR_apspWarshall
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
+SET client_min_messages TO NOTICE;
 \echo --q1
 SELECT * FROM pgr_apspWarshall(
         'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table WHERE id < 5',
diff --git a/src/astar/CMakeLists.txt b/src/astar/CMakeLists.txt
deleted file mode 100644
index 329e02c..0000000
--- a/src/astar/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-#MESSAGE("core/astar: ${PACKAGE_SQL_FILES}")
-SUBDIRS(doc src test)
diff --git a/src/astar/doc/doc-astar.queries b/src/astar/doc/doc-astar-v2.queries
similarity index 69%
copy from src/astar/doc/doc-astar.queries
copy to src/astar/doc/doc-astar-v2.queries
index 382d0a9..8ad9d5c 100644
--- a/src/astar/doc/doc-astar.queries
+++ b/src/astar/doc/doc-astar-v2.queries
@@ -1,9 +1,11 @@
-BEGIN;
-BEGIN
---q1
+SET client_min_messages TO NOTICE;
+SET
+-- q1
 SELECT * FROM pgr_AStar(
-    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2 FROM edge_table',
+    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2
+     FROM edge_table',
     4, 1, false, false);
+NOTICE:  Deprecated signature of function pgr_astar
  seq | id1 | id2 | cost 
 -----+-----+-----+------
    0 |   4 |  16 |    1
@@ -14,10 +16,12 @@ SELECT * FROM pgr_AStar(
    5 |   1 |  -1 |    0
 (6 rows)
 
---q2
+-- q2
 SELECT * FROM pgr_AStar(
-    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2, reverse_cost FROM edge_table ',
+    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2, reverse_cost
+      FROM edge_table ',
     4, 1, true, true);
+NOTICE:  Deprecated signature of function pgr_astar
  seq | id1 | id2 | cost 
 -----+-----+-----+------
    0 |   4 |   3 |    1
@@ -26,6 +30,4 @@ SELECT * FROM pgr_AStar(
    3 |   1 |  -1 |    0
 (4 rows)
 
---q3
-ROLLBACK;
-ROLLBACK
+-- q3
diff --git a/src/astar/doc/doc-astar.queries b/src/astar/doc/doc-astar.queries
index 382d0a9..47f8f39 100644
--- a/src/astar/doc/doc-astar.queries
+++ b/src/astar/doc/doc-astar.queries
@@ -1,31 +1,55 @@
-BEGIN;
-BEGIN
+SET client_min_messages TO NOTICE;
+SET
 --q1
-SELECT * FROM pgr_AStar(
-    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2 FROM edge_table',
-    4, 1, false, false);
- seq | id1 | id2 | cost 
------+-----+-----+------
-   0 |   4 |  16 |    1
-   1 |   9 |   9 |    1
-   2 |   6 |   8 |    1
-   3 |   5 |   4 |    1
-   4 |   2 |   1 |    1
-   5 |   1 |  -1 |    0
-(6 rows)
+SELECT * FROM pgr_astar(
+    'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    2 |    4 |    1 |        0
+   2 |        2 |    5 |    8 |    1 |        1
+   3 |        3 |    6 |    9 |    1 |        2
+   4 |        4 |    9 |   15 |    1 |        3
+   5 |        5 |   12 |   -1 |    0 |        4
+(5 rows)
 
 --q2
-SELECT * FROM pgr_AStar(
-    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2, reverse_cost FROM edge_table ',
-    4, 1, true, true);
+SELECT * FROM pgr_astar(
+    'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12, heuristic := 1);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    2 |    4 |    1 |        0
+   2 |        2 |    5 |    8 |    1 |        1
+   3 |        3 |    6 |    9 |    1 |        2
+   4 |        4 |    9 |   15 |    1 |        3
+   5 |        5 |   12 |   -1 |    0 |        4
+(5 rows)
+
+SELECT * FROM pgr_astar(
+    'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12, heuristic := 2);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    2 |    4 |    1 |        0
+   2 |        2 |    5 |    8 |    1 |        1
+   3 |        3 |    6 |    9 |    1 |        2
+   4 |        4 |    9 |   15 |    1 |        3
+   5 |        5 |   12 |   -1 |    0 |        4
+(5 rows)
+
+--q3
+SELECT * FROM pgr_astar(
+    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12, true, true);
+NOTICE:  Deprecated signature of function pgr_astar
  seq | id1 | id2 | cost 
 -----+-----+-----+------
-   0 |   4 |   3 |    1
-   1 |   3 |   2 |    1
-   2 |   2 |   1 |    1
-   3 |   1 |  -1 |    0
-(4 rows)
+   0 |   2 |   4 |    1
+   1 |   5 |   8 |    1
+   2 |   6 |   9 |    1
+   3 |   9 |  15 |    1
+   4 |  12 |  -1 |    0
+(5 rows)
 
---q3
-ROLLBACK;
-ROLLBACK
+--q4
diff --git a/src/astar/doc/pgr_astar.rst b/src/astar/doc/pgr_astar-v2.rst
similarity index 84%
copy from src/astar/doc/pgr_astar.rst
copy to src/astar/doc/pgr_astar-v2.rst
index b974a3d..390184e 100644
--- a/src/astar/doc/pgr_astar.rst
+++ b/src/astar/doc/pgr_astar-v2.rst
@@ -7,13 +7,16 @@
     Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
    ****************************************************************************
 
-.. _pgr_astar:
+.. _pgr_astar-V2.0:
 
-pgr_astar - Shortest Path A*
+pgr_astar - Deprecated Signature
 ===============================================================================
 
-.. index:: 
-	single: pgr_astar(text, integer, integer, boolean, boolean)
+.. warning:: This function signature is deprecated!!!
+
+    * That means it has been replaced by new signature(s)
+    * This signature is no longer supported, and may be removed from future versions.
+    * All code that use this function signature should be converted to use its replacement :ref:`pgr_astar`.
 
 Name
 -------------------------------------------------------------------------------
@@ -21,6 +24,7 @@ Name
 ``pgr_astar`` — Returns the shortest path using A* algorithm.
 
 
+
 Synopsis
 -------------------------------------------------------------------------------
 
@@ -75,15 +79,15 @@ Examples
 
 * Without ``reverse_cost``
 
-.. literalinclude:: doc-astar.queries
-   :start-after: --q1
-   :end-before: --q2
+.. literalinclude:: doc-astar-v2.queries
+   :start-after: -- q1
+   :end-before: -- q2
 
 * With ``reverse_cost``
 
-.. literalinclude:: doc-astar.queries
-   :start-after: --q2
-   :end-before: --q3
+.. literalinclude:: doc-astar-v2.queries
+   :start-after: -- q2
+   :end-before: -- q3
 
 
 The queries use the :ref:`sampledata` network.
@@ -92,5 +96,6 @@ The queries use the :ref:`sampledata` network.
 See Also
 -------------------------------------------------------------------------------
 
+* :ref:`pgr_astar`
 * :ref:`type_cost_result`
 * http://en.wikipedia.org/wiki/A*_search_algorithm
diff --git a/src/astar/doc/pgr_astar.rst b/src/astar/doc/pgr_astar.rst
index b974a3d..efe15be 100644
--- a/src/astar/doc/pgr_astar.rst
+++ b/src/astar/doc/pgr_astar.rst
@@ -7,90 +7,244 @@
     Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
    ****************************************************************************
 
-.. _pgr_astar:
+.. _pgr_aStar:
 
-pgr_astar - Shortest Path A*
+pgr_aStar
 ===============================================================================
 
-.. index:: 
-	single: pgr_astar(text, integer, integer, boolean, boolean)
 
 Name
 -------------------------------------------------------------------------------
 
-``pgr_astar`` — Returns the shortest path using A* algorithm.
+``pgr_aStar`` — Returns the shortest path using A* algorithm.
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph
+
+   Boost Graph Inside
 
 
 Synopsis
 -------------------------------------------------------------------------------
 
-The A* (pronounced "A Star") algorithm is based on Dijkstra's algorithm with a heuristic that allow it to solve most shortest path problems by evaluation only a sub-set of the overall graph. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
+The A* (pronounced "A Star") algorithm is based on Dijkstra's algorithm with a heuristic that allow it to solve most shortest path problems by evaluation only a sub-set of the overall graph.
 
-.. code-block:: sql
 
-	pgr_costResult[] pgr_astar(sql text, source integer, target integer,
-                               directed boolean, has_rcost boolean);
+Characteristics
+-------------------------------------------------------------------------------
 
+The main Characteristics are:
 
-Description
--------------------------------------------------------------------------------
+  - Process is done only on edges with positive costs.
+  - Vertices of the graph are:
 
-:sql: a SQL query, which should return a set of rows with the following columns:
+    - **positive** when it belongs to the edges_sql
+    - **negative** when it belongs to the points_sql
 
-	.. code-block:: sql
+  - Values are returned when there is a path.
 
-		SELECT id, source, target, cost, x1, y1, x2, y2 [,reverse_cost] FROM edge_table
+    - When the starting vertex and ending vertex are the same, there is no path.
 
+      - The agg_cost the non included values (v, v) is 0
 
-	:id: ``int4`` identifier of the edge
-	:source: ``int4`` identifier of the source vertex
-	:target: ``int4`` identifier of the target vertex
-	:cost: ``float8`` value, of the edge traversal cost. A negative cost will prevent the edge from being inserted in the graph.
-	:x1: ``x`` coordinate of the start point of the edge
-	:y1: ``y`` coordinate of the start point of the edge
-	:x2: ``x`` coordinate of the end point of the edge
-	:y2: ``y`` coordinate of the end point of the edge
-	:reverse_cost: (optional) the cost for the reverse traversal of the edge. This is only used when the ``directed`` and ``has_rcost`` parameters are ``true`` (see the above remark about negative costs).
+    - When the starting vertex and ending vertex are the different and there is no path:
 
-:source: ``int4`` id of the start point
-:target: ``int4`` id of the end point
-:directed: ``true`` if the graph is directed
-:has_rcost: if ``true``, the ``reverse_cost`` column of the SQL generated set of rows will be used for the cost of the traversal of the edge in the opposite direction.
+      - The agg_cost the non included values (u, v) is ∞
 
-Returns set of :ref:`type_cost_result`:
+  - When (x,y) coordinates for the same vertex identifier differ:
 
-:seq:   row sequence
-:id1:   node ID
-:id2:   edge ID (``-1`` for the last row)
-:cost:  cost to traverse from ``id1`` using ``id2``
+    - A random selection of the vertex's (x,y) coordinates is used.
 
+  - Running time: :math:`O((E + V) * \log V)`
 
-.. rubric:: History
 
-* Renamed in version 2.0.0
 
+Signature Summary
+-----------------
 
-Examples
--------------------------------------------------------------------------------
+.. code-block:: none
+
+    pgr_aStar(edges_sql, start_vid, end_vid)
+    pgr_aStar(edges_sql, start_vid, end_vid, directed, heuristic, factor, epsilon)
+    RETURNS SET OF (seq, path_seq, node, edge, cost, agg_cost)
+
+
+.. NOTE:: This signature is deprecated
+
+    .. code-block:: sql
+
+        pgr_aStar(sql, source integer, target integer, directed boolean, has_rcost boolean)
+        RETURNS SET OF pgr_costResult
+
+    - See :ref:`pgr_costResult <type_cost_result>`
+    - See :ref:`pgr_aStar-V2.0`
+
+Signatures
+-----------------
+
+.. index:: 
+    single: pgr_aStar(Minimal Signature)
+
+Minimal Signature
+...............................................................................
 
-* Without ``reverse_cost``
+.. code-block:: none
+
+    pgr_aStar(edges_sql, start_vid, end_vid)
+    RETURNS SET OF (seq, path_seq, node, edge, cost, agg_cost)
+
+:Example: Using the defaults
 
 .. literalinclude:: doc-astar.queries
    :start-after: --q1
    :end-before: --q2
 
-* With ``reverse_cost``
+
+.. index:: 
+    single: pgr_aStar(Complete Singature)
+
+Complete Signature
+...............................................................................
+.. code-block:: none
+
+    pgr_aStar(edges_sql, start_vid, end_vid, directed, heuristic, factor, epsilon)
+    RETURNS SET OF (seq, path_seq, node, edge, cost, agg_cost)
+
+:Example: Setting a Heuristic  
 
 .. literalinclude:: doc-astar.queries
    :start-after: --q2
    :end-before: --q3
 
 
+
+
+Description of the Signatures
+--------------------------------
+
+.. NOTE:: The following only aplies to the new signature(s)
+
+..
+    description of the edges_sql queries
+
+.. include:: ../../common/src/edges_input.h
+    :start-after: xy_edges_sql_start
+    :end-before: xy_edges_sql_end
+
+
+Description of the parameters of the signatures
+.................................................
+
+================ ====================== =================================================
+Parameter        Type                   Description
+================ ====================== =================================================
+**edges_sql**    ``TEXT``               Edges SQL query as described above.
+**start_vid**    ``ANY-INTEGER``        Starting vertex identifier.
+**end_vid**      ``ANY-INTEGER``        Ending vertex identifier.
+**directed**     ``BOOLEAN``            - Optional.
+
+                                          - When ``false`` the graph is considered as Undirected.
+                                          - Default is ``true`` which considers the graph as Directed.
+
+**heuristic**    ``INTEGER``            (optional). Heuristic number. Current valid values 0~5. Default ``5``
+
+                                          - 0: h(v) = 0 (Use this value to compare with pgr_dijkstra)
+                                          - 1: h(v) abs(max(dx, dy))
+                                          - 2: h(v) abs(min(dx, dy))
+                                          - 3: h(v) = dx * dx + dy * dy
+                                          - 4: h(v) = sqrt(dx * dx + dy * dy)
+                                          - 5: h(v) = abs(dx) + abs(dy)
+
+**factor**       ``FLOAT``              (optional). For units manipulation. :math:`factor > 0`.  Default ``1``.
+**epsilon**      ``FLOAT``              (optional). For less restricted results. :math:`factor >= 1`.  Default ``1``.
+================ ====================== =================================================
+
+ 
+
+
+Description of the return values
+.................................................
+
+Returns set of ``(seq, path_seq, node, edge, cost, agg_cost)``
+
+============= =========== =================================================
+Column           Type              Description
+============= =========== =================================================
+**seq**       ``INTEGER`` Row sequence.
+**path_seq**  ``INTEGER`` Path sequence that indicates the relative position on the path.
+**node**      ``BIGINT``  Identifier of the node:
+                            - A positive value indicates the node is a vertex of edges_sql.
+                            - A negative value indicates the node is a point of points_sql.
+
+**edge**      ``BIGINT``  Identifier of the edge used to go from ``node`` to the next node in the path sequence.
+                            - ``-1`` for the last row in the path sequence.
+
+**cost**      ``FLOAT``   Cost to traverse from ``node`` using ``edge`` to the next ``node`` in the path sequence.
+                            - ``0`` for the last row in the path sequence.
+
+**agg_cost**  ``FLOAT``   Aggregate cost from ``start_vid`` to ``node``.
+                            - ``0`` for the first row in the path sequence.
+
+============= =========== =================================================
+
+
+About factor
+-------------------------------------------------------------------------------
+
+.. rubric:: Analysis 1
+
+Working with cost/reverse_cost as length in degrees, x/y in lat/lon:
+Factor = 1   (no need to change units)
+
+.. rubric:: Analysis 2
+
+Working with cost/reverse_cost as length in meters, x/y in lat/lon:
+Factor =  would depend on the location of the points:
+
+======== ================================= ==========
+latitude  conversion                        Factor
+======== ================================= ==========
+45       1 longitude degree is  78846.81 m   78846
+ 0       1 longitude degree is 111319.46 m  111319
+======== ================================= ==========
+
+.. rubric:: Analysis 3
+
+Working with cost/reverse_cost as time in seconds, x/y in lat/lon:
+Factor: would depend on the location of the points and on the average speed
+say 25m/s is the speed.
+
+======== =========================================== ==========
+latitude  conversion                                  Factor
+======== =========================================== ==========
+45       1 longitude degree is (78846.81m)/(25m/s)   3153 s
+ 0       1 longitude degree is (111319.46 m)/(25m/s) 4452 s
+======== =========================================== ==========
+
+
+
+
+.. rubric:: History
+
+* Functionality added version 2.3.0
+* Renamed in version 2.0.0
+
+
+Deprecated Signature
+-------------------------------------------------------------------------------
+
+:Example: Using the deprecated signature 
+
+.. literalinclude:: doc-astar.queries
+   :start-after: --q3
+   :end-before: --q4
+
+
 The queries use the :ref:`sampledata` network.
 
 
 See Also
 -------------------------------------------------------------------------------
 
-* :ref:`type_cost_result`
+* http://www.boost.org/libs/graph/doc/astar_search.html
 * http://en.wikipedia.org/wiki/A*_search_algorithm
diff --git a/src/astar/sql/CMakeLists.txt b/src/astar/sql/CMakeLists.txt
index d34e55b..a7aba9a 100644
--- a/src/astar/sql/CMakeLists.txt
+++ b/src/astar/sql/CMakeLists.txt
@@ -1,7 +1,13 @@
 # Append in local scope
 LIST(APPEND PACKAGE_SQL_FILES
-    ${CMAKE_CURRENT_SOURCE_DIR}/astar.sql
-)
+    ${CMAKE_CURRENT_SOURCE_DIR}/astarV2.0.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/astarOneToOne.sql
+
+    #for version 3.0
+    #${CMAKE_CURRENT_SOURCE_DIR}/_astar.sql
+    #${CMAKE_CURRENT_SOURCE_DIR}/astar.sql
+    #${CMAKE_CURRENT_SOURCE_DIR}/astarCost.sql
+    )
 
 # set in parent scope
 SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
diff --git a/src/astar/sql/_astar.sql b/src/astar/sql/_astar.sql
new file mode 100644
index 0000000..1888c8c
--- /dev/null
+++ b/src/astar/sql/_astar.sql
@@ -0,0 +1,108 @@
+/*PGR-GNU*****************************************************************
+File: astarV3.0.sql
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+CREATE OR REPLACE FUNCTION _pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vid BIGINT,
+    end_vid BIGINT,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    only_cost BOOLEAN DEFAULT false,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+RETURNS SETOF RECORD AS
+'$libdir/${PGROUTING_LIBRARY_NAME}', 'astarOneToOne'
+LANGUAGE c IMMUTABLE STRICT;
+
+
+CREATE OR REPLACE FUNCTION _pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vid BIGINT,
+    end_vids anyarray,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    only_cost BOOLEAN DEFAULT false,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT end_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+RETURNS SETOF RECORD AS
+'$libdir/${PGROUTING_LIBRARY_NAME}', 'astarOneToMany'
+LANGUAGE c IMMUTABLE STRICT;
+
+CREATE OR REPLACE FUNCTION _pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vids anyarray,
+    end_vid BIGINT,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    only_cost BOOLEAN DEFAULT false,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT start_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+RETURNS SETOF RECORD AS
+'$libdir/${PGROUTING_LIBRARY_NAME}', 'astarManyToOne'
+LANGUAGE c IMMUTABLE STRICT;
+
+CREATE OR REPLACE FUNCTION _pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vids anyarray,
+    end_vids anyarray,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    only_cost BOOLEAN DEFAULT false,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+RETURNS SETOF RECORD AS
+'$libdir/${PGROUTING_LIBRARY_NAME}', 'astarManyToMany'
+LANGUAGE c IMMUTABLE STRICT;
diff --git a/src/astar/sql/astar.sql b/src/astar/sql/astar.sql
index 4585da4..7c71375 100644
--- a/src/astar/sql/astar.sql
+++ b/src/astar/sql/astar.sql
@@ -1,9 +1,14 @@
 /*PGR-GNU*****************************************************************
+File: astar.sql
 
--- Copyright (c) 2005 Sylvain Pasche,
---               2006-2007 Anton A. Patrushev, Orkney, Inc.
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
 ------
 
 This program is free software; you can redistribute it and/or modify
@@ -21,14 +26,111 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
+CREATE OR REPLACE FUNCTION pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vid BIGINT,
+    end_vid BIGINT,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT *
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7);
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
+CREATE OR REPLACE FUNCTION pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vid BIGINT,
+    end_vids ANYARRAY,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT end_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT *
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7);
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
+CREATE OR REPLACE FUNCTION pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vids ANYARRAY,
+    end_vid BIGINT,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT start_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT *
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7);
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
+CREATE OR REPLACE FUNCTION pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vids ANYARRAY,
+    end_vids ANYARRAY,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
 
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT *
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7);
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
 
------------------------------------------------------------------------
--- Core function for shortest_path_astar computation
--- Simillar to shortest_path in usage but uses the A* algorithm
--- instead of Dijkstra's.
------------------------------------------------------------------------
-CREATE OR REPLACE FUNCTION pgr_astar(sql text, source_id integer, target_id integer, directed boolean, has_reverse_cost boolean)
-    RETURNS SETOF pgr_costResult
-    AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'shortest_path_astar'
-    LANGUAGE c IMMUTABLE STRICT; 
diff --git a/src/astar/sql/astarCost.sql b/src/astar/sql/astarCost.sql
new file mode 100644
index 0000000..b3e57c0
--- /dev/null
+++ b/src/astar/sql/astarCost.sql
@@ -0,0 +1,120 @@
+/*PGR-GNU*****************************************************************
+File: astar.sql
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+CREATE OR REPLACE FUNCTION pgr_astarCost(
+    edges_sql TEXT, -- XY edges sql
+    BIGINT, -- start_id
+    BIGINT, -- end_id
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT $2, $3, a.agg_cost
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7, true) a;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
+CREATE OR REPLACE FUNCTION pgr_astarCost(
+    edges_sql TEXT, -- XY edges sql
+    BIGINT,
+    end_vids ANYARRAY,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT $2, a.end_vid, a.agg_cost 
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7, true) a;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
+CREATE OR REPLACE FUNCTION pgr_astarCost(
+    edges_sql TEXT, -- XY edges sql
+    start_vids ANYARRAY,
+    BIGINT,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT  a.start_vid, $3, a.agg_cost
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7, true) a;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
+CREATE OR REPLACE FUNCTION pgr_astarCost(
+    edges_sql TEXT, -- XY edges sql
+    start_vids ANYARRAY,
+    end_vids ANYARRAY,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT a.start_vid, a.end_vid, a.agg_cost
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7, true) a;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
+
diff --git a/src/dijkstra/sql/dijkstraVia.sql b/src/astar/sql/astarOneToOne.sql
similarity index 51%
copy from src/dijkstra/sql/dijkstraVia.sql
copy to src/astar/sql/astarOneToOne.sql
index f18a54b..ab9cd2e 100644
--- a/src/dijkstra/sql/dijkstraVia.sql
+++ b/src/astar/sql/astarOneToOne.sql
@@ -1,11 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: dijkstraViaVertex.sql
+File: astarOneToOne.sql
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
 
 ------
 
@@ -25,27 +27,49 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-CREATE OR REPLACE FUNCTION pgr_dijkstraVia(
-    edges_sql TEXT,
-    via_vertices ANYARRAY,
-    directed BOOLEAN DEFAULT TRUE,
-    strict BOOLEAN DEFAULT FALSE,
-    U_turn_on_edge BOOLEAN DEFAULT TRUE,
+CREATE OR REPLACE FUNCTION _pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vid BIGINT,
+    end_vid BIGINT,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
+    only_cost BOOLEAN DEFAULT false,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT node BIGINT,
+    OUT edge BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
 
+RETURNS SETOF RECORD AS
+'$libdir/${PGROUTING_LIBRARY_NAME}', 'astarOneToOne'
+LANGUAGE c IMMUTABLE STRICT;
 
+CREATE OR REPLACE FUNCTION pgr_astar(
+    edges_sql TEXT, -- XY edges sql
+    start_vid BIGINT,
+    end_vid BIGINT,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
     OUT seq INTEGER,
-    OUT path_id INTEGER,
     OUT path_seq INTEGER,
-    OUT start_vid BIGINT,
-    OUT end_vid BIGINT,
     OUT node BIGINT,
     OUT edge BIGINT,
     OUT cost FLOAT,
-    OUT agg_cost FLOAT,
-    OUT route_agg_cost FLOAT)
-
-  RETURNS SETOF RECORD AS
- '$libdir/${PGROUTING_LIBRARY_NAME}', 'dijkstraVia'
-    LANGUAGE c IMMUTABLE STRICT;
+    OUT agg_cost FLOAT)
 
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT *
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $3, $4, $5, $6, $7);
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
 
diff --git a/src/pickDeliver/test/pdp-any-01.test.sql b/src/astar/sql/astarV2.0.sql
similarity index 51%
rename from src/pickDeliver/test/pdp-any-01.test.sql
rename to src/astar/sql/astarV2.0.sql
index 18ab85e..b83075d 100644
--- a/src/pickDeliver/test/pdp-any-01.test.sql
+++ b/src/astar/sql/astarV2.0.sql
@@ -20,25 +20,31 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-BEGIN;
-
-    WITH results AS
-    (SELECT seq, route_id, node_id, cost from pgr_gsoc_vrppdtw(
-        'select * from customer order by id'::text, 25,200)
-    )
-    SELECT cost < 4000 FROM results WHERE seq = 0;
-
-    /*
-    WITH results AS
-    (SELECT seq, route_id, node_id, cost from pgr_gsoc_vrppdtw(
-        'select * from customer order by id'::text, 25,200)
-    )
-    SELECT count(*) FROM results;
-
-    WITH results AS
-    (SELECT seq, route_id, node_id, cost from pgr_gsoc_vrppdtw(
-        'select * from customer order by id'::text, 25,200)
-    )
-    SELECT route_id <= 14 FROM results WHERE seq = 136;
-*/
-    ROLLBACK;
+
+
+-- V2 signature
+CREATE OR REPLACE FUNCTION pgr_astar(edges_sql TEXT, source_id INTEGER, target_id INTEGER, directed BOOLEAN, has_rcost BOOLEAN)
+RETURNS SETOF pgr_costresult AS
+$BODY$
+DECLARE
+has_reverse BOOLEAN;
+sql TEXT;
+BEGIN
+    RAISE NOTICE 'Deprecated signature of function pgr_astar';
+    has_reverse =_pgr_parameter_check('astar', edges_sql, false);
+    sql = edges_sql;
+    IF (has_reverse != has_rcost) THEN
+        IF (has_reverse) THEN
+            sql = 'SELECT id, source, target, cost, x1,y1, x2, y2 FROM (' || edges_sql || ') a';
+        ELSE
+            raise EXCEPTION 'has_rcost set to true but reverse_cost not found';
+        END IF;
+    END IF;
+
+    RETURN query SELECT seq - 1 AS seq, node::INTEGER AS id1, edge::INTEGER AS id2, cost 
+    FROM pgr_astar(sql, source_id, target_id, directed);
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
diff --git a/src/astar/src/CMakeLists.txt b/src/astar/src/CMakeLists.txt
index 23220ea..0c576a9 100644
--- a/src/astar/src/CMakeLists.txt
+++ b/src/astar/src/CMakeLists.txt
@@ -1,3 +1,12 @@
 ADD_LIBRARY(astar OBJECT
-    astar.c
-    astar_boost_wrapper.cpp)
+    astarOneToOne.c
+    astarOneToOne_driver.cpp
+
+    #for version 3.0
+    #astarOneToMany.c
+    #astarOneToMany_driver.cpp
+
+    #astarManyToOne.c
+    #astarManyToMany.c
+    #astarManyToMany_driver.cpp
+    )
diff --git a/src/astar/src/astar.c b/src/astar/src/astar.c
deleted file mode 100644
index f4f95e6..0000000
--- a/src/astar/src/astar.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/*PGR-GNU*****************************************************************
-
- * A* Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2006 Anton A. Patrushev, Orkney, Inc.
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#include "../../common/src/pgr_types.h"
-#include "postgres.h"
-#include "executor/spi.h"
-#include "funcapi.h"
-#include "catalog/pg_type.h"
-#if PGSQL_VERSION > 92
-#include "access/htup_details.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <search.h>
-
-#include "astar.h"
-
-//-------------------------------------------------------------------------
-
-/*
- * Define this to have profiling enabled
- */
-//#define PROFILE
-
-#ifdef PROFILE
-#include <sys/time.h>
-
-struct timeval prof_astar, prof_store, prof_extract, prof_total;
-long proftime[5];
-long profipts1, profipts2, profopts;
-
-#define profstart(x) do { gettimeofday(&x, NULL); } while (0);
-#define profstop(n, x) do { struct timeval _profstop;   \
-        long _proftime;                         \
-        gettimeofday(&_profstop, NULL);                         \
-        _proftime = ( _profstop.tv_sec*1000000+_profstop.tv_usec) -     \
-                ( x.tv_sec*1000000+x.tv_usec); \
-        elog(NOTICE, \
-                "PRF(%s) %lu (%f ms)", \
-                (n), \
-             _proftime, _proftime / 1000.0);    \
-        } while (0);
-
-#else
-
-#define profstart(x) do { } while (0);
-#define profstop(n, x) do { } while (0);
-
-#endif // PROFILE
-
-
-//-------------------------------------------------------------------------
-
-Datum shortest_path_astar(PG_FUNCTION_ARGS);
-
-#undef DEBUG
-//#define DEBUG 1
-#include "../../common/src/debug_macro.h"
-#include "../../common/src/pgr_types.h"
-#include "../../common/src/postgres_connection.h"
-
-// The number of tuples to fetch from the SPI cursor at each iteration
-#define TUPLIMIT 1000
-
-typedef struct edge_astar_columns 
-{
-  int id;
-  int source;
-  int target;
-  int cost;
-  int reverse_cost;
-  int s_x;
-  int s_y;
-  int t_x;
-  int t_y;
-} edge_astar_columns_t;
-
-
-static int
-fetch_edge_astar_columns(SPITupleTable *tuptable, 
-             edge_astar_columns_t *edge_columns, 
-             bool has_reverse_cost)
-{
-  edge_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
-  edge_columns->source = SPI_fnumber(SPI_tuptable->tupdesc, "source");
-  edge_columns->target = SPI_fnumber(SPI_tuptable->tupdesc, "target");
-  edge_columns->cost = SPI_fnumber(SPI_tuptable->tupdesc, "cost");
-  if (edge_columns->id == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->source == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->target == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->cost == SPI_ERROR_NOATTRIBUTE) {
-
-      elog(ERROR, "Error, query must return columns "
-       "'id', 'source', 'target' and 'cost'");
-      return -1;
-  }
-
-  if (SPI_gettypeid(SPI_tuptable->tupdesc, 
-            edge_columns->source) != INT4OID ||
-      SPI_gettypeid(SPI_tuptable->tupdesc, 
-            edge_columns->target) != INT4OID ||
-      SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->cost) != FLOAT8OID) {
-
-      elog(ERROR, "Error, columns 'source', 'target' must be of type int4, "
-       "'cost' must be of type float8");
-      return -1;
-  }
-
-  PGR_DBG("columns: id %i source %i target %i cost %i", 
-      edge_columns->id, edge_columns->source, 
-      edge_columns->target, edge_columns->cost);
-
-  if (has_reverse_cost) {
-      edge_columns->reverse_cost = SPI_fnumber(SPI_tuptable->tupdesc, 
-                           "reverse_cost");
-
-      if (edge_columns->reverse_cost == SPI_ERROR_NOATTRIBUTE) {
-          elog(ERROR, "Error, reverse_cost is used, but query did't return "
-               "'reverse_cost' column");
-          return -1;
-      }
-
-      if (SPI_gettypeid(SPI_tuptable->tupdesc, 
-            edge_columns->reverse_cost) != FLOAT8OID) {
-          elog(ERROR, "Error, columns 'reverse_cost' must be of type float8");
-          return -1;
-      }
-
-      PGR_DBG("columns: reverse_cost cost %i", edge_columns->reverse_cost);
-  }
-
-  edge_columns->s_x = SPI_fnumber(SPI_tuptable->tupdesc, "x1");
-  edge_columns->s_y = SPI_fnumber(SPI_tuptable->tupdesc, "y1");
-  edge_columns->t_x = SPI_fnumber(SPI_tuptable->tupdesc, "x2");
-  edge_columns->t_y = SPI_fnumber(SPI_tuptable->tupdesc, "y2");
-
-  if (edge_columns->s_x == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->s_y == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->t_x == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->t_y == SPI_ERROR_NOATTRIBUTE) {
-
-      elog(ERROR, "Error, query must return columns "
-       "'x1', 'x2', 'y1' and 'y2'");
-      return -1;
-  }
-
-  PGR_DBG("columns: x1 %i y1 %i x2 %i y2 %i", 
-      edge_columns->s_x, edge_columns->s_y,
-      edge_columns->t_x,edge_columns->t_y);
-
-  return 0;
-}
-
-static void
-fetch_edge_astar(HeapTuple *tuple, TupleDesc *tupdesc, 
-         edge_astar_columns_t *edge_columns, 
-         edge_astar_t *target_edge)
-{
-  Datum binval;
-  bool isnull;
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->id, &isnull);
-  if (isnull) elog(ERROR, "id contains a null value");
-  target_edge->id = DatumGetInt32(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->source, &isnull);
-  if (isnull) elog(ERROR, "source contains a null value");
-  target_edge->source = DatumGetInt32(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->target, &isnull);
-  if (isnull) elog(ERROR, "target contains a null value");
-  target_edge->target = DatumGetInt32(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->cost, &isnull);
-  if (isnull) elog(ERROR, "cost contains a null value");
-  target_edge->cost = DatumGetFloat8(binval);
-
-  if (edge_columns->reverse_cost != -1) {
-      binval = SPI_getbinval(*tuple, *tupdesc, 
-                 edge_columns->reverse_cost, &isnull);
-      if (isnull) elog(ERROR, "reverse_cost contains a null value");
-      target_edge->reverse_cost =  DatumGetFloat8(binval);
-  }
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->s_x, &isnull);
-  if (isnull) elog(ERROR, "source x contains a null value");
-  target_edge->s_x = DatumGetFloat8(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->s_y, &isnull);
-  if (isnull) elog(ERROR, "source y contains a null value");
-  target_edge->s_y = DatumGetFloat8(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->t_x, &isnull);
-  if (isnull) elog(ERROR, "target x contains a null value");
-  target_edge->t_x = DatumGetFloat8(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->t_y, &isnull);
-  if (isnull) elog(ERROR, "target y contains a null value");
-  target_edge->t_y = DatumGetFloat8(binval);
-}
-
-
-static int compute_shortest_path_astar(char* sql, int source_vertex_id, 
-                       int target_vertex_id, bool directed, 
-                       bool has_reverse_cost, 
-                       path_element_t **path, size_t *path_count) 
-{
-
-  void *SPIplan;
-  Portal SPIportal;
-  bool moredata = TRUE;
-  size_t ntuples;
-  edge_astar_t *edges = NULL;
-  size_t total_tuples = 0;
-
-  int v_max_id=0;
-  int v_min_id=INT_MAX;  
-
-  edge_astar_columns_t edge_columns = {.id= -1, .source= -1, .target= -1, 
-                       .cost= -1, .reverse_cost= -1, 
-                       .s_x= -1, .s_y= -1, .t_x= -1, .t_y= -1};
-  char *err_msg;
-  int ret = -1;
-  register int z;
-
-  int s_count=0;
-  int t_count=0;
-
-  struct vItem
-  {
-    int id;
-    int key;
-  };
-
-  PGR_DBG("start shortest_path_astar\n");
-
-  pgr_SPI_connect();
-  SPIplan = pgr_SPI_prepare(sql);
-  SPIportal = pgr_SPI_cursor_open(SPIplan);
-
-
-  while (moredata == TRUE) {
-      SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
-
-      if (edge_columns.id == -1) {
-          if (fetch_edge_astar_columns(SPI_tuptable, &edge_columns, 
-                           has_reverse_cost) == -1) {
-              pgr_SPI_finish();
-              return -1;
-          }
-      }
-
-      ntuples = SPI_processed;
-      total_tuples += ntuples;
-      if (!edges)
-          edges = palloc(total_tuples * sizeof(edge_astar_t));
-      else
-          edges = repalloc(edges, total_tuples * sizeof(edge_astar_t));
-
-      if (edges == NULL) {
-          elog(ERROR, "Out of memory");
-              pgr_SPI_finish();
-              return -1;
-      }
-
-      if (ntuples > 0) {
-          size_t t;
-          SPITupleTable *tuptable = SPI_tuptable;
-          TupleDesc tupdesc = SPI_tuptable->tupdesc;
-
-          for (t = 0; t < ntuples; t++) {
-            HeapTuple tuple = tuptable->vals[t];
-            fetch_edge_astar(&tuple, &tupdesc, &edge_columns, 
-                   &edges[total_tuples - ntuples + t]);
-          }
-          SPI_freetuptable(tuptable);
-      } 
-      else {
-          moredata = FALSE;
-      }
-  }
-
-  //defining min and max vertex id
-
-  PGR_DBG("Total %i tuples", total_tuples);
-
-  for(z=0; z<total_tuples; z++) {
-    if(edges[z].source<v_min_id) v_min_id=edges[z].source;
-    if(edges[z].source>v_max_id) v_max_id=edges[z].source;
-    if(edges[z].target<v_min_id) v_min_id=edges[z].target;
-    if(edges[z].target>v_max_id) v_max_id=edges[z].target;      
-
-    PGR_DBG("%i <-> %i", v_min_id, v_max_id);
-  }
-
-  //::::::::::::::::::::::::::::::::::::  
-  //:: reducing vertex id (renumbering)
-  //::::::::::::::::::::::::::::::::::::
-  for(z=0; z<total_tuples; z++) {
-    //check if edges[] contains source and target
-    if(edges[z].source == source_vertex_id || 
-       edges[z].target == source_vertex_id)
-      ++s_count;
-    if(edges[z].source == target_vertex_id || 
-       edges[z].target == target_vertex_id)
-      ++t_count;
-
-    edges[z].source-=v_min_id;
-    edges[z].target-=v_min_id;
-    PGR_DBG("%i - %i", edges[z].source, edges[z].target);
-  }
-
-  PGR_DBG("Total %i tuples", total_tuples);
-
-  if(s_count == 0) {
-    elog(ERROR, "Start vertex was not found.");
-    return -1;
-  }
-
-  if(t_count == 0) {
-    elog(ERROR, "Target vertex was not found.");
-    return -1;
-  }
-
-  PGR_DBG("Total %i tuples", total_tuples);
-
-  profstop("extract", prof_extract);
-  profstart(prof_astar);
-
-  PGR_DBG("Calling boost_astar <%i>\n", total_tuples);
-
-  // calling C++ A* function    
-  ret = boost_astar(edges, total_tuples, source_vertex_id-v_min_id, 
-            target_vertex_id-v_min_id,
-            directed, has_reverse_cost,
-            path, path_count, &err_msg);
-
-  if (ret < 0) {
-      elog(ERROR, "Error computing path: %s", err_msg);
-  } 
-
-  PGR_DBG("SIZE %i\n",*path_count);
-  PGR_DBG("ret =  %i\n",ret);
-
-  //::::::::::::::::::::::::::::::::
-  //:: restoring original vertex id
-  //::::::::::::::::::::::::::::::::
-  for(z=0; z<*path_count; z++) {
-    //PGR_DBG("vetex %i\n",(*path)[z].vertex_id);
-    (*path)[z].vertex_id += v_min_id;
-  }  
-
-  profstop("astar", prof_astar);
-  profstart(prof_store);
-
-  pgr_SPI_finish();
-  return 0;
-
-}
-
-
-PG_FUNCTION_INFO_V1(shortest_path_astar);
-Datum
-shortest_path_astar(PG_FUNCTION_ARGS)
-{
-  FuncCallContext     *funcctx;
-  uint32_t                  call_cntr;
-  uint32_t                  max_calls;
-  TupleDesc            tuple_desc;
-  path_element_t      *path = 0;
-
-  /* stuff done only on the first call of the function */
-  if (SRF_IS_FIRSTCALL()) {
-      MemoryContext   oldcontext;
-      size_t path_count = 0;
-#ifdef DEBUG
-      int ret;
-#endif
-
-      // XXX profiling messages are not thread safe
-      profstart(prof_total);
-      profstart(prof_extract);
-
-      /* create a function context for cross-call persistence */
-      funcctx = SRF_FIRSTCALL_INIT();
-
-      /* switch to memory context appropriate for multiple function calls */
-      oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-
-
-#ifdef DEBUG
-      ret =
-#endif
- compute_shortest_path_astar(pgr_text2char(PG_GETARG_TEXT_P(0)),
-                    PG_GETARG_INT32(1),
-                    PG_GETARG_INT32(2),
-                    PG_GETARG_BOOL(3),
-                    PG_GETARG_BOOL(4), 
-                    &path, &path_count);
-
-#ifdef DEBUG
-      PGR_DBG("Ret is %i", ret);
-      int i;
-      for (i = 0; i < path_count; i++) {
-          PGR_DBG("Step # %i vertex_id  %i ", i, path[i].vertex_id);
-          PGR_DBG("        edge_id    %i ", path[i].edge_id);
-          PGR_DBG("        cost       %f ", path[i].cost);
-      }
-#endif
-
-      /* total number of tuples to be returned */
-      PGR_DBG("Conting tuples number\n");
-      funcctx->max_calls = (uint32_t)path_count;
-      funcctx->user_fctx = path;
-
-      PGR_DBG("Path count %i", path_count);
-
-      funcctx->tuple_desc = 
-            BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
-
-      MemoryContextSwitchTo(oldcontext);
-  }
-
-  /* stuff done on every call of the function */
-  PGR_DBG("Strange stuff doing\n");
-
-  funcctx = SRF_PERCALL_SETUP();
-
-  call_cntr = funcctx->call_cntr;
-  max_calls = funcctx->max_calls;
-  tuple_desc = funcctx->tuple_desc;
-  path = (path_element_t*) funcctx->user_fctx;
-
-  PGR_DBG("Trying to allocate some memory\n");
-
-  if (call_cntr < max_calls) {   /* do when there is more left to send */
-        HeapTuple    tuple;
-        Datum        result;
-        Datum *values;
-        bool* nulls;
-
-        values = palloc(4 * sizeof(Datum));
-        nulls = palloc(4 * sizeof(bool));
-
-        values[0] = Int32GetDatum(call_cntr);
-        nulls[0] = false;
-        values[1] = Int32GetDatum(path[call_cntr].vertex_id);
-        nulls[1] = false;
-        values[2] = Int32GetDatum(path[call_cntr].edge_id);
-        nulls[2] = false;
-        values[3] = Float8GetDatum(path[call_cntr].cost);
-        nulls[3] = false;
-
-        PGR_DBG("Heap making\n");
-
-        tuple = heap_form_tuple(tuple_desc, values, nulls);
-
-        PGR_DBG("Datum making\n");
-
-        /* make the tuple into a datum */
-        result = HeapTupleGetDatum(tuple);
-
-        PGR_DBG("Trying to free some memory\n");
-
-        /* clean up (this is not really necessary) */
-        pfree(values);
-        pfree(nulls);
-
-        SRF_RETURN_NEXT(funcctx, result);
-    }
-    else    /* do when there is no more left */
-    {
-        if (path) free(path);
-        profstop("store", prof_store);
-        profstop("total", prof_total);
-#ifdef PROFILE
-        elog(NOTICE, "_________");
-#endif
-        SRF_RETURN_DONE(funcctx);
-    }
-}
diff --git a/src/astar/src/astar.h b/src/astar/src/astar.h
deleted file mode 100644
index 7853b5a..0000000
--- a/src/astar/src/astar.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*PGR-GNU*****************************************************************
-
- * A* Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2006 Anton A. Patrushev, Orkney, Inc.
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
- 
-#define _ASTAR_H
-
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-#include "../../common/src/pgr_types.h"
-  int boost_astar(edge_astar_t *edges, size_t count, 
-                  int source_vertex_id, int target_vertex_id,
-                  bool directed, bool has_reverse_cost,
-                  path_element_t **path, size_t *path_count, char **err_msg);
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/dijkstra/src/many_to_many_dijkstra.c b/src/astar/src/astarManyToMany.c
similarity index 62%
copy from src/dijkstra/src/many_to_many_dijkstra.c
copy to src/astar/src/astarManyToMany.c
index 09503d8..2354c37 100644
--- a/src/dijkstra/src/many_to_many_dijkstra.c
+++ b/src/astar/src/astarManyToMany.c
@@ -1,6 +1,5 @@
 /*PGR-GNU*****************************************************************
-
-File: many_to_many_dijkstra.c
+File: astarOneToOne.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
@@ -8,7 +7,7 @@ Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Mail: 
 
 ------
 
@@ -36,104 +35,115 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
-
-/*
-   Uncomment when needed
-   */
-
-// #define DEBUG
-
 #include "fmgr.h"
+
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
 #include "./../../common/src/arrays_input.h"
-#include "./many_to_many_dijkstra_driver.h"
 
-PG_FUNCTION_INFO_V1(many_to_many_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+#include "./astarManyToMany_driver.h"
+
+PG_FUNCTION_INFO_V1(astarManyToMany);
 PGDLLEXPORT Datum
-#endif
-many_to_many_dijkstra(PG_FUNCTION_ARGS);
+astarManyToMany(PG_FUNCTION_ARGS);
 
 
-/******************************************************************************/
-/*                          MODIFY AS NEEDED                                  */
 static
 void
-process(
-        char* edges_sql,
+process(char* edges_sql,
         int64_t *start_vidsArr, size_t size_start_vidsArr,
         int64_t *end_vidsArr, size_t size_end_vidsArr,
         bool directed,
+        int heuristic,
+        double factor,
+        double epsilon,
         bool only_cost,
         General_path_element_t **result_tuples,
         size_t *result_count) {
+    if (heuristic > 5 || heuristic < 0) {
+        free(start_vidsArr);
+        free(end_vidsArr);
+        ereport(ERROR,
+                (errmsg("Unknown heuristic"),
+                 errhint("Valid values: 0~5")));
+    }
+    if (factor <= 0) {
+        free(start_vidsArr);
+        free(end_vidsArr);
+        ereport(ERROR,
+                (errmsg("Factor value out of range"),
+                 errhint("Valid values: positive non zero")));
+    }
+    if (epsilon < 1) {
+        free(start_vidsArr);
+        free(end_vidsArr);
+        ereport(ERROR,
+                (errmsg("Epsilon value out of range"),
+                 errhint("Valid values: 1 or greater than 1")));
+    }
+
+
+
     pgr_SPI_connect();
 
-    PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
-    size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    Pgr_edge_xy_t *edges = NULL;
+    size_t total_edges = 0;
+
+    pgr_get_edges_xy(edges_sql, &edges, &total_edges);
 
-    if (total_tuples == 0) {
+    if (total_edges == 0) {
         PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_tuples);
 
     PGR_DBG("Starting processing");
-    clock_t start_t = clock();
-
     char *err_msg = NULL;
-    do_pgr_many_to_many_dijkstra(
+    char *log_msg = NULL;
+    clock_t start_t = clock();
+    do_pgr_astarManyToMany(
             edges,
-            total_tuples,
-            start_vidsArr,
-            size_start_vidsArr,
-            end_vidsArr,
-            size_end_vidsArr,
+            total_edges,
+            start_vidsArr, size_start_vidsArr,
+            end_vidsArr, size_end_vidsArr,
             directed,
+            heuristic,
+            factor,
+            epsilon,
             only_cost,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
-    time_msg(" processing Dijkstra many to many", start_t, clock());
+    time_msg(" processing pgr_astar(many to many)", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    PGR_DBG("LOG: %s\n", log_msg);
+    if (log_msg) free(log_msg);
+
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
 
-    free(err_msg);
     pfree(edges);
     pgr_SPI_finish();
 }
-/*                                                                           */
-/*****************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-many_to_many_dijkstra(PG_FUNCTION_ARGS) {
+astarManyToMany(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+    uint32_t            call_cntr;
+    uint32_t            max_calls;
+    TupleDesc           tuple_desc;
 
-    /**************************************************************************/
-    /*                          MODIFY AS NEEDED                              */
-    /*                                                                        */
     General_path_element_t  *result_tuples = 0;
     size_t result_count = 0;
-    /*                                                                        */
-    /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
         MemoryContext   oldcontext;
@@ -141,52 +151,51 @@ many_to_many_dijkstra(PG_FUNCTION_ARGS) {
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
-        /*********************************************************************/
-        /*                          MODIFY AS NEEDED                         */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text,
-        // start_vids anyarray,
-        // end_vids anyarray,
-        // directed boolean default true,
+        /**********************************************************************/
+        /*
+           edges_sql TEXT,
+           start_vids ARRAY[ANY_INTEGER], -- anyarray
+           end_vids ARRAY[ANY_INTEGER], -- anyarray
+           directed BOOLEAN DEFAULT true,
+           heuristic INTEGER DEFAULT 0,
+           factor FLOAT DEFAULT 1.0,
+           epsilon FLOAT DEFAULT 1.0,
+
+         **********************************************************************/
 
-        PGR_DBG("Initializing arrays");
         int64_t* start_vidsArr;
         size_t size_start_vidsArr;
         start_vidsArr = (int64_t*)
             pgr_get_bigIntArray(&size_start_vidsArr, PG_GETARG_ARRAYTYPE_P(1));
-        PGR_DBG("start_vidsArr size %d ", size_start_vidsArr);
 
         int64_t* end_vidsArr;
         size_t size_end_vidsArr;
         end_vidsArr = (int64_t*)
             pgr_get_bigIntArray(&size_end_vidsArr, PG_GETARG_ARRAYTYPE_P(2));
-        PGR_DBG("end_vidsArr size %d ", size_end_vidsArr);
 
-        PGR_DBG("Calling process");
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
                 start_vidsArr, size_start_vidsArr,
                 end_vidsArr, size_end_vidsArr,
                 PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
+                PG_GETARG_INT32(4),
+                PG_GETARG_FLOAT8(5),
+                PG_GETARG_FLOAT8(6),
+                PG_GETARG_BOOL(7),
                 &result_tuples,
                 &result_count);
 
-        PGR_DBG("Cleaning arrays");
         free(end_vidsArr);
         free(start_vidsArr);
-        /*                                                                   */
-        /*********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
-        if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+        if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                      errmsg("function returning record called in context "
                          "that cannot accept type record")));
-        }
 
         funcctx->tuple_desc = tuple_desc;
         MemoryContextSwitchTo(oldcontext);
@@ -204,16 +213,17 @@ many_to_many_dijkstra(PG_FUNCTION_ARGS) {
         Datum        *values;
         bool*        nulls;
 
-        /*********************************************************************/
-        /*                          MODIFY AS NEEDED                         */
-        // OUT seq integer,
-        // OUT path_seq INTEGER,
-        // OUT start_vid,
-        // OUT end_vid BIGINT,
-        // OUT node bigint,
-        // OUT edge bigint,
-        // OUT cost float,
-        // OUT agg_cost float)
+        /*********************************************************************
+           OUT seq INTEGER,
+           OUT path_seq INTEGER,
+           OUT start_vid BIGINT,
+           OUT end_vid BIGINT,
+           OUT node BIGINT,
+           OUT edge BIGINT,
+           OUT cost FLOAT,
+           OUT agg_cost FLOAT
+         **********************************************************************/
+
 
         values = palloc(8 * sizeof(Datum));
         nulls = palloc(8 * sizeof(bool));
@@ -223,6 +233,7 @@ many_to_many_dijkstra(PG_FUNCTION_ARGS) {
             nulls[i] = false;
         }
 
+
         values[0] = Int32GetDatum(call_cntr + 1);
         values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
         values[2] = Int64GetDatum(result_tuples[call_cntr].start_id);
@@ -231,13 +242,12 @@ many_to_many_dijkstra(PG_FUNCTION_ARGS) {
         values[5] = Int64GetDatum(result_tuples[call_cntr].edge);
         values[6] = Float8GetDatum(result_tuples[call_cntr].cost);
         values[7] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
-        /*********************************************************************/
+
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
         result = HeapTupleGetDatum(tuple);
         SRF_RETURN_NEXT(funcctx, result);
     } else {
-        // cleanup
         if (result_tuples) free(result_tuples);
 
         SRF_RETURN_DONE(funcctx);
diff --git a/src/astar/src/astarManyToMany_driver.cpp b/src/astar/src/astarManyToMany_driver.cpp
new file mode 100644
index 0000000..7ebb3c8
--- /dev/null
+++ b/src/astar/src/astarManyToMany_driver.cpp
@@ -0,0 +1,172 @@
+/*PGR-GNU*****************************************************************
+File: astarOneToOne_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sstream>
+#include <deque>
+#include <algorithm>
+#include <vector>
+#include "./astarManyToMany_driver.h"
+
+// #define DEBUG
+
+#include "./../../common/src/pgr_types.h"
+
+#include "./pgr_astar.hpp"
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_alloc.hpp"
+
+template < class G >
+void
+pgr_astar(
+        G &graph,
+        std::deque< Path >  &paths,
+        std::vector < int64_t > sources,
+        std::vector < int64_t > targets,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost = false) {
+    Pgr_astar< G > fn_astar;
+    fn_astar.astar(graph, paths, sources, targets,
+            heuristic, factor, epsilon, only_cost);
+}
+
+
+/************************************************************
+  edges_sql TEXT,
+  vertex_table TEXT,
+  start_vid BIGINT,
+  end_vid BIGINT  directed BOOLEAN DEFAULT true,
+ ***********************************************************/
+void do_pgr_astarManyToMany(
+        Pgr_edge_xy_t  *edges,
+        size_t total_edges,
+        int64_t  *start_vidsArr, size_t size_start_vidsArr,
+        int64_t  *end_vidsArr, size_t size_end_vidsArr,
+        bool directed,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost,
+        General_path_element_t **return_tuples,
+        size_t *return_count,
+        char ** log_msg,
+        char ** err_msg) {
+    std::ostringstream err;
+    std::ostringstream log;
+    try {
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+        pgassert(!(*return_tuples));
+        pgassert(*return_count == 0);
+        pgassert(total_edges != 0);
+
+
+        if (total_edges <= 1) {
+            err << "Required: more than one edge\n";
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        std::deque< Path >paths;
+        log << "Inserting target vertices into a c++ vector structure\n";
+        std::vector< int64_t > end_vids(
+                end_vidsArr,
+                end_vidsArr + size_end_vidsArr);
+        std::vector< int64_t > start_vids(
+                start_vidsArr,
+                start_vidsArr + size_start_vidsArr);
+
+        graphType gType = directed? DIRECTED: UNDIRECTED;
+
+        if (directed) {
+            log << "Working with directed Graph\n";
+            pgrouting::xyDirectedGraph digraph(
+                    pgrouting::extract_vertices(edges, total_edges),
+                    gType);
+            digraph.graph_insert_data(edges, total_edges);
+            pgr_astar(digraph, paths, start_vids, end_vids,
+                    heuristic, factor, epsilon, only_cost);
+        } else {
+            log << "Working with Undirected Graph\n";
+            pgrouting::xyUndirectedGraph undigraph(
+                    pgrouting::extract_vertices(edges, total_edges),
+                    gType);
+            undigraph.graph_insert_data(edges, total_edges);
+            pgr_astar(undigraph, paths, start_vids, end_vids,
+                    heuristic, factor, epsilon, only_cost);
+        }
+
+        size_t count(0);
+        count = count_tuples(paths);
+
+
+        if (count == 0) {
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            log <<
+                "No paths found\n";
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
+        log << "Converting a set of paths into the tuples\n";
+        (*return_count) = (collapse_paths(return_tuples, paths));
+
+        *err_msg = NULL;
+        *log_msg = strdup(log.str().c_str());
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    }
+}
diff --git a/src/withPoints/src/many_to_many_withPoints_driver.h b/src/astar/src/astarManyToMany_driver.h
similarity index 64%
copy from src/withPoints/src/many_to_many_withPoints_driver.h
copy to src/astar/src/astarManyToMany_driver.h
index a9ee9b3..7f34268 100644
--- a/src/withPoints/src/many_to_many_withPoints_driver.h
+++ b/src/astar/src/astarManyToMany_driver.h
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: many_to_many_withPoints_driver.h
+File: astarOneToMany_driver.h
 
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
@@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_ASTAR_SRC_ASTARMANYTOMANY_DRIVER_H_
+#define SRC_ASTAR_SRC_ASTARMANYTOMANY_DRIVER_H_
+
 #pragma once
 
 #include "./../../common/src/pgr_types.h"
@@ -34,38 +37,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-//  CREATE OR REPLACE FUNCTION pgr_withPoint(
-//  edges_sql TEXT,
-//  points_sql TEXT,
-//  start_pid ANYARRAY,
-//  end_pid BIGINT,
-//  directed BOOLEAN DEFAULT true,
-    int do_pgr_many_to_many_withPoints(
-            pgr_edge_t  *edges,
+    /*********************************************************
+      edges_sql TEXT,
+      vertex_table TEXT,
+      start_vid BIGINT,
+      end_vid BIGINT  directed BOOLEAN DEFAULT true,
+     ********************************************************/
+    void do_pgr_astarManyToMany(
+            Pgr_edge_xy_t  *data_edges,
             size_t total_edges,
-
-            Point_on_edge_t  *points,
-            size_t total_points,
-
-            pgr_edge_t  *edges_of_points,
-            size_t total_edges_of_points,
-
-            int64_t  *start_pidsArr,
-            size_t size_start_pidsArr,
-
-            int64_t  *end_pidsArr,
-            size_t size_end_pidsArr,
-
-
-            char driving_side,
-            bool details,
+            int64_t  *start_vidsArr, size_t size_start_vidsArr,
+            int64_t  *end_vidsArr, size_t size_end_vidsArr,
             bool directed,
+            int heuristic,
+            double factor,
+            double epsilon,
             bool only_cost,
             General_path_element_t **return_tuples,
             size_t *return_count,
+            char ** log_msg,
             char ** err_msg);
 
+
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_ASTAR_SRC_ASTARMANYTOMANY_DRIVER_H_
diff --git a/src/dijkstra/src/many_to_one_dijkstra.c b/src/astar/src/astarManyToOne.c
similarity index 60%
copy from src/dijkstra/src/many_to_one_dijkstra.c
copy to src/astar/src/astarManyToOne.c
index 161b292..aeebf3e 100644
--- a/src/dijkstra/src/many_to_one_dijkstra.c
+++ b/src/astar/src/astarManyToOne.c
@@ -1,6 +1,5 @@
 /*PGR-GNU*****************************************************************
-
-File: many_to_one_dijkstra.c
+File: astarOneToOne.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
@@ -8,7 +7,7 @@ Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Mail: 
 
 ------
 
@@ -36,50 +35,63 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
-
-/*
- * Uncomment when needed
- */
-
-// #define DEBUG
-
 #include "fmgr.h"
+
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
 #include "./../../common/src/arrays_input.h"
-#include "./many_to_one_dijkstra_driver.h"
 
-PG_FUNCTION_INFO_V1(many_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+#include "./astarOneToMany_driver.h"
+
+PG_FUNCTION_INFO_V1(astarManyToOne);
 PGDLLEXPORT Datum
-#endif
-many_to_one_dijkstra(PG_FUNCTION_ARGS);
-/******************************************************************************/
-/*                          MODIFY AS NEEDED                                  */
+astarManyToOne(PG_FUNCTION_ARGS);
+
+
 static
 void
-process(
-        char* edges_sql,
-        int64_t *start_vidsArr,
-        size_t size_start_vidsArr,
+process(char* edges_sql,
+        int64_t *start_vidsArr, size_t size_start_vidsArr,
         int64_t end_vid,
         bool directed,
+        int heuristic,
+        double factor,
+        double epsilon,
         bool only_cost,
         General_path_element_t **result_tuples,
         size_t *result_count) {
+    if (heuristic > 5 || heuristic < 0) {
+        free(start_vidsArr);
+        ereport(ERROR,
+                (errmsg("Unknown heuristic"),
+                 errhint("Valid values: 0~5")));
+    }
+    if (factor <= 0) {
+        free(start_vidsArr);
+        ereport(ERROR,
+                (errmsg("Factor value out of range"),
+                 errhint("Valid values: positive non zero")));
+    }
+    if (epsilon < 1) {
+        free(start_vidsArr);
+        ereport(ERROR,
+                (errmsg("Epsilon value out of range"),
+                 errhint("Valid values: 1 or greater than 1")));
+    }
+
+
+
     pgr_SPI_connect();
 
-    PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
-    size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    Pgr_edge_xy_t *edges = NULL;
+    size_t total_edges = 0;
+
+    pgr_get_edges_xy_reversed(edges_sql, &edges, &total_edges);
 
-    if (total_tuples == 0) {
+    if (total_edges == 0) {
         PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
@@ -87,52 +99,50 @@ process(
         return;
     }
 
-    PGR_DBG("Total %ld tuples in query:", total_tuples);
-
     PGR_DBG("Starting processing");
-    clock_t start_t = clock();
-
     char *err_msg = NULL;
-    do_pgr_many_to_one_dijkstra(
+    char *log_msg = NULL;
+    clock_t start_t = clock();
+    do_pgr_astarOneToMany(
             edges,
-            total_tuples,
-            start_vidsArr,
-            size_start_vidsArr,
+            total_edges,
             end_vid,
+            start_vidsArr, size_start_vidsArr,
             directed,
+            heuristic,
+            factor,
+            epsilon,
             only_cost,
             result_tuples,
             result_count,
-            &err_msg);
-    time_msg(" processing Dijkstra many to one", start_t, clock());
+            &log_msg,
+            &err_msg,
+            false);  // not normal
+    time_msg(" processing pgr_astar(many to one)", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    PGR_DBG("LOG: %s\n", log_msg);
+    if (log_msg) free(log_msg);
+
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        free(start_vidsArr);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
 
-    free(err_msg);
     pfree(edges);
     pgr_SPI_finish();
 }
-/*                                                                            */
-/******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-many_to_one_dijkstra(PG_FUNCTION_ARGS) {
+astarManyToOne(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+    uint32_t            call_cntr;
+    uint32_t            max_calls;
+    TupleDesc           tuple_desc;
 
-    /**************************************************************************/
-    /*                          MODIFY AS NEEDED                              */
-    /*                                                                        */
     General_path_element_t  *result_tuples = 0;
     size_t result_count = 0;
-    /*                                                                        */
-    /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
         MemoryContext   oldcontext;
@@ -140,45 +150,44 @@ many_to_one_dijkstra(PG_FUNCTION_ARGS) {
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
-        /*********************************************************************/
-        /*                          MODIFY AS NEEDED                         */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text,
-        // start_vids anyarray,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+        /**********************************************************************
+           edges_sql TEXT,
+           start_vid BIGINT,
+           end_vids ARRAY[ANY_INTEGER], -- anyarray
+           directed BOOLEAN DEFAULT true,
+           heuristic INTEGER DEFAULT 0,
+           factor FLOAT DEFAULT 1.0,
+           epsilon FLOAT DEFAULT 1.0,
+
+         **********************************************************************/
 
-        PGR_DBG("Initializing arrays");
         int64_t* start_vidsArr;
         size_t size_start_vidsArr;
         start_vidsArr = (int64_t*)
             pgr_get_bigIntArray(&size_start_vidsArr, PG_GETARG_ARRAYTYPE_P(1));
-        PGR_DBG("start_vidsArr size %ld ", size_start_vidsArr);
 
-        PGR_DBG("Calling process");
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
                 start_vidsArr, size_start_vidsArr,
                 PG_GETARG_INT64(2),
                 PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
+                PG_GETARG_INT32(4),
+                PG_GETARG_FLOAT8(5),
+                PG_GETARG_FLOAT8(6),
+                PG_GETARG_BOOL(7),
                 &result_tuples,
                 &result_count);
 
-        PGR_DBG("Cleaning arrays");
         free(start_vidsArr);
-        /*                                                                   */
-        /*********************************************************************/
+
 
         funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
-        if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+        if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                      errmsg("function returning record called in context "
                          "that cannot accept type record")));
-        }
 
         funcctx->tuple_desc = tuple_desc;
         MemoryContextSwitchTo(oldcontext);
@@ -196,16 +205,16 @@ many_to_one_dijkstra(PG_FUNCTION_ARGS) {
         Datum        *values;
         bool*        nulls;
 
-        /*********************************************************************/
-        /*                          MODIFY AS NEEDED                         */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT start_vid BIGINT,
-        // OUT end_vid BIGINT,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT)
+        /*********************************************************************
+           OUT seq INTEGER,
+           OUT path_seq INTEGER,
+           OUT end_vid BIGINT,
+           OUT node BIGINT,
+           OUT edge BIGINT,
+           OUT cost FLOAT,
+           OUT agg_cost FLOAT
+         **********************************************************************/
+
 
         values = palloc(7 * sizeof(Datum));
         nulls = palloc(7 * sizeof(bool));
@@ -215,23 +224,21 @@ many_to_one_dijkstra(PG_FUNCTION_ARGS) {
             nulls[i] = false;
         }
 
-        // postgres starts counting from 1
+
         values[0] = Int32GetDatum(call_cntr + 1);
         values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].start_id);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].end_id);
         values[3] = Int64GetDatum(result_tuples[call_cntr].node);
         values[4] = Int64GetDatum(result_tuples[call_cntr].edge);
         values[5] = Float8GetDatum(result_tuples[call_cntr].cost);
         values[6] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
-        /*********************************************************************/
+
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
         result = HeapTupleGetDatum(tuple);
         SRF_RETURN_NEXT(funcctx, result);
     } else {
-        // cleanup
         if (result_tuples) free(result_tuples);
-
         SRF_RETURN_DONE(funcctx);
     }
 }
diff --git a/src/dijkstra/src/one_to_many_dijkstra.c b/src/astar/src/astarOneToMany.c
similarity index 60%
copy from src/dijkstra/src/one_to_many_dijkstra.c
copy to src/astar/src/astarOneToMany.c
index 496f333..ba0e222 100644
--- a/src/dijkstra/src/one_to_many_dijkstra.c
+++ b/src/astar/src/astarOneToMany.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_many_dijkstra.c
+File: astarOneToOne.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer:
+Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Mail: 
 
 ------
 
@@ -35,104 +35,113 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
-
-/*
- * Uncomment when needed
- */
-
-// #define DEBUG
-
 #include "fmgr.h"
+
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
 #include "./../../common/src/arrays_input.h"
-#include "./one_to_many_dijkstra_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_many_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+#include "./astarOneToMany_driver.h"
+
+PG_FUNCTION_INFO_V1(astarOneToMany);
 PGDLLEXPORT Datum
-#endif
-one_to_many_dijkstra(PG_FUNCTION_ARGS);
+astarOneToMany(PG_FUNCTION_ARGS);
 
 
-/******************************************************************************/
-/*                          MODIFY AS NEEDED                                  */
 static
 void
-process(
-        char* edges_sql,
+process(char* edges_sql,
         int64_t start_vid,
-        int64_t *end_vidsArr,
-        size_t size_end_vidsArr,
+        int64_t *end_vidsArr, size_t size_end_vidsArr,
         bool directed,
+        int heuristic,
+        double factor,
+        double epsilon,
         bool only_cost,
         General_path_element_t **result_tuples,
         size_t *result_count) {
+    if (heuristic > 5 || heuristic < 0) {
+        free(end_vidsArr);
+        ereport(ERROR,
+                (errmsg("Unknown heuristic"),
+                 errhint("Valid values: 0~5")));
+    }
+    if (factor <= 0) {
+        free(end_vidsArr);
+        ereport(ERROR,
+                (errmsg("Factor value out of range"),
+                 errhint("Valid values: positive non zero")));
+    }
+    if (epsilon < 1) {
+        free(end_vidsArr);
+        ereport(ERROR,
+                (errmsg("Epsilon value out of range"),
+                 errhint("Valid values: 1 or greater than 1")));
+    }
+
+
+
     pgr_SPI_connect();
 
-    PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
-    size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    Pgr_edge_xy_t *edges = NULL;
+    size_t total_edges = 0;
 
-    if (total_tuples == 0) {
+    pgr_get_edges_xy(edges_sql, &edges, &total_edges);
+
+    if (total_edges == 0) {
         PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_tuples);
 
     PGR_DBG("Starting processing");
-    clock_t start_t = clock();
-
     char *err_msg = NULL;
-    do_pgr_one_to_many_dijkstra(
+    char *log_msg = NULL;
+    clock_t start_t = clock();
+    do_pgr_astarOneToMany(
             edges,
-            total_tuples,
+            total_edges,
             start_vid,
-            end_vidsArr,
-            size_end_vidsArr,
+            end_vidsArr, size_end_vidsArr,
             directed,
+            heuristic,
+            factor,
+            epsilon,
             only_cost,
             result_tuples,
             result_count,
-            &err_msg);
-    time_msg(" processing Dijkstra one to many", start_t, clock());
+            &log_msg,
+            &err_msg,
+            true);
+    time_msg(" processing pgr_astar(one to Many)", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    PGR_DBG("LOG: %s\n", log_msg);
+    if (log_msg) free(log_msg);
+
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
 
-    free(err_msg);
     pfree(edges);
     pgr_SPI_finish();
 }
-/*                                                                            */
-/******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_many_dijkstra(PG_FUNCTION_ARGS) {
+astarOneToMany(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+    uint32_t            call_cntr;
+    uint32_t            max_calls;
+    TupleDesc           tuple_desc;
 
-    /**************************************************************************/
-    /*                          MODIFY AS NEEDED                              */
-    /*                                                                        */
     General_path_element_t  *result_tuples = 0;
     size_t result_count = 0;
-    /*                                                                        */
-    /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
         MemoryContext   oldcontext;
@@ -140,45 +149,44 @@ one_to_many_dijkstra(PG_FUNCTION_ARGS) {
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
-        /**********************************************************************/
-        /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(sql text,
-        // start_vid bigint,
-        // end_vids anyarray,
-        // directed boolean default true,
-        // only_cost boolean default false
+        /*****************************************************************
+           edges_sql TEXT,
+           start_vid BIGINT,
+           end_vids ARRAY[ANY_INTEGER], -- anyarray
+           directed BOOLEAN DEFAULT true,
+           heuristic INTEGER DEFAULT 0,
+           factor FLOAT DEFAULT 1.0,
+           epsilon FLOAT DEFAULT 1.0,
+
+         ****************************************************************/
 
-        PGR_DBG("Initializing arrays");
         int64_t* end_vidsArr;
         size_t size_end_vidsArr;
         end_vidsArr = (int64_t*)
             pgr_get_bigIntArray(&size_end_vidsArr, PG_GETARG_ARRAYTYPE_P(2));
-        PGR_DBG("targetsArr size %ld ", size_end_vidsArr);
 
-        PGR_DBG("Calling process");
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
                 PG_GETARG_INT64(1),
                 end_vidsArr, size_end_vidsArr,
                 PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
+                PG_GETARG_INT32(4),
+                PG_GETARG_FLOAT8(5),
+                PG_GETARG_FLOAT8(6),
+                PG_GETARG_BOOL(7),
                 &result_tuples,
                 &result_count);
 
-        PGR_DBG("Cleaning arrays");
         free(end_vidsArr);
-        /*                                                                    */
-        /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
-        if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+        if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                      errmsg("function returning record called in context "
                          "that cannot accept type record")));
-        }
 
         funcctx->tuple_desc = tuple_desc;
         MemoryContextSwitchTo(oldcontext);
@@ -196,26 +204,26 @@ one_to_many_dijkstra(PG_FUNCTION_ARGS) {
         Datum        *values;
         bool*        nulls;
 
-        /*********************************************************************/
-        /*                          MODIFY AS NEEDED                         */
-        // OUT seq integer,
-        // OUT path_seq INTEGER,
-        // OUT end_vid BIGINT,
-        // OUT node bigint,
-        // OUT edge bigint,
-        // OUT cost float,
-        // OUT agg_cost float)
+        /*********************************************************************
+           OUT seq INTEGER,
+           OUT path_seq INTEGER,
+           OUT end_vid BIGINT,
+           OUT node BIGINT,
+           OUT edge BIGINT,
+           OUT cost FLOAT,
+           OUT agg_cost FLOAT
+         *********************************************************************/
+
 
         values = palloc(7 * sizeof(Datum));
         nulls = palloc(7 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 7; ++i) {
             nulls[i] = false;
         }
 
-        // postgres starts counting from 1
+
         values[0] = Int32GetDatum(call_cntr + 1);
         values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
         values[2] = Int64GetDatum(result_tuples[call_cntr].end_id);
@@ -223,15 +231,13 @@ one_to_many_dijkstra(PG_FUNCTION_ARGS) {
         values[4] = Int64GetDatum(result_tuples[call_cntr].edge);
         values[5] = Float8GetDatum(result_tuples[call_cntr].cost);
         values[6] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
-        /*********************************************************************/
+
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
         result = HeapTupleGetDatum(tuple);
         SRF_RETURN_NEXT(funcctx, result);
     } else {
-        // cleanup
         if (result_tuples) free(result_tuples);
-
         SRF_RETURN_DONE(funcctx);
     }
 }
diff --git a/src/astar/src/astarOneToMany_driver.cpp b/src/astar/src/astarOneToMany_driver.cpp
new file mode 100644
index 0000000..af341c8
--- /dev/null
+++ b/src/astar/src/astarOneToMany_driver.cpp
@@ -0,0 +1,182 @@
+/*PGR-GNU*****************************************************************
+File: astarOneToOne_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sstream>
+#include <deque>
+#include <algorithm>
+#include <vector>
+#include "./astarOneToMany_driver.h"
+
+
+#include "./../../common/src/pgr_types.h"
+#include "./pgr_astar.hpp"
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_alloc.hpp"
+
+template < class G >
+void
+pgr_astar(
+        G &graph,
+        std::deque< Path >  &paths,
+        int64_t source,
+        std::vector < int64_t > targets,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost = false) {
+    Pgr_astar< G > fn_astar;
+    fn_astar.astar(graph, paths, source, targets,
+            heuristic, factor, epsilon, only_cost);
+}
+
+
+/************************************************************
+  edges_sql TEXT,
+  vertex_table TEXT,
+  start_vid BIGINT,
+  end_vid BIGINT  directed BOOLEAN DEFAULT true,
+ ***********************************************************/
+void do_pgr_astarOneToMany(
+        Pgr_edge_xy_t  *edges,
+        size_t total_edges,
+        int64_t start_vid,
+        int64_t  *end_vidsArr, size_t size_end_vidsArr,
+        bool directed,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost,
+        General_path_element_t **return_tuples,
+        size_t *return_count,
+        char ** log_msg,
+        char ** err_msg,
+        bool normal) {
+    std::ostringstream err;
+    std::ostringstream log;
+    try {
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+        pgassert(!(*return_tuples));
+        pgassert(*return_count == 0);
+        pgassert(total_edges != 0);
+
+
+        if (total_edges <= 1) {
+            err << "Required: more than one edge\n";
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        std::deque< Path >paths;
+        log << "Inserting target vertices into a c++ vector structure\n";
+        std::vector< int64_t > end_vids(
+                end_vidsArr,
+                end_vidsArr + size_end_vidsArr);
+
+        graphType gType = directed? DIRECTED: UNDIRECTED;
+
+        if (directed) {
+            log << "Working with directed Graph\n";
+            pgrouting::xyDirectedGraph digraph(
+                    pgrouting::extract_vertices(edges, total_edges),
+                    gType);
+            digraph.graph_insert_data(edges, total_edges);
+            pgr_astar(digraph, paths, start_vid, end_vids,
+                    heuristic, factor, epsilon, only_cost);
+        } else {
+            log << "Working with Undirected Graph\n";
+            pgrouting::xyUndirectedGraph undigraph(
+                    pgrouting::extract_vertices(edges, total_edges),
+                    gType);
+            undigraph.graph_insert_data(edges, total_edges);
+            pgr_astar(undigraph, paths, start_vid, end_vids,
+                    heuristic, factor, epsilon, only_cost);
+        }
+        if (!normal) {
+            for (auto &path : paths) {
+                log << "reversing path\n";
+                log << path;
+                path.reverse();
+                log << "reversed path\n";
+                log << path;
+            }
+        }
+        log << "checking reversed paths\n";
+        for (auto path : paths) {
+            log << "reversed path\n";
+            log << path;
+        }
+
+        size_t count(0);
+        count = count_tuples(paths);
+
+
+        if (count == 0) {
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            log <<
+                "No paths found\n";
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
+        log << "Converting a set of paths into the tuples\n";
+        (*return_count) = (collapse_paths(return_tuples, paths));
+
+        *err_msg = NULL;
+        *log_msg = strdup(log.str().c_str());
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    }
+}
diff --git a/src/withPoints/src/many_to_many_withPoints_driver.h b/src/astar/src/astarOneToMany_driver.h
similarity index 63%
copy from src/withPoints/src/many_to_many_withPoints_driver.h
copy to src/astar/src/astarOneToMany_driver.h
index a9ee9b3..17e8694 100644
--- a/src/withPoints/src/many_to_many_withPoints_driver.h
+++ b/src/astar/src/astarOneToMany_driver.h
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: many_to_many_withPoints_driver.h
+File: astarOneToMany_driver.h
 
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
@@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_ASTAR_SRC_ASTARONETOMANY_DRIVER_H_
+#define SRC_ASTAR_SRC_ASTARONETOMANY_DRIVER_H_
+
 #pragma once
 
 #include "./../../common/src/pgr_types.h"
@@ -34,38 +37,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-//  CREATE OR REPLACE FUNCTION pgr_withPoint(
-//  edges_sql TEXT,
-//  points_sql TEXT,
-//  start_pid ANYARRAY,
-//  end_pid BIGINT,
-//  directed BOOLEAN DEFAULT true,
-    int do_pgr_many_to_many_withPoints(
-            pgr_edge_t  *edges,
+    /*********************************************************
+      edges_sql TEXT,
+      vertex_table TEXT,
+      start_vid BIGINT,
+      end_vid BIGINT  directed BOOLEAN DEFAULT true,
+     ********************************************************/
+    void do_pgr_astarOneToMany(
+            Pgr_edge_xy_t  *data_edges,
             size_t total_edges,
-
-            Point_on_edge_t  *points,
-            size_t total_points,
-
-            pgr_edge_t  *edges_of_points,
-            size_t total_edges_of_points,
-
-            int64_t  *start_pidsArr,
-            size_t size_start_pidsArr,
-
-            int64_t  *end_pidsArr,
-            size_t size_end_pidsArr,
-
-
-            char driving_side,
-            bool details,
+            int64_t start_vid,
+            int64_t  *end_vidsArr, size_t size_end_vidsArr,
             bool directed,
+            int heuristic,
+            double factor,
+            double epsilon,
             bool only_cost,
             General_path_element_t **return_tuples,
             size_t *return_count,
-            char ** err_msg);
+            char ** log_msg,
+            char ** err_msg,
+            bool normal);
+
 
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_ASTAR_SRC_ASTARONETOMANY_DRIVER_H_
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/astar/src/astarOneToOne.c
similarity index 61%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/astar/src/astarOneToOne.c
index d099701..330a2b3 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/astar/src/astarOneToOne.c
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: astarOneToOne.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
@@ -7,7 +7,7 @@ Mail: project at pgrouting.org
 
 Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Mail:
 
 ------
 
@@ -35,109 +35,110 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
-
-/*
-  Uncomment when needed
-*/
-// #define DEBUG
-
 #include "fmgr.h"
+
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
 
-PG_MODULE_MAGIC;
+#include "./astarOneToOne_driver.h"
+
+PGDLLEXPORT Datum astarOneToOne(PG_FUNCTION_ARGS);
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
 
-/******************************************************************************/
-/*                          MODIFY AS NEEDED                                  */
 static
 void
-process(
-        char* edges_sql,
+process(char* edges_sql,
         int64_t start_vid,
         int64_t end_vid,
         bool directed,
+        int heuristic,
+        double factor,
+        double epsilon,
         bool only_cost,
         General_path_element_t **result_tuples,
         size_t *result_count) {
+    if (heuristic > 5 || heuristic < 0) {
+        ereport(ERROR,
+                (errmsg("Unknown heuristic"),
+                 errhint("Valid values: 0~5")));
+    }
+    if (factor <= 0) {
+        ereport(ERROR,
+                (errmsg("Factor value out of range"),
+                 errhint("Valid values: positive non zero")));
+    }
+    if (epsilon < 1) {
+        ereport(ERROR,
+                (errmsg("Epsilon value out of range"),
+                 errhint("Valid values: 1 or greater than 1")));
+    }
+
+
+
     pgr_SPI_connect();
 
     PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
+    Pgr_edge_xy_t *edges = NULL;
+    size_t total_edges = 0;
 
-    if (start_vid == end_vid) {
-        (*result_count) = 0;
-        (*result_tuples) = NULL;
-        pgr_SPI_finish();
-        return;
-    }
+    pgr_get_edges_xy(edges_sql, &edges, &total_edges);
+    PGR_DBG("Total %ld edges in query:", total_edges);
 
-    size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
-
-    if (total_tuples == 0) {
+    if (total_edges == 0) {
         PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_tuples);
 
     PGR_DBG("Starting processing");
-    clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
+    char *log_msg = NULL;
+    clock_t start_t = clock();
+    do_pgr_astarOneToOne(
             edges,
-            total_tuples,
+            total_edges,
             start_vid,
             end_vid,
             directed,
+            heuristic,
+            factor,
+            epsilon,
             only_cost,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
+    time_msg(" processing pgr_astar(one to one)", start_t, clock());
 
-    time_msg(" processing Dijkstra one to one", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    PGR_DBG("LOG: %s\n", log_msg);
+    if (log_msg) free(log_msg);
+
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
 
-    free(err_msg);
     pfree(edges);
     pgr_SPI_finish();
 }
-/*                                                                            */
-/******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(astarOneToOne);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
+astarOneToOne(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+    uint32_t            call_cntr;
+    uint32_t            max_calls;
+    TupleDesc           tuple_desc;
 
-    /**************************************************************************/
-    /*                          MODIFY AS NEEDED                              */
-    /*                                                                        */
     General_path_element_t  *result_tuples = 0;
     size_t result_count = 0;
-    /*                                                                        */
-    /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
         MemoryContext   oldcontext;
@@ -145,12 +146,16 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
-        /**********************************************************************/
-        /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+        /**********************************************************************
+           edges_sql TEXT,
+           start_vid BIGINT,
+           end_vid BIGINT,
+           directed BOOLEAN DEFAULT true,
+           heuristic INTEGER DEFAULT 0,
+           factor FLOAT DEFAULT 1.0,
+           epsilon FLOAT DEFAULT 1.0,
+
+         **********************************************************************/
 
         PGR_DBG("Calling process");
         process(
@@ -158,22 +163,21 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
                 PG_GETARG_INT64(1),
                 PG_GETARG_INT64(2),
                 PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
+                PG_GETARG_INT32(4),
+                PG_GETARG_FLOAT8(5),
+                PG_GETARG_FLOAT8(6),
+                PG_GETARG_BOOL(7),
                 &result_tuples,
                 &result_count);
 
-        /*                                                                    */
-        /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
-        if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+        if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                      errmsg("function returning record called in context "
                          "that cannot accept type record")));
-        }
 
         funcctx->tuple_desc = tuple_desc;
         MemoryContextSwitchTo(oldcontext);
@@ -191,32 +195,32 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
         Datum        *values;
         bool*        nulls;
 
-        /**********************************************************************/
-        /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
+        /**********************************************************************
+           OUT seq INTEGER,
+           OUT path_seq INTEGER,
+           OUT node BIGINT,
+           OUT edge BIGINT,
+           OUT cost FLOAT,
+           OUT agg_cost FLOAT
+         *********************************************************************/
+
 
         values = palloc(6 * sizeof(Datum));
         nulls = palloc(6 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 6; ++i) {
             nulls[i] = false;
         }
 
-        // postgres starts counting from 1
+
         values[0] = Int32GetDatum(call_cntr + 1);
         values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
         values[2] = Int64GetDatum(result_tuples[call_cntr].node);
         values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
         values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
         values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
-        /**********************************************************************/
+
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
         result = HeapTupleGetDatum(tuple);
diff --git a/src/astar/src/astarOneToOne_driver.cpp b/src/astar/src/astarOneToOne_driver.cpp
new file mode 100644
index 0000000..3bed03f
--- /dev/null
+++ b/src/astar/src/astarOneToOne_driver.cpp
@@ -0,0 +1,167 @@
+/*PGR-GNU*****************************************************************
+File: astarOneToOne_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sstream>
+#include <deque>
+#include <algorithm>
+#include <vector>
+#include "./astarOneToOne_driver.h"
+
+#include "./../../common/src/pgr_types.h"
+
+#include "./pgr_astar.hpp"
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_alloc.hpp"
+
+template < class G >
+void
+pgr_astar(
+        G &graph,
+        Path &path,
+        int64_t source,
+        int64_t target,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost = false) {
+    Pgr_astar< G > fn_astar;
+    fn_astar.astar(graph, path, source, target,
+            heuristic, factor, epsilon, only_cost);
+}
+
+
+/************************************************************
+  edges_sql TEXT,
+  vertex_table TEXT,
+  start_vid BIGINT,
+  end_vid BIGINT  directed BOOLEAN DEFAULT true,
+ ***********************************************************/
+void do_pgr_astarOneToOne(
+        Pgr_edge_xy_t  *data_edges,
+        size_t total_edges,
+        int64_t start_vid,
+        int64_t end_vid,
+        bool directed,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost,
+        General_path_element_t **return_tuples,
+        size_t *return_count,
+        char ** log_msg,
+        char ** err_msg) {
+    std::ostringstream err;
+    std::ostringstream log;
+    try {
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+        pgassert(!(*return_tuples));
+        pgassert(*return_count == 0);
+        pgassert(total_edges != 0);
+
+        if (total_edges <= 1) {
+            log << "Required: more than one edge\n";
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+
+        graphType gType = directed? DIRECTED: UNDIRECTED;
+
+        Path path;
+
+        if (directed) {
+            log << "Working with directed Graph\n";
+            pgrouting::xyDirectedGraph digraph(gType);
+            log << "Working with directed Graph 1 \n";
+            digraph.graph_insert_data(data_edges, total_edges);
+#ifdef DEBUG
+            log << digraph;
+#endif
+            log << "Working with directed Graph 2\n";
+            pgr_astar(digraph, path, start_vid, end_vid,
+                    heuristic, factor, epsilon, only_cost);
+            log << "Working with directed Graph 3\n";
+        } else {
+            log << "Working with Undirected Graph\n";
+            pgrouting::xyUndirectedGraph undigraph(gType);
+            undigraph.graph_insert_data(data_edges, total_edges);
+#ifdef DEBUG
+            log << undigraph;
+#endif
+            pgr_astar(undigraph, path, start_vid, end_vid,
+                    heuristic, factor, epsilon, only_cost);
+        }
+
+        auto count = path.size();
+
+        if (count == 0) {
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            log <<
+                "No paths found\n";
+            *log_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        size_t sequence = 0;
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
+        path.generate_postgres_data(return_tuples, sequence);
+        (*return_count) = sequence;
+
+        *err_msg = NULL;
+        *log_msg = strdup(log.str().c_str());
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    }
+}
diff --git a/src/withPoints/src/many_to_many_withPoints_driver.h b/src/astar/src/astarOneToOne_driver.h
similarity index 66%
copy from src/withPoints/src/many_to_many_withPoints_driver.h
copy to src/astar/src/astarOneToOne_driver.h
index a9ee9b3..f0b7f70 100644
--- a/src/withPoints/src/many_to_many_withPoints_driver.h
+++ b/src/astar/src/astarOneToOne_driver.h
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: many_to_many_withPoints_driver.h
+File: astarOneToOne_driver.h
 
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
@@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef  SRC_ASTAR_SRC_ASTARONETOONE_DRIVER_H_
+#define  SRC_ASTAR_SRC_ASTARONETOONE_DRIVER_H_
 #pragma once
 
 #include "./../../common/src/pgr_types.h"
@@ -34,38 +36,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-//  CREATE OR REPLACE FUNCTION pgr_withPoint(
-//  edges_sql TEXT,
-//  points_sql TEXT,
-//  start_pid ANYARRAY,
-//  end_pid BIGINT,
-//  directed BOOLEAN DEFAULT true,
-    int do_pgr_many_to_many_withPoints(
-            pgr_edge_t  *edges,
+    /*********************************************************
+      edges_sql TEXT,
+      vertex_table TEXT,
+      start_vid BIGINT,
+      end_vid BIGINT  directed BOOLEAN DEFAULT true,
+     ********************************************************/
+    void do_pgr_astarOneToOne(
+            Pgr_edge_xy_t  *data_edges,
             size_t total_edges,
-
-            Point_on_edge_t  *points,
-            size_t total_points,
-
-            pgr_edge_t  *edges_of_points,
-            size_t total_edges_of_points,
-
-            int64_t  *start_pidsArr,
-            size_t size_start_pidsArr,
-
-            int64_t  *end_pidsArr,
-            size_t size_end_pidsArr,
-
-
-            char driving_side,
-            bool details,
+            int64_t start_vid,
+            int64_t end_vid,
             bool directed,
+            int heuristic,
+            double factor,
+            double epsilon,
             bool only_cost,
             General_path_element_t **return_tuples,
             size_t *return_count,
+            char ** log_msg,
             char ** err_msg);
 
+
 #ifdef __cplusplus
 }
 #endif
 
+#endif  //  SRC_ASTAR_SRC_ASTARONETOONE_DRIVER_H_
diff --git a/src/astar/src/astar_boost_wrapper.cpp b/src/astar/src/astar_boost_wrapper.cpp
deleted file mode 100644
index 186aab3..0000000
--- a/src/astar/src/astar_boost_wrapper.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-/*PGR-GNU*****************************************************************
-
- * A* Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2006 Anton A. Patrushev, Orkney, Inc.
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-// Include C header first for windows build issue
-
-#ifdef __MINGW32__
-#include <winsock2.h>
-#include <windows.h>
-#ifdef unlink
-#undef unlink
-#endif
-#endif
-
-
-#if 0
-extern "C" {
-#include "postgres.h"
-}
-#endif
-
-#include <boost/config.hpp>
-
-#include <boost/graph/graph_traits.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/astar_search.hpp>
-
-#include <cmath>    // for sqrt
-#include "astar.h"
-
-using namespace std;
-using namespace boost;
-
-// Maximal number of nodes in the path (to avoid infinite loops)
-#define MAX_NODES 100000000
-
-struct Edge
-{
-  int id;
-  double cost;
-  //double distance;
-};
-  
-struct Vertex
-{
-  int id;
-  double x;
-  double y;
-};
-
-
-struct found_goal {}; // exception for termination
-
-// visitor that terminates when we find the goal
-template <class Vertex>
-class astar_goal_visitor : public boost::default_astar_visitor
-{
-    public:
-      astar_goal_visitor(Vertex goal) : m_goal(goal) {}
-      template <class Graph>
-      void examine_vertex(Vertex u, Graph& g) {
-        if(u == m_goal)
-          throw found_goal();
-        num_vertices(g); 
-      }
-    private:
-      Vertex m_goal;
-};
-
-// Heuristic function which tells us how far the current node is
-// from the target node.
-//
-// (|dx|+|dy|)/2 is used currently.
-template <class Graph, class CostType>
-class distance_heuristic : public astar_heuristic<Graph, CostType>
-{
-    public:
-      typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
-      distance_heuristic(Graph& g, Vertex goal):m_g(g), m_goal(goal){}
-      CostType operator()(Vertex u)
-      {
-        CostType dx = m_g[m_goal].x - m_g[u].x;
-        CostType dy = m_g[m_goal].y - m_g[u].y;
-        //You can choose any heuristical function from below
-        //return ::max(dx, dy);
-        //return ::sqrt(dx * dx + dy * dy)/4;
-        //return 0;
-        return (::fabs(dx)+::fabs(dy))/2;
-      } 
-    private:
-      Graph& m_g;
-      Vertex m_goal;
-};
-
-
-// Adds an edge to the graph.
-// Edge id, cost, source and target ids and coordinates are copied also
-template <class G, class E>
-static void
-graph_add_edge(G &graph, int id, int source, int target, 
-         double cost, double s_x, double s_y, double t_x, double t_y)
-{
-  E e;
-  bool inserted;
-    
-  if (cost < 0) // edges are not inserted in the graph if cost is negative
-    return;
-
-  tie(e, inserted) = add_edge(source, target, graph);
-
-  graph[e].cost = cost;
-  graph[e].id = id;
-
-  typedef typename graph_traits<G>::vertex_descriptor Vertex;
-  Vertex s = vertex(source, graph);
-  Vertex t = vertex(target, graph);
-  graph[s].x=s_x;
-  graph[s].y=s_y;
-  graph[t].x=t_x;
-  graph[t].y=t_y;
-}
-
-int 
-boost_astar(edge_astar_t *edges, size_t count, 
-      int source_vertex_id, int target_vertex_id,
-      bool directed, bool has_reverse_cost,
-      path_element_t **path, size_t *path_count, char **err_msg)
-{
-try {
-
-  // FIXME: use a template for the directedS parameters
-  typedef adjacency_list < listS, vecS, directedS, Vertex, Edge> graph_t;
-
-  typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
-  typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
-
-  // FIXME: compute this value
-  const  auto num_nodes = ((directed && has_reverse_cost ? 2 : 1) * 
-          count) + 100;
-
-  graph_t graph(num_nodes);
-
-  // interfers with APPLE build, can it just be commented out?
-  //property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, 
-  //                   graph);
-
-  for (std::size_t j = 0; j < count; ++j)
-  {
-
-      graph_add_edge<graph_t, edge_descriptor>(graph, 
-                 edges[j].id, edges[j].source, 
-                 edges[j].target, edges[j].cost, 
-                 edges[j].s_x, edges[j].s_y, 
-                 edges[j].t_x, edges[j].t_y);
-
-      if (!directed || (directed && has_reverse_cost))
-      {
-        double cost;
-
-        if (has_reverse_cost)
-        {
-            cost = edges[j].reverse_cost;
-        }
-        else 
-        {
-            cost = edges[j].cost;
-        }
-
-        graph_add_edge<graph_t, edge_descriptor>(graph, 
-               edges[j].id, 
-               edges[j].target, 
-               edges[j].source, 
-               cost, 
-               edges[j].t_x, 
-               edges[j].t_y, 
-               edges[j].s_x, 
-               edges[j].s_y);
-        }
-  }
-
-  std::vector<vertex_descriptor> predecessors(num_vertices(graph));
-
-  vertex_descriptor source_vertex = vertex(source_vertex_id, graph);
-
-  if ((long)source_vertex < 0) 
-  {
-      *err_msg = (char *) "Source vertex not found";
-      return -1;
-  }
-
-  vertex_descriptor target_vertex = vertex(target_vertex_id, graph);
-  if ((long)target_vertex < 0)
-  {
-      *err_msg = (char *) "Target vertex not found";
-      return -1;
-  }
-
-  std::vector<double> distances(num_vertices(graph));
-
-  try {
-    // Call A* named parameter interface
-    astar_search
-      (graph, source_vertex,
-       distance_heuristic<graph_t, double>(graph, target_vertex),
-       predecessor_map(&predecessors[0]).
-       weight_map(get(&Edge::cost, graph)).
-       distance_map(&distances[0]).
-       visitor(astar_goal_visitor<vertex_descriptor>(target_vertex)));
-
-  } 
-  catch(found_goal& fg) {
-    // Target vertex found
-    vector<vertex_descriptor> path_vect;
-    int max = MAX_NODES;
-    path_vect.push_back(target_vertex);
-  
-    while (target_vertex != source_vertex) 
-    {
-        if (target_vertex == predecessors[target_vertex]) 
-        {
-            *err_msg = (char *) "No path found";
-            return 0;
-      
-        }
-        target_vertex = predecessors[target_vertex];
-
-        path_vect.push_back(target_vertex);
-        if (!max--) 
-        {
-            *err_msg = (char *) "Overflow";
-            return -1;
-        }
-    }
-
-    *path = (path_element_t *) malloc(sizeof(path_element_t) * 
-              (path_vect.size() + 1));
-    *path_count = path_vect.size();
-
-    for(int64_t i = static_cast<int64_t>(path_vect.size()) - 1, j = 0; i >= 0; i--, j++)
-    {
-        graph_traits < graph_t >::vertex_descriptor v_src;
-        graph_traits < graph_t >::vertex_descriptor v_targ;
-        graph_traits < graph_t >::edge_descriptor e;
-        graph_traits < graph_t >::out_edge_iterator out_i, out_end;
-
-        (*path)[j].vertex_id = static_cast<int>(path_vect.at(i));
-
-        (*path)[j].edge_id = -1;
-        (*path)[j].cost = distances[target_vertex];
-        
-        if (i == 0) 
-        {
-            continue;
-        }
-
-        v_src = path_vect.at(i);
-        v_targ = path_vect.at(i - 1);
-        double cost = 99999999.9;
-        int edge_id = 0;
-
-        for (tie(out_i, out_end) = out_edges(v_src, graph); 
-             out_i != out_end; ++out_i)
-        {
-            graph_traits < graph_t >::vertex_descriptor targ; // v   set but not used
-            e = *out_i;
-            // v = source(e, graph);
-            targ = target(e, graph);
-                                                                
-            if (targ == v_targ)
-            {
-                if (graph[*out_i].cost < cost)
-                {
-                    edge_id = graph[*out_i].id;
-                    cost = graph[*out_i].cost;
-                }
-            }
-        }
-        (*path)[j].edge_id = edge_id;
-        (*path)[j].cost = cost;
-    }
-
-    return EXIT_SUCCESS;
-  }
- }
- catch(...) {
-    *err_msg = (char *) "Unknown exception caught!";
-    return -1;
- }
- *err_msg = (char *) "No path found";
- return 0;
-}
-
diff --git a/src/astar/src/pgr_astar.hpp b/src/astar/src/pgr_astar.hpp
new file mode 100644
index 0000000..92159a4
--- /dev/null
+++ b/src/astar/src/pgr_astar.hpp
@@ -0,0 +1,567 @@
+/*PGR-GNU*****************************************************************
+
+File: pgr_astar.hpp
+
+Copyright (c) 2015 Vicky Vergara
+Mail: vicky_vergara at hotmail.com
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+// Include C header first for windows build issue
+
+#if 0
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+#endif
+
+#include <boost/config.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/astar_search.hpp>
+
+#include <cmath>
+
+
+#include <deque>
+#include <limits>
+#include <algorithm>
+#include <vector>
+#include <set>
+
+#include "./../../common/src/basePath_SSEC.hpp"
+#include "./../../common/src/pgr_base_graph.hpp"
+
+
+
+
+
+template < class G >
+class Pgr_astar {
+ public:
+     typedef typename G::V V;
+     typedef typename G::B_G B_G;
+
+
+     //! @name Astar
+     //@{
+     //! one to one
+     void astar(
+             G &graph,
+             Path &path,
+             int64_t start_vertex,
+             int64_t end_vertex,
+             int heuristic,
+             double factor,
+             double epsilon,
+             bool only_cost = false);
+
+     //! one to Many
+     void astar(
+             G &graph,
+             std::deque< Path > &paths,
+             int64_t start_vertex,
+             const std::vector< int64_t > &end_vertex,
+             int heuristic,
+             double factor,
+             double epsilon,
+             bool only_cost = false);
+
+     //! Many to Many
+     void astar(
+             G &graph,
+             std::deque< Path > &paths,
+             std::vector< int64_t > start_vertex,
+             const std::vector< int64_t > &end_vertex,
+             int heuristic,
+             double factor,
+             double epsilon,
+             bool only_cost = false);
+
+     //@}
+
+ private:
+     //! Call to Astar  1 source to 1 target
+     bool astar_1_to_1(
+             G &graph,
+             V source,
+             V target,
+             int heuristic,
+             double factor,
+             double epsilon);
+
+     //! Call to astar  1 source to many targets
+     bool astar_1_to_many(
+             G &graph,
+             V source,
+             const std::vector< V > &targets,
+             int heuristic,
+             double factor,
+             double epsilon);
+
+
+
+     void clear() {
+         predecessors.clear();
+         distances.clear();
+     }
+
+     void get_path(
+             const G &graph,
+             V source,
+             V target,
+             Path &path) const;
+     void get_cost(
+             const G &graph,
+             V source,
+             V target,
+             Path &path) const;
+
+     // used when multiple goals
+     void get_path(
+             const G &graph,
+             std::deque< Path > &paths,
+             V source,
+             std::vector< V > &targets) const;
+
+     void get_cost(
+             const G &graph,
+             std::deque< Path > &paths,
+             V source,
+             std::vector< V > &targets) const;
+
+     //! @name members;
+     //@{
+     struct found_goals{};  //!< exception for termination
+     std::vector< V > predecessors;
+     std::vector< double > distances;
+     std::deque< V > nodesInDistance;
+     //@}
+
+     // euclidean distance heuristic for one goal
+     class distance_heuristic : public boost::astar_heuristic< B_G, double > {
+      public:
+          distance_heuristic(B_G &g, V goal, int heuristic, double factor)
+              : m_g(g),
+              m_factor(factor),
+              m_heuristic(heuristic) {
+                  m_goals.insert(goal);
+              }
+          distance_heuristic(
+                  B_G &g,
+                  std::vector< V > goals,
+                  int heuristic,
+                  double factor)
+              : m_g(g),
+              m_goals(goals.begin(), goals.end()),
+              m_factor(factor),
+              m_heuristic(heuristic) {}
+
+          double operator()(V u) {
+              if (m_heuristic == 0) return 0;
+              if (m_goals.empty()) return 0;
+              double best_h(std::numeric_limits<double>::max());
+              for (auto goal : m_goals) {
+                  double current(std::numeric_limits<double>::max());
+                  double dx = m_g[goal].x() - m_g[u].x();
+                  double dy = m_g[goal].y() - m_g[u].y();
+                  switch (m_heuristic) {
+                      case 0:
+                          current = 0;
+                      case 1:
+                          current = std::fabs(std::max(dx, dy)) * m_factor;
+                      case 2:
+                          current = std::fabs(std::min(dx, dy)) * m_factor;
+                      case 3:
+                          current = (dx * dx + dy * dy) * m_factor * m_factor;
+                      case 4:
+                          current = std::sqrt(dx * dx + dy * dy) * m_factor;
+                      case 5:
+                          current = (std::fabs(dx) + std::fabs(dy)) * m_factor;
+                      default:
+                          current = 0;
+                  }
+                  if (current < best_h) {
+                      best_h = current;
+                  }
+              }
+              {
+                  auto s_it = m_goals.find(u);
+                  if (!(s_it == m_goals.end())) {
+                      // found one more goal
+                      m_goals.erase(s_it);
+                  }
+              }
+              return best_h;
+          }
+
+      private:
+          B_G &m_g;
+          std::set< V > m_goals;
+          double m_factor;
+          int m_heuristic;
+     };  // class distance_heuristic
+
+
+     //! visitor that terminates when we find the goal
+     class astar_one_goal_visitor : public boost::default_astar_visitor {
+      public:
+          explicit astar_one_goal_visitor(V goal) : m_goal(goal) {}
+          template <class B_G>
+              void examine_vertex(V u, B_G &g) {
+                  if (u == m_goal)
+                      throw found_goals();
+                  // using g, otherwise is throws a warning
+                  num_edges(g);
+              }
+      private:
+          V m_goal;
+     };  // class astar_one_goal_visitor
+
+     //! class for stopping when all targets are found
+     class astar_many_goals_visitor : public boost::default_astar_visitor {
+      public:
+          explicit astar_many_goals_visitor(std::vector< V > goals)
+              :m_goals(goals.begin(), goals.end()) {}
+          template <class B_G>
+              void examine_vertex(V u, B_G &g) {
+                  auto s_it = m_goals.find(u);
+                  if (s_it == m_goals.end()) return;
+                  // found one more goal
+                  m_goals.erase(s_it);
+                  if (m_goals.size() == 0) throw found_goals();
+                  num_edges(g);
+              }
+      private:
+          std::set< V > m_goals;
+     };
+};  // pgr_astar
+
+/******************** IMPLEMENTTION ******************/
+
+//! astar 1 to 1
+template < class G >
+void
+Pgr_astar< G >::astar(
+        G &graph,
+        Path &path,
+        int64_t start_vertex,
+        int64_t end_vertex,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost) {
+    clear();
+
+    // adjust predecessors and distances vectors
+    predecessors.resize(graph.num_vertices());
+    distances.resize(graph.num_vertices());
+
+
+    if (!graph.has_vertex(start_vertex)
+            || !graph.has_vertex(end_vertex)) {
+        path.clear();
+        return;
+    }
+
+    // get the graphs source and target
+    auto v_source(graph.get_V(start_vertex));
+    auto v_target(graph.get_V(end_vertex));
+
+    // perform the algorithm
+    astar_1_to_1(graph, v_source, v_target, heuristic, factor, epsilon);
+
+    // get the results
+    if (only_cost) {
+        get_cost(graph, v_source, v_target, path);
+    } else {
+        get_path(graph, v_source, v_target, path);
+    }
+    return;
+}
+
+//! astar 1 to many
+template < class G >
+void
+Pgr_astar< G >::astar(
+        G &graph,
+        std::deque< Path > &paths,
+        int64_t start_vertex,
+        const std::vector< int64_t > &end_vertex,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost) {
+    clear();
+
+    // adjust predecessors and distances vectors
+    predecessors.resize(graph.num_vertices());
+    distances.resize(graph.num_vertices());
+
+    // get the graphs source and targets
+    if (!graph.has_vertex(start_vertex)) return;
+    auto v_source(graph.get_V(start_vertex));
+
+    std::set< V > s_v_targets;
+    for (const auto &vertex : end_vertex) {
+        if (graph.has_vertex(vertex)) {
+            s_v_targets.insert(graph.get_V(vertex));
+        }
+    }
+
+    std::vector< V > v_targets(s_v_targets.begin(), s_v_targets.end());
+    // perform the algorithm
+    astar_1_to_many(graph, v_source, v_targets, heuristic, factor, epsilon);
+
+    // get the results // route id are the targets
+    if (only_cost) {
+        get_cost(graph, paths, v_source, v_targets);
+    } else {
+        get_path(graph, paths, v_source, v_targets);
+    }
+
+    std::stable_sort(paths.begin(), paths.end(),
+            [](const Path &e1, const Path &e2)->bool {
+            return e1.end_id() < e2.end_id();
+            });
+
+    return;
+}
+
+// preparation for many to many
+template < class G >
+void
+Pgr_astar< G >::astar(
+        G &graph, std::deque< Path > &paths,
+        std::vector< int64_t > start_vertex,
+        const std::vector< int64_t > &end_vertex,
+        int heuristic,
+        double factor,
+        double epsilon,
+        bool only_cost) {
+    std::stable_sort(start_vertex.begin(), start_vertex.end());
+    start_vertex.erase(
+            std::unique(start_vertex.begin(), start_vertex.end()),
+            start_vertex.end());
+
+    for (const auto &start : start_vertex) {
+        astar(graph, paths, start, end_vertex,
+                heuristic, factor, epsilon, only_cost);
+    }
+
+    std::sort(paths.begin(), paths.end(),
+            [](const Path &e1, const Path &e2)->bool {
+            return e1.end_id() < e2.end_id();
+            });
+    std::stable_sort(paths.begin(), paths.end(),
+            [](const Path &e1, const Path &e2)->bool {
+            return e1.start_id() < e2.start_id();
+            });
+    return;
+}
+
+
+
+
+//! Call to Astar  1 source to 1 target
+template < class G >
+bool
+Pgr_astar< G >::astar_1_to_1(
+        G &graph,
+        V source,
+        V target,
+        int heuristic,
+        double factor,
+        double epsilon) {
+    bool found = false;
+    try {
+        // Call A* named parameter interface
+        boost::astar_search(
+                graph.graph, source,
+                distance_heuristic(graph.graph, target,
+                    heuristic, factor * epsilon),
+                boost::predecessor_map(&predecessors[0])
+                .weight_map(get(&pgrouting::Basic_edge::cost, graph.graph))
+                .distance_map(&distances[0])
+                .visitor(astar_one_goal_visitor(target)));
+    }
+    catch(found_goals &) {
+        found = true;  // Target vertex found
+    }
+    return found;
+}
+
+
+//! Call to astar  1 source to many targets
+template <class G>
+bool
+Pgr_astar< G >::astar_1_to_many(
+        G &graph,
+        V source,
+        const std::vector< V > &targets,
+        int heuristic,
+        double factor,
+        double epsilon) {
+    bool found = false;
+    try {
+        boost::astar_search(
+                graph.graph, source,
+                distance_heuristic(
+                    graph.graph, targets,
+                    heuristic, factor * epsilon),
+                boost::predecessor_map(&predecessors[0])
+                .weight_map(get(&pgrouting::Basic_edge::cost, graph.graph))
+                .distance_map(&distances[0])
+                .visitor(astar_many_goals_visitor(targets)));
+    }
+    catch(found_goals &fg) {
+        found = true;  // Target vertex found
+    }
+    return found;
+}
+
+
+/*
+ * GET_COST
+ */
+
+
+
+template < class G >
+void
+Pgr_astar< G >::get_cost(
+        const G &graph,
+        V source,
+        V target,
+        Path &r_path) const {
+    // backup of the target
+    int64_t from(graph.graph[source].id);
+    int64_t to(graph.graph[target].id);
+
+    // no path was found
+    if (target == predecessors[target]) {
+        r_path.clear();
+    } else {
+        Path path(from, to);
+        path.push_front(
+                {to, -1, distances[target], distances[target]});
+        r_path = path;
+    }
+}
+
+template < class G >
+void
+Pgr_astar< G >::get_cost(
+        const G &graph,
+        std::deque< Path > &paths,
+        V source,
+        std::vector< V > &targets) const {
+    Path path;
+    for (auto s_it = targets.begin(); s_it != targets.end(); ++s_it) {
+        path.clear();
+        get_cost(graph, source, *s_it, path);
+        paths.push_back(path);
+    }
+}
+
+
+/*
+ * GET_PATH
+ */
+
+
+template < class G >
+void
+Pgr_astar< G >::get_path(
+        const G &graph,
+        std::deque< Path > &paths,
+        V source,
+        std::vector< V > &targets) const {
+    Path path;
+    typename std::vector< V >::iterator s_it;
+    for (s_it = targets.begin(); s_it != targets.end(); ++s_it) {
+        path.clear();
+        get_path(graph, source, *s_it, path);
+        paths.push_back(path);
+    }
+}
+
+template < class G >
+void
+Pgr_astar< G >::get_path(
+        const G &graph,
+        V source,
+        V target,
+        Path &r_path) const {
+    // backup of the target
+    V target_back = target;
+    uint64_t from(graph.graph[source].id);
+    uint64_t to(graph.graph[target].id);
+
+    // no path was found
+    if (target == predecessors[target]) {
+        r_path.clear();
+        return;
+    }
+
+    // find out how large is the path
+    int64_t result_size = 1;
+    while (target != source) {
+        if (target == predecessors[target]) break;
+        result_size++;
+        target = predecessors[target];
+    }
+
+    // recover the target
+    target = target_back;
+
+    // variables that are going to be stored
+    int64_t vertex_id;
+    int64_t edge_id;
+    double cost;
+
+    // working from the last to the beginning
+
+    // initialize the sequence
+    auto seq = result_size;
+    // the last stop is the target
+    Path path(from, to);
+    path.push_front(
+            {graph.graph[target].id, -1,
+            0,  distances[target]});
+
+    while (target != source) {
+        // we are done when the predecesor of the target is the target
+        if (target == predecessors[target]) break;
+        // values to be inserted in the path
+        --seq;
+        cost = distances[target] - distances[predecessors[target]];
+        vertex_id = graph.graph[predecessors[target]].id;
+        edge_id = graph.get_edge_id(predecessors[target], target, cost);
+
+        path.push_front({vertex_id, edge_id,
+                cost, (distances[target] - cost)});
+        target = predecessors[target];
+    }
+    r_path = path;
+    return;
+}
+
diff --git a/src/astar/test/doc-astar-v2.result b/src/astar/test/doc-astar-v2.result
new file mode 100644
index 0000000..e996171
--- /dev/null
+++ b/src/astar/test/doc-astar-v2.result
@@ -0,0 +1,15 @@
+-- q1
+NOTICE:  Deprecated signature of function pgr_astar
+0|4|16|1
+1|9|9|1
+2|6|8|1
+3|5|4|1
+4|2|1|1
+5|1|-1|0
+-- q2
+NOTICE:  Deprecated signature of function pgr_astar
+0|4|3|1
+1|3|2|1
+2|2|1|1
+3|1|-1|0
+-- q3
diff --git a/src/astar/test/doc-astar-v2.test.sql b/src/astar/test/doc-astar-v2.test.sql
new file mode 100644
index 0000000..6cf0060
--- /dev/null
+++ b/src/astar/test/doc-astar-v2.test.sql
@@ -0,0 +1,13 @@
+SET client_min_messages TO NOTICE;
+
+\echo -- q1
+SELECT * FROM pgr_AStar(
+    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2
+     FROM edge_table',
+    4, 1, false, false);
+\echo -- q2
+SELECT * FROM pgr_AStar(
+    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2, reverse_cost
+      FROM edge_table ',
+    4, 1, true, true);
+\echo -- q3
diff --git a/src/astar/test/doc-astar.result b/src/astar/test/doc-astar.result
index 8041ba8..50be369 100644
--- a/src/astar/test/doc-astar.result
+++ b/src/astar/test/doc-astar.result
@@ -1,13 +1,25 @@
 --q1
-0|4|16|1
-1|9|9|1
-2|6|8|1
-3|5|4|1
-4|2|1|1
-5|1|-1|0
+1|1|2|4|1|0
+2|2|5|8|1|1
+3|3|6|9|1|2
+4|4|9|15|1|3
+5|5|12|-1|0|4
 --q2
-0|4|3|1
-1|3|2|1
-2|2|1|1
-3|1|-1|0
+1|1|2|4|1|0
+2|2|5|8|1|1
+3|3|6|9|1|2
+4|4|9|15|1|3
+5|5|12|-1|0|4
+1|1|2|4|1|0
+2|2|5|8|1|1
+3|3|6|9|1|2
+4|4|9|15|1|3
+5|5|12|-1|0|4
 --q3
+NOTICE:  Deprecated signature of function pgr_astar
+0|2|4|1
+1|5|8|1
+2|6|9|1
+3|9|15|1
+4|12|-1|0
+--q4
diff --git a/src/astar/test/doc-astar.test.sql b/src/astar/test/doc-astar.test.sql
index 857e70e..b2cac85 100644
--- a/src/astar/test/doc-astar.test.sql
+++ b/src/astar/test/doc-astar.test.sql
@@ -1,16 +1,18 @@
-BEGIN;
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
---              PGR_AStar
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
+SET client_min_messages TO NOTICE;
+
 \echo --q1
-SELECT * FROM pgr_AStar(
-    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2 FROM edge_table',
-    4, 1, false, false);
+SELECT * FROM pgr_astar(
+    'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12);
 \echo --q2
-SELECT * FROM pgr_AStar(
-    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2, reverse_cost FROM edge_table ',
-    4, 1, true, true);
+SELECT * FROM pgr_astar(
+    'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12, heuristic := 1);
+SELECT * FROM pgr_astar(
+    'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12, heuristic := 2);
 \echo --q3
-ROLLBACK;
+SELECT * FROM pgr_astar(
+    'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table',
+    2, 12, true, true);
+\echo --q4
diff --git a/src/astar/test/pgtap/astarV2.0-compare-dijkstra.test.sql b/src/astar/test/pgtap/astarV2.0-compare-dijkstra.test.sql
new file mode 100644
index 0000000..db179f6
--- /dev/null
+++ b/src/astar/test/pgtap/astarV2.0-compare-dijkstra.test.sql
@@ -0,0 +1,121 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+\i setup.sql
+
+SELECT plan(2312);
+
+SET client_min_messages TO ERROR;
+
+UPDATE edge_table SET cost = cost + 0.001 * id * id, reverse_cost = reverse_cost + 0.001 * id * id;
+
+CREATE or REPLACE FUNCTION astarCompareDijkstra(cant INTEGER default 17)
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+inner_sql TEXT;
+dijkstra_sql TEXT;
+astar_sql TEXT;
+BEGIN
+
+    FOR i IN 1.. cant LOOP
+        FOR j IN 1.. cant LOOP
+
+            -- DIRECTED
+            inner_sql := 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, true)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, true)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, false)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, false)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+
+
+            inner_sql := 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, false)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, false)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, true)';
+            RETURN query SELECT throws_ok(astar_sql);
+
+
+
+            -- UNDIRECTED
+            inner_sql := 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, true)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, true)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, false)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, false)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+
+
+            inner_sql := 'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, false)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, false)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, true)';
+            RETURN query SELECT throws_ok(astar_sql);
+
+
+
+        END LOOP;
+    END LOOP;
+
+    RETURN;
+END
+$BODY$
+language plpgsql;
+
+SELECT * from astarCompareDijkstra();
+
+
+SELECT * FROM finish();
+ROLLBACK;
+
diff --git a/src/astar/test/pgtap/astar-types-check.sql b/src/astar/test/pgtap/astarV2.0-types-check.sql
similarity index 63%
rename from src/astar/test/pgtap/astar-types-check.sql
rename to src/astar/test/pgtap/astarV2.0-types-check.sql
index ba74850..d565132 100644
--- a/src/astar/test/pgtap/astar-types-check.sql
+++ b/src/astar/test/pgtap/astarV2.0-types-check.sql
@@ -1,13 +1,38 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
 
 \i setup.sql
 -- TESTING DOCUMNETATIONS INFORMATION
 
-SELECT plan(33);
+set client_min_messages = ERROR;
+SELECT plan(35);
 
 -- RECEIVES 5 PARAMETERS
 
 SELECT has_function('pgr_astar',ARRAY['text', 'integer', 'integer', 'boolean', 'boolean']);
-SELECT function_returns('pgr_astar', 'setof pgr_costresult','Returns set of costResult[]');
+SELECT function_returns('pgr_astar',
+    ARRAY['text', 'integer', 'integer', 'boolean', 'boolean'],
+    'setof pgr_costresult');
 
 
 -- CHECKING THE INNER QUERY
@@ -21,177 +46,150 @@ SELECT * FROM pgr_astar(
 SELECT lives_ok('q1', 'edges query accepts INTEGER & FLOAT');
 
 
-
-SELECT todo_start('issue #140 must accept ANY-INTEGER and ANY-NUMERICAL');
 -- some test pass because the code is not checking
 
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::BIGINT, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'id accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::SMALLINT, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'id accepts SMALLINT');
+        2, 3, true, true)');
+SELECT throws_ok(
+    'SELECT * FROM pgr_astar(
+        ''SELECT id::FLOAT8, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
+        2, 3, true, true)');
+SELECT throws_ok(
+    'SELECT * FROM pgr_astar(
+        ''SELECT id::REAL, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
+        2, 3, true, true)');
 
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::BIGINT, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'source accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::SMALLINT, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'source accepts SMALLINT');
+        2, 3, true, true)');
 
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::BIGINT, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'target accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::SMALLINT, cost::FLOAT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'target accepts SMALLINT');
+        2, 3, true, true)');
 
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::BIGINT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'cost accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::INTEGER, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'cost accepts INTEGER');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::SMALLINT, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'cost accepts SMALLINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::REAL, reverse_cost::FLOAT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'cost accepts REAL');
+        2, 3, true, true)');
 
-SELECT lives_ok(
+-- reverse_cost
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::BIGINT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'reverse_cost accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::INTEGER, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'reverse_cost accepts INTEGER');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::SMALLINT, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'reverse_cost accepts SMALLINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::REAL, x1::FLOAT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'reverse_cost accepts REAL');
+        2, 3, true, true)');
 
 -- x1
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::BIGINT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x1 accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::INTEGER, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x1 accepts INTEGER');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::SMALLINT, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x1 accepts SMALLINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x1::REAL, y1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x1 accepts REAL');
+        2, 3, true, true)');
 
 -- x2
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x2::BIGINT, y1::FLOAT, x1::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x2 accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x2::INTEGER, y1::FLOAT, x1::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x2 accepts INTEGER');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x2::SMALLINT, y1::FLOAT, x1::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x2 accepts SMALLINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, x2::REAL, y1::FLOAT, x1::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'x2 accepts REAL');
+        2, 3, true, true)');
 
 
 -- y1
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y1::BIGINT, x1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y1 accepts BIGINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y1::INTEGER, x1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y1 accepts INTEGER');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y1::SMALLINT, x1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y1 accepts SMALLINT');
-SELECT lives_ok(
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
         ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y1::REAL, x1::FLOAT, x2::FLOAT, y2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y1 accepts REAL');
+        2, 3, true, true)');
 
 -- y2
-SELECT lives_ok(
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
-        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::BIGINT, y1::FLOAT, x1::FLOAT, x2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y2 accepts BIGINT');
-SELECT lives_ok(
+        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::BIGINT, x1::FLOAT, x2::FLOAT, y1::FLOAT FROM edge_table'',
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
-        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::INTEGER, y1::FLOAT, x1::FLOAT, x2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y2 accepts INTEGER');
-SELECT lives_ok(
+        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::INTEGER, x1::FLOAT, x2::FLOAT, y1::FLOAT FROM edge_table'',
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
-        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::SMALLINT, y1::FLOAT, x1::FLOAT, x2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y2 accepts SMALLINT');
-SELECT lives_ok(
+        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::SMALLINT, x1::FLOAT, x2::FLOAT, y1::FLOAT FROM edge_table'',
+        2, 3, true, true)');
+SELECT throws_ok(
     'SELECT * FROM pgr_astar(
-        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::REAL, y1::FLOAT, x1::FLOAT, x2::FLOAT FROM edge_table'',
-        2, 3, true, true)',
-        'y2 accepts REAL');
-
-SELECT todo_end();
-
-
+        ''SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT, y2::REAL, x1::FLOAT, x2::FLOAT, y1::FLOAT FROM edge_table'',
+        2, 3, true, true)');
 
 
 SELECT finish();
diff --git a/src/astar/test/pgtap/astarV2.0-types-check2.sql b/src/astar/test/pgtap/astarV2.0-types-check2.sql
new file mode 100644
index 0000000..5508ba8
--- /dev/null
+++ b/src/astar/test/pgtap/astarV2.0-types-check2.sql
@@ -0,0 +1,223 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+\i setup.sql
+
+SELECT plan(87);
+SET client_min_messages TO ERROR;
+
+
+SELECT has_function('pgr_astar', ARRAY['text', 'integer', 'integer', 'boolean', 'boolean']);
+SELECT function_returns('pgr_astar', ARRAY['text', 'integer', 'integer', 'boolean', 'boolean'],'setof pgr_costresult');
+
+CREATE OR REPLACE FUNCTION test_Integer(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM edge_table $$, 2, 3, true, false)';
+    
+    query := start_sql || '('|| parameter || ')::SMALLINT ' || end_sql;
+    RETURN query SELECT throws_ok(query,
+        'XX000', 
+        'Error, columns ''source'', ''target'' must be of type int4, ''cost'' must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is SMALLINT'
+    );
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT throws_ok(query,
+        'XX000', 
+        'Error, columns ''source'', ''target'' must be of type int4, ''cost'' must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is BIGINT'
+    );
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_ok(query,
+        'XX000', 
+        'Error, columns ''source'', ''target'' must be of type int4, ''cost'' must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is REAL'
+    );
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT throws_ok(query,
+        'XX000', 
+        'Error, columns ''source'', ''target'' must be of type int4, ''cost'' must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is FLOAT8'
+    );
+END;
+$BODY$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION test_float8(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM edge_table $$, 2, 3, true, false)';
+    
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT throws_like(query,
+        '%must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is SMALLINT'
+    );
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT throws_like(query,
+        '%must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is INTEGER'
+    );
+    
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT throws_like(query,
+        '%must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is BIGINT'
+    );
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_like(query,
+        '%must be of type float8',
+        'SHOULD throw BECAUSE ' || parameter || ' is REAL'
+    );
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+-- with reverse cost
+SELECT test_integer('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'id::INTEGER');
+SELECT test_integer('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'source::INTEGER');
+SELECT test_integer('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'source::INTEGER');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'cost::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'reverse_cost::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'x1::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'y1::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'x2::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8', 'reverse_cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'y2::FLOAT8');
+
+
+
+
+-- without reverse cost
+SELECT test_integer('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'id::INTEGER');
+SELECT test_integer('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'source::INTEGER');
+SELECT test_integer('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'source::INTEGER');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'cost::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'x1::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'y1::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'x2::FLOAT8');
+SELECT test_float8('pgr_astar',
+    ARRAY['id::INTEGER', 'source::INTEGER', 'target::INTEGER',
+    'cost::FLOAT8',
+    'x1::FLOAT8', 'y1::FLOAT8', 'x2::FLOAT8', 'y2::FLOAT8'],
+    'y2::FLOAT8');
+
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/astar/test/pgtap/astar_oneToOne-compare-dijkstra.test.sql b/src/astar/test/pgtap/astar_oneToOne-compare-dijkstra.test.sql
new file mode 100644
index 0000000..589acf9
--- /dev/null
+++ b/src/astar/test/pgtap/astar_oneToOne-compare-dijkstra.test.sql
@@ -0,0 +1,112 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+\i setup.sql
+
+SELECT plan(1734);
+
+SET client_min_messages TO ERROR;
+
+UPDATE edge_table SET cost = cost + 0.001 * id * id, reverse_cost = reverse_cost + 0.001 * id * id;
+
+CREATE or REPLACE FUNCTION astarCompareDijkstra(cant INTEGER default 17)
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+inner_sql TEXT;
+dijkstra_sql TEXT;
+astar_sql TEXT;
+BEGIN
+
+    FOR i IN 1.. cant LOOP
+        FOR j IN 1.. cant LOOP
+
+            -- DIRECTED
+            inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+
+
+            inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+
+
+            -- UNDIRECTED
+            inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+
+
+            inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)';
+
+            astar_sql := 'SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)';
+            RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
+
+
+        END LOOP;
+    END LOOP;
+
+    RETURN;
+END
+$BODY$
+language plpgsql;
+
+SELECT * from astarCompareDijkstra();
+
+
+SELECT * FROM finish();
+ROLLBACK;
+
diff --git a/src/astar/test/pgtap/astar_oneToOne-compare-dijkstra1.test.sql b/src/astar/test/pgtap/astar_oneToOne-compare-dijkstra1.test.sql
new file mode 100644
index 0000000..b6010d3
--- /dev/null
+++ b/src/astar/test/pgtap/astar_oneToOne-compare-dijkstra1.test.sql
@@ -0,0 +1,143 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+\i setup.sql
+
+SELECT plan(1100);
+
+SET client_min_messages TO ERROR;
+
+UPDATE edge_table SET cost = cost + 0.001 * id * id, reverse_cost = reverse_cost + 0.001 * id * id;
+
+CREATE or REPLACE FUNCTION astarCompareDijkstra(
+    cant INTEGER default 5,
+    heuristic INTEGER default 0,
+    factor FLOAT default 1,
+    epsilon FLOAT default 1)
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+inner_sql TEXT;
+dijkstra_sql TEXT;
+astar_sql TEXT;
+count_query TEXT;
+value_query TEXT;
+t_query TEXT;
+BEGIN
+
+    FOR i IN 1.. cant LOOP
+        FOR j IN 1.. cant LOOP
+
+            -- DIRECTED
+
+            -- with reverse_cost
+            inner_sql := 'SELECT id, source, target, cost * ' || factor || ' AS cost, reverse_cost * ' || factor || ' AS reverse_cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'dijkstra AS (SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)) ';
+            astar_sql := 'astar AS (SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, ' || heuristic || ', ' || factor || ', ' || epsilon || ')) ';
+            count_query := ' dc AS (SELECT count(*) FROM dijkstra),'
+                      || ' ac AS (SELECT count(*) FROM astar),'
+                      || ' count_q AS (SELECT dc.count = ac.count AS result FROM dc, ac)';
+            value_query := ' vc AS (SELECT a.agg_cost/d.agg_cost <= ' || epsilon || '  AS result'
+                || ' from (SELECT agg_cost from astar WHERE edge = -1) AS a, (SELECT agg_cost from dijkstra WHERE edge = -1) AS d) ';
+                    
+            t_query := 'WITH ' 
+                || dijkstra_sql || ', ' 
+                || astar_sql || ', ' 
+                || count_query  || ', '
+                || value_query
+                || ' (SELECT * FROM count_q) UNION (SELECT * FROM vc)';
+
+            RETURN query SELECT results_eq(t_query, 'select true', t_query);
+
+
+            -- no reverse_cost
+            inner_sql := 'SELECT id, source, target, cost * ' ||factor || ' AS cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'dijkstra AS (SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true)) ';
+            astar_sql := 'astar AS (SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', true, ' || heuristic || ', ' || factor || ', ' || epsilon || ')) ';
+            t_query := 'WITH ' 
+                || dijkstra_sql || ', ' 
+                || astar_sql || ', ' 
+                || count_query  || ', '
+                || value_query
+                || ' (SELECT * FROM count_q) UNION (SELECT * FROM vc)';
+            RETURN query SELECT results_eq(t_query, 'select true', t_query);
+
+
+
+            -- UNDIRECTED
+            -- with reverse_cost
+            inner_sql := 'SELECT id, source, target, cost * ' || factor || ' AS cost, reverse_cost * ' || factor || ' AS reverse_cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'dijkstra AS (SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)) ';
+            astar_sql := 'astar AS (SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, ' || heuristic || ', ' || factor || ', ' || epsilon || ')) ';
+            t_query := 'WITH ' 
+                || dijkstra_sql || ', ' 
+                || astar_sql || ', ' 
+                || count_query  || ', '
+                || value_query
+                || ' (SELECT * FROM count_q) UNION (SELECT * FROM vc)';
+            RETURN query SELECT results_eq(t_query, 'select true', t_query);
+
+
+            -- no reverse_cost
+            inner_sql := 'SELECT id, source, target, cost * ' ||factor || ' AS cost, x1, y1, x2, y2 FROM edge_table';
+            dijkstra_sql := 'dijkstra AS (SELECT * FROM pgr_dijkstra($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false)) ';
+            astar_sql := 'astar AS (SELECT * FROM pgr_astar($$' || inner_sql || '$$, ' || i || ', ' || j
+                || ', false, ' || heuristic || ', ' || factor || ', ' || epsilon || ')) ';
+            t_query := 'WITH ' 
+                || dijkstra_sql || ', ' 
+                || astar_sql || ', ' 
+                || count_query  || ', '
+                || value_query
+                || ' (SELECT * FROM count_q) UNION (SELECT * FROM vc)';
+            RETURN query SELECT results_eq(t_query, 'select true', t_query);
+
+        END LOOP;
+    END LOOP;
+
+    RETURN;
+END
+$BODY$
+language plpgsql;
+
+SELECT * from astarCompareDijkstra(5, 0, 78846, 1);
+SELECT * from astarCompareDijkstra(5, 1, 78846, 1);
+SELECT * from astarCompareDijkstra(5, 1, 78846, 1.5);
+SELECT * from astarCompareDijkstra(5, 2, 78846, 1);
+SELECT * from astarCompareDijkstra(5, 2, 78846, 1.5);
+SELECT * from astarCompareDijkstra(5, 3, 78846, 1);
+SELECT * from astarCompareDijkstra(5, 3, 78846, 1.5);
+SELECT * from astarCompareDijkstra(5, 4, 78846, 1);
+SELECT * from astarCompareDijkstra(5, 4, 78846, 1.5);
+SELECT * from astarCompareDijkstra(5, 5, 78846, 1);
+SELECT * from astarCompareDijkstra(5, 5, 78846, 1.5);
+
+SELECT * FROM finish();
+ROLLBACK;
+
diff --git a/src/astar/test/pgtap/astar_oneToOne-types-check.sql b/src/astar/test/pgtap/astar_oneToOne-types-check.sql
new file mode 100644
index 0000000..af2b0da
--- /dev/null
+++ b/src/astar/test/pgtap/astar_oneToOne-types-check.sql
@@ -0,0 +1,216 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+\i setup.sql
+
+SELECT plan(93);
+SET client_min_messages TO ERROR;
+
+
+SELECT has_function('pgr_astar',
+    ARRAY['text', 'bigint', 'bigint', 'boolean',
+        'integer', 'double precision', 'double precision']);
+SELECT function_returns('pgr_astar',
+    ARRAY['text', 'bigint', 'bigint', 'boolean',
+        'integer', 'double precision', 'double precision'],
+    'setof record');
+
+CREATE OR REPLACE FUNCTION test_anyInteger(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM edge_table $$, 2, 3, true)';
+    
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION test_anyNumerical(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM edge_table $$, 2, 3, true)';
+    
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+--with reverse cost
+SELECT test_anyInteger('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'id');
+SELECT test_anyInteger('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'source');
+SELECT test_anyInteger('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'target');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'cost');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'reverse_cost');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'x1');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'y1');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'x2');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'y2');
+
+
+--without reverse cost
+SELECT test_anyInteger('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'id');
+SELECT test_anyInteger('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'source');
+SELECT test_anyInteger('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'target');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'cost');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'x1');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'y1');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'x2');
+SELECT test_anyNumerical('pgr_astar',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'y2');
+
+SELECT throws_ok(
+    $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', 
+        2, 3,
+        true, 6, 1, 1)$$,
+    'XX000',
+    'Unknown heuristic',
+        'SHOULD THROW because heuristic > 5'
+);
+
+SELECT throws_ok(
+    $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', 
+        2, 3,
+        true, -1, 1, 1)$$,
+    'XX000',
+    'Unknown heuristic',
+    'SHOULD THROW because heuristic < 0'
+);
+
+SELECT throws_ok(
+    $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', 
+        2, 3,
+        true, 0, 0, 1)$$,
+    'XX000',
+    'Factor value out of range',
+    'SHOULD THROW because factor = 0'
+);
+
+SELECT throws_ok(
+    $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', 
+        2, 3,
+        true, 0, -1.4, 1)$$,
+    'XX000',
+    'Factor value out of range',
+    'SHOULD THROW because factor < 0'
+);
+
+SELECT throws_ok(
+    $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', 
+        2, 3,
+        true, 0, 1, -3)$$,
+    'XX000',
+    'Epsilon value out of range',
+    'SHOULD THROW because epsilon < 0'
+);
+SELECT throws_ok(
+    $$SELECT * FROM pgr_astar('SELECT * FROM edge_table', 
+        2, 3,
+        true, 0, 1, 0.9)$$,
+    'XX000',
+    'Epsilon value out of range',
+    'SHOULD THROW because epsilon < 1'
+);
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/astar/test/spas-any-00.result b/src/astar/test/spas-any-00.result
deleted file mode 100644
index e0f6167..0000000
--- a/src/astar/test/spas-any-00.result
+++ /dev/null
@@ -1,5 +0,0 @@
-0|11|13|1
-1|12|15|1
-2|9|9|1
-3|6|8|1
-4|5|-1|0
diff --git a/src/astar/test/spas-any-01.result b/src/astar/test/spas-any-01.result
deleted file mode 100644
index f777225..0000000
--- a/src/astar/test/spas-any-01.result
+++ /dev/null
@@ -1,2 +0,0 @@
-0|10|2|1
-1|20|-1|0
diff --git a/src/astar/test/spas-any-01.test.sql b/src/astar/test/spas-any-01.test.sql
deleted file mode 100644
index 60f6f48..0000000
--- a/src/astar/test/spas-any-01.test.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-select * from pgr_astar('
-    SELECT unnest(array[1,2]) as id,
-    unnest(array[10,10]) as source,
-    unnest(array[20,20]) as target,
-    unnest(array[0,1])::float8 as x1,
-    unnest(array[0,1])::float8 as x2,
-    unnest(array[0,1])::float8 as y1,
-    unnest(array[0,1])::float8 as y2,
-    unnest(array[2,1])::float8 as cost
-    '::text, 10, 20, false, false);
diff --git a/src/astar/test/test.conf b/src/astar/test/test.conf
index 6667a22..a4129d5 100644
--- a/src/astar/test/test.conf
+++ b/src/astar/test/test.conf
@@ -5,11 +5,13 @@
         'comment' => 'astar test for any versions.',
         'data' => [''],
         'tests' => [qw(
-            spas-any-00
-            spas-any-01
-            doc-astar)],
+            doc-astar-v2
+            doc-astar
+            )],
         'documentation' => [qw(
-            doc-astar)]
+            doc-astar-v2
+            doc-astar
+            )]
     },
 #    'vpg-vpgis' => {}, # for version specific tests
 #    '8-1' => {},       # for pg 8.x and postgis 1.x
diff --git a/src/bd_astar/CMakeLists.txt b/src/bd_astar/CMakeLists.txt
deleted file mode 100644
index a9219b9..0000000
--- a/src/bd_astar/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(PACKAGE_SQL_FILES "")
-add_subdirectory(sql)
-set(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-
-subdirs(doc src test)
-
diff --git a/src/bd_astar/doc/pgr_bdAstar.rst b/src/bd_astar/doc/pgr_bdAstar.rst
index b446669..5c4fa9b 100644
--- a/src/bd_astar/doc/pgr_bdAstar.rst
+++ b/src/bd_astar/doc/pgr_bdAstar.rst
@@ -13,7 +13,7 @@ pgr_bdAstar - Bi-directional A* Shortest Path
 ===============================================================================
 
 .. index:: 
-	single: pgr_bdAstar(text, integer, integer, boolean, boolean)
+	single: bdAstar(Complete Signaature)
 
 Name
 -------------------------------------------------------------------------------
@@ -24,7 +24,7 @@ Name
 Synopsis
 -------------------------------------------------------------------------------
 
-This is a bi-directional A* search algorithm. It searchs from the source toward the distination and at the same time from the destination to the source and terminates whe these to searchs meet in the middle. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
+This is a bi-directional A* search algorithm. It searches from the source toward the distination and at the same time from the destination to the source and terminates whe these to searches meet in the middle. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
 
 .. code-block:: sql
 
diff --git a/src/bd_astar/src/BiDirAStar.cpp b/src/bd_astar/src/BiDirAStar.cpp
index b0a9156..d71f61e 100644
--- a/src/bd_astar/src/BiDirAStar.cpp
+++ b/src/bd_astar/src/BiDirAStar.cpp
@@ -2,7 +2,7 @@
 
 * $Id$
 *
-* Project:  pgRouting bdsp and bdastar algorithms
+* Project: pgRouting bdsp and bdastar algorithms
 * Purpose:
 * Author:   Razequl Islam <ziboncsedu at gmail.com>
 *
@@ -24,7 +24,7 @@ all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -32,55 +32,49 @@ THE SOFTWARE.
 
 ********************************************************************PGR-MIT*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
 
-#include "BiDirAStar.h"
+#include <math.h>
+#include "./BiDirAStar.h"
 
-BiDirAStar::BiDirAStar(void)
-{
+BiDirAStar::BiDirAStar(void) {
 }
 
-BiDirAStar::~BiDirAStar(void)
-{
+BiDirAStar::~BiDirAStar(void) {
 }
 
-void BiDirAStar::init()
-{
-	//max_edge_id = 0;
-	//max_node_id = 0;
-	
+void BiDirAStar::init() {
+    // max_edge_id = 0;
+    // max_node_id = 0;
 }
 
 /*
-	Initialization and allocation of memories.
-*/
+   Initialization and allocation of memories.
+   */
 
-void BiDirAStar::initall(int maxNode)
-{
-	int i;
+void BiDirAStar::initall(int maxNode) {
+    int i;
 
     // DBG("BiDirAStar::initall(%d) called\n", maxNode);
 
-	m_pFParent = new PARENT_PATH[maxNode + 1];
-	m_pRParent = new PARENT_PATH[maxNode + 1];
+    m_pFParent = new PARENT_PATH[maxNode + 1];
+    m_pRParent = new PARENT_PATH[maxNode + 1];
 
-	m_pFCost = new double[maxNode + 1];
-	m_pRCost = new double[maxNode + 1];
+    m_pFCost = new double[maxNode + 1];
+    m_pRCost = new double[maxNode + 1];
 
-	for(i = 0; i <= maxNode; i++)
-	{
-		m_pFParent[i].par_Node = -2;
-		m_pRParent[i].par_Node = -2;
-		m_pFCost[i] = INF;
-		m_pRCost[i] = INF;
-		
-	}
-	m_MinCost = INF;
-	m_MidNode = -1;
+    for (i = 0; i <= maxNode; i++) {
+        m_pFParent[i].par_Node = -2;
+        m_pRParent[i].par_Node = -2;
+        m_pFCost[i] = INF;
+        m_pRCost[i] = INF;
+    }
+    m_MinCost = INF;
+    m_MidNode = -1;
 
     // reserve space for nodes and edges
     m_vecNodeVector.reserve(maxNode + 1);
@@ -89,447 +83,394 @@ void BiDirAStar::initall(int maxNode)
 }
 
 /*
-	Delete the allocated memories to avoid memory leak.
-*/
+   Delete the allocated memories to avoid memory leak.
+   */
 
-void BiDirAStar::deleteall()
-{
+void BiDirAStar::deleteall() {
     // DBG("Calling BiDirAStar::deleteall\n");
-	delete [] m_pFParent;
-	delete [] m_pRParent;
-	delete [] m_pFCost;
-	delete [] m_pRCost;
+    delete [] m_pFParent;
+    delete [] m_pRParent;
+    delete [] m_pFCost;
+    delete [] m_pRCost;
     // DBG("Leaving BiDirAStar::deleteall\n");
 }
 
 /*
-	Get the current cost from source to the current node if direction is 1 else the cost to reach target from the current node.
-*/
-
-double BiDirAStar::getcost(int node_id, int dir)
-{
-	if(dir == 1)
-	{
-		return(m_pFCost[node_id]);
-	}
-	else
-	{
-		return(m_pRCost[node_id]);
-	}
+   Get the current cost from source to the current node if direction is 1 else the cost to reach target from the current node.
+   */
+
+double BiDirAStar::getcost(int node_id, int dir) {
+    if (dir == 1) {
+        return(m_pFCost[node_id]);
+    } else {
+        return(m_pRCost[node_id]);
+    }
 }
 
 
-double BiDirAStar::dist(double x1, double y1, double x2, double y2)
-{
-	double ret = fabs((x1 - x2) + fabs(y1 - y2));
-	//double ret = sqrt(x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
-	return(ret * 10);
+double BiDirAStar::dist(double x1, double y1, double x2, double y2) {
+    double ret = fabs((x1 - x2) + fabs(y1 - y2));
+    // double ret = sqrt(x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
+    return(ret * 10);
 }
 
 /*
-	Get the heuristic cost of the node depending on dir (1 for forward search and -1 for reverse search).
-*/
-double BiDirAStar::gethcost(int node_id, int dir)
-{
-	if(dir == -1)
-	{
-		return(dist(m_vecNodeVector[node_id].xpos, m_vecNodeVector[node_id].ypos, m_vecNodeVector[m_lStartNodeId].xpos, m_vecNodeVector[m_lStartNodeId].ypos));
-	}
-	else
-	{
-		return(dist(m_vecNodeVector[node_id].xpos, m_vecNodeVector[node_id].ypos, m_vecNodeVector[m_lEndNodeId].xpos, m_vecNodeVector[m_lEndNodeId].ypos));
-	}
+   Get the heuristic cost of the node depending on dir (1 for forward search and -1 for reverse search).
+   */
+double BiDirAStar::gethcost(int node_id, int dir) {
+    if (dir == -1) {
+        return(dist(m_vecNodeVector[node_id].xpos, m_vecNodeVector[node_id].ypos, m_vecNodeVector[m_lStartNodeId].xpos, m_vecNodeVector[m_lStartNodeId].ypos));
+    } else {
+        return(dist(m_vecNodeVector[node_id].xpos, m_vecNodeVector[node_id].ypos, m_vecNodeVector[m_lEndNodeId].xpos, m_vecNodeVector[m_lEndNodeId].ypos));
+    }
 }
 
 /*
-	Set the forward or reverse cost list depending on dir (1 for forward search and -1 for reverse search).
-*/
-
-
-void BiDirAStar::setcost(int node_id, int dir, double c)
-{
-	if(dir == 1)
-	{
-		m_pFCost[node_id] = c;
-	}
-	else
-	{
-		m_pRCost[node_id] = c;
-	}
+   Set the forward or reverse cost list depending on dir (1 for forward search and -1 for reverse search).
+   */
+
+
+void BiDirAStar::setcost(int node_id, int dir, double c) {
+    if (dir == 1) {
+        m_pFCost[node_id] = c;
+    } else {
+        m_pRCost[node_id] = c;
+    }
 }
 
-void BiDirAStar::setparent(int node_id, int dir, int parnode, int paredge)
-{
-	if(dir == 1)
-	{
-		m_pFParent[node_id].par_Node = parnode;
-		m_pFParent[node_id].par_Edge = paredge;
-	}
-	else
-	{
-		m_pRParent[node_id].par_Node = parnode;
-		m_pRParent[node_id].par_Edge = paredge;
-	}
+void BiDirAStar::setparent(int node_id, int dir, int parnode, int paredge) {
+    if (dir == 1) {
+        m_pFParent[node_id].par_Node = parnode;
+        m_pFParent[node_id].par_Edge = paredge;
+    } else {
+        m_pRParent[node_id].par_Node = parnode;
+        m_pRParent[node_id].par_Edge = paredge;
+    }
 }
 
 /*
-	Reconstruct path for forward search. It is like normal dijkstra. The parent array contains the parent of the current node and there is a -1 in the source.
-	So one need to recurse upto the source and then add the current node and edge to the list.
-*/
-
-void BiDirAStar::fconstruct_path(int node_id)
-{
-	if(m_pFParent[node_id].par_Node == -1)
-		return;
-	fconstruct_path(m_pFParent[node_id].par_Node);
-	path_element_t pt;
-	pt.vertex_id = m_pFParent[node_id].par_Node;
-	pt.edge_id = m_pFParent[node_id].par_Edge;
-	pt.cost = m_pFCost[node_id] - m_pFCost[m_pFParent[node_id].par_Node];
-	m_vecPath.push_back(pt);
+   Reconstruct path for forward search. It is like normal dijkstra. The parent array contains the parent of the current node and there is a -1 in the source.
+   So one need to recurse up to the source and then add the current node and edge to the list.
+   */
+
+void BiDirAStar::fconstruct_path(int node_id) {
+    if (m_pFParent[node_id].par_Node == -1)
+        return;
+    fconstruct_path(m_pFParent[node_id].par_Node);
+    path_element_t pt;
+    pt.vertex_id = m_pFParent[node_id].par_Node;
+    pt.edge_id = m_pFParent[node_id].par_Edge;
+    pt.cost = m_pFCost[node_id] - m_pFCost[m_pFParent[node_id].par_Node];
+    m_vecPath.push_back(pt);
 }
 
 /*
-	Reconstruct path for the reverse search. In this case the subsequent node is stored in the parent and the target contains a -1. So one need to add the node
-	and edge to the list and then recurse through the parent upto hitting a -1.
-*/
-
-void BiDirAStar::rconstruct_path(int node_id)
-{
-	path_element_t pt;
-	if(m_pRParent[node_id].par_Node == -1)
-	{
-		pt.vertex_id = node_id;
-		pt.edge_id = -1;
-		pt.cost = 0.0;
-		return;
-	}
-	pt.vertex_id = node_id;
-	pt.cost = m_pRCost[node_id] - m_pRCost[m_pRParent[node_id].par_Node];
-	pt.edge_id = m_pRParent[node_id].par_Edge;
-	m_vecPath.push_back(pt);
-	rconstruct_path(m_pRParent[node_id].par_Node);
+   Reconstruct path for the reverse search. In this case the subsequent node is stored in the parent and the target contains a -1. So one need to add the node
+   and edge to the list and then recurse through the parent up to hitting a -1.
+   */
+
+void BiDirAStar::rconstruct_path(int node_id) {
+    path_element_t pt;
+    if (m_pRParent[node_id].par_Node == -1) {
+        pt.vertex_id = node_id;
+        pt.edge_id = -1;
+        pt.cost = 0.0;
+        return;
+    }
+    pt.vertex_id = node_id;
+    pt.cost = m_pRCost[node_id] - m_pRCost[m_pRParent[node_id].par_Node];
+    pt.edge_id = m_pRParent[node_id].par_Edge;
+    m_vecPath.push_back(pt);
+    rconstruct_path(m_pRParent[node_id].par_Node);
 }
 
 /*
-	This is the main exploration module. The parameter dir indicates whether the exploration will be in forward or reverser direction. The reference to the corresponding
-	que is also passed as parameter que. The current node and the current costs are also available as parameter.
-*/
-
-//void BiDirAStar::explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que)
-void BiDirAStar::explore(int cur_node, double cur_cost, int dir, MinHeap &que)
-{
-	size_t i;
-	// Number of connected edges
-	auto con_edge = m_vecNodeVector[cur_node].Connected_Edges_Index.size();
-	double edge_cost;
-	for(i = 0; i < con_edge; i++)
-	{
-		auto edge_index = m_vecNodeVector[cur_node].Connected_Edges_Index[i];
-		// Get the edge from the edge list.
-		GraphEdgeInfo edge = m_vecEdgeVector[edge_index];
-		// Get the connected node
-		int new_node = m_vecNodeVector[cur_node].Connected_Nodes[i];
-#if 0  // mult is set but not used
-		int mult;
-		
-		if(edge.Direction == 0)
-			mult = 1;
-		else
-			mult = dir;
+   This is the main exploration module. The parameter dir indicates whether the exploration will be in forward or reverser direction. The reference to the corresponding
+   que is also passed as parameter que. The current node and the current costs are also available as parameter.
+   */
+
+// void BiDirAStar::explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que)
+void BiDirAStar::explore(int cur_node, double cur_cost, int dir, MinHeap &que) {
+    size_t i;
+    // Number of connected edges
+    auto con_edge = m_vecNodeVector[cur_node].Connected_Edges_Index.size();
+    double edge_cost;
+    for (i = 0; i < con_edge; i++) {
+        auto edge_index = m_vecNodeVector[cur_node].Connected_Edges_Index[i];
+        // Get the edge from the edge list.
+        GraphEdgeInfo edge = m_vecEdgeVector[edge_index];
+        // Get the connected node
+        int new_node = m_vecNodeVector[cur_node].Connected_Nodes[i];
+#if 0  //  mult is set but not used
+        int mult;
+
+        if (edge.Direction == 0)
+            mult = 1;
+        else
+            mult = dir;
 #endif
-		if(cur_node == edge.StartNode)
-		{
-			// Current node is the startnode of the edge. For forward search it should use forward cost, otherwise it should use the reverse cost,
-			// i.e. if the reverse direction is valid then this node may be visited from the end node.
-			if(dir > 0)
-				edge_cost = edge.Cost;
-			else
-				edge_cost = edge.ReverseCost;
-			// Check if the direction is valid for exploration
-			if(edge.Direction == 0 || edge_cost >= 0.0)
-			{
-				//edge_cost = edge.Cost * mult;
-				// Check if the current edge gives better result
-				if(cur_cost + edge_cost < getcost(new_node, dir))
-				{
-					// explore the node, and push it in the queue. the value in the queue will also contain the heuristic cost
-					setcost(new_node, dir, cur_cost + edge_cost);
-					setparent(new_node, dir, cur_node, edge.EdgeID);
-					que.push(std::make_pair(cur_cost + edge_cost + gethcost(new_node, dir), new_node));
-
-					// Update the minimum cost found so far.
-					if(getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost)
-					{
-						m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
-						m_MidNode = new_node;
-					}
-				}
-			}
-		}
-		else
-		{
-			// Current node is the endnode of the edge. For forward search it should use reverse cost, otherwise it should use the forward cost,
-			// i.e. if the forward direction is valid then this node may be visited from the start node.
-			if(dir > 0)
-				edge_cost = edge.ReverseCost;
-			else
-				edge_cost = edge.Cost;
-			// Check if the direction is valid for exploration
-			if(edge.Direction == 0 || edge_cost >= 0.0)
-			{
-				//edge_cost = edge.ReverseCost * mult;
-				
-				// Check if the current edge gives better result
-				if(cur_cost + edge_cost < getcost(new_node, dir))
-				{
-					// explore the node, and push it in the queue. the value in the queue will also contain the heuristic cost
-					setcost(new_node, dir, cur_cost + edge_cost);
-					setparent(new_node, dir, cur_node, edge.EdgeID);
-					que.push(std::make_pair(cur_cost + edge_cost + gethcost(new_node, dir), new_node));
-					// Update the minimum cost found so far.
-					if(getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost)
-					{
-						m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
-						m_MidNode = new_node;
-					}
-				}
-			}
-		}
-	}
+        if (cur_node == edge.StartNode) {
+            // Current node is the startnode of the edge. For forward search it should use forward cost, otherwise it should use the reverse cost,
+            // i.e. if the reverse direction is valid then this node may be visited from the end node.
+            if (dir > 0)
+                edge_cost = edge.Cost;
+            else
+                edge_cost = edge.ReverseCost;
+            // Check if the direction is valid for exploration
+            if (edge.Direction == 0 ||  edge_cost >= 0.0) {
+                // edge_cost = edge.Cost * mult;
+                // Check if the current edge gives better result
+                if (cur_cost + edge_cost < getcost(new_node, dir)) {
+                    // explore the node, and push it in the queue. the value in the queue will also contain the heuristic cost
+                    setcost(new_node, dir, cur_cost + edge_cost);
+                    setparent(new_node, dir, cur_node, edge.EdgeID);
+                    que.push(std::make_pair(cur_cost + edge_cost + gethcost(new_node, dir), new_node));
+
+                    // Update the minimum cost found so far.
+                    if (getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost) {
+                        m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
+                        m_MidNode = new_node;
+                    }
+                }
+            }
+        } else {
+            // Current node is the endnode of the edge. For forward search it should use reverse cost, otherwise it should use the forward cost,
+            // i.e. if the forward direction is valid then this node may be visited from the start node.
+            if (dir > 0)
+                edge_cost = edge.ReverseCost;
+            else
+                edge_cost = edge.Cost;
+            // Check if the direction is valid for exploration
+            if (edge.Direction == 0 ||  edge_cost >= 0.0) {
+                // edge_cost = edge.ReverseCost * mult;
+
+                // Check if the current edge gives better result
+                if (cur_cost + edge_cost < getcost(new_node, dir)) {
+                    // explore the node, and push it in the queue. the value in the queue will also contain the heuristic cost
+                    setcost(new_node, dir, cur_cost + edge_cost);
+                    setparent(new_node, dir, cur_node, edge.EdgeID);
+                    que.push(std::make_pair(cur_cost + edge_cost + gethcost(new_node, dir), new_node));
+                    // Update the minimum cost found so far.
+                    if (getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost) {
+                        m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
+                        m_MidNode = new_node;
+                    }
+                }
+            }
+        }
+    }
 }
 
-/* 
-	This is the entry function that the wrappers should call. Most of the parameters are trivial. maxNode refers to Maximum
-	node id. As we run node based exploration cost, parent etc will be based on maximam node id.
-*/
-
-int BiDirAStar:: bidir_astar(edge_astar_t *edges, size_t edge_count, int maxNode, int start_vertex, int end_vertex,
-				path_element_t **path, size_t *path_count, char **err_msg)
-{
-	max_node_id = maxNode;
-	max_edge_id = -1;
-	
-	// Allocate memory for local storage like cost and parent holder
-	initall(maxNode);
-
-	// construct the graph from the edge list, i.e. populate node and edge data structures
-	construct_graph(edges, edge_count, maxNode);
-	
-	m_lStartNodeId = start_vertex;
-	m_lEndNodeId = end_vertex;
-
-	// int nodeCount = m_vecNodeVector.size();
-	
-	MinHeap fque(maxNode + 2);
-	MinHeap rque(maxNode + 2);
-	//std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > fque;
-	//std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > rque;
-	
-	m_vecPath.clear();
-
-	// Initialize the forward search
-	m_pFParent[start_vertex].par_Node = -1;
-	m_pFParent[start_vertex].par_Edge = -1;
-	m_pFCost[start_vertex] = 0.0;
-	fque.push(std::make_pair(0.0, start_vertex));
-
-	// Initialize the reverse search
-	m_pRParent[end_vertex].par_Node = -1;
-	m_pRParent[end_vertex].par_Edge = -1;
-	m_pRCost[end_vertex] = 0.0;
-	rque.push(std::make_pair(0.0, end_vertex));
-
-	// int new_node;
-	int cur_node;
-	// int dir;
 /*
-	The main loop. The algorithm is as follows:
-	1. IF the sum of the current minimum of both heap is greater than so far found path, we cannot get any better, so break the loop.
-	2. IF the reverse heap minimum is lower than the forward heap minimum, explore from reverse direction.
-	3. ELSE explore from the forward directtion.
-*/
-
-	while(!fque.empty() && !rque.empty())
-	{
-		PDI fTop = fque.top();
-		PDI rTop = rque.top();
-		if(m_pFCost[fTop.second] + m_pRCost[rTop.second] > m_MinCost) //We are done, there is no path with lower cost
-			break;
-
-		if(rTop.first < fTop.first) // Explore from reverse queue
-		{
-			if(rTop.first > m_MinCost)
-				break;
-			cur_node = rTop.second;
-			int dir = -1;
-			rque.pop();
-			explore(cur_node, m_pRCost[rTop.second], dir, rque);
-		}
-		else                        // Explore from forward queue
-		{
-			if(fTop.first > m_MinCost)
-				break;
-			cur_node = fTop.second;
-			int dir = 1;
-			fque.pop();
-			explore(cur_node, m_pFCost[fTop.second], dir, fque);
-		}
-	}
+   This is the entry function that the wrappers should call. Most of the parameters are trivial. maxNode refers to Maximum
+   node id. As we run node based exploration cost, parent etc will be based on maximam node id.
+   */
 
-/*
-	Path reconstruction part. m_MidNode is the joining point where two searches meet to make a shortest path. It is updated in explore.
-	If it contains -1, then no path is found. Other wise we have a shortest path and that is reconstructed in the m_vecPath.
-*/
-
-	if(m_MidNode == -1)
-	{
-		*err_msg = (char *)"Path Not Found";
-		deleteall();
-		return -1;
-	}
-	else
-	{
-		// reconstruct path from forward search
-		fconstruct_path(m_MidNode);
-		// reconstruct path from backward search
-		rconstruct_path(m_MidNode);
-
-		// insert the last row in the path trace (having edge_id = -1 and cost = 0.0)
-		path_element_t pelement;
-		pelement.vertex_id = end_vertex;
-		pelement.edge_id = -1;
-		pelement.cost = 0.0;
-		m_vecPath.push_back(pelement);
-
-		// Transfer data path to path_element_t format and allocate memory and populate the pointer
-		*path = (path_element_t *) malloc(sizeof(path_element_t) * (m_vecPath.size() + 1));
-		*path_count = m_vecPath.size();
-
-		for(size_t i = 0; i < *path_count; i++)
-		{
-			(*path)[i].vertex_id = m_vecPath[i].vertex_id;
-			(*path)[i].edge_id = m_vecPath[i].edge_id;
-			(*path)[i].cost = m_vecPath[i].cost;
-		}
-		
-	}
-	deleteall();
-	return 0;
+int BiDirAStar:: bidir_astar(edge_astar_t *edges, size_t edge_count, int maxNode, int start_vertex, int end_vertex,
+        path_element_t **path, size_t *path_count, char **err_msg) {
+    max_node_id = maxNode;
+    max_edge_id = -1;
+
+    // Allocate memory for local storage like cost and parent holder
+    initall(maxNode);
+
+    // construct the graph from the edge list, i.e. populate node and edge data structures
+    construct_graph(edges, edge_count, maxNode);
+
+    m_lStartNodeId = start_vertex;
+    m_lEndNodeId = end_vertex;
+
+    // int nodeCount = m_vecNodeVector.size();
+
+    MinHeap fque(maxNode + 2);
+    MinHeap rque(maxNode + 2);
+    // std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > fque;
+    // std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > rque;
+
+    m_vecPath.clear();
+
+    // Initialize the forward search
+    m_pFParent[start_vertex].par_Node = -1;
+    m_pFParent[start_vertex].par_Edge = -1;
+    m_pFCost[start_vertex] = 0.0;
+    fque.push(std::make_pair(0.0, start_vertex));
+
+    // Initialize the reverse search
+    m_pRParent[end_vertex].par_Node = -1;
+    m_pRParent[end_vertex].par_Edge = -1;
+    m_pRCost[end_vertex] = 0.0;
+    rque.push(std::make_pair(0.0, end_vertex));
+
+    // int new_node;
+    int cur_node;
+    // int dir;
+    /*
+       The main loop. The algorithm is as follows:
+       1. IF the sum of the current minimum of both heap is greater than so far found path, we cannot get any better, so break the loop.
+       2. IF the reverse heap minimum is lower than the forward heap minimum, explore from reverse direction.
+       3. ELSE explore from the forward directtion.
+       */
+
+    while (!fque.empty() &&  !rque.empty()) {
+        PDI fTop = fque.top();
+        PDI rTop = rque.top();
+        if (m_pFCost[fTop.second] + m_pRCost[rTop.second] > m_MinCost)  // We are done, there is no path with lower cost
+            break;
+
+        if (rTop.first < fTop.first) {
+            //  Explore from reverse queue
+            if (rTop.first > m_MinCost)
+                break;
+            cur_node = rTop.second;
+            int dir = -1;
+            rque.pop();
+            explore(cur_node, m_pRCost[rTop.second], dir, rque);
+        } else {
+            // Explore from forward queue
+            if (fTop.first > m_MinCost)
+                break;
+            cur_node = fTop.second;
+            int dir = 1;
+            fque.pop();
+            explore(cur_node, m_pFCost[fTop.second], dir, fque);
+        }
+    }
+
+    /*
+       Path reconstruction part. m_MidNode is the joining point where two searches meet to make a shortest path. It is updated in explore.
+       If it contains -1, then no path is found. Other wise we have a shortest path and that is reconstructed in the m_vecPath.
+       */
+
+    if (m_MidNode == -1) {
+        *err_msg = (char *)"Path Not Found";
+        deleteall();
+        return -1;
+    } else {
+        // reconstruct path from forward search
+        fconstruct_path(m_MidNode);
+        // reconstruct path from backward search
+        rconstruct_path(m_MidNode);
+
+        // insert the last row in the path trace (having edge_id = -1 and cost = 0.0)
+        path_element_t pelement;
+        pelement.vertex_id = end_vertex;
+        pelement.edge_id = -1;
+        pelement.cost = 0.0;
+        m_vecPath.push_back(pelement);
+
+        // Transfer data path to path_element_t format and allocate memory and populate the pointer
+        *path = (path_element_t *) malloc(sizeof(path_element_t) * (m_vecPath.size() + 1));
+        *path_count = m_vecPath.size();
+
+        for (size_t i = 0; i < *path_count; i++) {
+            (*path)[i].vertex_id = m_vecPath[i].vertex_id;
+            (*path)[i].edge_id = m_vecPath[i].edge_id;
+            (*path)[i].cost = m_vecPath[i].cost;
+        }
+    }
+    deleteall();
+    return 0;
 }
 
 /*
-	Populate the member variables of the class using the edge list. Basically there is a node list and an edge list. Each node contains the list of adjacent nodes and 
-	corresponding edge indices from edge list that connect this node with the adjacent nodes.
-*/
+   Populate the member variables of the class using the edge list. Basically there is a node list and an edge list. Each node contains the list of adjacent nodes and
+   corresponding edge indices from edge list that connect this node with the adjacent nodes.
+   */
 
-bool BiDirAStar::construct_graph(edge_astar_t* edges, size_t edge_count, int maxNode)
-{
-	int i;
+bool BiDirAStar::construct_graph(edge_astar_t* edges, size_t edge_count, int maxNode) {
+    int i;
 
     // DBG("Calling BiDirAStar::construct_graph(edges, ecnt:%d, maxNode:%d)\n", edge_count, maxNode);
 
-	// Create a dummy node
-	GraphNodeInfo nodeInfo;
-	nodeInfo.Connected_Edges_Index.clear();
-	nodeInfo.Connected_Nodes.clear();
+    // Create a dummy node
+    GraphNodeInfo nodeInfo;
+    nodeInfo.Connected_Edges_Index.clear();
+    nodeInfo.Connected_Nodes.clear();
 
-	// Insert the dummy node into the node list. This acts as place holder. Also change the nodeId so that nodeId and node index in the vector are same.
-	// There may be some nodes here that does not appear in the edge list. The size of the list is upto maxNode which is equal to maximum node id.
+    // Insert the dummy node into the node list. This acts as place holder. Also change the nodeId so that nodeId and node index in the vector are same.
+    // There may be some nodes here that does not appear in the edge list. The size of the list is up to maxNode which is equal to maximum node id.
     // DBG("    Adding nodes to m_vecNodeVector\n");
-	for(i = 0; i <= maxNode; i++)
-	{
-		nodeInfo.NodeID = i;
-		m_vecNodeVector.push_back(nodeInfo);
-	}
+    for (i = 0; i <= maxNode; i++) {
+        nodeInfo.NodeID = i;
+        m_vecNodeVector.push_back(nodeInfo);
+    }
 
-	// Process each edge from the edge list and update the member data structures accordingly.
+    // Process each edge from the edge list and update the member data structures accordingly.
     // DBG("    Reserving edges for graph(%d)\n", edge_count);
     m_vecEdgeVector.reserve(edge_count);
     // DBG("    Adding edges to graph\n");
-	for(size_t i = 0; i < edge_count; i++)
-	{
-		addEdge(edges[i]);
-	}
+    for (size_t i = 0; i < edge_count; i++) {
+        addEdge(edges[i]);
+    }
 
     // DBG("Leaving BiDirAStar::construct_graph\n");
-	return true;
+    return true;
 }
 
 /*
-	Process the edge and populate the member nodelist and edgelist. The nodelist already contains upto maxNode dummy entries with nodeId same as index. Now the
-	connectivity information needs to be updated.
-*/
-
-bool BiDirAStar::addEdge(edge_astar_t edgeIn)
-{
-	// long lTest;
-	// Check if the edge is already processed.
-	Long2LongMap::iterator itMap = m_mapEdgeId2Index.find(edgeIn.id);
-	if(itMap != m_mapEdgeId2Index.end())	
-		return false;
-
-	// Create a GraphEdgeInfo using the information of the current edge
-	GraphEdgeInfo newEdge;
-	newEdge.EdgeID = edgeIn.id;
-	newEdge.EdgeIndex = m_vecEdgeVector.size();	
-	newEdge.StartNode = edgeIn.source;
-	newEdge.EndNode = edgeIn.target;
-	newEdge.Cost = edgeIn.cost;
-	newEdge.ReverseCost = edgeIn.reverse_cost;
-
-	// Set the direction. If both cost and reverse cost has positive value the edge is bidirectional and direction field is 0. If cost is positive and reverse cost
-	// negative then the edge is unidirectional with direction = 1 (goes from source to target) otherwise it is unidirectional with direction = -1 (goes from target
-	// to source). Another way of creating unidirectional edge is assigning big values in cost or reverse_cost. In that case the direction is still zero and this case
-	// is handled in the algorithm automatically.
-	if(newEdge.Cost >= 0.0 && newEdge.ReverseCost >= 0)
-	{
-		newEdge.Direction = 0;
-	}
-	else if(newEdge.Cost >= 0.0)
-	{
-		newEdge.Direction = 1;
-	}
-	else
-	{
-		newEdge.Direction = -1;
-	}
-
-	if(edgeIn.id > max_edge_id)
-	{
-		max_edge_id = edgeIn.id;
-	}
-
-	// Update max_edge_id
-	if(newEdge.StartNode > max_node_id)
-	{
-		return false;//max_node_id = newEdge.StartNode;
-	}
-	if(newEdge.EndNode > max_node_id)
-	{
-		return false;//max_node_id = newEdge.EdgeIndex;
-	}
-
-	m_vecNodeVector[newEdge.StartNode].xpos = edgeIn.s_x;
-	m_vecNodeVector[newEdge.StartNode].ypos = edgeIn.s_y;
-
-	m_vecNodeVector[newEdge.EndNode].xpos = edgeIn.t_x;
-	m_vecNodeVector[newEdge.EndNode].ypos = edgeIn.t_y;
-
-	// update connectivity information for the start node.
-	m_vecNodeVector[newEdge.StartNode].Connected_Nodes.push_back(newEdge.EndNode);
-	m_vecNodeVector[newEdge.StartNode].Connected_Edges_Index.push_back(newEdge.EdgeIndex);
-
-	// update connectivity information for the end node.
-	m_vecNodeVector[newEdge.EndNode].Connected_Nodes.push_back(newEdge.StartNode);
-	m_vecNodeVector[newEdge.EndNode].Connected_Edges_Index.push_back(newEdge.EdgeIndex);
-
-
-	
-	//Adding edge to the list
-	m_mapEdgeId2Index.insert(std::make_pair(newEdge.EdgeID, m_vecEdgeVector.size()));
-	m_vecEdgeVector.push_back(newEdge);
-
-	//
-	return true;
+   Process the edge and populate the member nodelist and edgelist. The nodelist already contains up to maxNode dummy entries with nodeId same as index. Now the
+   connectivity information needs to be updated.
+   */
+
+bool BiDirAStar::addEdge(edge_astar_t edgeIn) {
+    // long lTest;
+    // Check if the edge is already processed.
+    Long2LongMap::iterator itMap = m_mapEdgeId2Index.find(edgeIn.id);
+    if (itMap != m_mapEdgeId2Index.end())
+        return false;
+
+    // Create a GraphEdgeInfo using the information of the current edge
+    GraphEdgeInfo newEdge;
+    newEdge.EdgeID = edgeIn.id;
+    newEdge.EdgeIndex = m_vecEdgeVector.size();
+    newEdge.StartNode = edgeIn.source;
+    newEdge.EndNode = edgeIn.target;
+    newEdge.Cost = edgeIn.cost;
+    newEdge.ReverseCost = edgeIn.reverse_cost;
+
+    // Set the direction. If both cost and reverse cost has positive value the edge is bidirectional and direction field is 0. If cost is positive and reverse cost
+    // negative then the edge is unidirectional with direction = 1 (goes from source to target) otherwise it is unidirectional with direction = -1 (goes from target
+    // to source). Another way of creating unidirectional edge is assigning big values in cost or reverse_cost. In that case the direction is still zero and this case
+    // is handled in the algorithm automatically.
+    if (newEdge.Cost >= 0.0 &&  newEdge.ReverseCost >= 0) {
+        newEdge.Direction = 0;
+    } else if (newEdge.Cost >= 0.0) {
+        newEdge.Direction = 1;
+    } else {
+        newEdge.Direction = -1;
+    }
+
+    if (edgeIn.id > max_edge_id) {
+        max_edge_id = edgeIn.id;
+    }
+
+    // Update max_edge_id
+    if (newEdge.StartNode > max_node_id) {
+        return false;  // max_node_id = newEdge.StartNode;
+    }
+    if (newEdge.EndNode > max_node_id) {
+        return false;  // max_node_id = newEdge.EdgeIndex;
+    }
+
+    m_vecNodeVector[newEdge.StartNode].xpos = edgeIn.s_x;
+    m_vecNodeVector[newEdge.StartNode].ypos = edgeIn.s_y;
+
+    m_vecNodeVector[newEdge.EndNode].xpos = edgeIn.t_x;
+    m_vecNodeVector[newEdge.EndNode].ypos = edgeIn.t_y;
+
+    // update connectivity information for the start node.
+    m_vecNodeVector[newEdge.StartNode].Connected_Nodes.push_back(newEdge.EndNode);
+    m_vecNodeVector[newEdge.StartNode].Connected_Edges_Index.push_back(newEdge.EdgeIndex);
+
+    // update connectivity information for the end node.
+    m_vecNodeVector[newEdge.EndNode].Connected_Nodes.push_back(newEdge.StartNode);
+    m_vecNodeVector[newEdge.EndNode].Connected_Edges_Index.push_back(newEdge.EdgeIndex);
+
+
+
+    // Adding edge to the list
+    m_mapEdgeId2Index.insert(std::make_pair(newEdge.EdgeID, m_vecEdgeVector.size()));
+    m_vecEdgeVector.push_back(newEdge);
+
+    return true;
 }
diff --git a/src/bd_astar/src/BiDirAStar.h b/src/bd_astar/src/BiDirAStar.h
index 2c699c8..9e371ba 100644
--- a/src/bd_astar/src/BiDirAStar.h
+++ b/src/bd_astar/src/BiDirAStar.h
@@ -31,99 +31,97 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
 ********************************************************************PGR-MIT*/
-#ifndef BIDIRASTAR_H
-#define BIDIRASTAR_H
+#ifndef SRC_BD_ASTAR_SRC_BIDIRASTAR_H_
+#define SRC_BD_ASTAR_SRC_BIDIRASTAR_H_
+#pragma once
 
 #include <vector>
 #include <map>
 #include <utility>
 
-#include "MinHeap.h"
-#include "bdastar.h"
+#include "./MinHeap.h"
+#include "./bdastar_driver.h"
 
 #define INF 1e15
 
 
 
-typedef std::vector<long> LongVector;
+typedef std::vector<size_t> LongVector;
 typedef std::vector<LongVector> VectorOfLongVector;
 typedef std::pair<double, int> PDI;
 
-typedef struct{
+typedef struct {
     int par_Node;
     int par_Edge;
-}PARENT_PATH;
+} PARENT_PATH;
 
-typedef struct{
+typedef struct {
     int NodeID;
     double xpos;
     double ypos;
     std::vector<int> Connected_Nodes;
     std::vector<size_t> Connected_Edges_Index;
-}GraphNodeInfo;
-
-struct GraphEdgeInfo
-{
-public:
-    int EdgeID;
-    size_t EdgeIndex;
-    int Direction;
-    double Cost;
-    double ReverseCost;
-    int StartNode;
-    int EndNode;
+} GraphNodeInfo;
+
+struct GraphEdgeInfo {
+ public:
+     int EdgeID;
+     size_t EdgeIndex;
+     int Direction;
+     double Cost;
+     double ReverseCost;
+     int StartNode;
+     int EndNode;
 };
 
 typedef std::vector<GraphEdgeInfo> GraphEdgeVector;
-typedef std::map<long,LongVector> Long2LongVectorMap;
-typedef std::map<long,long> Long2LongMap;
+typedef std::map<size_t, LongVector> Long2LongVectorMap;
+typedef std::map<size_t, size_t> Long2LongMap;
 typedef std::vector<GraphNodeInfo> GraphNodeVector;
 
 
-class BiDirAStar
-{
-public:
-    BiDirAStar(void);
-    ~BiDirAStar(void);
-    
-    int bidir_astar(edge_astar_t *edges, size_t edge_count, int maxNode, int start_vertex, int end_vertex,
-        path_element_t **path, size_t *path_count, char **err_msg);
-    
-
-private:
-    bool construct_graph(edge_astar_t *edges, size_t edge_count, int maxNode);
-    void fconstruct_path(int node_id);
-    void rconstruct_path(int node_id);
-    bool addEdge(edge_astar_t edgeIn);
-    bool connectEdge(GraphEdgeInfo& firstEdge, GraphEdgeInfo& secondEdge, bool bIsStartNodeSame);
-    void init();
-    void initall(int maxNode);
-    void deleteall();
-    //void explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que);
-    void explore(int cur_node, double cur_cost, int dir, MinHeap &que);
-    double getcost(int node_id, int dir);
-    void setcost(int node_id, int dir, double c);
-    void setparent(int node_id, int dir, int parnode, int paredge);
-    double gethcost(int node_id, int dir);
-    double dist(double x1, double y1, double x2, double y2);
-
-private:
-    GraphEdgeVector m_vecEdgeVector;
-    Long2LongMap m_mapEdgeId2Index;
-    Long2LongVectorMap m_mapNodeId2Edge;
-    GraphNodeVector m_vecNodeVector;
-    int max_node_id;
-    int max_edge_id;
-    int m_lStartNodeId;
-    int m_lEndNodeId;
-
-    double m_MinCost;
-    int m_MidNode;
-    std::vector <path_element_t> m_vecPath;
-    PARENT_PATH *m_pFParent;
-    PARENT_PATH *m_pRParent;
-    double *m_pFCost;
-    double *m_pRCost;
+class BiDirAStar {
+ public:
+     BiDirAStar(void);
+     ~BiDirAStar(void);
+
+     int bidir_astar(edge_astar_t *edges, size_t edge_count, int maxNode, int start_vertex, int end_vertex,
+             path_element_t **path, size_t *path_count, char **err_msg);
+
+ private:
+     bool construct_graph(edge_astar_t *edges, size_t edge_count, int maxNode);
+     void fconstruct_path(int node_id);
+     void rconstruct_path(int node_id);
+     bool addEdge(edge_astar_t edgeIn);
+     bool connectEdge(GraphEdgeInfo& firstEdge, GraphEdgeInfo& secondEdge, bool bIsStartNodeSame);
+     void init();
+     void initall(int maxNode);
+     void deleteall();
+     // void explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que);
+     void explore(int cur_node, double cur_cost, int dir, MinHeap &que);
+     double getcost(int node_id, int dir);
+     void setcost(int node_id, int dir, double c);
+     void setparent(int node_id, int dir, int parnode, int paredge);
+     double gethcost(int node_id, int dir);
+     double dist(double x1, double y1, double x2, double y2);
+
+ private:
+     GraphEdgeVector m_vecEdgeVector;
+     Long2LongMap m_mapEdgeId2Index;
+     Long2LongVectorMap m_mapNodeId2Edge;
+     GraphNodeVector m_vecNodeVector;
+     int max_node_id;
+     int max_edge_id;
+     int m_lStartNodeId;
+     int m_lEndNodeId;
+
+     double m_MinCost;
+     int m_MidNode;
+     std::vector <path_element_t> m_vecPath;
+     PARENT_PATH *m_pFParent;
+     PARENT_PATH *m_pRParent;
+     double *m_pFCost;
+     double *m_pRCost;
 };
 
-#endif
+#endif  // SRC_BD_ASTAR_SRC_BIDIRASTAR_H_
diff --git a/src/bd_astar/src/CMakeLists.txt b/src/bd_astar/src/CMakeLists.txt
index 2d19acb..0c700ab 100644
--- a/src/bd_astar/src/CMakeLists.txt
+++ b/src/bd_astar/src/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_library(bd_astar OBJECT 
     bdastar.c 
     MinHeap.cpp 
-    bdastar_core.cpp BiDirAStar.cpp)
+    bdastar_driver.cpp
+    BiDirAStar.cpp)
diff --git a/src/bd_astar/src/MinHeap.cpp b/src/bd_astar/src/MinHeap.cpp
index 1288654..992606a 100644
--- a/src/bd_astar/src/MinHeap.cpp
+++ b/src/bd_astar/src/MinHeap.cpp
@@ -2,7 +2,7 @@
 
 * $Id$
 *
-* Project:  pgRouting bdsp and bdastar algorithms
+* Project: pgRouting bdsp and bdastar algorithms
 * Purpose:
 * Author:   Razequl Islam <ziboncsedu at gmail.com>
 *
@@ -24,7 +24,7 @@ all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -32,142 +32,120 @@ THE SOFTWARE.
 
 ********************************************************************PGR-MIT*/
 
-#include "MinHeap.h"
+#include "./MinHeap.h"
+#include <string.h>
+#include <utility>
 
-MinHeap::MinHeap(int maxNode)
-{
-	init(maxNode);
+
+MinHeap::MinHeap(int maxNode) {
+    init(maxNode);
 }
 
-MinHeap::~MinHeap(void)
-{
-	reset();
+MinHeap::~MinHeap(void) {
+    reset();
 }
 
-bool MinHeap::reset(void)
-{
-	if(m_HeapTree != NULL)
-	{
-		delete [] m_HeapTree;
-		m_HeapTree = NULL;
-	}
-	if(m_Index != NULL)
-	{
-		delete [] m_Index;
-		m_Index = NULL;
-	}
-	return true;
+bool MinHeap::reset(void) {
+    if (m_HeapTree != NULL) {
+        delete [] m_HeapTree;
+        m_HeapTree = NULL;
+    }
+    if (m_Index != NULL) {
+        delete [] m_Index;
+        m_Index = NULL;
+    }
+    return true;
 }
 
-bool MinHeap::init(int maxNode)
-{
-	m_HeapTree = new PDI[maxNode + 1];
-	m_Index = new int[maxNode + 1];
-	memset(m_Index, -1, sizeof(int) * (maxNode + 1));
-	m_MaxNodeID = maxNode;
-	m_CurrentSize = 0;
-	return true;
+bool MinHeap::init(int maxNode) {
+    m_HeapTree = new PDI[maxNode + 1];
+    m_Index = new int[maxNode + 1];
+    memset(m_Index, -1, sizeof(int) * (maxNode + 1));
+    m_MaxNodeID = maxNode;
+    m_CurrentSize = 0;
+    return true;
 }
 
-void MinHeap::push(PDI node)
-{
-	int nid = node.second;
-	double ncost = node.first;
-	if(m_Index[nid] != -1)
-	{
-		int pos = m_Index[nid];
-		if(ncost < m_HeapTree[pos].first)
-		{
-			m_HeapTree[pos].first = ncost;
-			shift_up(pos);
-		}
-		else
-		{
-			return;
-		}
-	}
-	else
-	{
-		m_CurrentSize++;
-		m_HeapTree[m_CurrentSize] = node;
-		m_Index[nid] = m_CurrentSize;
-		shift_up(m_CurrentSize);
-	}
+void MinHeap::push(PDI node) {
+    int nid = node.second;
+    double ncost = node.first;
+    if (m_Index[nid] != -1) {
+        int pos = m_Index[nid];
+        if (ncost < m_HeapTree[pos].first) {
+            m_HeapTree[pos].first = ncost;
+            shift_up(pos);
+        } else {
+            return;
+        }
+    } else {
+        m_CurrentSize++;
+        m_HeapTree[m_CurrentSize] = node;
+        m_Index[nid] = m_CurrentSize;
+        shift_up(m_CurrentSize);
+    }
 }
 
-PDI MinHeap::top(void)
-{
-	return(m_HeapTree[1]);
+PDI MinHeap::top(void) {
+    return(m_HeapTree[1]);
 }
 
-bool MinHeap::empty(void)
-{
-	if(m_CurrentSize == 0)
-		return true;
-	return false;
+bool MinHeap::empty(void) {
+    if (m_CurrentSize == 0)
+        return true;
+    return false;
 }
 
-void MinHeap::pop(void)
-{
-	if(m_CurrentSize == 0)
-		return;
-	int nid = m_HeapTree[1].second;
-	m_Index[nid] = -1;
-	m_HeapTree[1] = m_HeapTree[m_CurrentSize];
-	m_Index[m_HeapTree[1].second] = 1;
-	m_CurrentSize--;
-	shift_down(1);
+void MinHeap::pop(void) {
+    if (m_CurrentSize == 0)
+        return;
+    int nid = m_HeapTree[1].second;
+    m_Index[nid] = -1;
+    m_HeapTree[1] = m_HeapTree[m_CurrentSize];
+    m_Index[m_HeapTree[1].second] = 1;
+    m_CurrentSize--;
+    shift_down(1);
 }
 
-void MinHeap::shift_up(int node)
-{
-	while(node > 1)
-	{
-		int par_node = node / 2;
-		if(m_HeapTree[par_node].first <= m_HeapTree[node].first)
-		{
-			return;
-		}
-		PDI temp = m_HeapTree[par_node];
-		m_HeapTree[par_node] = m_HeapTree[node];
-		m_HeapTree[node] = temp;
-		m_Index[m_HeapTree[node].second] = node;
-		m_Index[m_HeapTree[par_node].second] = par_node;
-		node = par_node;
-	}
-	return;
+void MinHeap::shift_up(int node) {
+    while (node > 1) {
+        int par_node = node / 2;
+        if (m_HeapTree[par_node].first <= m_HeapTree[node].first) {
+            return;
+        }
+        PDI temp = m_HeapTree[par_node];
+        m_HeapTree[par_node] = m_HeapTree[node];
+        m_HeapTree[node] = temp;
+        m_Index[m_HeapTree[node].second] = node;
+        m_Index[m_HeapTree[par_node].second] = par_node;
+        node = par_node;
+    }
+    return;
 }
 
-void MinHeap::shift_down(int node)
-{
-	while(node < m_CurrentSize)
-	{
-		int left_child = node * 2;
-		int right_child = node * 2 + 1;
-		if(left_child > m_CurrentSize)
-		{
-			return;
-		}
-		int smallest = node;
-		if(m_HeapTree[left_child] < m_HeapTree[smallest])
-		{
-			smallest = left_child;
-		}
-		if(right_child <= m_CurrentSize)
-		{
-			if(m_HeapTree[right_child] < m_HeapTree[smallest])
-			{
-				smallest = right_child;
-			}
-		}
-		if(node == smallest)
-			return;
-		PDI temp = m_HeapTree[node];
-		m_HeapTree[node] = m_HeapTree[smallest];
-		m_HeapTree[smallest] = temp;
-		m_Index[m_HeapTree[node].second] = node;
-		m_Index[m_HeapTree[smallest].second] = smallest;
-		node = smallest;
-	}
-	return;
+void MinHeap::shift_down(int node) {
+    while (node < m_CurrentSize) {
+        int left_child = node * 2;
+        int right_child = node * 2 + 1;
+        if (left_child > m_CurrentSize) {
+            return;
+        }
+        int smallest = node;
+        if (m_HeapTree[left_child] < m_HeapTree[smallest]) {
+            smallest = left_child;
+        }
+        if (right_child <= m_CurrentSize) {
+            if (m_HeapTree[right_child] < m_HeapTree[smallest]) {
+                smallest = right_child;
+            }
+        }
+        if (node == smallest)
+            return;
+        PDI temp = m_HeapTree[node];
+        m_HeapTree[node] = m_HeapTree[smallest];
+        m_HeapTree[smallest] = temp;
+        m_Index[m_HeapTree[node].second] = node;
+        m_Index[m_HeapTree[smallest].second] = smallest;
+        node = smallest;
+    }
+    return;
 }
diff --git a/src/bd_astar/src/MinHeap.h b/src/bd_astar/src/MinHeap.h
index 2760a3a..804bbdc 100644
--- a/src/bd_astar/src/MinHeap.h
+++ b/src/bd_astar/src/MinHeap.h
@@ -32,41 +32,35 @@ THE SOFTWARE.
 
 ********************************************************************PGR-MIT*/
 
-#ifndef MINHEAP_H
-#define MINHEAP_H
+#ifndef SRC_BD_ASTAR_SRC_MINHEAP_H_
+#define SRC_BD_ASTAR_SRC_MINHEAP_H_
+#pragma once
 
-#include <string>
-#include <stdlib.h>
-#include <iostream>
-#include <map>
-#include <math.h>
-#include <string.h>
+#include <utility>
 
 typedef std::pair<double, int> PDI;
 
-class MinHeap
-{
-public:
-	MinHeap(int maxNode);
-	~MinHeap(void);
-
-	bool reset(void);
-	bool init(int maxNode);
-	void push(PDI node);
-	PDI top();
-	void pop();
-	bool empty();
-
-private:
-	void shift_up(int node);
-	void shift_down(int node);
-
-private:
-	PDI *m_HeapTree;
-	int *m_Index;
-	int m_MaxNodeID;
-	int m_CurrentSize;
-
+class MinHeap {
+ public:
+     explicit MinHeap(int maxNode);
+     ~MinHeap(void);
+
+     bool reset(void);
+     bool init(int maxNode);
+     void push(PDI node);
+     PDI top();
+     void pop();
+     bool empty();
+
+ private:
+     void shift_up(int node);
+     void shift_down(int node);
+
+ private:
+     PDI *m_HeapTree;
+     int *m_Index;
+     int m_MaxNodeID;
+     int m_CurrentSize;
 };
 
-#endif
+#endif  // SRC_BD_ASTAR_SRC_MINHEAP_H_
diff --git a/src/bd_astar/src/bdastar.c b/src/bd_astar/src/bdastar.c
index a920c70..47d64dc 100644
--- a/src/bd_astar/src/bdastar.c
+++ b/src/bd_astar/src/bdastar.c
@@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "../../common/src/pgr_types.h"
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
@@ -36,56 +35,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <stdlib.h>
 #include <search.h>
 
+#include "../../common/src/pgr_types.h"
 #include "../../common/src/postgres_connection.h"
-#include "bdastar.h"
-
-//-------------------------------------------------------------------------
-
-/*
- * Define this to have profiling enabled
- */
-//#define PROFILE
-
-#ifdef PROFILE
-#include <sys/time.h>
-
-struct timeval prof_astar, prof_store, prof_extract, prof_total;
-long proftime[5];
-long profipts1, profipts2, profopts;
-
-#define profstart(x) do { gettimeofday(&x, NULL); } while (0);
-#define profstop(n, x) do { struct timeval _profstop;   \
-        long _proftime;                         \
-        gettimeofday(&_profstop, NULL);                         \
-        _proftime = ( _profstop.tv_sec*1000000+_profstop.tv_usec) -     \
-                ( x.tv_sec*1000000+x.tv_usec); \
-        elog(NOTICE, \
-                "PRF(%s) %lu (%f ms)", \
-                (n), \
-             _proftime, _proftime / 1000.0);    \
-        } while (0);
-
-#else
-
-#define profstart(x) do { } while (0);
-#define profstop(n, x) do { } while (0);
-
-#endif // PROFILE
+#include "./bdastar_driver.h"
 
 
 //-------------------------------------------------------------------------
 
+PGDLLEXPORT
 Datum bidir_astar_shortest_path(PG_FUNCTION_ARGS);
 
 #undef DEBUG
 #include "../../common/src/debug_macro.h"
 
-
 // The number of tuples to fetch from the SPI cursor at each iteration
 #define TUPLIMIT 1000
 
-typedef struct edge_astar_columns
-{
+typedef struct edge_astar_columns {
   int id;
   int source;
   int target;
@@ -101,8 +67,7 @@ typedef struct edge_astar_columns
 static int
 fetch_edge_astar_columns(SPITupleTable *tuptable,
              edge_astar_columns_t *edge_columns,
-             bool has_reverse_cost)
-{
+             bool has_reverse_cost) {
   edge_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
   edge_columns->source = SPI_fnumber(SPI_tuptable->tupdesc, "source");
   edge_columns->target = SPI_fnumber(SPI_tuptable->tupdesc, "target");
@@ -112,7 +77,6 @@ fetch_edge_astar_columns(SPITupleTable *tuptable,
       edge_columns->source == SPI_ERROR_NOATTRIBUTE ||
       edge_columns->target == SPI_ERROR_NOATTRIBUTE ||
       edge_columns->cost == SPI_ERROR_NOATTRIBUTE) {
-
       elog(ERROR, "Error, query must return columns "
             "'id', 'source', 'target' and 'cost'");
       return -1;
@@ -123,7 +87,6 @@ fetch_edge_astar_columns(SPITupleTable *tuptable,
       SPI_gettypeid(SPI_tuptable->tupdesc,
             edge_columns->target) != INT4OID ||
       SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->cost) != FLOAT8OID) {
-
       elog(ERROR, "Error, columns 'source', 'target' must be of type int4, "
             "'cost' must be of type float8");
       return -1;
@@ -161,7 +124,6 @@ fetch_edge_astar_columns(SPITupleTable *tuptable,
       edge_columns->s_y == SPI_ERROR_NOATTRIBUTE ||
       edge_columns->t_x == SPI_ERROR_NOATTRIBUTE ||
       edge_columns->t_y == SPI_ERROR_NOATTRIBUTE) {
-
       elog(ERROR, "Error, query must return columns "
        "'x1', 'x2', 'y1' and 'y2'");
       return -1;
@@ -169,7 +131,7 @@ fetch_edge_astar_columns(SPITupleTable *tuptable,
 
   PGR_DBG("columns: x1 %i y1 %i x2 %i y2 %i",
       edge_columns->s_x, edge_columns->s_y,
-      edge_columns->t_x,edge_columns->t_y);
+      edge_columns->t_x, edge_columns->t_y);
 
   return 0;
 }
@@ -177,8 +139,7 @@ fetch_edge_astar_columns(SPITupleTable *tuptable,
 static void
 fetch_edge_astar(HeapTuple *tuple, TupleDesc *tupdesc,
          edge_astar_columns_t *edge_columns,
-         edge_astar_t *target_edge)
-{
+         edge_astar_t *target_edge) {
   Datum binval;
   bool isnull;
 
@@ -227,8 +188,7 @@ fetch_edge_astar(HeapTuple *tuple, TupleDesc *tupdesc,
 static int compute_shortest_path_astar(char* sql, int source_vertex_id,
                        int target_vertex_id, bool directed,
                        bool has_reverse_cost,
-                       path_element_t **path, size_t *path_count)
-{
+                       path_element_t **path, size_t *path_count) {
   void *SPIplan;
   Portal SPIportal;
   bool moredata = TRUE;
@@ -236,18 +196,22 @@ static int compute_shortest_path_astar(char* sql, int source_vertex_id,
   edge_astar_t *edges = NULL;
   size_t total_tuples = 0;
 
-  int v_max_id=0;
-  int v_min_id=INT_MAX;
+  int v_max_id = 0;
+  int v_min_id = INT_MAX;
 
-  edge_astar_columns_t edge_columns = {.id= -1, .source= -1, .target= -1,
-                       .cost= -1, .reverse_cost= -1,
-                       .s_x= -1, .s_y= -1, .t_x= -1, .t_y= -1};
+#ifndef _MSC_VER
+  edge_astar_columns_t edge_columns = {.id =  -1, .source =  -1, .target =  -1,
+                       .cost =  -1, .reverse_cost =  -1,
+                       .s_x =  -1, .s_y =  -1, .t_x =  -1, .t_y =  -1};
+#else  // _MSC_VER
+  edge_astar_columns_t edge_columns = {-1, -1, -1, -1, -1, -1, -1, -1, -1};
+#endif  // _MSC_VER
   char *err_msg;
   int ret = -1;
   register int z;
 
-  int s_count=0;
-  int t_count=0;
+  int s_count = 0;
+  int t_count = 0;
 
   struct vItem {
     int id;
@@ -295,60 +259,55 @@ static int compute_shortest_path_astar(char* sql, int source_vertex_id,
                        &edges[total_tuples - ntuples + t]);
           }
           SPI_freetuptable(tuptable);
-      }
-      else {
+      } else {
           moredata = FALSE;
       }
   }
 
-  //defining min and max vertex id
+  // defining min and max vertex id
 
-  PGR_DBG("Total %i tuples", total_tuples);
+  PGR_DBG("Total %lu tuples", total_tuples);
 
-  for(z=0; z<total_tuples; z++)
-  {
-    if(edges[z].source<v_min_id) v_min_id=edges[z].source;
-    if(edges[z].source>v_max_id) v_max_id=edges[z].source;
-    if(edges[z].target<v_min_id) v_min_id=edges[z].target;
-    if(edges[z].target>v_max_id) v_max_id=edges[z].target;
+  for (z = 0; z < total_tuples; z++) {
+    if (edges[z].source < v_min_id) v_min_id = edges[z].source;
+    if (edges[z].source > v_max_id) v_max_id = edges[z].source;
+    if (edges[z].target < v_min_id) v_min_id = edges[z].target;
+    if (edges[z].target > v_max_id) v_max_id = edges[z].target;
     PGR_DBG("%i <-> %i", v_min_id, v_max_id);
   }
 
   //::::::::::::::::::::::::::::::::::::
   //:: reducing vertex id (renumbering)
   //::::::::::::::::::::::::::::::::::::
-  for(z=0; z<total_tuples; z++) {
-    //check if edges[] contains source and target
-    if(edges[z].source == source_vertex_id ||
+  for (z=0; z < total_tuples; z++) {
+    // check if edges[] contains source and target
+    if (edges[z].source == source_vertex_id ||
        edges[z].target == source_vertex_id)
       ++s_count;
-    if(edges[z].source == target_vertex_id ||
+    if (edges[z].source == target_vertex_id ||
        edges[z].target == target_vertex_id)
       ++t_count;
 
-    edges[z].source-=v_min_id;
-    edges[z].target-=v_min_id;
+    edges[z].source -= v_min_id;
+    edges[z].target -= v_min_id;
     PGR_DBG("%i - %i", edges[z].source, edges[z].target);
   }
 
-  PGR_DBG("Total %i tuples", total_tuples);
+  PGR_DBG("Total %lu tuples", total_tuples);
 
-  if(s_count == 0) {
+  if (s_count == 0) {
     elog(ERROR, "Start vertex was not found.");
     return -1;
   }
 
-  if(t_count == 0) {
+  if (t_count == 0) {
     elog(ERROR, "Target vertex was not found.");
     return -1;
   }
 
-  PGR_DBG("Total %i tuples", total_tuples);
-
-  profstop("extract", prof_extract);
-  profstart(prof_astar);
+  PGR_DBG("Total %lu tuples", total_tuples);
 
-  PGR_DBG("Calling bidir_astar <%i>\n", total_tuples);
+  PGR_DBG("Calling bidir_astar <%lu>\n", total_tuples);
 
   // calling C++ A* function
   ret = bdastar_wrapper(edges, total_tuples, v_max_id + 1, source_vertex_id-v_min_id,
@@ -356,21 +315,17 @@ static int compute_shortest_path_astar(char* sql, int source_vertex_id,
             directed, has_reverse_cost,
             path, path_count, &err_msg);
 
-  PGR_DBG("SIZE %i\n",*path_count);
+  PGR_DBG("SIZE %lu\n", *path_count);
 
-  PGR_DBG("ret =  %i\n",ret);
+  PGR_DBG("ret =  %i\n", ret);
 
   //::::::::::::::::::::::::::::::::
   //:: restoring original vertex id
   //::::::::::::::::::::::::::::::::
-  for(z=0; z<*path_count; z++) {
-    //PGR_DBG("vetex %i\n",(*path)[z].vertex_id);
-    (*path)[z].vertex_id+=v_min_id;
+  for (z = 0; z < *path_count; z++) {
+    // PGR_DBG("vetex %i\n",(*path)[z].vertex_id);
+    (*path)[z].vertex_id += v_min_id;
   }
-
-  profstop("astar", prof_astar);
-  profstart(prof_store);
-
   if (ret < 0) {
       elog(ERROR, "Error computing path: %s", err_msg);
   }
@@ -380,9 +335,8 @@ static int compute_shortest_path_astar(char* sql, int source_vertex_id,
 
 
 PG_FUNCTION_INFO_V1(bidir_astar_shortest_path);
-Datum
-bidir_astar_shortest_path(PG_FUNCTION_ARGS)
-{
+PGDLLEXPORT Datum
+bidir_astar_shortest_path(PG_FUNCTION_ARGS) {
   FuncCallContext     *funcctx;
   uint32_t                  call_cntr;
   uint32_t                  max_calls;
@@ -397,10 +351,6 @@ bidir_astar_shortest_path(PG_FUNCTION_ARGS)
       int ret;
 #endif
 
-      // XXX profiling messages are not thread safe
-      profstart(prof_total);
-      profstart(prof_extract);
-
       /* create a function context for cross-call persistence */
       funcctx = SRF_FIRSTCALL_INIT();
 
@@ -435,7 +385,7 @@ bidir_astar_shortest_path(PG_FUNCTION_ARGS)
       funcctx->max_calls = (uint32_t)path_count;
       funcctx->user_fctx = path;
 
-      PGR_DBG("Path count %i", path_count);
+      PGR_DBG("Path count %lu", path_count);
 
       funcctx->tuple_desc =
             BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
@@ -490,16 +440,9 @@ bidir_astar_shortest_path(PG_FUNCTION_ARGS)
       pfree(nulls);
 
       SRF_RETURN_NEXT(funcctx, result);
-  }
-  else {   /* do when there is no more left */
+  } else {   /* do when there is no more left */
       PGR_DBG("Freeing path");
       if (path) free(path);
-
-      profstop("store", prof_store);
-      profstop("total", prof_total);
-#ifdef PROFILE
-      elog(NOTICE, "_________");
-#endif
       SRF_RETURN_DONE(funcctx);
   }
 }
diff --git a/src/bd_astar/src/bdastar_core.cpp b/src/bd_astar/src/bdastar_driver.cpp
similarity index 76%
rename from src/bd_astar/src/bdastar_core.cpp
rename to src/bd_astar/src/bdastar_driver.cpp
index 1267fa8..79c8e3a 100644
--- a/src/bd_astar/src/bdastar_core.cpp
+++ b/src/bd_astar/src/bdastar_driver.cpp
@@ -2,7 +2,7 @@
 
 * $Id$
 *
-* Project:  pgRouting bdsp and bdastar algorithms
+* Project: pgRouting bdsp and bdastar algorithms
 * Purpose:
 * Author:   Razequl Islam <ziboncsedu at gmail.com>
 *
@@ -24,7 +24,7 @@ all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -32,29 +32,28 @@ THE SOFTWARE.
 
 ********************************************************************PGR-MIT*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
 
 #include <exception>
-#include "BiDirAStar.h"
-#include "bdastar.h"
+#include "./BiDirAStar.h"
+#include "./bdastar_driver.h"
 
 int bdastar_wrapper(edge_astar_t *edges, size_t edge_count, int maxnode,
                   int source_vertex_id, int target_vertex_id,
                   bool directed, bool has_reverse_cost,
-                  path_element_t **path, size_t *path_count, char **err_msg)
-{
+                  path_element_t **path, size_t *path_count, char **err_msg) {
     int res;
 
     try {
-	    BiDirAStar bdastar;
-	    res = bdastar.bidir_astar(edges, edge_count, maxnode, source_vertex_id, target_vertex_id, path, path_count, err_msg);
-        // TODO  this are an unused parameters have to be used
-        if (has_reverse_cost) {};
-        if (directed) {};
+        BiDirAStar bdastar;
+        res = bdastar.bidir_astar(edges, edge_count, maxnode, source_vertex_id, target_vertex_id, path, path_count, err_msg);
+        // TODO(someone) this are an unused parameters have to be used
+        if (has_reverse_cost) {}
+        if (directed) {}
     }
     catch(std::exception& e) {
         *err_msg = (char *) e.what();
@@ -68,6 +67,6 @@ int bdastar_wrapper(edge_astar_t *edges, size_t edge_count, int maxnode,
     if (res < 0)
         return res;
     else
-	    return EXIT_SUCCESS;
+        return EXIT_SUCCESS;
 }
 
diff --git a/src/bd_astar/src/bdastar.h b/src/bd_astar/src/bdastar_driver.h
similarity index 89%
rename from src/bd_astar/src/bdastar.h
rename to src/bd_astar/src/bdastar_driver.h
index a7b96d7..386f402 100644
--- a/src/bd_astar/src/bdastar.h
+++ b/src/bd_astar/src/bdastar_driver.h
@@ -24,9 +24,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef _BDASTAR_H
-#define _BDASTAR_H
+#ifndef SRC_BD_ASTAR_SRC_BDASTAR_DRIVER_H_
+#define SRC_BD_ASTAR_SRC_BDASTAR_DRIVER_H_
+#pragma once
 
+#include "stdlib.h"
 #include "../../common/src/pgr_types.h"
 
 
@@ -42,4 +44,4 @@ extern "C" {
 }
 #endif
 
-#endif
+#endif  // SRC_BD_ASTAR_SRC_BDASTAR_DRIVER_H_
diff --git a/src/bd_astar/tester/BiDirAStar.cpp b/src/bd_astar/tester/BiDirAStar.cpp
index 773de69..0599933 100644
--- a/src/bd_astar/tester/BiDirAStar.cpp
+++ b/src/bd_astar/tester/BiDirAStar.cpp
@@ -158,7 +158,7 @@ void BiDirAStar::setparent(int node_id, int dir, int parnode, int paredge)
 
 /*
 	Reconstruct path for forward search. It is like normal dijkstra. The parent array contains the parent of the current node and there is a -1 in the source.
-	So one need to recurse upto the source and then add the current node and edge to the list.
+	So one need to recurse up to the source and then add the current node and edge to the list.
 */
 
 void BiDirAStar::fconstruct_path(int node_id)
@@ -175,7 +175,7 @@ void BiDirAStar::fconstruct_path(int node_id)
 
 /*
 	Reconstruct path for the reverse search. In this case the subsequent node is stored in the parent and the target contains a -1. So one need to add the node
-	and edge to the list and then recurse through the parent upto hitting a -1.
+	and edge to the list and then recurse through the parent up to hitting a -1.
 */
 
 void BiDirAStar::rconstruct_path(int node_id)
@@ -416,7 +416,7 @@ bool BiDirAStar::construct_graph(edge_astar_t* edges, int edge_count, int maxNod
 	nodeInfo.Connected_Nodes.clear();
 
 	// Insert the dummy node into the node list. This acts as place holder. Also change the nodeId so that nodeId and node index in the vector are same.
-	// There may be some nodes here that does not appear in the edge list. The size of the list is upto maxNode which is equal to maximum node id.
+	// There may be some nodes here that does not appear in the edge list. The size of the list is up to maxNode which is equal to maximum node id.
 	for(i = 0; i <= maxNode; i++)
 	{
 		nodeInfo.NodeID = i;
@@ -433,7 +433,7 @@ bool BiDirAStar::construct_graph(edge_astar_t* edges, int edge_count, int maxNod
 }
 
 /*
-	Process the edge and populate the member nodelist and edgelist. The nodelist already contains upto maxNode dummy entries with nodeId same as index. Now the
+	Process the edge and populate the member nodelist and edgelist. The nodelist already contains up to maxNode dummy entries with nodeId same as index. Now the
 	connectivity information needs to be updated.
 */
 
diff --git a/src/bd_dijkstra/CMakeLists.txt b/src/bd_dijkstra/CMakeLists.txt
deleted file mode 100644
index a9219b9..0000000
--- a/src/bd_dijkstra/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(PACKAGE_SQL_FILES "")
-add_subdirectory(sql)
-set(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-
-subdirs(doc src test)
-
diff --git a/src/bd_dijkstra/doc/doc-bdDijkstra.queries b/src/bd_dijkstra/doc/doc-bdDijkstra.queries
index 47cd559..3566f29 100644
--- a/src/bd_dijkstra/doc/doc-bdDijkstra.queries
+++ b/src/bd_dijkstra/doc/doc-bdDijkstra.queries
@@ -6,11 +6,11 @@ SELECT * FROM pgr_bdDijkstra(
     4, 10, false, false);
  seq | id1 | id2 | cost 
 -----+-----+-----+------
-   0 |   4 |   3 |    0
-   1 |   3 |   2 |    0
-   2 |   2 |   4 |    1
-   3 |   5 |  10 |    1
-   4 |  10 |  -1 |    0
+   0 |   4 |     |    0
+   1 |   3 |     |    0
+   2 |   2 |     |    1
+   3 |   5 |     |    1
+   4 |  10 |     |    0
 (5 rows)
 
 --q2
diff --git a/src/bd_dijkstra/doc/pgr_bdDijkstra.rst b/src/bd_dijkstra/doc/pgr_bdDijkstra.rst
index 52801ae..ced7ae3 100644
--- a/src/bd_dijkstra/doc/pgr_bdDijkstra.rst
+++ b/src/bd_dijkstra/doc/pgr_bdDijkstra.rst
@@ -13,8 +13,7 @@ pgr_bdDijkstra - Bi-directional Dijkstra Shortest Path
 ===============================================================================
 
 .. index:: 
-	single: pgr_bdDijkstra(text, integer, integer, boolean, boolean)
-	module: bidirectional, dijkstra
+	single: bdDijkstra(Complete Signature)
 
 
 Name
@@ -26,7 +25,7 @@ Name
 Synopsis
 -------------------------------------------------------------------------------
 
-This is a bi-directional Dijkstra search algorithm. It searchs from the source toward the distination and at the same time from the destination to the source and terminates whe these to searchs meet in the middle. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
+This is a bi-directional Dijkstra search algorithm. It searches from the source toward the distination and at the same time from the destination to the source and terminates whe these to searches meet in the middle. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
 
 .. code-block:: sql
 
diff --git a/src/bd_dijkstra/src/BiDirDijkstra.cpp b/src/bd_dijkstra/src/BiDirDijkstra.cpp
index 76fca3a..e9fa103 100644
--- a/src/bd_dijkstra/src/BiDirDijkstra.cpp
+++ b/src/bd_dijkstra/src/BiDirDijkstra.cpp
@@ -2,7 +2,7 @@
 
 * $Id$
 *
-* Project:  pgRouting bdsp and bdastar algorithms
+* Project: pgRouting bdsp and bdastar algorithms
 * Purpose:
 * Author:   Razequl Islam <ziboncsedu at gmail.com>
 Copyright (c) 2015 pgRouting developers
@@ -26,58 +26,55 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-MIT*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
+#include <queue>
+#include <vector>
+#include <functional>
+
 #include "BiDirDijkstra.h"
-#include "../../common/src/memory_func.hpp"
+#include "../../common/src/pgr_alloc.hpp"
 
 
 
-BiDirDijkstra::BiDirDijkstra(void)
-{
+BiDirDijkstra::BiDirDijkstra(void) {
 }
 
-BiDirDijkstra::~BiDirDijkstra(void)
-{
+BiDirDijkstra::~BiDirDijkstra(void) {
 }
 
-void BiDirDijkstra::init()
-{
-	//max_edge_id = 0;
-	//max_node_id = 0;
-	
+void BiDirDijkstra::init() {
+    // max_edge_id = 0;
+    // max_node_id = 0;
 }
 
 /*
-	Initialization and allocation of memories.
+    Initialization and allocation of memories.
 */
-void BiDirDijkstra::initall(int maxNode)
-{
-	int i;
-	m_vecPath.clear();
+void BiDirDijkstra::initall(int maxNode) {
+    int i;
+    m_vecPath.clear();
     // DBG("BiDirDijkstra::initall: allocating m_pFParent, m_pRParent maxNode: %d\n", maxNode+1);
-	m_pFParent = new PARENT_PATH[maxNode + 1];
-	m_pRParent = new PARENT_PATH[maxNode + 1];
+    m_pFParent = new PARENT_PATH[maxNode + 1];
+    m_pRParent = new PARENT_PATH[maxNode + 1];
     // DBG("BiDirDijkstra::initall: allocated m_pFParent, m_pRParent\n");
 
     // DBG("BiDirDijkstra::initall: allocating m_pFCost, m_pRCost maxNode: %d\n", maxNode+1);
-	m_pFCost = new double[maxNode + 1];
-	m_pRCost = new double[maxNode + 1];
+    m_pFCost = new double[maxNode + 1];
+    m_pRCost = new double[maxNode + 1];
     // DBG("BiDirDijkstra::initall: allocated m_pFCost, m_pRCost\n");
 
-	for(i = 0; i <= maxNode; i++)
-	{
-		m_pFParent[i].par_Node = -2;
-		m_pRParent[i].par_Node = -2;
-		m_pFCost[i] = INF;
-		m_pRCost[i] = INF;
-		
-	}
-	m_MinCost = INF;
-	m_MidNode = -1;
+    for (i = 0; i <= maxNode; i++) {
+        m_pFParent[i].par_Node = -2;
+        m_pRParent[i].par_Node = -2;
+        m_pFCost[i] = INF;
+        m_pRCost[i] = INF;
+    }
+    m_MinCost = INF;
+    m_MidNode = -1;
 
     // DBG("BiDirDijkstra::initall: m_vecNodeVector.reserve(%d)\n", maxNode + 1);
     // reserve space for nodes
@@ -86,421 +83,378 @@ void BiDirDijkstra::initall(int maxNode)
 }
 
 /*
-	Delete the allocated memories to avoid memory leak.
+    Delete the allocated memories to avoid memory leak.
 */
-void BiDirDijkstra::deleteall()
-{
-	std::vector<GraphNodeInfo*>::iterator it;
-	for(it  = m_vecNodeVector.begin(); it != m_vecNodeVector.end(); it++){
-		delete *it;
-	}
-	m_vecNodeVector.clear();
-	delete [] m_pFParent;
-	delete [] m_pRParent;
-	delete [] m_pFCost;
-	delete [] m_pRCost;
+void BiDirDijkstra::deleteall() {
+    std::vector<GraphNodeInfo*>::iterator itNode;
+    for (itNode = m_vecNodeVector.begin(); itNode != m_vecNodeVector.end(); itNode++) {
+        delete *itNode;
+    }
+    m_vecNodeVector.clear();
+    std::vector<GraphEdgeInfo*>::iterator itEdge;
+    for (itEdge = m_vecEdgeVector.begin(); itEdge != m_vecEdgeVector.end(); itEdge++) {
+        delete *itEdge;
+    }
+    m_vecEdgeVector.clear();
+    delete [] m_pFParent;
+    delete [] m_pRParent;
+    delete [] m_pFCost;
+    delete [] m_pRCost;
 }
 
 /*
-	Get the current cost from source to the current node if direction is 1 else the cost to reach target from the current node.
+    Get the current cost from source to the current node if direction is 1 else the cost to reach target from the current node.
 */
-double BiDirDijkstra::getcost(int node_id, int dir)
-{
-	if(dir == 1)
-	{
-		return(m_pFCost[node_id]);
-	}
-	else
-	{
-		return(m_pRCost[node_id]);
-	}
+double BiDirDijkstra::getcost(int node_id, int dir) {
+    if (dir == 1) {
+        return(m_pFCost[node_id]);
+    } else {
+        return(m_pRCost[node_id]);
+    }
 }
 /*
-	Set the forward or reverse cost list depending on dir (1 for forward search and -1 for reverse search.
+    Set the forward or reverse cost list depending on dir (1 for forward search and -1 for reverse search.
 */
-void BiDirDijkstra::setcost(int node_id, int dir, double c)
-{
-	if(dir == 1)
-	{
-		m_pFCost[node_id] = c;
-	}
-	else
-	{
-		m_pRCost[node_id] = c;
-	}
+void BiDirDijkstra::setcost(int node_id, int dir, double c) {
+    if (dir == 1) {
+        m_pFCost[node_id] = c;
+    } else {
+        m_pRCost[node_id] = c;
+    }
 }
 
-void BiDirDijkstra::setparent(int node_id, int dir, int parnode, int paredge)
-{
-	if(dir == 1)
-	{
-		m_pFParent[node_id].par_Node = parnode;
-		m_pFParent[node_id].par_Edge = paredge;
-	}
-	else
-	{
-		m_pRParent[node_id].par_Node = parnode;
-		m_pRParent[node_id].par_Edge = paredge;
-	}
+void BiDirDijkstra::setparent(int node_id, int dir, int parnode, int paredge) {
+    if (dir == 1) {
+        m_pFParent[node_id].par_Node = parnode;
+        m_pFParent[node_id].par_Edge = paredge;
+    } else {
+        m_pRParent[node_id].par_Node = parnode;
+        m_pRParent[node_id].par_Edge = paredge;
+    }
 }
 
 /*
-	Reconstruct path for forward search. It is like normal dijkstra. The parent array contains the parent of the current node and there is a -1 in the source.
-	So one need to recurse upto the source and then add the current node and edge to the list.
+    Reconstruct path for forward search. It is like normal dijkstra. The parent array contains the parent of the current node and there is a -1 in the source.
+    So one need to recurse up to the source and then add the current node and edge to the list.
 */
-void BiDirDijkstra::fconstruct_path(int node_id)
-{
-	if(m_pFParent[node_id].par_Node == -1)
-		return;
-	fconstruct_path(m_pFParent[node_id].par_Node);
-	path_element_t pt;
-	pt.vertex_id = m_pFParent[node_id].par_Node;
-	pt.edge_id = m_pFParent[node_id].par_Edge;
-	pt.cost = m_pFCost[node_id] - m_pFCost[m_pFParent[node_id].par_Node];
-	m_vecPath.push_back(pt);
+void BiDirDijkstra::fconstruct_path(int node_id) {
+    if (m_pFParent[node_id].par_Node == -1)
+        return;
+    fconstruct_path(m_pFParent[node_id].par_Node);
+    path_element_t pt;
+    pt.vertex_id = m_pFParent[node_id].par_Node;
+    pt.edge_id = m_pFParent[node_id].par_Edge;
+    pt.cost = m_pFCost[node_id] - m_pFCost[m_pFParent[node_id].par_Node];
+    m_vecPath.push_back(pt);
 }
 
 /*
-	Reconstruct path for the reverse search. In this case the subsequent node is stored in the parent and the target contains a -1. So one need to add the node
-	and edge to the list and then recurse through the parent upto hitting a -1.
+    Reconstruct path for the reverse search. In this case the subsequent node is stored in the parent and the target contains a -1. So one need to add the node
+    and edge to the list and then recurse through the parent up to hitting a -1.
 */
 
-void BiDirDijkstra::rconstruct_path(int node_id)
-{
-	path_element_t pt;
-	if(m_pRParent[node_id].par_Node == -1)
-	{
-		pt.vertex_id = node_id;
-		pt.edge_id = -1;
-		pt.cost = 0.0;
-		return;
-	}
-	pt.vertex_id = node_id;
-	pt.cost = m_pRCost[node_id] - m_pRCost[m_pRParent[node_id].par_Node];
-	pt.edge_id = m_pRParent[node_id].par_Edge;
-	m_vecPath.push_back(pt);
-	rconstruct_path(m_pRParent[node_id].par_Node);
+void BiDirDijkstra::rconstruct_path(int node_id) {
+    path_element_t pt;
+    if (m_pRParent[node_id].par_Node == -1) {
+        pt.vertex_id = node_id;
+        pt.edge_id = -1;
+        pt.cost = 0.0;
+        return;
+    }
+    pt.vertex_id = node_id;
+    pt.cost = m_pRCost[node_id] - m_pRCost[m_pRParent[node_id].par_Node];
+    pt.edge_id = m_pRParent[node_id].par_Edge;
+    m_vecPath.push_back(pt);
+    rconstruct_path(m_pRParent[node_id].par_Node);
 }
 
 /*
-	This is the main exploration module. The parameter dir indicates whether the exploration will be in forward or reverser direction. The reference to the corresponding
-	que is also passed as parameter que. The current node and the current costs are also available as parameter.
+    This is the main exploration module. The parameter dir indicates whether the exploration will be in forward or reverser direction. The reference to the corresponding
+    que is also passed as parameter que. The current node and the current costs are also available as parameter.
 */
 
-void BiDirDijkstra::explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que)
-{
-	int i;
-	// Number of connected edges
-	int con_edge = m_vecNodeVector[cur_node]->Connected_Edges_Index.size();
-	double edge_cost;
-
-	for(i = 0; i < con_edge; i++)
-	{
-		int edge_index = m_vecNodeVector[cur_node]->Connected_Edges_Index[i];
-		// Get the edge from the edge list.
-		GraphEdgeInfo edge = m_vecEdgeVector[edge_index];
-		// Get the connected node
-		int new_node = m_vecNodeVector[cur_node]->Connected_Nodes[i];
-		
-		if(cur_node == edge.StartNode)
-		{
-			// Current node is the startnode of the edge. For forward search it should use forward cost, otherwise it should use the reverse cost,
-			// i.e. if the reverse direction is valid then this node may be visited from the end node.
-			if(dir > 0)
-				edge_cost = edge.Cost;
-			else
-				edge_cost = edge.ReverseCost;
-
-			// Check if the direction is valid for exploration
-			if(edge.Direction == 0 || edge_cost >= 0.0)
-			{			
-				// Check if the current edge gives better result
-				if(cur_cost + edge_cost < getcost(new_node, dir))
-				{
-					// explore the node, and push it in the queue
-					setcost(new_node, dir, cur_cost + edge_cost);
-					setparent(new_node, dir, cur_node, edge.EdgeID);
-					que.push(std::make_pair(cur_cost + edge_cost, new_node));
-
-					// Update the minimum cost found so far.
-					if(getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost)
-					{
-						m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
-						m_MidNode = new_node;
-					}
-				}
-			}
-		}
-		else
-		{
-			// Current node is the endnode of the edge. For forward search it should use reverse cost, otherwise it should use the forward cost,
-			// i.e. if the forward direction is valid then this node may be visited from the start node.
-			if(dir > 0)
-				edge_cost = edge.ReverseCost;
-			else
-				edge_cost = edge.Cost;
-
-			// Check if the direction is valid for exploration
-			if(edge.Direction == 0 || edge_cost >= 0.0)
-			{
-				// Check if the current edge gives better result
-				if(cur_cost + edge_cost < getcost(new_node, dir))
-				{
-					setcost(new_node, dir, cur_cost + edge_cost);
-					setparent(new_node, dir, cur_node, edge.EdgeID);
-					que.push(std::make_pair(cur_cost + edge_cost, new_node));
-
-					// Update the minimum cost found so far.
-					if(getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost)
-					{
-						m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
-						m_MidNode = new_node;
-					}
-				}
-			}
-		}
-	}
+void BiDirDijkstra::explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que) {
+    int i;
+    // Number of connected edges
+    int con_edge = static_cast<int>(m_vecNodeVector[cur_node]->Connected_Edges_Index.size());
+    double edge_cost;
+
+    for (i = 0; i < con_edge; i++) {
+        int edge_index = m_vecNodeVector[cur_node]->Connected_Edges_Index[i];
+        // Get the edge from the edge list.
+        GraphEdgeInfo edge = *m_vecEdgeVector[edge_index];
+        // Get the connected node
+        int new_node = m_vecNodeVector[cur_node]->Connected_Nodes[i];
+
+        if (cur_node == edge.StartNode) {
+            // Current node is the startnode of the edge. For forward search it should use forward cost, otherwise it should use the reverse cost,
+            // i.e. if the reverse direction is valid then this node may be visited from the end node.
+            if (dir > 0)
+                edge_cost = edge.Cost;
+            else
+                edge_cost = edge.ReverseCost;
+
+            // Check if the direction is valid for exploration
+            if (edge.Direction == 0 ||  edge_cost >= 0.0) {
+                // Check if the current edge gives better result
+                if (cur_cost + edge_cost < getcost(new_node, dir)) {
+                    // explore the node, and push it in the queue
+                    setcost(new_node, dir, cur_cost + edge_cost);
+                    setparent(new_node, dir, cur_node, edge.EdgeID);
+                    que.push(std::make_pair(cur_cost + edge_cost, new_node));
+
+                    // Update the minimum cost found so far.
+                    if (getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost) {
+                        m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
+                        m_MidNode = new_node;
+                    }
+                }
+            }
+        } else {
+            // Current node is the endnode of the edge. For forward search it should use reverse cost, otherwise it should use the forward cost,
+            // i.e. if the forward direction is valid then this node may be visited from the start node.
+            if (dir > 0)
+                edge_cost = edge.ReverseCost;
+            else
+                edge_cost = edge.Cost;
+
+            // Check if the direction is valid for exploration
+            if (edge.Direction == 0 ||  edge_cost >= 0.0) {
+                // Check if the current edge gives better result
+                if (cur_cost + edge_cost < getcost(new_node, dir)) {
+                    setcost(new_node, dir, cur_cost + edge_cost);
+                    setparent(new_node, dir, cur_node, edge.EdgeID);
+                    que.push(std::make_pair(cur_cost + edge_cost, new_node));
+
+                    // Update the minimum cost found so far.
+                    if (getcost(new_node, dir) + getcost(new_node, dir * -1) < m_MinCost) {
+                        m_MinCost = getcost(new_node, dir) + getcost(new_node, dir * -1);
+                        m_MidNode = new_node;
+                    }
+                }
+            }
+        }
+    }
 }
 
-/* 
-	This is the entry function that the wrappers should call. Most of the parameters are trivial. maxNode refers to Maximum
-	node id. As we run node based exploration cost, parent etc will be based on maximam node id.
+/*
+    This is the entry function that the wrappers should call. Most of the parameters are trivial. maxNode refers to Maximum
+    node id. As we run node based exploration cost, parent etc will be based on maximam node id.
 */
 
 
 int BiDirDijkstra::bidir_dijkstra(edge_t *edges, unsigned int edge_count, int maxNode, int start_vertex, int end_vertex,
-				path_element_t **path, int *path_count, char **err_msg)
-{
-	max_node_id = maxNode;
-	max_edge_id = -1;
-	
-	// Allocate memory for local storage like cost and parent holder
-    // DBG("calling initall(maxNode=%d)\n", maxNode);
-	initall(maxNode);
-
-	// construct the graph from the edge list, i.e. populate node and edge data structures
+                path_element_t **path, int *path_count, char **err_msg) {
+    max_node_id = maxNode;
+    max_edge_id = -1;
+
+    // Allocate memory for local storage like cost and parent holder
+    // DBG("calling initall(maxNode = %d)\n", maxNode);
+    initall(maxNode);
+
+    // construct the graph from the edge list, i.e. populate node and edge data structures
     // DBG("Calling construct_graph\n");
-	construct_graph(edges, edge_count, maxNode);
-	
-
-	//int nodeCount = m_vecNodeVector.size();
-	// DBG("Setting up std::priority_queue\n");
-	std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > fque;
-	std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > rque;
-	
+    construct_graph(edges, edge_count, maxNode);
+
+
+    // int nodeCount = m_vecNodeVector.size();
+    // DBG("Setting up std::priority_queue\n");
+    std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > fque;
+    std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > rque;
+
     // DBG("calling m_vecPath.clear()\n");
-	m_vecPath.clear();
+    m_vecPath.clear();
 
-	// Initialize the forward search
-	m_pFParent[start_vertex].par_Node = -1;
-	m_pFParent[start_vertex].par_Edge = -1;
-	m_pFCost[start_vertex] = 0.0;
-	fque.push(std::make_pair(0.0, start_vertex));
+    // Initialize the forward search
+    m_pFParent[start_vertex].par_Node = -1;
+    m_pFParent[start_vertex].par_Edge = -1;
+    m_pFCost[start_vertex] = 0.0;
+    fque.push(std::make_pair(0.0, start_vertex));
 
-	// Initialize the reverse search
-	m_pRParent[end_vertex].par_Node = -1;
-	m_pRParent[end_vertex].par_Edge = -1;
-	m_pRCost[end_vertex] = 0.0;
-	rque.push(std::make_pair(0.0, end_vertex));
+    // Initialize the reverse search
+    m_pRParent[end_vertex].par_Node = -1;
+    m_pRParent[end_vertex].par_Edge = -1;
+    m_pRCost[end_vertex] = 0.0;
+    rque.push(std::make_pair(0.0, end_vertex));
 
-	int i;
-	// int new_node;
-	int cur_node;
-	// int dir;
+    int i;
+    // int new_node;
+    int cur_node;
+    // int dir;
 
 /*
-	The main loop. The algorithm is as follows:
-	1. IF the sum of the current minimum of both heap is greater than so far found path, we cannot get any better, so break the loop.
-	2. IF the reverse heap minimum is lower than the forward heap minimum, explore from reverse direction.
-	3. ELSE explore from the forward directtion.
+    The main loop. The algorithm is as follows:
+    1. IF the sum of the current minimum of both heap is greater than so far found path, we cannot get any better, so break the loop.
+    2. IF the reverse heap minimum is lower than the forward heap minimum, explore from reverse direction.
+    3. ELSE explore from the forward directtion.
 */
 
-	while(!fque.empty() && !rque.empty())
-	{
-		PDI fTop = fque.top();
-		PDI rTop = rque.top();
-		if(fTop.first + rTop.first > m_MinCost) //We are done, there is no path with lower cost
-			break;
-
-		if(rTop.first < fTop.first) // Explore from reverse queue
-		{
-			cur_node = rTop.second;
-			int dir = -1;
-			rque.pop();
-			explore(cur_node, rTop.first, dir, rque);
-		}
-		else                        // Explore from forward queue
-		{
-			cur_node = fTop.second;
-			int dir = 1;
-			fque.pop();
-			explore(cur_node, fTop.first, dir, fque);
-		}
-	}
+    while (!fque.empty() &&  !rque.empty()) {
+        PDI fTop = fque.top();
+        PDI rTop = rque.top();
+        if (fTop.first + rTop.first > m_MinCost)  // We are done, there is no path with lower cost
+            break;
+
+        if (rTop.first < fTop.first) {
+            //  Explore from reverse queue
+            cur_node = rTop.second;
+            int dir = -1;
+            rque.pop();
+            explore(cur_node, rTop.first, dir, rque);
+        } else {
+            // Explore from forward queue
+            cur_node = fTop.second;
+            int dir = 1;
+            fque.pop();
+            explore(cur_node, fTop.first, dir, fque);
+        }
+    }
 
 /*
-	Path reconstruction part. m_MidNode is the joining point where two searches meet to make a shortest path. It is updated in explore.
-	If it contains -1, then no path is found. Other wise we have a shortest path and that is reconstructed in the m_vecPath.
-*/ 
-	if(m_MidNode == -1)
-	{
-		*err_msg = (char *)"Path Not Found";
-		deleteall();
-		return -1;
-	}
-	else
-	{
-		// reconstruct path from forward search
-		fconstruct_path(m_MidNode);
-		// reconstruct path from backward search
-		rconstruct_path(m_MidNode);
-
-		// insert the last row in the path trace (having edge_id = -1 and cost = 0.0)
-		path_element_t pelement;
-		pelement.vertex_id = end_vertex;
-		pelement.edge_id = -1;
-		pelement.cost = 0.0;
-		m_vecPath.push_back(pelement);
-
-		// Transfer data path to path_element_t format and allocate memory and populate the pointer
-
-        // DBG("BiDirDijkstra::bidir_dijkstra: allocating path m_vecPath.size=%d\n", m_vecPath.size() + 1);
-		//*path = (path_element_t *) malloc(sizeof(path_element_t) * (m_vecPath.size() + 1));
-        *path=NULL;
-		*path = get_memory(m_vecPath.size(), (*path));
-		*path_count = m_vecPath.size();
+    Path reconstruction part. m_MidNode is the joining point where two searches meet to make a shortest path. It is updated in explore.
+    If it contains -1, then no path is found. Other wise we have a shortest path and that is reconstructed in the m_vecPath.
+*/
+    if (m_MidNode == -1) {
+        *err_msg = (char *)"Path Not Found";
+        deleteall();
+        return -1;
+    } else {
+        // reconstruct path from forward search
+        fconstruct_path(m_MidNode);
+        // reconstruct path from backward search
+        rconstruct_path(m_MidNode);
+
+        // insert the last row in the path trace (having edge_id = -1 and cost = 0.0)
+        path_element_t pelement;
+        pelement.vertex_id = end_vertex;
+        pelement.edge_id = -1;
+        pelement.cost = 0.0;
+        m_vecPath.push_back(pelement);
+
+        // Transfer data path to path_element_t format and allocate memory and populate the pointer
+
+        // DBG("BiDirDijkstra::bidir_dijkstra: allocating path m_vecPath.size = %d\n", m_vecPath.size() + 1);
+        // *path = (path_element_t *) malloc(sizeof(path_element_t) * (m_vecPath.size() + 1));
+        *path = NULL;
+        *path = pgr_alloc(m_vecPath.size(), (*path));
+        *path_count = static_cast<int>(m_vecPath.size());
         // DBG("BiDirDijkstra::bidir_dijkstra: allocated path\n");
 
-		for(i = 0; i < *path_count; i++)
-		{
-			(*path)[i].vertex_id = m_vecPath[i].vertex_id;
-			(*path)[i].edge_id = m_vecPath[i].edge_id;
-			(*path)[i].cost = m_vecPath[i].cost;
-		}
-		
-	}
+        for (i = 0; i < *path_count; i++) {
+            (*path)[i].vertex_id = m_vecPath[i].vertex_id;
+            (*path)[i].edge_id = m_vecPath[i].edge_id;
+            (*path)[i].cost = m_vecPath[i].cost;
+        }
+    }
     // DBG("calling deleteall\n");
-	deleteall();
+    deleteall();
     // DBG("back from deleteall\n");
-	return 0;
+    return 0;
 }
 
 /*
-	Populate the member variables of the class using the edge list. Basically there is a node list and an edge list. Each node contains the list of adjacent nodes and 
-	corresponding edge indices from edge list that connect this node with the adjacent nodes.
+    Populate the member variables of the class using the edge list. Basically there is a node list and an edge list. Each node contains the list of adjacent nodes and
+    corresponding edge indices from edge list that connect this node with the adjacent nodes.
 */
 
-bool BiDirDijkstra::construct_graph(edge_t* edges, int edge_count, int maxNode)
-{
-	int i;
+bool BiDirDijkstra::construct_graph(edge_t* edges, int edge_count, int maxNode) {
+    int i;
 
-	/*
-	// Create a dummy node
+    /*
+    // Create a dummy node
     DBG("Create a dummy node\n");
-	GraphNodeInfo nodeInfo;
+    GraphNodeInfo nodeInfo;
     DBG("calling nodeInfo.Connected_Edges_Index.clear\n");
-	nodeInfo.Connected_Edges_Index.clear();
+    nodeInfo.Connected_Edges_Index.clear();
     DBG("calling nodeInfo.Connected_Nodes.clear\n");
-	nodeInfo.Connected_Nodes.clear();
-	*/
+    nodeInfo.Connected_Nodes.clear();
+    */
 
-	// Insert the dummy node into the node list. This acts as place holder. Also change the nodeId so that nodeId and node index in the vector are same.
-	// There may be some nodes here that does not appear in the edge list. The size of the list is upto maxNode which is equal to maximum node id.
+    // Insert the dummy node into the node list. This acts as place holder. Also change the nodeId so that nodeId and node index in the vector are same.
+    // There may be some nodes here that does not appear in the edge list. The size of the list is up to maxNode which is equal to maximum node id.
     // DBG("m_vecNodeVector.push_back for 0 - %d\n", maxNode);
-	for(i = 0; i <= maxNode; i++)
-	{
-		// Create a dummy node
-		GraphNodeInfo* nodeInfo = new GraphNodeInfo();
-		nodeInfo->Connected_Edges_Index.clear();
-		nodeInfo->Connected_Nodes.clear();
-		
-		nodeInfo->NodeID = i;
-		m_vecNodeVector.push_back(nodeInfo);
-	}
-
-	// Process each edge from the edge list and update the member data structures accordingly.
+    for (i = 0; i <= maxNode; i++) {
+        // Create a dummy node
+        GraphNodeInfo* nodeInfo = new GraphNodeInfo();
+        nodeInfo->Connected_Edges_Index.clear();
+        nodeInfo->Connected_Nodes.clear();
+
+        nodeInfo->NodeID = i;
+        m_vecNodeVector.push_back(nodeInfo);
+    }
+
+    // Process each edge from the edge list and update the member data structures accordingly.
     // DBG("reserving space for m_vecEdgeVector.reserve(%d)\n", edge_count);
     m_vecEdgeVector.reserve(edge_count);
     // DBG("calling addEdge in a loop\n");
-	for(i = 0; i < edge_count; i++)
-	{
-		addEdge(edges[i]);
-	}
+    for (i = 0; i < edge_count; i++) {
+        addEdge(edges[i]);
+    }
 
-	return true;
+    return true;
 }
 
 /*
-	Process the edge and populate the member nodelist and edgelist. The nodelist already contains upto maxNode dummy entries with nodeId same as index. Now the
-	connectivity information needs to be updated.
+    Process the edge and populate the member nodelist and edgelist. The nodelist already contains up to maxNode dummy entries with nodeId same as index. Now the
+    connectivity information needs to be updated.
 */
 
-bool BiDirDijkstra::addEdge(edge_t edgeIn)
-{
-	// long lTest;
-
-	// Check if the edge is already processed.
-	Long2LongMap::iterator itMap = m_mapEdgeId2Index.find(edgeIn.id);
-	if(itMap != m_mapEdgeId2Index.end())	
-		return false;
-
-
-	// Create a GraphEdgeInfo using the information of the current edge
-	GraphEdgeInfo newEdge;
-	newEdge.EdgeID = edgeIn.id;
-	newEdge.EdgeIndex = m_vecEdgeVector.size();	
-	newEdge.StartNode = edgeIn.source;
-	newEdge.EndNode = edgeIn.target;
-	newEdge.Cost = edgeIn.cost;
-	newEdge.ReverseCost = edgeIn.reverse_cost;
-
-	// Set the direction. If both cost and reverse cost has positive value the edge is bidirectional and direction field is 0. If cost is positive and reverse cost
-	// negative then the edge is unidirectional with direction = 1 (goes from source to target) otherwise it is unidirectional with direction = -1 (goes from target
-	// to source). Another way of creating unidirectional edge is assigning big values in cost or reverse_cost. In that case the direction is still zero and this case
-	// is handled in the algorithm automatically.
-	if(newEdge.Cost >= 0.0 && newEdge.ReverseCost >= 0)
-	{
-		newEdge.Direction = 0;
-	}
-	else if(newEdge.Cost >= 0.0)
-	{
-		newEdge.Direction = 1;
-	}
-	else
-	{
-		newEdge.Direction = -1;
-	}
-
-	// Update max_edge_id
-	if(edgeIn.id > max_edge_id)
-	{
-		max_edge_id = edgeIn.id;
-	}
-
-	//Update max_node_id
-	if(newEdge.StartNode > max_node_id)
-	{
-		return false;//max_node_id = newEdge.StartNode;
-	}
-	if(newEdge.EndNode > max_node_id)
-	{
-		return false;//max_node_id = newEdge.EdgeIndex;
-	}
-
-	// update connectivity information for the start node.
-	m_vecNodeVector[newEdge.StartNode]->Connected_Nodes.push_back(newEdge.EndNode);
-	m_vecNodeVector[newEdge.StartNode]->Connected_Edges_Index.push_back(newEdge.EdgeIndex);
-
-	// update connectivity information for the start node.
-	m_vecNodeVector[newEdge.EndNode]->Connected_Nodes.push_back(newEdge.StartNode);
-	m_vecNodeVector[newEdge.EndNode]->Connected_Edges_Index.push_back(newEdge.EdgeIndex);
-
-
-	
-	//Adding edge to the list
-	m_mapEdgeId2Index.insert(std::make_pair(newEdge.EdgeID, m_vecEdgeVector.size()));
-	m_vecEdgeVector.push_back(newEdge);
-
-	//
-	return true;
+bool BiDirDijkstra::addEdge(edge_t edgeIn) {
+    // long lTest;
+
+    // Check if the edge is already processed.
+    Long2LongMap::iterator itMap = m_mapEdgeId2Index.find(edgeIn.id);
+    if (itMap != m_mapEdgeId2Index.end())
+        return false;
+
+
+    // Create a GraphEdgeInfo using the information of the current edge
+    GraphEdgeInfo *newEdge = new GraphEdgeInfo();
+    newEdge->EdgeID = static_cast<int>(edgeIn.id);
+    newEdge->EdgeIndex = static_cast<int>(m_vecEdgeVector.size());
+    newEdge->StartNode = static_cast<int>(edgeIn.source);
+    newEdge->EndNode = static_cast<int>(edgeIn.target);
+    newEdge->Cost = edgeIn.cost;
+    newEdge->ReverseCost = edgeIn.reverse_cost;
+
+    // Set the direction. If both cost and reverse cost has positive value the edge is bidirectional and direction field is 0. If cost is positive and reverse cost
+    // negative then the edge is unidirectional with direction = 1 (goes from source to target) otherwise it is unidirectional with direction = -1 (goes from target
+    // to source). Another way of creating unidirectional edge is assigning big values in cost or reverse_cost. In that case the direction is still zero and this case
+    // is handled in the algorithm automatically.
+    if (newEdge->Cost >= 0.0 &&  newEdge->ReverseCost >= 0) {
+        newEdge->Direction = 0;
+    } else if (newEdge->Cost >= 0.0) {
+        newEdge->Direction = 1;
+    } else {
+        newEdge->Direction = -1;
+    }
+
+    // Update max_edge_id
+    if (edgeIn.id > max_edge_id) {
+        max_edge_id = static_cast<int>(edgeIn.id);
+    }
+
+    // Update max_node_id
+    if (newEdge->StartNode > max_node_id) {
+        return false;  // max_node_id = newEdge.StartNode;
+    }
+    if (newEdge->EndNode > max_node_id) {
+        return false;  // max_node_id = newEdge.EdgeIndex;
+    }
+
+    // update connectivity information for the start node.
+    m_vecNodeVector[newEdge->StartNode]->Connected_Nodes.push_back(newEdge->EndNode);
+    m_vecNodeVector[newEdge->StartNode]->Connected_Edges_Index.push_back(newEdge->EdgeIndex);
+
+    // update connectivity information for the start node.
+    m_vecNodeVector[newEdge->EndNode]->Connected_Nodes.push_back(newEdge->StartNode);
+    m_vecNodeVector[newEdge->EndNode]->Connected_Edges_Index.push_back(newEdge->EdgeIndex);
+
+
+
+    // Adding edge to the list
+    m_mapEdgeId2Index.insert(std::make_pair(newEdge->EdgeID, m_vecEdgeVector.size()));
+    m_vecEdgeVector.push_back(newEdge);
+
+    return true;
 }
diff --git a/src/bd_dijkstra/src/BiDirDijkstra.h b/src/bd_dijkstra/src/BiDirDijkstra.h
index 3650dca..c4ae4a3 100644
--- a/src/bd_dijkstra/src/BiDirDijkstra.h
+++ b/src/bd_dijkstra/src/BiDirDijkstra.h
@@ -2,7 +2,7 @@
 
 * $Id$
 *
-* Project:  pgRouting bdsp and bdastar algorithms
+* Project: pgRouting bdsp and bdastar algorithms
 * Purpose:
 * Author:   Razequl Islam <ziboncsedu at gmail.com>
 Copyright (c) 2015 pgRouting developers
@@ -26,8 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-MIT*/
 
-#ifndef BIDIRDIJKSTRA_H
-#define BIDIRDIJKSTRA_H
+#ifndef SRC_BD_DIJKSTRA_SRC_BIDIRDIJKSTRA_H_
+#define SRC_BD_DIJKSTRA_SRC_BIDIRDIJKSTRA_H_
+#pragma once
 
 #include <vector>
 #include <map>
@@ -36,30 +37,29 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <functional>
 
 #include "../../common/src/pgr_types.h"
-#include "bdsp.h"
+#include "./bdsp_driver.h"
 
 #define INF 1e15
 
 
 
-typedef std::vector<long> LongVector;
+typedef std::vector<int64_t> LongVector;
 typedef std::vector<LongVector> VectorOfLongVector;
 typedef std::pair<double, int> PDI;
 
-typedef struct{
+typedef struct {
     int par_Node;
     int par_Edge;
-}PARENT_PATH;
+} PARENT_PATH;
 
-typedef struct{
+typedef struct {
     int NodeID;
     std::vector<int> Connected_Nodes;
     std::vector<int> Connected_Edges_Index;
-}GraphNodeInfo;
+} GraphNodeInfo;
 
-struct GraphEdgeInfo
-{
-public:
+struct GraphEdgeInfo {
+ public:
     int EdgeID;
     int EdgeIndex;
     int Direction;
@@ -69,53 +69,52 @@ public:
     int EndNode;
 };
 
-typedef std::vector<GraphEdgeInfo> GraphEdgeVector;
-typedef std::map<long,LongVector> Long2LongVectorMap;
-typedef std::map<long,long> Long2LongMap;
+typedef std::vector<GraphEdgeInfo*> GraphEdgeVector;
+typedef std::map<int64_t, LongVector> Long2LongVectorMap;
+typedef std::map<int64_t, int64_t> Long2LongMap;
 typedef std::vector<GraphNodeInfo*> GraphNodeVector;
 
 
-class BiDirDijkstra
-{
-public:
-    BiDirDijkstra(void);
-    ~BiDirDijkstra(void);
-    
-    int bidir_dijkstra(edge_t *edges, unsigned int edge_count, int maxNode, int start_vertex, int end_vertex,
-        path_element_t **path, int *path_count, char **err_msg);
-    
-
-private:
-    bool construct_graph(edge_t *edges, int edge_count, int maxNode);
-    void fconstruct_path(int node_id);
-    void rconstruct_path(int node_id);
-    bool addEdge(edge_t edgeIn);
-    bool connectEdge(GraphEdgeInfo& firstEdge, GraphEdgeInfo& secondEdge, bool bIsStartNodeSame);
-    void init();
-    void initall(int maxNode);
-    void deleteall();
-    void explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que);
-    double getcost(int node_id, int dir);
-    void setcost(int node_id, int dir, double c);
-    void setparent(int node_id, int dir, int parnode, int paredge);
-
-private:
-    GraphEdgeVector m_vecEdgeVector;
-    Long2LongMap m_mapEdgeId2Index;
-    Long2LongVectorMap m_mapNodeId2Edge;
-    GraphNodeVector m_vecNodeVector;
-    int max_node_id;
-    int max_edge_id;
-    int m_lStartNodeId;
-    int m_lEndNodeId;
-
-    double m_MinCost;
-    int m_MidNode;
-    std::vector <path_element_t> m_vecPath;
-    PARENT_PATH *m_pFParent;
-    PARENT_PATH *m_pRParent;
-    double *m_pFCost;
-    double *m_pRCost;
+class BiDirDijkstra {
+ public:
+     BiDirDijkstra(void);
+     ~BiDirDijkstra(void);
+
+     int bidir_dijkstra(edge_t *edges, unsigned int edge_count, int maxNode, int start_vertex, int end_vertex,
+             path_element_t **path, int *path_count, char **err_msg);
+
+
+ private:
+     bool construct_graph(edge_t *edges, int edge_count, int maxNode);
+     void fconstruct_path(int node_id);
+     void rconstruct_path(int node_id);
+     bool addEdge(edge_t edgeIn);
+     bool connectEdge(GraphEdgeInfo& firstEdge, GraphEdgeInfo& secondEdge, bool bIsStartNodeSame);
+     void init();
+     void initall(int maxNode);
+     void deleteall();
+     void explore(int cur_node, double cur_cost, int dir, std::priority_queue<PDI, std::vector<PDI>, std::greater<PDI> > &que);
+     double getcost(int node_id, int dir);
+     void setcost(int node_id, int dir, double c);
+     void setparent(int node_id, int dir, int parnode, int paredge);
+
+ private:
+     GraphEdgeVector m_vecEdgeVector;
+     Long2LongMap m_mapEdgeId2Index;
+     Long2LongVectorMap m_mapNodeId2Edge;
+     GraphNodeVector m_vecNodeVector;
+     int max_node_id;
+     int max_edge_id;
+     int m_lStartNodeId;
+     int m_lEndNodeId;
+
+     double m_MinCost;
+     int m_MidNode;
+     std::vector <path_element_t> m_vecPath;
+     PARENT_PATH *m_pFParent;
+     PARENT_PATH *m_pRParent;
+     double *m_pFCost;
+     double *m_pRCost;
 };
 
-#endif
+#endif  // SRC_BD_DIJKSTRA_SRC_BIDIRDIJKSTRA_H_
diff --git a/src/bd_dijkstra/src/CMakeLists.txt b/src/bd_dijkstra/src/CMakeLists.txt
index 1c161c1..161833f 100644
--- a/src/bd_dijkstra/src/CMakeLists.txt
+++ b/src/bd_dijkstra/src/CMakeLists.txt
@@ -1,5 +1,5 @@
 ADD_LIBRARY(bd_dijkstra OBJECT 
     bdsp.c 
-    bdsp_core.cpp 
+    bdsp_driver.cpp 
     BiDirDijkstra.cpp)
 
diff --git a/src/bd_dijkstra/src/bdsp.c b/src/bd_dijkstra/src/bdsp.c
index 66668b6..67f1e77 100644
--- a/src/bd_dijkstra/src/bdsp.c
+++ b/src/bd_dijkstra/src/bdsp.c
@@ -2,7 +2,7 @@
 
 * $Id$
 *
-* Project:  pgRouting bdsp and bdastar algorithms
+* Project: pgRouting bdsp and bdastar algorithms
 * Purpose:
 * Author:   Razequl Islam <ziboncsedu at gmail.com>
 Copyright (c) 2015 pgRouting developers
@@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-MIT*/
 
-#include "bdsp.h"
 
 #include "postgres.h"
 #include "executor/spi.h"
@@ -37,15 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #include "fmgr.h"
 
-PG_FUNCTION_INFO_V1(bidir_dijkstra_shortest_path);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS);
 
 
+#include "bdsp_driver.h"
 
 
 #undef DEBUG
@@ -53,13 +46,12 @@ bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS);
 #include "../../common/src/pgr_types.h"
 #include "../../common/src/postgres_connection.h"
 
-
 // The number of tuples to fetch from the SPI cursor at each iteration
 #define TUPLIMIT 1000
 
+PGDLLEXPORT Datum bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS);
 
-typedef struct edge_columns
-{
+typedef struct edge_columns {
   int id;
   int source;
   int target;
@@ -71,12 +63,11 @@ typedef struct edge_columns
 
 /*
  * This function fetches the edge columns from the SPITupleTable.
- * 
-*/ 
+ *
+*/
 static int
-fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns, 
-                   bool has_reverse_cost)
-{
+fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns,
+                   bool has_reverse_cost) {
   edge_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
   edge_columns->source = SPI_fnumber(SPI_tuptable->tupdesc, "source");
   edge_columns->target = SPI_fnumber(SPI_tuptable->tupdesc, "target");
@@ -86,7 +77,6 @@ fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns,
       edge_columns->source == SPI_ERROR_NOATTRIBUTE ||
       edge_columns->target == SPI_ERROR_NOATTRIBUTE ||
       edge_columns->cost == SPI_ERROR_NOATTRIBUTE) {
-
       elog(ERROR, "Error, query must return columns "
            "'id', 'source', 'target' and 'cost'");
       return -1;
@@ -95,17 +85,16 @@ fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns,
   if (SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->source) != INT4OID ||
       SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->target) != INT4OID ||
       SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->cost) != FLOAT8OID) {
-
       elog(ERROR, "Error, columns 'source', 'target' must be of type int4, 'cost' must be of type float8");
       return -1;
   }
 
-  PGR_DBG("columns: id %i source %i target %i cost %i", 
-      edge_columns->id, edge_columns->source, 
+  PGR_DBG("columns: id %i source %i target %i cost %i",
+      edge_columns->id, edge_columns->source,
       edge_columns->target, edge_columns->cost);
 
   if (has_reverse_cost) {
-      edge_columns->reverse_cost = SPI_fnumber(SPI_tuptable->tupdesc, 
+      edge_columns->reverse_cost = SPI_fnumber(SPI_tuptable->tupdesc,
                                                "reverse_cost");
 
       if (edge_columns->reverse_cost == SPI_ERROR_NOATTRIBUTE) {
@@ -114,7 +103,7 @@ fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns,
           return -1;
       }
 
-      if (SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->reverse_cost) 
+      if (SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->reverse_cost)
             != FLOAT8OID) {
           elog(ERROR, "Error, columns 'reverse_cost' must be of type float8");
           return -1;
@@ -128,13 +117,12 @@ fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns,
 
 /*
  * To fetch a edge from Tuple.
- * 
+ *
  */
 
 static void
-fetch_edge(HeapTuple *tuple, TupleDesc *tupdesc, 
-           edge_columns_t *edge_columns, edge_t *target_edge)
-{
+fetch_edge(HeapTuple *tuple, TupleDesc *tupdesc,
+           edge_columns_t *edge_columns, edge_t *target_edge) {
   Datum binval;
   bool isnull;
 
@@ -155,35 +143,38 @@ fetch_edge(HeapTuple *tuple, TupleDesc *tupdesc,
   target_edge->cost = DatumGetFloat8(binval);
 
   if (edge_columns->reverse_cost != -1) {
-      binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->reverse_cost, 
+      binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->reverse_cost,
                              &isnull);
       if (isnull) elog(ERROR, "reverse_cost contains a null value");
-      target_edge->reverse_cost =  DatumGetFloat8(binval);
+      target_edge->reverse_cost = DatumGetFloat8(binval);
   }
 }
 
-static int compute_bidirsp(char* sql, int start_vertex, 
-                                 int end_vertex, bool directed, 
-                                 bool has_reverse_cost, 
-                                 path_element_t **path, int *path_count) 
-{
+static int compute_bidirsp(char* sql, int64_t start_vertex,
+                                 int64_t end_vertex, bool directed,
+                                 bool has_reverse_cost,
+                                 path_element_t **path, int *path_count) {
   void *SPIplan;
   Portal SPIportal;
   bool moredata = TRUE;
-  int ntuples;
+  uint32_t ntuples;
   edge_t *edges = NULL;
-  int total_tuples = 0;
-  edge_columns_t edge_columns = {.id= -1, .source= -1, .target= -1, 
-                                 .cost= -1, .reverse_cost= -1};
-  int v_max_id=0;
-  int v_min_id=INT_MAX;
+  uint32_t total_tuples = 0;
+#ifndef _MSC_VER
+  edge_columns_t edge_columns = {.id = -1, .source = -1, .target = -1,
+                                 .cost = -1, .reverse_cost = -1};
+#else  //  _MSC_VER
+  edge_columns_t edge_columns = {-1, -1, -1, -1, -1};
+#endif  //  _MSC_VER
+  int64_t v_max_id = 0;
+  int64_t v_min_id = INT_MAX;
 
   int s_count = 0;
   int t_count = 0;
 
   char *err_msg;
   int ret = -1;
-  register int z;
+  int64_t z;
 
   PGR_DBG("start shortest_path\n");
 
@@ -195,7 +186,7 @@ static int compute_bidirsp(char* sql, int start_vertex,
       SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
 
       if (edge_columns.id == -1) {
-          if (fetch_edge_columns(SPI_tuptable, &edge_columns, 
+          if (fetch_edge_columns(SPI_tuptable, &edge_columns,
                                  has_reverse_cost) == -1) {
             pgr_SPI_finish();
             return -1;
@@ -216,57 +207,56 @@ static int compute_bidirsp(char* sql, int start_vertex,
       }
 
       if (ntuples > 0) {
-          int t;
+          uint64_t t;
           SPITupleTable *tuptable = SPI_tuptable;
           TupleDesc tupdesc = SPI_tuptable->tupdesc;
 
           for (t = 0; t < ntuples; t++) {
               HeapTuple tuple = tuptable->vals[t];
-              fetch_edge(&tuple, &tupdesc, &edge_columns, 
+              fetch_edge(&tuple, &tupdesc, &edge_columns,
                          &edges[total_tuples - ntuples + t]);
           }
           SPI_freetuptable(tuptable);
-      } 
-      else {
+      } else {
           moredata = FALSE;
       }
   }
 
-  //defining min and max vertex id
+  // defining min and max vertex id
 
   PGR_DBG("Total %i tuples", total_tuples);
 
-  for(z=0; z<total_tuples; z++) {
-    if(edges[z].source<v_min_id) v_min_id=edges[z].source;
-    if(edges[z].source>v_max_id) v_max_id=edges[z].source;
-    if(edges[z].target<v_min_id) v_min_id=edges[z].target;
-    if(edges[z].target>v_max_id) v_max_id=edges[z].target; 
-    //PGR_DBG("%i <-> %i", v_min_id, v_max_id);
+  for (z = 0; z < total_tuples; z++) {
+    if (edges[z].source < v_min_id) v_min_id = edges[z].source;
+    if (edges[z].source > v_max_id) v_max_id = edges[z].source;
+    if (edges[z].target < v_min_id) v_min_id = edges[z].target;
+    if (edges[z].target > v_max_id) v_max_id = edges[z].target;
+    // PGR_DBG("%i <-> %i", v_min_id, v_max_id);
   }
 
-  //::::::::::::::::::::::::::::::::::::  
+  //::::::::::::::::::::::::::::::::::::
   //:: reducing vertex id (renumbering)
   //::::::::::::::::::::::::::::::::::::
-  for(z=0; z<total_tuples; z++) {
-    //check if edges[] contains source and target
-    if(edges[z].source == start_vertex || edges[z].target == start_vertex)
+  for (z = 0; z < total_tuples; z++) {
+    // check if edges[] contains source and target
+    if (edges[z].source == start_vertex ||  edges[z].target == start_vertex)
       ++s_count;
-    if(edges[z].source == end_vertex || edges[z].target == end_vertex)
+    if (edges[z].source == end_vertex ||  edges[z].target == end_vertex)
       ++t_count;
 
     edges[z].source -= v_min_id;
     edges[z].target -= v_min_id;
-    //PGR_DBG("%i - %i", edges[z].source, edges[z].target);      
+    // PGR_DBG("%i - %i", edges[z].source, edges[z].target);
   }
 
   PGR_DBG("Total %i tuples", total_tuples);
 
-  if(s_count == 0) {
+  if (s_count == 0) {
     elog(ERROR, "Start vertex was not found.");
     return -1;
   }
 
-  if(t_count == 0) {
+  if (t_count == 0) {
     elog(ERROR, "Target vertex was not found.");
     return -1;
   }
@@ -274,29 +264,29 @@ static int compute_bidirsp(char* sql, int start_vertex,
   start_vertex -= v_min_id;
   end_vertex   -= v_min_id;
 
-  //v_max_id -= v_min_id;
+  // v_max_id -= v_min_id;
 
-  PGR_DBG("Calling bidirsp_wrapper(edges, %d, %d, %d, %d, %d, %d, ...)\n",
+  PGR_DBG("Calling bidirsp_wrapper(edges, %u, %ld, %ld, %ld, %d, %d, ...)\n",
         total_tuples, v_max_id + 2, start_vertex, end_vertex,
         directed, has_reverse_cost);
 
-  ret = bidirsp_wrapper(edges, total_tuples, v_max_id + 2, start_vertex, end_vertex,
+  ret = bidirsp_wrapper(edges, total_tuples, (int)v_max_id + 2, (int)start_vertex, (int)end_vertex,
                        directed, has_reverse_cost,
                        path, path_count, &err_msg);
 
   PGR_DBG("Back from bidirsp_wrapper() ret: %d", ret);
   if (ret < 0) {
       elog(ERROR, "Error computing path: %s", err_msg);
-  } 
+  }
 
   PGR_DBG("*path_count = %i\n", *path_count);
 
   //::::::::::::::::::::::::::::::::
   //:: restoring original vertex id
   //::::::::::::::::::::::::::::::::
-  for(z=0; z<*path_count; z++) {
-    //PGR_DBG("vetex %i\n",(*path)[z].vertex_id);
-    (*path)[z].vertex_id+=v_min_id;
+  for (z = 0; z < *path_count; z++) {
+    // PGR_DBG("vetex %i\n", (*path)[z].vertex_id);
+    (*path)[z].vertex_id+= v_min_id;
   }
 
   PGR_DBG("ret = %i\n", ret);
@@ -306,23 +296,18 @@ static int compute_bidirsp(char* sql, int start_vertex,
 }
 
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(bidir_dijkstra_shortest_path);
 PGDLLEXPORT Datum
-#endif
-bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS)
-{
-
+bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS) {
   FuncCallContext     *funcctx;
-  int                  call_cntr;
-  int                  max_calls;
+  uint32_t                  call_cntr;
+  uint32_t                  max_calls;
   TupleDesc            tuple_desc;
   path_element_t      *path;
   // char *               sql;
 
 
-  // stuff done only on the first call of the function 
+  // stuff done only on the first call of the function
   if (SRF_IS_FIRSTCALL()) {
       MemoryContext   oldcontext;
       int path_count = 0;
@@ -338,8 +323,8 @@ bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS)
       oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
       // verify that the first 5 args are not NULL
-      for (i=0; i<5; i++)
-        if(PG_ARGISNULL(i)) {
+      for (i = 0; i < 5; i++)
+        if (PG_ARGISNULL(i)) {
             elog(ERROR, "bidir_dijkstra_shortest_path(): Argument %i may not be NULL", i+1);
         }
 
@@ -349,10 +334,10 @@ bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS)
       ret =
 #endif
         compute_bidirsp(pgr_text2char(PG_GETARG_TEXT_P(0)),
-                                   PG_GETARG_INT32(1),
-                                   PG_GETARG_INT32(2),
+                                   (int64_t)PG_GETARG_INT32(1),
+                                   (int64_t)PG_GETARG_INT32(2),
                                    PG_GETARG_BOOL(3),
-                                   PG_GETARG_BOOL(4), 
+                                   PG_GETARG_BOOL(4),
                                    &path, &path_count);
 #ifdef DEBUG
     double total_cost = 0;
@@ -360,26 +345,26 @@ bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS)
       if (ret >= 0) {
           int i;
           for (i = 0; i < path_count; i++) {
-             // PGR_DBG("Step %i vertex_id  %i ", i, path[i].vertex_id);
+             // PGR_DBG("Step %i vertex_id %i ", i, path[i].vertex_id);
              // PGR_DBG("        edge_id    %i ", path[i].edge_id);
              // PGR_DBG("        cost       %f ", path[i].cost);
-              total_cost+=path[i].cost;
+              total_cost+= path[i].cost;
             }
         }
-        PGR_DBG("Total cost is: %f",total_cost);
+        PGR_DBG("Total cost is: %f", total_cost);
 #endif
 
-      // total number of tuples to be returned 
-      funcctx->max_calls = path_count;
+      // total number of tuples to be returned
+      funcctx->max_calls = (uint32_t)path_count;
       funcctx->user_fctx = path;
 
-      funcctx->tuple_desc = 
+      funcctx->tuple_desc =
           BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
 
       MemoryContextSwitchTo(oldcontext);
   }
 
-  // stuff done on every call of the function 
+  // stuff done on every call of the function
   funcctx = SRF_PERCALL_SETUP();
 
   call_cntr = funcctx->call_cntr;
@@ -387,7 +372,7 @@ bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS)
   tuple_desc = funcctx->tuple_desc;
   path = (path_element_t*) funcctx->user_fctx;
 
-  if (call_cntr < max_calls) {   // do when there is more left to send 
+  if (call_cntr < max_calls) {   // do when there is more left to send
       HeapTuple    tuple;
       Datum        result;
       Datum *values;
@@ -407,16 +392,15 @@ bidir_dijkstra_shortest_path(PG_FUNCTION_ARGS)
 
       tuple = heap_form_tuple(tuple_desc, values, nulls);
 
-      // make the tuple into a datum 
+      // make the tuple into a datum
       result = HeapTupleGetDatum(tuple);
 
-      // clean up (this is not really necessary) 
+      // clean up (this is not really necessary)
       pfree(values);
       pfree(nulls);
 
       SRF_RETURN_NEXT(funcctx, result);
-  }
-  else {   // do when there is no more left 
+  } else {   // do when there is no more left
       PGR_DBG("Going to free path");
       if (path) free(path);
       SRF_RETURN_DONE(funcctx);
diff --git a/src/bd_dijkstra/src/bdsp_core.cpp b/src/bd_dijkstra/src/bdsp_driver.cpp
similarity index 76%
rename from src/bd_dijkstra/src/bdsp_core.cpp
rename to src/bd_dijkstra/src/bdsp_driver.cpp
index 4170cf9..a7c7d45 100644
--- a/src/bd_dijkstra/src/bdsp_core.cpp
+++ b/src/bd_dijkstra/src/bdsp_driver.cpp
@@ -2,7 +2,7 @@
 
 * $Id$
 *
-* Project:  pgRouting bdsp and bdastar algorithms
+* Project: pgRouting bdsp and bdastar algorithms
 * Purpose:
 * Author:   Razequl Islam <ziboncsedu at gmail.com>
 Copyright (c) 2015 pgRouting developers
@@ -26,30 +26,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-MIT*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
+#include "./bdsp_driver.h"
+
 #include <exception>
-#include "BiDirDijkstra.h"
-#include "bdsp.h"
+#include "./BiDirDijkstra.h"
 
 
 
 int bidirsp_wrapper(
-    edge_t *edges,
-    unsigned int edge_count,
-    int maxNode,
-    int start_vertex,
-    int end_vertex,
-    bool directed,
-    bool has_reverse_cost,
-    path_element_t **path,
-    int *path_count,
-    char **err_msg
-    )
-{
+        edge_t *edges,
+        unsigned int edge_count,
+        int maxNode,
+        int start_vertex,
+        int end_vertex,
+        bool directed,
+        bool has_reverse_cost,
+        path_element_t **path,
+        int *path_count,
+        char **err_msg
+        ) {
     int res;
 
     try {
@@ -57,10 +57,9 @@ int bidirsp_wrapper(
         BiDirDijkstra bddijkstra;
         // DBG("BiDirDijkstra initialized\n");
         res = bddijkstra.bidir_dijkstra(edges, edge_count, maxNode, start_vertex, end_vertex, path, path_count, err_msg);
-        // TODO  this are an unused parameters have to be used
-        if (has_reverse_cost) {};
-        if (directed) {};
-
+        // TODO(someone) this are an unused parameters have to be used
+        if (has_reverse_cost) {}
+        if (directed) {}
     }
     catch(std::exception& e) {
         // DBG("catch(std::exception e.what: %s\n", e.what());
@@ -78,4 +77,3 @@ int bidirsp_wrapper(
         return res;
     return 0;
 }
-
diff --git a/src/bd_dijkstra/src/bdsp.h b/src/bd_dijkstra/src/bdsp_driver.h
similarity index 67%
rename from src/bd_dijkstra/src/bdsp.h
rename to src/bd_dijkstra/src/bdsp_driver.h
index 3bbac82..1320763 100644
--- a/src/bd_dijkstra/src/bdsp.h
+++ b/src/bd_dijkstra/src/bdsp_driver.h
@@ -23,29 +23,33 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-#ifndef _BDSP_H
-#define _BDSP_H
+#ifndef SRC_BD_DIJKSTRA_SRC_BDSP_DRIVER_H_
+#define SRC_BD_DIJKSTRA_SRC_BDSP_DRIVER_H_
 
-
-#include "postgres.h"
+#if defined(_MSC_VER) &&  _MSC_VER < 1600
+#define ELOG_H
+#endif
 #include "../../common/src/pgr_types.h"
 
 typedef pgr_edge_t edge_t;
 
 #ifdef __cplusplus
-extern "C"
+extern "C" {
 #endif
 
-int bidirsp_wrapper( edge_t *edges, 
-			unsigned int edge_count,
-			int maxNode,
-			int start_vertex, 
-			int end_vertex,
-		    bool directed, 
-		    bool has_reverse_cost,
-            path_element_t **path, 
-            int *path_count, 
-            char **err_msg
-            );
+int bidirsp_wrapper(edge_t *edges,
+            unsigned int edge_count,
+            int maxNode,
+            int start_vertex,
+            int end_vertex,
+            bool directed,
+            bool has_reverse_cost,
+            path_element_t **path,
+            int *path_count,
+            char **err_msg);
 
+#ifdef __cplusplus
+}
 #endif
+
+#endif  // SRC_BD_DIJKSTRA_SRC_BDSP_DRIVER_H_
diff --git a/src/bd_dijkstra/test/doc-bdDijkstra.result b/src/bd_dijkstra/test/doc-bdDijkstra.result
index 1c4acd8..c43ef68 100644
--- a/src/bd_dijkstra/test/doc-bdDijkstra.result
+++ b/src/bd_dijkstra/test/doc-bdDijkstra.result
@@ -1,13 +1,13 @@
 --q1
-0|4|3|0
-1|3|2|0
-2|2|4|1
-3|5|10|1
-4|10|-1|0
+0|4||0
+1|3||0
+2|2||1
+3|5||1
+4|10||0
 --q2
-0|4|3|1
-1|3|2|1
-2|2|4|1
-3|5|10|1
-4|10|-1|0
+0|4||1
+1|3||1
+2|2||1
+3|5||1
+4|10||0
 --q3
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
deleted file mode 100644
index 2ff45f2..0000000
--- a/src/common/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-#MESSAGE("core/common: ${PACKAGE_SQL_FILES}")
-SUBDIRS(doc src test)
diff --git a/src/common/doc/types/cost_result.rst b/src/common/doc/types/cost_result.rst
index e44fc6c..7e70987 100644
--- a/src/common/doc/types/cost_result.rst
+++ b/src/common/doc/types/cost_result.rst
@@ -14,7 +14,6 @@ pgr_costResult[]
 
 .. index:: 
     single: pgr_costResult[]
-    module: types
 
 Name
 -------------------------------------------------------------------------------
@@ -48,7 +47,6 @@ pgr_costResult3[] - Multiple Path Results with Cost
 
 .. index:: 
     single: pgr_costResult3[]
-    module: types
 
 Name
 -------------------------------------------------------------------------------
diff --git a/src/common/doc/types/geom_result.rst b/src/common/doc/types/geom_result.rst
index 846a632..e47fe6e 100644
--- a/src/common/doc/types/geom_result.rst
+++ b/src/common/doc/types/geom_result.rst
@@ -14,7 +14,6 @@ pgr_geomResult[]
 
 .. index:: 
 	single: pgr_geomResult[]
-	module: types
 
 Name
 -------------------------------------------------------------------------------
diff --git a/src/common/doc/utilities/end_point.rst b/src/common/doc/utilities/end_point.rst
index b0c8b03..3400cf5 100644
--- a/src/common/doc/utilities/end_point.rst
+++ b/src/common/doc/utilities/end_point.rst
@@ -9,11 +9,14 @@
 
 .. _pgr_end_point:
 
-pgr_endPoint 
+pgr_endPoint - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_endPoint(geometry) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -22,8 +25,6 @@ Name
 
 .. note:: This function is intended for the developer's aid. 
 
-.. warning:: This function is being deprecated on 2.1. 
-             Use `_pgr_endPoint` instead
 
 Synopsis
 -------------------------------------------------------------------------------
diff --git a/src/common/doc/utilities/get_column_name.rst b/src/common/doc/utilities/get_column_name.rst
index d66da13..f25b273 100644
--- a/src/common/doc/utilities/get_column_name.rst
+++ b/src/common/doc/utilities/get_column_name.rst
@@ -9,11 +9,14 @@
 
 .. _pgr_get_column_name:
 
-pgr_getColumnName
+pgr_getColumnName - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_getColumnName(text,text) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -23,9 +26,6 @@ Name
 .. note:: This function is intended for the developer’s aid.
 
 
-.. warning:: This function is deprecated in 2.1.
-             Use `_pgr_getColumnName` instead
-
 Synopsis
 -------------------------------------------------------------------------------
 
@@ -42,7 +42,7 @@ Description
 Parameters
 
 :tab: ``text`` table name with or without schema component.
-:col: ``text`` column name to be retrived.
+:col: ``text`` column name to be retrieved.
 
 Returns 
 
@@ -83,6 +83,6 @@ See Also
 -------------------------------------------------------------------------------
 
 * :ref:`developer` for the tree layout of the project.
-* :ref:`pgr_is_column_in_table` to check only for the existance of the column.
+* :ref:`pgr_is_column_in_table` to check only for the existence of the column.
 * :ref:`pgr_get_table_name` to retrieve the name of the table as is stored in the postgres administration tables.
 
diff --git a/src/common/doc/utilities/get_table_name.rst b/src/common/doc/utilities/get_table_name.rst
index 98dc64b..61a3e91 100644
--- a/src/common/doc/utilities/get_table_name.rst
+++ b/src/common/doc/utilities/get_table_name.rst
@@ -9,12 +9,14 @@
 
 .. _pgr_get_table_name:
 
-pgr_getTableName
+pgr_getTableName - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_getTableName(text,text) -- deprecated
-	module: common
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -23,9 +25,6 @@ Name
 
 .. note:: This function is intended for the developer’s aid.
 
-.. warning:: This function is  deprecated in 2.1
-             Use `_pgr_getTableName` instead
-
 Synopsis
 -------------------------------------------------------------------------------
 
@@ -102,6 +101,6 @@ See Also
 -------------------------------------------------------------------------------
 
 * :ref:`developer` for the tree layout of the project.
-* :ref:`pgr_is_column_in_table` to check only for the existance of the column.
+* :ref:`pgr_is_column_in_table` to check only for the existence of the column.
 * :ref:`pgr_get_table_name` to retrieve the name of the table as is stored in the postgres administration tables.
 
diff --git a/src/common/doc/utilities/index.rst b/src/common/doc/utilities/index.rst
deleted file mode 100644
index 1162060..0000000
--- a/src/common/doc/utilities/index.rst
+++ /dev/null
@@ -1,44 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _developer_functions:
-
-Developers's Functions
-===============================================================================
-
-.. warning:: This functions have being deprecated in version 2.1
-
-
-The functions have being renamed but documentation will not be generated for
-any of the developer's functions.
-
-   -  :ref:`pgr_get_column_name`
-   -  :ref:`pgr_get_table_name`
-   -  :ref:`pgr_is_column_indexed`
-   -  :ref:`pgr_is_column_in_table`
-   -  :ref:`pgr_point_to_id`
-   -  :ref:`pgr_quote_ident`
-   -  :ref:`pgr_versionless`
-   -  :ref:`pgr_start_point`
-   -  :ref:`pgr_end_point`
-
-
-.. toctree::
-   :hidden:
-
-   get_column_name
-   get_table_name
-   is_column_indexed
-   is_column_in_table
-   point_to_id
-   quote_ident
-   versionless
-   start_point
-   end_point
-
diff --git a/src/common/doc/utilities/is_column_in_table.rst b/src/common/doc/utilities/is_column_in_table.rst
index 5369fbc..d44ba17 100644
--- a/src/common/doc/utilities/is_column_in_table.rst
+++ b/src/common/doc/utilities/is_column_in_table.rst
@@ -9,12 +9,14 @@
 
 .. _pgr_is_column_in_table:
 
-pgr_isColumnInTable
+pgr_isColumnInTable - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_isColumnInTable(text,text) -- deprecated
-	module: common
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -23,10 +25,6 @@ Name
 
 .. note:: This function is intended for the developer’s aid.
 
-.. warning:: This function is  deprecated in 2.1
-             Use `_pgr_isColumnInTable` instead
-
-
 
 Synopsis
 -------------------------------------------------------------------------------
diff --git a/src/common/doc/utilities/is_column_indexed.rst b/src/common/doc/utilities/is_column_indexed.rst
index bd883c0..aa38c8e 100644
--- a/src/common/doc/utilities/is_column_indexed.rst
+++ b/src/common/doc/utilities/is_column_indexed.rst
@@ -9,12 +9,14 @@
 
 .. _pgr_is_column_indexed:
 
-pgr_isColumnIndexed
+pgr_isColumnIndexed - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_isColumnIndexed(text,text) -- deprecated
-	module: common
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -23,9 +25,6 @@ Name
 
 .. note:: This function is intended for the developer’s aid.
 
-.. warning:: This function is deprecated in 2.1
-             Use `_pgr_isColumnIndexed` instead
-
 
 Synopsis
 -------------------------------------------------------------------------------
@@ -85,7 +84,7 @@ See Also
 -------------------------------------------------------------------------------
 
 * :ref:`developer` for the tree layout of the project.
-* :ref:`pgr_is_column_in_table` to check only for the existance of the column in the table.
+* :ref:`pgr_is_column_in_table` to check only for the existence of the column in the table.
 * :ref:`pgr_get_column_name` to get the name of the column as is stored in the postgres administration tables.
 * :ref:`pgr_get_table_name` to get the name of the table as is stored in the postgres administration tables.
 
diff --git a/src/common/doc/utilities/point_to_id.rst b/src/common/doc/utilities/point_to_id.rst
index 00f2c3e..11d010d 100644
--- a/src/common/doc/utilities/point_to_id.rst
+++ b/src/common/doc/utilities/point_to_id.rst
@@ -9,11 +9,14 @@
 
 .. _pgr_point_to_id:
 
-pgr_pointToId
+pgr_pointToId - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_pointToId(geometry,double precision,text,integer) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -22,11 +25,6 @@ Name
 
 .. note:: This function is intended for the developer's aid.
 
- Use :ref:`pgr_createTopology <pgr_create_topology>` or :ref:`pgr_createVerticesTable <pgr_create_vert_table>` instead. 
-
-.. warning:: This function is  deprecated in 2.1
-
-
 
 Synopsis
 -------------------------------------------------------------------------------
@@ -48,8 +46,8 @@ Description
 
 This function returns the id of the row that corresponds to the ``point`` geometry 
 
-  - When the ``point`` geometry already exists in the vertices table ``vertname``, it returns the corresponing ``id``.
-  - When the ``point`` geometry is not found in the vertices table ``vertname``, the funcion inserts the ``point`` and returns the corresponing ``id`` of the newly created vertex.
+  - When the ``point`` geometry already exists in the vertices table ``vertname``, it returns the corresponding ``id``.
+  - When the ``point`` geometry is not found in the vertices table ``vertname``, the function inserts the ``point`` and returns the corresponding ``id`` of the newly created vertex.
  
 .. warning:: The function do not perform any checking of the parameters. Any validation has to be done before calling this function.
 
diff --git a/src/common/doc/utilities/quote_ident.rst b/src/common/doc/utilities/quote_ident.rst
index 9b5f56e..84dcbb5 100644
--- a/src/common/doc/utilities/quote_ident.rst
+++ b/src/common/doc/utilities/quote_ident.rst
@@ -9,11 +9,14 @@
 
 .. _pgr_quote_ident:
 
-pgr_quote_ident 
+pgr_quote_ident  - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_quote_ident(text) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -22,9 +25,6 @@ Name
 
 .. note:: This function is intended for the developer's aid. 
 
-.. warning:: This function is deprecated in 2.1
-             Use `_pgr_quote_ident` instead
-
 
 Synopsis
 -------------------------------------------------------------------------------
diff --git a/src/common/doc/utilities/start_point.rst b/src/common/doc/utilities/start_point.rst
index 5f7ff64..b0fca55 100644
--- a/src/common/doc/utilities/start_point.rst
+++ b/src/common/doc/utilities/start_point.rst
@@ -9,11 +9,14 @@
 
 .. _pgr_start_point:
 
-pgr_startPoint 
+pgr_startPoint  - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_startPoint(geometry) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -22,8 +25,6 @@ Name
 
 .. note:: This function is intended for the developer's aid. 
 
-.. warning:: This function is deprecated in 2.1
-             Use `_pgr_startPoint` instead
 
 Synopsis
 -------------------------------------------------------------------------------
diff --git a/src/common/doc/utilities/versionless.rst b/src/common/doc/utilities/versionless.rst
index 6332b48..b833d2c 100644
--- a/src/common/doc/utilities/versionless.rst
+++ b/src/common/doc/utilities/versionless.rst
@@ -9,11 +9,14 @@
 
 .. _pgr_versionless:
 
-pgr_versionless
+pgr_versionless - Deprecated Function
 ===============================================================================
 
-.. index:: 
-	single: pgr_versionless(text,text) -- deprecated
+.. warning:: This function is deprecated!!!
+
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 -------------------------------------------------------------------------------
@@ -22,8 +25,6 @@ Name
 
 .. note:: This function is intended for the developer’s aid.
 
-.. warning:: This function is deprecated in 2.1.
-             Use `_pgr_versionless` instead
 
 Synopsis
 -------------------------------------------------------------------------------
diff --git a/src/common/sql/CMakeLists.txt b/src/common/sql/CMakeLists.txt
index 86a9a5a..9219504 100644
--- a/src/common/sql/CMakeLists.txt
+++ b/src/common/sql/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Append in local scope
 LIST(APPEND PACKAGE_SQL_FILES
+    ${CMAKE_CURRENT_SOURCE_DIR}/pgRouting-header.sql
     ${CMAKE_CURRENT_SOURCE_DIR}/pgrouting-types.sql
     ${CMAKE_CURRENT_SOURCE_DIR}/pgrouting_version.sql
     ${CMAKE_CURRENT_SOURCE_DIR}/pgrouting_utilities.sql
diff --git a/src/common/sql/pgRouting-header.sql b/src/common/sql/pgRouting-header.sql
new file mode 100644
index 0000000..218fb7b
--- /dev/null
+++ b/src/common/sql/pgRouting-header.sql
@@ -0,0 +1,37 @@
+\echo Use "CREATE EXTENSION pgrouting" to load this file. \quit
+
+
+
+
+--- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+---
+--- pgRouting provides geospatial routing functionality.
+--- http://pgrouting.org
+--- copyright 
+--- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+---
+---
+--- This is free software; you can redistribute and/or modify it:
+--- the terms of the GNU General Public Licence. See the COPYING file.
+--- the terms of the MIT-X Licence. See the COPYING file.
+---
+--- The following functions have MIT-X licence:
+---     pgr_version()
+---     pgr_tsp(matrix float8[][], startpt integer, endpt integer DEFAULT -1, OUT seq integer, OUT id integer)
+---     _pgr_makeDistanceMatrix(sqlin text, OUT dmatrix double precision[], OUT ids integer[])
+---     pgr_analyzegraph(edge_table text,tolerance double precision,the_geom text default 'the_geom',id text default 'id',source text default 'source',target text default 'target',rows_where text default 'true')
+---
+---
+--- All other functions are under GNU General Public Licence.
+---
+--- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+--
+-- WARNING: Any change in this file must be evaluated for compatibility.
+--          Changes cleanly handled by postgis_upgrade.sql are fine,
+--          other changes will require a bump in Major version.
+--          Currently only function replaceble by CREATE OR REPLACE
+--          are cleanly handled.
+--
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
diff --git a/src/common/sql/pgr_parameter_check.sql b/src/common/sql/pgr_parameter_check.sql
index d017515..0c88312 100644
--- a/src/common/sql/pgr_parameter_check.sql
+++ b/src/common/sql/pgr_parameter_check.sql
@@ -60,7 +60,7 @@ CREATE OR REPLACE FUNCTION _pgr_parameter_check(fn text, sql text, big boolean d
     END;
 
     -- checking the fixed columns and data types of the integers
-    IF fn IN ('dijkstra') THEN
+    IF fn IN ('dijkstra','astar') THEN
         BEGIN
           execute 'select id,source,target,cost  from ('||safesql||') as __b__' into rec;
           EXCEPTION
@@ -82,8 +82,28 @@ CREATE OR REPLACE FUNCTION _pgr_parameter_check(fn text, sql text, big boolean d
     END IF;
  
 
+    IF fn IN ('astar') THEN
+        BEGIN
+          execute 'select x1,y1,x2,y2  from ('||safesql||') as __b__' into rec;
+          EXCEPTION
+            WHEN OTHERS THEN
+                RAISE EXCEPTION 'An expected column was not found in the query'
+                  USING ERRCODE = 'XX000',
+                   HINT = 'Please veryfy the column names: x1,y1, x2,y2';
+        END;
+        execute 'select pg_typeof(x1)::text as x1_type, pg_typeof(y1)::text as y1_type, pg_typeof(x2)::text as x2_type, pg_typeof(y2)::text as y2_type'
+            || ' from ('||safesql||') AS __b__ ' into rec;
+        -- Version 2.0.0 is more restrictive
+        IF NOT(   (rec.x1_type = 'double precision'::text)
+              AND (rec.y1_type = 'double precision'::text)
+              AND (rec.x2_type = 'double precision'::text)
+              AND (rec.y2_type = 'double precision'::text)) THEN
+            RAISE EXCEPTION 'Columns: x1, y1, x2, y2 must be of type float8'
+            USING ERRCODE = 'XX000';
+        END IF;
+    END IF;
 
-        -- checking the fixed columns and data types of the integers
+    -- checking the fixed columns and data types of the integers
     IF fn IN ('johnson') THEN
         BEGIN
           execute 'select source,target,cost  from ('||safesql||') as __b__' into rec;
@@ -108,7 +128,7 @@ CREATE OR REPLACE FUNCTION _pgr_parameter_check(fn text, sql text, big boolean d
 
     -- Checking the data types of the optional reverse_cost";
     has_rcost := false;
-    IF fn IN ('johnson','dijkstra') THEN
+    IF fn IN ('johnson','dijkstra','astar') THEN
       BEGIN
         execute 'select reverse_cost, pg_typeof(reverse_cost)::text as rev_type  from ('||safesql||' ) AS __b__ limit 1 ' into rec1;
         has_rcost := true;
@@ -125,7 +145,7 @@ CREATE OR REPLACE FUNCTION _pgr_parameter_check(fn text, sql text, big boolean d
            END IF;
         ELSE -- Version 2.0.0 is more restrictive
            IF (rec1.rev_type != 'double precision') then
-             RAISE EXCEPTION 'Illegal type in optional parameter reverse_cost, expected: double precision'
+             RAISE EXCEPTION 'Illegal type in optional parameter reverse_cost, must be of type float8'
              USING ERRCODE = 'XX000';
            END IF;
         END IF;
diff --git a/src/common/sql/pgrouting_utilities.sql b/src/common/sql/pgrouting_utilities.sql
index 0528d48..ae778c9 100644
--- a/src/common/sql/pgrouting_utilities.sql
+++ b/src/common/sql/pgrouting_utilities.sql
@@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    Examples:
         *          select * from  _pgr_getTableName('tab');
         *        naming record;
-                 excecute 'select * from  _pgr_getTableName('||quote_literal(tab)||')' INTO naming;
+                 execute 'select * from  _pgr_getTableName('||quote_literal(tab)||')' INTO naming;
                  schema=naming.sname; table=naming.tname
 
 
@@ -143,8 +143,8 @@ LANGUAGE plpgsql VOLATILE STRICT;
  Examples:
         *          select  _pgr_getColumnName('tab','col');
         *          select  _pgr_getColumnName('myschema','mytable','col');
-                 excecute 'select _pgr_getColumnName('||quote_literal('tab')||','||quote_literal('col')||')' INTO column;
-                 excecute 'select _pgr_getColumnName('||quote_literal(sname)||','||quote_literal(sname)||','||quote_literal('col')||')' INTO column;
+                 execute 'select _pgr_getColumnName('||quote_literal('tab')||','||quote_literal('col')||')' INTO column;
+                 execute 'select _pgr_getColumnName('||quote_literal(sname)||','||quote_literal(sname)||','||quote_literal('col')||')' INTO column;
 
    Author: Vicky Vergara <vicky_vergara at hotmail.com>>
 
@@ -209,7 +209,7 @@ LANGUAGE plpgsql VOLATILE STRICT;
    Examples:
         *          select  _pgr_isColumnName('tab','col');
         *        flag boolean;
-                 excecute 'select _pgr_getColumnName('||quote_literal('tab')||','||quote_literal('col')||')' INTO flag;
+                 execute 'select _pgr_getColumnName('||quote_literal('tab')||','||quote_literal('col')||')' INTO flag;
 
    Returns true  if column "col" exists in table "tab"
            false when "tab" doesn't exist or when "col" is not in table "tab"
@@ -240,7 +240,7 @@ $BODY$
    Examples:
         *          select  _pgr_isColumnIndexed('tab','col');
         *        flag boolean;
-                 excecute 'select _pgr_getColumnIndexed('||quote_literal('tab')||','||quote_literal('col')||')' INTO flag;
+                 execute 'select _pgr_getColumnIndexed('||quote_literal('tab')||','||quote_literal('col')||')' INTO flag;
 
    Author: Stephen Woodbridge <woodbri at imaptools.com>
 
diff --git a/src/common/sql/utilities_pgr.sql b/src/common/sql/utilities_pgr.sql
index 2f93cc8..830b441 100644
--- a/src/common/sql/utilities_pgr.sql
+++ b/src/common/sql/utilities_pgr.sql
@@ -125,8 +125,8 @@ LANGUAGE plpgsql VOLATILE STRICT;
  Examples:  
 	* 	 select  _pgr_getColumnType('tab','col');
 	* 	 select  _pgr_getColumnType('myschema','mytable','col');
-        	 excecute 'select _pgr_getColumnType('||quote_literal('tab')||','||quote_literal('col')||')' INTO column;
-        	 excecute 'select _pgr_getColumnType('||quote_literal(sname)||','||quote_literal(sname)||','||quote_literal('col')||')' INTO column;
+        	 execute 'select _pgr_getColumnType('||quote_literal('tab')||','||quote_literal('col')||')' INTO column;
+        	 execute 'select _pgr_getColumnType('||quote_literal(sname)||','||quote_literal(sname)||','||quote_literal('col')||')' INTO column;
 
    Author: Vicky Vergara <vicky_vergara at hotmail.com>>
 
diff --git a/src/common/src/CMakeLists.txt b/src/common/src/CMakeLists.txt
index 19c84d0..bc34b64 100644
--- a/src/common/src/CMakeLists.txt
+++ b/src/common/src/CMakeLists.txt
@@ -2,9 +2,21 @@ ADD_LIBRARY(common OBJECT
     postgres_connection.c
     restrictions_input.c
     basePath_SSEC.cpp
+
     points_input.c
+    matrixRows_input.c
     get_check_data.c
     edges_input.c
+    
+    coordinates_input.c
     arrays_input.c
+
     time_msg.c
+    pgr_assert.cpp
+
+    basic_vertex.cpp
+    xy_vertex.cpp
+    ch_vertex.cpp
+    ch_edge.cpp
+    basic_edge.cpp
     )
diff --git a/src/common/src/arrays_input.c b/src/common/src/arrays_input.c
index 67c3ad5..d57508e 100644
--- a/src/common/src/arrays_input.c
+++ b/src/common/src/arrays_input.c
@@ -22,14 +22,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "./pgr_types.h"
-#include "postgres.h"
+#include <postgres.h>
 #include "utils/lsyscache.h"
 #include "catalog/pg_type.h"
 #include "utils/array.h"
 
 
 // #define DEBUG
+#include "./pgr_types.h"
 #include "./time_msg.h"
 #include "./debug_macro.h"
 #include "./arrays_input.h"
@@ -48,12 +48,11 @@ int64_t* pgr_get_bigIntArray(size_t *arrlen, ArrayType *input) {
     int64_t      *data;
     clock_t start_t = clock();
 
-    PGR_DBG("Geting integer array");
+    PGR_DBG("Getting integer array");
     /* get input array element type */
     i_eltype = ARR_ELEMTYPE(input);
     get_typlenbyvalalign(i_eltype, &i_typlen, &i_typbyval, &i_typalign);
 
-
     /* validate input data type */
     switch (i_eltype) {
         case INT2OID:
@@ -90,7 +89,97 @@ int64_t* pgr_get_bigIntArray(size_t *arrlen, ArrayType *input) {
 
     for (i = 0; i < (*arrlen); i++) {
         if (nulls[i]) {
-            data[i] = -1;
+            free(data);
+            elog(ERROR, "NULL value found in Array!");
+        } else {
+            switch (i_eltype) {
+                case INT2OID:
+                    data[i] = (int64_t) DatumGetInt16(i_data[i]);
+                    break;
+                case INT4OID:
+                    data[i] = (int64_t) DatumGetInt32(i_data[i]);
+                    break;
+                case INT8OID:
+                    data[i] = DatumGetInt64(i_data[i]);
+                    break;
+            }
+        }
+    }
+
+    pfree(nulls);
+    pfree(i_data);
+
+    PGR_DBG("Finished processing array");
+    time_msg(" reading Array", start_t, clock());
+    return (int64_t*)data;
+}
+
+
+
+int64_t* pgr_get_bigIntArray_allowEmpty(size_t *arrlen, ArrayType *input) {
+    int         ndims;
+    bool       *nulls;
+    Oid         i_eltype;
+    int16       i_typlen;
+    bool        i_typbyval;
+    char        i_typalign;
+    Datum      *i_data;
+    int         i;
+    int         n;
+    int64_t      *data;
+    clock_t start_t = clock();
+
+    PGR_DBG("Getting integer array");
+    /* get input array element type */
+    i_eltype = ARR_ELEMTYPE(input);
+    get_typlenbyvalalign(i_eltype, &i_typlen, &i_typbyval, &i_typalign);
+
+    /* validate input data type */
+    switch (i_eltype) {
+        case INT2OID:
+        case INT4OID:
+        case INT8OID:
+            break;
+        default:
+            elog(ERROR, "Expected array of ANY-INTEGER");
+            return (int64_t*) NULL;
+            break;
+    }
+
+    /* get various pieces of data from the input array */
+    ndims = ARR_NDIM(input);
+    n = (*ARR_DIMS(input));
+    (*arrlen) = (size_t)(n);
+    // PGR_DBG("dimensions %d", ndims);
+    // PGR_DBG("array size %ld", (*arrlen));
+
+    if (ndims == 0) {
+        (*arrlen) = 0;
+        PGR_DBG("array size %ld", (*arrlen));
+        return (int64_t*) NULL;
+    }
+
+    if (ndims > 1) {
+        elog(ERROR, "Expected less than two dimension");
+    }
+
+    /* get src data */
+    deconstruct_array(input, i_eltype, i_typlen, i_typbyval, i_typalign,
+            &i_data, &nulls, &n);
+
+    /* construct a C array */
+    data = (int64_t *) malloc((*arrlen) * sizeof(int64_t));
+
+    if (!data) {
+        elog(ERROR, "Out of memory!");
+    }
+
+    PGR_DBG("array size %ld", (*arrlen));
+
+    for (i = 0; i < (*arrlen); i++) {
+        if (nulls[i]) {
+            free(data);
+            elog(ERROR, "NULL value found in Array!");
         } else {
             switch (i_eltype) {
                 case INT2OID:
diff --git a/src/common/src/arrays_input.h b/src/common/src/arrays_input.h
index 9a1f9a8..7671b23 100644
--- a/src/common/src/arrays_input.h
+++ b/src/common/src/arrays_input.h
@@ -22,8 +22,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_ARRAYS_INPUT_H_
+#define SRC_COMMON_SRC_ARRAYS_INPUT_H_
 #pragma once
 
 #include "./pgr_types.h"
 
 int64_t* pgr_get_bigIntArray(size_t *arrlen, ArrayType *input);
+
+// Allows the input array to be empty
+int64_t* pgr_get_bigIntArray_allowEmpty(size_t *arrlen, ArrayType *input);
+
+#endif  // SRC_COMMON_SRC_ARRAYS_INPUT_H_
diff --git a/src/common/src/baseGraph.hpp b/src/common/src/baseGraph.hpp
deleted file mode 100644
index ab8d6b9..0000000
--- a/src/common/src/baseGraph.hpp
+++ /dev/null
@@ -1,564 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-vicky_vergara at hotmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#ifndef SRC_COMMON_SRC_BASE_GRAPH_HPP_
-#define SRC_COMMON_SRC_BASE_GRAPH_HPP_
-
-#include <boost/config.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/graph_utility.hpp>
-
-#include <deque>
-#include <vector>
-#include <set>
-#include <map>
-#include <limits>
-
-#include "./pgr_types.h"
-
-/*! \brief boost::graph simplified to pgRouting needs
-
-  This class gives the handling basics of a boost::graph of kind G
-  where G:
-  can be an undirected graph or a directed graph.
-
-Usage:
-======
-
-Given the following types:
-~~~~{.c}
-typedef boost::adjacency_list < boost::vecS, boost::vecS,
-boost::undirectedS,
-boost_vertex_t, boost_edge_t > UndirectedGraph;
-
-typedef boost::adjacency_list < boost::vecS, boost::vecS,
-boost::bidirectionalS,
-boost_vertex_t, boost_edge_t > DirectedGraph;
-~~~~
-
-direct usage:
----------------
-
-~~~~{.c}
-Pgr_base_graph < DirectedGraph > digraph(gType, initial_size);
-Pgr_base_graph < UndirectedGraph > undigraph(gType, initial_size);
-~~~~
-
-usage by inheritance:
----------------------
-
-~~~~{.c}
-class my_graph: public Pgr_base_graph {
-explicit my_graph(graphType gtype, const int initial_size)
-:Pgr_base_graph< G >(gtype, initial_size) {}
-// the class: my_graph will have the functionality of this class
-}
-
-my_graph < DirectedGraph > digraph(gType, initial_size);
-my_graph < UndirectedGraph > undigraph(gType, initial_size);
-~~~~
-
-*/
-
-typedef typename boost::adjacency_list < boost::vecS, boost::vecS,
-        boost::undirectedS,
-        boost_vertex_t, boost_edge_t > UndirectedGraph;
-
-typedef typename boost::adjacency_list < boost::vecS, boost::vecS,
-        boost::bidirectionalS,
-        boost_vertex_t, boost_edge_t > DirectedGraph;
-
-
-template <class G>
-class Pgr_base_graph {
- public:
-     /** @name Graph related types
-       Type      |     boost meaning     |   pgRouting Meaning
-       :---------: | :-------------------- | :----------------------
-       G        | boost::adjacency_list |   Graph
-       V        | vertex_descriptor     |   Think of it as local ID of a vertex
-       E        | edge_descriptor       |   Think of it as local ID of an edge
-       V_i      | vertex_iterator       |   To cycle the vertices of the Graph
-       E_i      | edge_iterator         |   To cycle the edges of the Graph
-       EO_i     | out_edge_iterator     |   To cycle the out going edges of a vertex
-       EI_i     | in_edge_iterator      |   To cycle the in coming edges of a vertex (only in bidirectional graphs)
-       */
-     //@{
-     typedef typename boost::graph_traits < G >::vertex_descriptor V;
-     typedef typename boost::graph_traits < G >::edge_descriptor E;
-     typedef typename boost::graph_traits < G >::vertex_iterator V_i;
-     typedef typename boost::graph_traits < G >::edge_iterator E_i;
-     typedef typename boost::graph_traits < G >::out_edge_iterator EO_i;
-     typedef typename boost::graph_traits < G >::in_edge_iterator EI_i;
-
-     typedef typename boost::graph_traits < G >::vertices_size_type     vertices_size_type;
-     typedef typename boost::graph_traits < G >::edges_size_type        edges_size_type;
-     typedef typename boost::graph_traits < G >::degree_size_type       degree_size_type;
-
-     //@}
-
-     /** @name Id handling related types
-       Type      |  Meaning       |   pgRouting Meaning
-       :---------: | :------------- | :----------------------
-       id_to_V  | maps id -> V   | given an id store the V
-       V_to_id  | maps V -> id   | given a V store the id
-       LI       | Left Iterator  | iterates over id_to_V
-       RI       | right Iterator | iterates over V_to_id
-       */
-     //@{
-     typedef typename std::map< int64_t, V > id_to_V;
-     typedef typename std::map< V, int64_t > V_to_id;
-     typedef typename id_to_V::const_iterator LI;
-     typedef typename V_to_id::const_iterator RI;
-     //@}
-
-     //! @name The Graph
-     //@{
-     G graph;                //!< The graph
-     size_t m_num_vertices;  //!< number of vertices
-     graphType m_gType;      //!< type (DIRECTED or UNDIRECTED)
-     //@}
-
-     //! @name Id handling
-     //@{
-     id_to_V  vertices_map;   //!< id -> graph id
-     V_to_id  gVertices_map;  //!< graph id -> id
-     //@}
-
-     //! @name Graph Modification
-     //@{
-     //! Used for storing the removed_edges
-     std::deque<boost_edge_t> removed_edges;
-
-     //! Used for storing modified edges because of adding points
-     // TODO
-#if 0
-     std::deque<boost_edge_t> modified_edges;
-     std::deque< Point_on_edge > points;
-     // map to get wich boost edge was modified
-     std::map < int64_t, int64_t >;
-#endif
-     //@}
-
-#if 0
-     void add_point(Point_on_edge &point, int driving) {
-         // we have:
-         // point.point_id
-         // point.edge_id
-         // point.fraction
-         // Look for the edge in modified edges
-         //
-         // Driving: 0: doesnt matter (both), 1) right, 2) left
-         bool found = false;
-         int64_t edge_to_modify = 0;
-         for (const auto &edge : modified_edges) {
-             if (point.edge_id == edge.id) {
-                 found = true;
-                 break;
-             }
-             ++edge_to_modify;
-         }
-
-         //was not there so look for it in the graph
-         if (!found) {
-             E_i edge_ptr, edges_end;
-             for (boost::tie(edge_ptr, edges_end) = edges(graph);
-                     edge_ptr != edges_end; ++edge_ptr) {
-                 if (point.edge_id == edge_ptr->id) {
-                     modified_edges.push_back(*edge_ptr);
-                     boost::remove_edge(edge_ptr, graph);
-                     //delete the edge from the graph
-                     found = true;
-                     break;
-                 }
-             }
-         }
-
-         // add the point
-         int64_t vertex_id = -(points.size() + 1);
-         point.vertex_id = vertex_id;
-         points.push_back(point);
-
-         // add the vertex
-         LI vm_s;
-         vm_s = vertices_map.find(vertex_id);
-         if (vm_s == vertices_map.end()) {
-             vertices_map[vertex_id]=  m_num_vertices;
-             gVertices_map[m_num_vertices++] = vertex_id;
-             vm_s = vertices_map.find(vertex_id);
-         }
-
-         if (!found) {
-             // the vertex remains disconnected
-             // because the edge was not found
-             return;
-         }
-         
-     }
-#endif
-
-
-
-
-
-     //! @name The Graph
-     //@{
-     //! \brief Constructor
-     /*!
-       Prepares the _graph_ to be of type _gtype_ with the
-       aproximate number of vertices its coing to have as *initial_size*
-       */
-     explicit Pgr_base_graph< G >(graphType gtype, const size_t initial_size)
-         : graph(1),
-         m_num_vertices(0),
-         m_gType(gtype)
-    {}
-
-     //! \brief Inserts *count* edges of type *pgr_edge_t* into the graph
-     void graph_insert_data(const pgr_edge_t *data_edges, int64_t count) {
-         for (unsigned int i = 0; i < count; ++i) {
-             graph_add_edge(data_edges[i]);
-         }
-         adjust_vertices();
-         for ( int64_t i = 0; (unsigned int) i < gVertices_map.size(); ++i )
-             graph[i].id = gVertices_map.find(i)->second;
-     }
-
-     void graph_insert_data( const std::vector <pgr_edge_t > &data_edges) {
-         for (const auto edge : data_edges) {
-             graph_add_edge(edge);
-         }
-         adjust_vertices();
-         for ( int64_t i = 0; (unsigned int) i < gVertices_map.size(); ++i )
-             graph[i].id = gVertices_map.find(i)->second;
-     }
-
-     //! \brief Disconnects all edges from p_from to p_to
-     /*!
-       - No edge is disconnected if the vertices id's do not exist in the graph
-       - All removed edges are stored for future reinsertion
-       - All parallel edges are disconnected (automatically by boost)
-
-       ![disconnect_edge(2,3) on an UNDIRECTED graph](disconnectEdgeUndirected.png)
-       ![disconnect_edge(2,3) on a DIRECTED graph](disconnectEdgeDirected.png)
-
-       @param [IN] *p_from* original vertex id of the starting point of the edge
-       @param [IN] *p_to*   original vertex id of the ending point of the edge
-       */
-     void disconnect_edge(int64_t p_from, int64_t p_to) {
-         V g_from;
-         V g_to;
-         boost_edge_t d_edge;
-         // nothing to do, the vertex doesnt exist
-         if (!get_gVertex(p_from, g_from)) return;
-         if (!get_gVertex(p_to, g_to)) return;
-         EO_i out, out_end;
-         // store the edges that are going to be removed
-         for (boost::tie(out, out_end) = out_edges(g_from, graph);
-                 out != out_end; ++out) {
-             if (target(*out, graph) == g_to) {
-                 d_edge.id = graph[*out].id;
-                 d_edge.source = graph[source(*out, graph)].id;
-                 d_edge.target = graph[target(*out, graph)].id;
-                 d_edge.cost = graph[*out].cost;
-                 //        d_edge.reverse_cost = -1;
-                 removed_edges.push_back(d_edge);
-             }
-         }
-         // the actual removal
-         boost::remove_edge(g_from, g_to, graph);
-     }
-
-
-     //! @name boost wrappers
-     //@{
-     //! \brief get the out-degree  of a vertex
-     /*!
-       \returns 0: The out degree of a vertex that its not in the graph
-
-       @param [IN] *vertex_id* original vertex id
-       */
-
-
-     degree_size_type out_degree(int64_t vertex_id) const{
-         V v_from;
-         if (!get_gVertex(vertex_id, v_from)) {
-             return 0;
-         }
-         return out_degree(v_from);
-     }
-
-     degree_size_type out_degree(V &v) const {
-         return boost::out_degree(v, graph);
-     }
-     //@}
-
-
-     //! \brief Disconnects the outgoing edges with a particular original id from a vertex
-     /*!
-       - No edge is disconnected if it doesn't exist in the graph
-       - Removed edges are stored for future reinsertion
-       - all outgoing edges with the edge_id are removed if they exist
-
-       @param [IN] *vertex_id* original vertex
-       @param [IN] *edge_id* original edge_id
-       */
-     void disconnect_out_going_edge(int64_t vertex_id, int64_t edge_id) {
-         V v_from;
-         boost_edge_t d_edge;
-
-         // nothing to do, the vertex doesnt exist
-         if (!get_gVertex(vertex_id, v_from)) {
-             return;
-         }
-
-         EO_i out, out_end;
-         bool change = true;
-         // store the edge that are going to be removed
-         while (change) {
-             change = false;
-             for (boost::tie(out, out_end) = out_edges(v_from, graph);
-                     out != out_end; ++out) {
-                 if (graph[*out].id  == edge_id) {
-                     d_edge.id = graph[*out].id;
-                     d_edge.source = graph[source(*out, graph)].id;
-                     d_edge.target = graph[target(*out, graph)].id;
-                     d_edge.cost = graph[*out].cost;
-                     //        d_edge.reverse_cost = -1;
-                     removed_edges.push_back(d_edge);
-                     boost::remove_edge((*out), graph);
-                     change = true;
-                     break;
-                 }
-             }
-         }
-
-     }
-
-
-     //! \brief Disconnects all incomming and outgoing edges from the vertex
-     /*!
-       boost::graph doesn't recommend th to insert/remove vertices, so a vertex removal is
-       simulated by disconnecting the vertex from the graph
-
-       - No edge is disconnected if the vertices id's do not exist in the graph
-       - All removed edges are stored for future reinsertion
-       - All parallel edges are disconnected (automatically by boost)
-
-       ![disconnect_vertex(2) on an UNDIRECTED graph](disconnectVertexUndirected.png)
-       ![disconnect_vertex(2) on a DIRECTED graph](disconnectVertexDirected.png)
-
-       @param [IN] *p_vertex* original vertex id of the starting point of the edge
-       */
-     void disconnect_vertex(int64_t p_vertex) {
-         V g_vertex;
-         boost_edge_t d_edge;
-         // nothing to do, the vertex doesnt exist
-         if (!get_gVertex(p_vertex, g_vertex)) return;
-         EO_i out, out_end;
-         // store the edges that are going to be removed
-         for (boost::tie(out, out_end) = out_edges(g_vertex, graph);
-                 out != out_end; ++out) {
-             d_edge.id = graph[*out].id;
-             d_edge.source = graph[source(*out, graph)].id;
-             d_edge.target = graph[target(*out, graph)].id;
-             d_edge.cost = graph[*out].cost;
-             //        d_edge.reverse_cost = -1;
-             removed_edges.push_back(d_edge);
-         }
-
-         // special case
-         if (m_gType == DIRECTED) {
-             EI_i in, in_end;
-             for (boost::tie(in, in_end) = in_edges(g_vertex, graph);
-                     in != in_end; ++in) {
-                 d_edge.id = graph[*in].id;
-                 d_edge.source = graph[source(*in, graph)].id;
-                 d_edge.target = graph[target(*in, graph)].id;
-                 d_edge.cost = graph[*in].cost;
-                 //           d_edge.reverse_cost = -1;
-                 removed_edges.push_back(d_edge);
-             }
-         }
-
-         V d_vertex = boost::vertex(vertices_map.find(p_vertex)->second, graph);
-         // delete incomming and outgoing edges from the vertex
-         boost::clear_vertex(d_vertex, graph);
-     }
-
-     //! \brief Reconnects all edges that were removed
-     void restore_graph() {
-         while (removed_edges.size() != 0) {
-             graph_add_edge(removed_edges[0]);
-             removed_edges.pop_front();
-         }
-     }
-     //@}
-
-     //! @name only for stand by program
-     //@{
-     void print_graph(std::ostream &log = std::cout) const {
-         EO_i out, out_end;
-         V_i vi;
-
-         for (vi = vertices(graph).first; vi != vertices(graph).second; ++vi) {
-             if ((*vi) >= m_num_vertices) continue;
-             log << (*vi) << " out_edges(" << graph[(*vi)].id << "):";
-             for (boost::tie(out, out_end) = out_edges(*vi, graph);
-                     out != out_end; ++out) {
-                 log << ' ' << graph[*out].id << "=(" << graph[source(*out, graph)].id
-                     << ", " << graph[target(*out, graph)].id << ") = "
-                     <<  graph[*out].cost <<"\t";
-             }
-             log << std::endl;
-         }
-     }
-     //@}
-
-
-     bool get_gVertex(int64_t vertex_id, V &gVertex) const {
-         LI vertex_ptr = vertices_map.find(vertex_id);
-
-         if (vertex_ptr == vertices_map.end())
-             return false;
-
-         gVertex = vertex(vertex_ptr->second, graph);
-         return true;
-     }
-
- public:
-     int64_t
-         get_edge_id(V from, V to, float8 &distance) const {
-             E e;
-             EO_i out_i, out_end;
-             V v_source, v_target;
-             float8 minCost =  std::numeric_limits<float8>::max();
-             int64_t minEdge = -1;
-             for (boost::tie(out_i, out_end) = boost::out_edges(from, graph);
-                     out_i != out_end; ++out_i) {
-                 e = *out_i;
-                 v_target = target(e, graph);
-                 v_source = source(e, graph);
-                 if ((from == v_source) && (to == v_target)
-                         && (distance == graph[e].cost))
-                     return graph[e].id;
-                 if ((from == v_source) && (to == v_target)
-                         && (minCost > graph[e].cost)) {
-                     minCost = graph[e].cost;
-                     minEdge = graph[e].id;
-                 }
-             }
-             distance = minEdge == -1? 0: minCost;
-             return minEdge;
-         }
-
- public:
-     size_t num_vertices() const { return m_num_vertices; }
-     void
-         adjust_vertices() {
-             while (boost::num_vertices(graph) != num_vertices()) {
-                 if (boost::num_vertices(graph) > num_vertices()) {
-                     boost::remove_vertex(boost::num_vertices(graph), graph);
-                 }
-             }
-         }
-
-
-     boost_vertex_t operator[](V v) const {
-         return graph[v];
-     }
-
- private:
-
-
-     void
-         graph_add_edge(const boost_edge_t &edge ) {
-             bool inserted;
-             LI vm_s, vm_t;
-             E e;
-
-             vm_s = vertices_map.find(edge.source);
-             if (vm_s == vertices_map.end()) {
-                 vertices_map[edge.source]=  m_num_vertices;
-                 gVertices_map[m_num_vertices++] = edge.source;
-                 vm_s = vertices_map.find(edge.source);
-             }
-
-             vm_t = vertices_map.find(edge.target);
-             if (vm_t == vertices_map.end()) {
-                 vertices_map[edge.target]=  m_num_vertices;
-                 gVertices_map[m_num_vertices++] = edge.target;
-                 vm_t = vertices_map.find(edge.target);
-             }
-
-             if (edge.cost >= 0) {
-                 boost::tie(e, inserted) =
-                     boost::add_edge(vm_s->second, vm_t->second, graph);
-                 graph[e].cost = edge.cost;
-                 graph[e].id = edge.id;
-                 graph[e].first = edge.first;
-             }
-         }
-
-     void
-         graph_add_edge(const pgr_edge_t &edge ) {
-             bool inserted;
-             LI vm_s, vm_t;
-             E e;
-             if ((edge.cost < 0) && (edge.reverse_cost < 0))
-                 return;
-
-             vm_s = vertices_map.find(edge.source);
-             if (vm_s == vertices_map.end()) {
-                 vertices_map[edge.source]=  m_num_vertices;
-                 gVertices_map[m_num_vertices++] = edge.source;
-                 vm_s = vertices_map.find(edge.source);
-             }
-
-             vm_t = vertices_map.find(edge.target);
-             if (vm_t == vertices_map.end()) {
-                 vertices_map[edge.target]=  m_num_vertices;
-                 gVertices_map[m_num_vertices++] = edge.target;
-                 vm_t = vertices_map.find(edge.target);
-             }
-
-             if (edge.cost >= 0) {
-                 boost::tie(e, inserted) =
-                     boost::add_edge(vm_s->second, vm_t->second, graph);
-                 graph[e].cost = edge.cost;
-                 graph[e].id = edge.id;
-                 graph[e].first = true;
-             }
-
-             if (edge.reverse_cost >= 0) {
-                 boost::tie(e, inserted) =
-                     boost::add_edge(vm_t->second, vm_s->second, graph);
-                 graph[e].cost = edge.reverse_cost;
-                 graph[e].id = edge.id;
-                 graph[e].first = false;
-             }
-         }
-};
-
-
-#endif  // SRC_COMMON_SRC_BASE_GRAPH_HPP_
diff --git a/src/common/src/basePath_SSEC.cpp b/src/common/src/basePath_SSEC.cpp
index 3cca77f..6fd668f 100644
--- a/src/common/src/basePath_SSEC.cpp
+++ b/src/common/src/basePath_SSEC.cpp
@@ -21,9 +21,12 @@ along with this program; if not, write to the Free Software
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#ifdef open
+#undef open
+#endif
 #endif
 
 
@@ -31,7 +34,6 @@ along with this program; if not, write to the Free Software
 #include <deque>
 #include <iostream>
 #include <algorithm>
-#include "postgres.h"
 #include "./pgr_types.h"
 
 
@@ -45,6 +47,25 @@ void Path::push_back(Path_t data) {
     m_tot_cost += data.cost;
 }
 
+void Path::reverse() {
+    // std::swap(m_start_id, m_end_id);
+    std::deque< Path_t > newpath;
+    for (size_t i = 0; i < path.size(); ++i) {
+        newpath.push_front({
+                path[i].node,
+                (i == 0? -1 : path[i - 1].edge),
+                (i == 0? 0 : path[i - 1].cost),
+                0
+                });
+    }
+    for (size_t i = 0; i < newpath.size(); ++i) {
+        newpath[i].agg_cost = (i == 0)?
+            0 :
+            newpath[i - 1].agg_cost +  newpath[i - 1].cost;
+    }
+    path = newpath;
+}
+
 
 
 void Path::clear() {
@@ -100,10 +121,10 @@ void Path::appendPath(const Path &o_path) {
 
 void Path::generate_postgres_data(
         General_path_element_t **postgres_data,
-        size_t &sequence) const{
+        size_t &sequence) const {
     int i = 1;
     for (const auto e : path) {
-        (*postgres_data)[sequence] = 
+        (*postgres_data)[sequence] =
         {i, start_id(), end_id(), e.node, e.edge, e.cost, e.agg_cost};
         ++i;
         ++sequence;
@@ -114,7 +135,6 @@ void Path::generate_postgres_data(
 void Path::get_pg_dd_path(
         General_path_element_t **ret_path,
         size_t &sequence) const {
-
     for (unsigned int i = 0; i < path.size(); i++) {
         (*ret_path)[sequence].seq = i;
         (*ret_path)[sequence].start_id = start_id();
@@ -131,7 +151,6 @@ void Path::get_pg_dd_path(
 void Path::get_pg_ksp_path(
         General_path_element_t **ret_path,
         size_t &sequence, int routeId) const {
-
     for (unsigned int i = 0; i < path.size(); i++) {
         (*ret_path)[sequence].seq = i + 1;
         (*ret_path)[sequence].start_id = routeId;
@@ -139,7 +158,9 @@ void Path::get_pg_ksp_path(
         (*ret_path)[sequence].node = path[i].node;
         (*ret_path)[sequence].edge = path[i].edge;
         (*ret_path)[sequence].cost = path[i].cost;
-        (*ret_path)[sequence].agg_cost = (i == 0)? 0: (*ret_path)[sequence-1].agg_cost +  path[i-1].cost;
+        (*ret_path)[sequence].agg_cost = (i == 0)?
+            0 :
+            (*ret_path)[sequence-1].agg_cost +  path[i-1].cost;
         sequence++;
     }
 }
diff --git a/src/common/src/basePath_SSEC.hpp b/src/common/src/basePath_SSEC.hpp
index 2faf640..1964b10 100644
--- a/src/common/src/basePath_SSEC.hpp
+++ b/src/common/src/basePath_SSEC.hpp
@@ -23,16 +23,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 #pragma once
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
+
 
 #include <deque>
 #include <iostream>
 #include <algorithm>
-#include "postgres.h"
 #include "./pgr_types.h"
 
 class Path {
     typedef std::deque< Path_t >::iterator pthIt;
     typedef std::deque< Path_t >::const_iterator ConstpthIt;
+
  private:
     std::deque< Path_t > path;
     int64_t m_start_id;
@@ -57,37 +65,39 @@ class Path {
     void push_back(Path_t data);
     const Path_t& operator[](size_t i) const {return path[i];}
     Path_t& operator[](size_t i) {return path[i];}
+
     pthIt begin() {return path.begin();}
     pthIt end() {return path.end();}
-    void erase(pthIt pos) {path.erase(pos);}
     ConstpthIt begin() const {return path.begin();}
     ConstpthIt end() const {return path.end();}
-    const Path_t& back() const {return path.back();};
-    Path_t& back() {return path.back();};
-    const Path_t& front() const {return path.front();};
-    Path_t& front() {return path.front();};
+
+
+    void erase(pthIt pos) {path.erase(pos);}
+    const Path_t& back() const {return path.back();}
+    Path_t& back() {return path.back();}
+    const Path_t& front() const {return path.front();}
+    Path_t& front() {return path.front();}
 
 
     Path_t set_data(
-            int64_t d_from, 
+            int64_t d_from,
             int64_t d_to,
             int64_t d_vertex,
-            int64_t d_edge, 
-            float8 d_cost,
-            float8 d_tot_cost);
+            int64_t d_edge,
+            double d_cost,
+            double d_tot_cost);
 
     void push_front(
             int64_t d_vertex,
-            int64_t d_edge, 
-            float8 d_cost,
-            float8 d_tot_cost);
+            int64_t d_edge,
+            double d_cost,
+            double d_tot_cost);
     void clear();
 
     friend std::ostream& operator<<(std::ostream &log, const Path &p);
 
 
-    void fix_path(int64_t from, int64_t to);
-
+    void reverse();
 
     Path  getSubpath(unsigned int j) const;
 
@@ -123,32 +133,31 @@ class Path {
 
     /*
      * sort the paths by size from greater to smaller
-     *        and sort each path by node 
+     *        and sort each path by node
      * all the nodes on p2 are going to be compared
      * with the nodes of p1
      *
      * When both paths reach the node and p1.agg_cost > p2.agg_cost
-     *    erase the node of p1 
-     *    (cant erase from p2 because we loose the iterators
+     *    erase the node of p1
+     *    (can't erase from p2 because we loose the iterators
      *     so in a future cycle it will be deleted)
      *
-     * sort the paths by start_id, 
+     * sort the paths by start_id,
      */
 
     friend void equi_cost(std::deque< Path > &paths) {
-
         /* sort paths by size: largest first */
-        std::sort(paths.begin(), paths.end(), 
-                [](const Path &e1, const Path &e2)->bool { 
-                return e2.size() < e1.size(); 
+        std::sort(paths.begin(), paths.end(),
+                [](const Path &e1, const Path &e2)->bool {
+                return e2.size() < e1.size();
                 });
 
         /* sort each path by node: smaller id first */
         for (auto &p : paths) {
-            if (p.size() < 2) continue; 
-            std::sort(p.begin(), p.end(), 
-                    [](const Path_t &e1, const Path_t &e2)->bool { 
-                    return e1.node < e2.node; 
+            if (p.size() < 2) continue;
+            std::sort(p.begin(), p.end(),
+                    [](const Path_t &e1, const Path_t &e2)->bool {
+                    return e1.node < e2.node;
                     });
         }
 
@@ -158,11 +167,13 @@ class Path {
                 for (const auto &stop : p2.path) {
                     /* find the node of p2 in p1 */
                     auto pos = lower_bound(p1.begin(), p1.end(), stop,
-                            [](const Path_t &l, const Path_t &r )->bool { 
-                            return l.node < r.node; 
+                            [](const Path_t &l, const Path_t &r)->bool {
+                            return l.node < r.node;
                             });
-                            
-                    if (pos != p1.end() && stop.node == pos->node && stop.agg_cost < pos->agg_cost) {
+
+                    if (pos != p1.end()
+                            && (stop.node == pos->node)
+                            && (stop.agg_cost < pos->agg_cost)) {
                         /* both share the same node &
                          * the second path has the smallest
                          *  So erasing from the first path */
@@ -173,22 +184,22 @@ class Path {
         }
 
         /* sort paths by start_id */
-        std::sort(paths.begin(), paths.end(), 
-                [](const Path &e1, const Path &e2)->bool { 
-                return e1.start_id() < e2.start_id(); 
+        std::sort(paths.begin(), paths.end(),
+                [](const Path &e1, const Path &e2)->bool {
+                return e1.start_id() < e2.start_id();
                 });
 
         /* sort each path by agg_cost, node */
         for (auto &path : paths) {
             /* least influential data first */
             std::sort(path.begin(), path.end(),
-                    [](const Path_t &l, const  Path_t &r)   
+                    [](const Path_t &l, const  Path_t &r)
                     { return l.node < r.node;});
             /* preserve the order of what we did before */
             std::stable_sort(path.begin(), path.end(),
-                    [](const Path_t &l, const  Path_t &r)   
+                    [](const Path_t &l, const  Path_t &r)
                     { return l.agg_cost < r.agg_cost;});
-        }                               
+        }
     }
 
     friend size_t count_tuples(const std::deque< Path > &paths) {
diff --git a/src/common/src/postgres_connection.h b/src/common/src/basic_edge.cpp
similarity index 71%
copy from src/common/src/postgres_connection.h
copy to src/common/src/basic_edge.cpp
index a7306bf..1a26931 100644
--- a/src/common/src/postgres_connection.h
+++ b/src/common/src/basic_edge.cpp
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: postgres_connection.h
+ *
 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
 vicky_vergara at hotmail.com
@@ -21,17 +21,23 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
 
-#pragma once
+#include "./basic_edge.h"
 
-#include "postgres.h"
-#include "executor/spi.h"
 
-// #include "./pgr_types.h"
+namespace pgrouting {
 
-void pgr_send_error(int errcode);
-void pgr_SPI_finish(void);
-void pgr_SPI_connect(void);
-SPIPlanPtr pgr_SPI_prepare(char* sql);
-Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan);
-char* pgr_text2char(text *in);
+    void Basic_edge::cp_members(const Basic_edge &other) {
+        this->id = other.id;
+        this->cost = other.cost;
+        this->first = other.first;
+    }
+
+}  // namespace pgrouting
diff --git a/src/pickDeliver/src/customers_input.h b/src/common/src/basic_edge.h
similarity index 69%
copy from src/pickDeliver/src/customers_input.h
copy to src/common/src/basic_edge.h
index eb8055e..811c2ee 100644
--- a/src/pickDeliver/src/customers_input.h
+++ b/src/common/src/basic_edge.h
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: edges_input.h
+ *
 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
 vicky_vergara at hotmail.com
@@ -22,25 +22,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_BASIC_EDGE_H_
+#define SRC_COMMON_SRC_BASIC_EDGE_H_
 #pragma once
 
 #include "./pgr_types.h"
-#include "./pdp.h"
-
-
-/*!
-  int64_t id;
-  double x;
-  double y;
-  double demand;
-  double Etime;
-  double Ltime;
-  double Stime;
-  int64_t Pindex;
-  int64_t Dindex;
-  double Ddist;
-*/
-void pgr_get_customers(
-        char *sql,
-        Customer **customers,
-        size_t *total_customers);
+
+
+namespace pgrouting {
+
+class Basic_edge{
+ public:
+     void cp_members(const Basic_edge &other);
+
+ public:
+     int64_t source;
+     int64_t target;
+
+     int64_t id;
+     double cost;
+     bool first;  // originally was true (source, target) false (target, source)
+};
+
+}  // namespace pgrouting
+
+#endif  // SRC_COMMON_SRC_BASIC_EDGE_H_
diff --git a/src/common/src/basic_vertex.cpp b/src/common/src/basic_vertex.cpp
new file mode 100644
index 0000000..7f4d7b3
--- /dev/null
+++ b/src/common/src/basic_vertex.cpp
@@ -0,0 +1,146 @@
+/*PGR-GNU*****************************************************************
+ *
+
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+vicky_vergara at hotmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
+
+
+#include <vector>
+#include <algorithm>
+
+#include <sstream>
+#include "./basic_vertex.h"
+#include "./pgr_types.h"
+#include "./pgr_assert.h"
+
+
+namespace pgrouting {
+
+    std::ostream& operator<<(std::ostream& log, const Basic_vertex &v) {
+        log << v.id;
+        return log;
+    }
+
+    size_t check_vertices(
+            std::vector < Basic_vertex > vertices) {
+        auto count(vertices.size());
+        std::stable_sort(
+                vertices.begin(), vertices.end(),
+                [](const Basic_vertex &lhs, const Basic_vertex &rhs)
+                {return lhs.id < rhs.id;});
+        vertices.erase(
+                std::unique(
+                    vertices.begin(), vertices.end(),
+                    [](const Basic_vertex &lhs, const Basic_vertex &rhs)
+                    {return lhs.id == rhs.id;}), vertices.end());
+
+        return vertices.size() - count;
+    }
+
+
+    std::vector < Basic_vertex > extract_vertices(
+            std::vector < Basic_vertex > vertices,
+            const std::vector <pgr_edge_t > data_edges) {
+        if (data_edges.empty()) return vertices;
+
+        vertices.reserve(vertices.size() + data_edges.size() * 2);
+
+        for (const auto edge : data_edges) {
+            Basic_vertex vertex;
+
+            vertex.id = edge.source;
+            vertices.push_back(vertex);
+
+            vertex.id = edge.target;
+            vertices.push_back(vertex);
+        }
+
+        /*
+         * sort and delete duplicates
+         */
+        std::stable_sort(vertices.begin(), vertices.end(),
+                [](const Basic_vertex &lhs, const Basic_vertex &rhs)
+                {return lhs.id < rhs.id;});
+
+        vertices.erase(
+                std::unique(vertices.begin(), vertices.end(),
+                    [](const Basic_vertex &lhs, const Basic_vertex &rhs)
+                    {return lhs.id == rhs.id;}), vertices.end());
+
+        return vertices;
+    }
+
+
+    std::vector < Basic_vertex > extract_vertices(
+            const std::vector <pgr_edge_t > data_edges) {
+        std::vector< Basic_vertex > vertices;
+        if (data_edges.empty()) return vertices;
+
+        vertices.reserve(data_edges.size() * 2);
+
+        for (const auto edge : data_edges) {
+            Basic_vertex vertex;
+
+            vertex.id = edge.source;
+            vertices.push_back(vertex);
+
+            vertex.id = edge.target;
+            vertices.push_back(vertex);
+        }
+
+        /*
+         * sort and delete duplicates
+         */
+        std::stable_sort(vertices.begin(), vertices.end(),
+                [](const Basic_vertex &lhs, const Basic_vertex &rhs)
+                {return lhs.id < rhs.id;});
+
+        vertices.erase(
+                std::unique(vertices.begin(), vertices.end(),
+                    [](const Basic_vertex &lhs, const Basic_vertex &rhs)
+                    {return lhs.id == rhs.id;}), vertices.end());
+
+        return vertices;
+    }
+
+    std::vector < Basic_vertex > extract_vertices(
+            const pgr_edge_t *data_edges, int64_t count) {
+        return extract_vertices(
+                std::vector < pgr_edge_t >(
+                    data_edges, data_edges + count));
+    }
+
+    std::vector < Basic_vertex > extract_vertices(
+            std::vector < Basic_vertex > vertices,
+            const pgr_edge_t *data_edges, int64_t count) {
+        return extract_vertices(
+                vertices, std::vector < pgr_edge_t >(
+                    data_edges, data_edges + count));
+    }
+
+}  // namespace pgrouting
diff --git a/src/common/src/basic_vertex.h b/src/common/src/basic_vertex.h
new file mode 100644
index 0000000..7373d00
--- /dev/null
+++ b/src/common/src/basic_vertex.h
@@ -0,0 +1,79 @@
+/*PGR-GNU*****************************************************************
+ *
+
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+vicky_vergara at hotmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#ifndef SRC_COMMON_SRC_BASIC_VERTEX_H_
+#define SRC_COMMON_SRC_BASIC_VERTEX_H_
+#pragma once
+
+#include <vector>
+
+#include "./pgr_types.h"
+
+
+namespace pgrouting {
+
+class Basic_vertex {
+ public:
+     Basic_vertex() :
+         id(0) {}
+     Basic_vertex(const Basic_vertex &v) :
+         id(v.id) {}
+
+     explicit Basic_vertex(const int64_t _id) :
+         id(_id) {}
+
+     Basic_vertex(const pgr_edge_t &other, bool is_source) :
+         id(is_source? other.source : other.target) {}
+
+     void cp_members(const Basic_vertex &other) {
+         this->id = other.id;
+     }
+
+
+     friend std::ostream& operator<<(std::ostream& log, const Basic_vertex &v);
+ public:
+     int64_t id;
+};
+
+size_t check_vertices(std::vector < Basic_vertex > vertices);
+
+
+std::vector < Basic_vertex > extract_vertices(
+        std::vector < Basic_vertex > vertices,
+        const pgr_edge_t *data_edges, int64_t count);
+
+std::vector < Basic_vertex > extract_vertices(
+        std::vector < Basic_vertex > vertices,
+        const std::vector < pgr_edge_t > data_edges);
+
+std::vector < Basic_vertex > extract_vertices(
+        const pgr_edge_t *data_edges, int64_t count);
+
+std::vector < Basic_vertex > extract_vertices(
+        const std::vector < pgr_edge_t > data_edges);
+
+
+}  // namespace pgrouting
+
+#endif  // SRC_COMMON_SRC_BASIC_VERTEX_H_
diff --git a/src/common/src/ch_edge.cpp b/src/common/src/ch_edge.cpp
new file mode 100644
index 0000000..5875cf7
--- /dev/null
+++ b/src/common/src/ch_edge.cpp
@@ -0,0 +1,124 @@
+/*PGR-GNU*****************************************************************
+File: ch_edge.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#include "./ch_edge.h"
+namespace pgrouting {
+namespace contraction {
+
+void Edge::cp_members(const Edge &other, std::ostringstream& log) {
+        log << "Copying members of edge\n";
+        log << other;
+        #if 0
+        this->cost = other.cost;
+        log << "after copying cost of edge\n";
+        log << *this;
+        this->first = other.first;
+        log << "after copying first of edge\n";
+        log << *this;
+        this->source = other.source;
+        log << "after copying source of edge\n";
+        log << *this;
+        this->target = other.target;
+        log << "after copying target of edge\n";
+        log << *this;
+        this->m_contracted_vertices += other.contracted_vertices();
+        log << "after adding contracted vertices\n";
+        log << *this;
+        #endif
+        this->cost = other.cost;
+        this->id = other.id;
+        this->first = other.first;
+        this->source = other.source;
+        this->target = other.target;
+        this->m_contracted_vertices += other.contracted_vertices();
+        #if 0
+        log << "copying eid: " << other.id << "\n";
+        this->id = other.id;
+        // log << "after copying id of edge\n";
+        log << *this;
+        #endif
+    }
+
+
+void Edge::cp_members(const Edge &other) {
+        
+        this->cost = other.cost;
+        this->id = other.id;
+        this->first = other.first;
+        this->source = other.source;
+        this->target = other.target;
+        this->m_contracted_vertices += other.contracted_vertices();
+    }
+
+void Edge::cp_members(const Basic_edge &other) {
+        this->id = other.id;
+        this->cost = other.cost;
+        this->first = other.first;
+    }
+bool Edge::has_contracted_vertices() const {
+    if (m_contracted_vertices.size() == 0)
+        return false;
+    return true;
+}
+
+const Identifiers<int64_t>& Edge::contracted_vertices() const {
+    return m_contracted_vertices;
+}
+
+
+void Edge::add_contracted_vertex(Vertex& v, int64_t vid) {
+    // adding the id(boost graph) of the contracted vertex v
+    m_contracted_vertices += vid;
+    // adding the ids of the contracted vertices of the given vertex v
+    m_contracted_vertices += v.contracted_vertices();
+    // empty the contracted vertices of the given vertex v
+    v.clear_contracted_vertices();
+}
+
+void Edge::add_contracted_edge_vertices(Edge &e) {
+    // adding the ids of the contracted vertices of the given edge e
+    m_contracted_vertices += e.contracted_vertices();
+    // empty the contracted vertices of the given edge e
+    e.clear_contracted_vertices();
+}
+
+std::ostream& operator <<(std::ostream& os, const Edge& e) {
+    os << "{\n    id: " << e.id << ",\n";
+    os << "    source: " << e.source << ",\n";
+    os << "    target: " << e.target << ",\n";
+    os << "    cost: " << e.cost << ",\n";
+    os << "    first: " << e.first << ",\n";
+    os << "    contracted vertices: ";
+    os << e.contracted_vertices();
+    os << "\n}";
+    os << "\n";
+    return os;
+}
+}  // namespace contraction
+}  // namespace pgrouting
diff --git a/src/common/src/ch_edge.h b/src/common/src/ch_edge.h
new file mode 100644
index 0000000..f5a424a
--- /dev/null
+++ b/src/common/src/ch_edge.h
@@ -0,0 +1,75 @@
+/*PGR-GNU*****************************************************************
+File: ch_edge.h
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#ifndef SRC_COMMON_SRC_CH_EDGE_H_
+#define SRC_COMMON_SRC_CH_EDGE_H_
+#pragma once
+
+#include <iostream>
+#include <sstream>
+#include "./ch_vertex.h"
+#include "./basic_edge.h"
+namespace pgrouting {
+namespace contraction {
+
+class Edge {
+ public:
+     Edge() = default;
+     Edge(int64_t eid, int64_t source, int64_t target, double cost) :
+         id(eid), source(source),
+         target(target), cost(cost), first(true) {}
+     Edge(int64_t eid, int64_t source, int64_t target,
+             double cost, bool first) :
+         id(eid), source(source),
+         target(target), cost(cost), first(first) {}
+
+     void cp_members(const Edge &other, std::ostringstream& log);
+     void cp_members(const Edge &other);
+     void cp_members(const Basic_edge &other);
+     void add_contracted_vertex(Vertex& v, int64_t vid);
+     void add_contracted_edge_vertices(Edge& e);
+     bool has_contracted_vertices() const;
+     void clear_contracted_vertices() { m_contracted_vertices.clear(); }
+     const Identifiers<int64_t>& contracted_vertices() const;
+     friend std::ostream& operator <<(std::ostream& os, const Edge& e);
+
+ public:
+     int64_t id;
+     int64_t source;
+     int64_t target;
+     double cost;
+     bool first;
+ private:
+     Identifiers<int64_t> m_contracted_vertices;
+};
+
+}  // namespace contraction
+}  // namespace pgrouting
+
+#endif  // SRC_COMMON_SRC_CH_EDGE_H_
diff --git a/src/common/src/ch_vertex.cpp b/src/common/src/ch_vertex.cpp
new file mode 100644
index 0000000..7ed5a99
--- /dev/null
+++ b/src/common/src/ch_vertex.cpp
@@ -0,0 +1,120 @@
+/*PGR-GNU*****************************************************************
+File: ch_vertex.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#include <algorithm>
+#include <vector>
+#include "./ch_vertex.h"
+
+namespace pgrouting {
+namespace contraction {
+
+
+const Identifiers<int64_t>& Vertex::contracted_vertices() const {
+    return m_contracted_vertices;
+}
+
+
+bool Vertex::has_contracted_vertices() const {
+    if (m_contracted_vertices.size() == 0)
+        return false;
+    return true;
+}
+
+void Vertex::add_contracted_vertex(Vertex& v, int64_t vid) {
+    // adding the id(boost graph) of the contracted vertex v
+    m_contracted_vertices += vid;
+    // adding the ids of the contracted vertices of the given vertex v
+    m_contracted_vertices += v.contracted_vertices();
+    // empty the contracted vertices of the given vertex v
+    v.clear_contracted_vertices();
+}
+
+std::ostream& operator <<(std::ostream& os, const Vertex& v) {
+    os << "{\n    id: " << v.id << ",\n";
+    os << "    contracted vertices: ";
+    os << v.contracted_vertices();
+    os << "\n}";
+    os << "\n";
+    return os;
+}
+
+
+size_t
+check_vertices(
+    std::vector < Vertex > vertices) {
+    auto count(vertices.size());
+    std::stable_sort(
+        vertices.begin(), vertices.end(),
+        [](const Vertex &lhs, const Vertex &rhs)
+        {return lhs.id < rhs.id;});
+    vertices.erase(
+        std::unique(
+            vertices.begin(), vertices.end(),
+            [](const Vertex &lhs, const Vertex &rhs)
+            {return lhs.id == rhs.id;}), vertices.end());
+    return count - vertices.size();
+}
+
+std::vector < Vertex >
+extract_vertices(
+    const std::vector <pgr_edge_t > &data_edges) {
+    std::vector< Vertex > vertices;
+    if (data_edges.empty()) return vertices;
+    vertices.reserve(data_edges.size() * 2);
+    for (const auto edge : data_edges) {
+        Vertex v_source(edge, true);
+        vertices.push_back(v_source);
+
+        Vertex v_target(edge, false);
+        vertices.push_back(v_target);
+    }
+    /*
+     * sort and delete duplicates
+     */
+    std::stable_sort(
+        vertices.begin(), vertices.end(),
+        [](const Vertex &lhs, const Vertex &rhs)
+        {return lhs.id < rhs.id;});
+    vertices.erase(
+        std::unique(
+            vertices.begin(), vertices.end(),
+            [](const Vertex &lhs, const Vertex &rhs)
+            {return lhs.id == rhs.id;}), vertices.end());
+    return vertices;
+}
+
+std::vector < Vertex >
+extract_vertices(
+    const pgr_edge_t *data_edges,
+    int64_t count) {
+    return extract_vertices(
+        std::vector < pgr_edge_t >(data_edges, data_edges + count));
+}
+
+}  // namespace contraction
+}  // namespace pgrouting
diff --git a/src/common/src/ch_vertex.h b/src/common/src/ch_vertex.h
new file mode 100644
index 0000000..aebe9b5
--- /dev/null
+++ b/src/common/src/ch_vertex.h
@@ -0,0 +1,76 @@
+/*PGR-GNU*****************************************************************
+File: ch_vertex.h
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#ifndef SRC_COMMON_SRC_CH_VERTEX_H_
+#define SRC_COMMON_SRC_CH_VERTEX_H_
+#include <iostream>
+#include <sstream>
+#include <vector>
+
+#include "./pgr_types.h"
+#include "./identifiers.hpp"
+
+namespace pgrouting {
+namespace contraction {
+
+
+class Vertex {
+ public:
+    int64_t id;
+    Vertex() = default;
+    Vertex(const Vertex &) = default;
+    Vertex(const pgr_edge_t &other, bool is_source) :
+      id(is_source? other.source : other.target)
+      {}
+    void cp_members(const Vertex &other) {
+        this->id = other.id;
+    }
+    void add_contracted_vertex(Vertex& v, int64_t vid);
+    void add_vertex_id(int64_t vid) {m_contracted_vertices += vid;}
+    const Identifiers<int64_t>& contracted_vertices() const;
+    bool has_contracted_vertices() const;
+    void clear_contracted_vertices() {m_contracted_vertices.clear();}
+    friend std::ostream& operator <<(std::ostream& os, const Vertex& v);
+ private:
+    Identifiers<int64_t> m_contracted_vertices;
+};
+
+size_t
+check_vertices(std::vector < Vertex > vertices);
+
+std::vector < Vertex >
+extract_vertices(
+    const pgr_edge_t *data_edges, int64_t count);
+
+std::vector < Vertex >
+extract_vertices(
+    const std::vector < pgr_edge_t > &data_edges);
+
+}  // namespace contraction
+}  // namespace pgrouting
+#endif  // SRC_COMMON_SRC_CH_VERTEX_H_
diff --git a/src/tsp/src/distances_input.c b/src/common/src/coordinates_input.c
similarity index 54%
copy from src/tsp/src/distances_input.c
copy to src/common/src/coordinates_input.c
index 01a8989..cfca56d 100644
--- a/src/tsp/src/distances_input.c
+++ b/src/common/src/coordinates_input.c
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: distances_input.c
+File: matrixRows_input.c
 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
 vicky_vergara at hotmail.com
@@ -23,35 +23,43 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 // #define DEBUG
+#include "./coordinates_input.h"
+
 #include "./debug_macro.h"
-#include "./../../common/src/pgr_types.h"
-#include "./../../common/src/postgres_connection.h"
-#include "./../../common/src/get_check_data.h"
-#include "./distances_input.h"
+#include "./pgr_types.h"
+#include "./postgres_connection.h"
+#include "./get_check_data.h"
+#include "./time_msg.h"
 
 
 
 static
-void pgr_fetch_distance(
+void pgr_fetch_row(
         HeapTuple *tuple,
         TupleDesc *tupdesc,
         Column_info_t info[3],
-        Matrix_cell_t *distance) {
-
-    distance->from_vid = pgr_SPI_getBigInt(tuple, tupdesc,  info[0]);
-    distance->to_vid = pgr_SPI_getBigInt(tuple, tupdesc,  info[1]);
-    distance->cost = pgr_SPI_getFloat8(tuple, tupdesc, info[2]);
+        int64_t *default_id,
+        Coordinate_t *distance) {
+    if (column_found(info[0].colNumber)) {
+        distance->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
+    } else {
+        distance->id = *default_id;
+        ++(*default_id);
+    }
+    distance->x = pgr_SPI_getFloat8(tuple, tupdesc,  info[1]);
+    distance->y = pgr_SPI_getFloat8(tuple, tupdesc, info[2]);
 }
 
 /*!
- * bigint start_vid,
- * bigint end_vid,
- * float agg_cost,
+ * bigint id,
+ * float x,
+ * float y,
  */
-void pgr_get_distances(
+void pgr_get_coordinates(
         char *sql,
-        Matrix_cell_t **distances,
-        size_t *total_distances) {
+        Coordinate_t **coordinates,
+        size_t *total_coordinates) {
+    clock_t start_t = clock();
 
     const int tuple_limit = 1000000;
 
@@ -65,13 +73,14 @@ void pgr_get_distances(
         info[i].colNumber = -1;
         info[i].type = 0;
         info[i].strict = true;
-        info[i].eType = ANY_INTEGER;
+        info[i].eType = ANY_NUMERICAL;
     }
-    info[0].name = strdup("start_vid");
-    info[1].name = strdup("end_vid");
-    info[2].name = strdup("agg_cost");
+    info[0].name = strdup("id");
+    info[1].name = strdup("x");
+    info[2].name = strdup("y");
 
-    info[2].eType = ANY_NUMERICAL;
+    info[0].eType = ANY_INTEGER;
+    info[0].strict = false;
 
 
     void *SPIplan;
@@ -82,35 +91,41 @@ void pgr_get_distances(
 
 
     bool moredata = TRUE;
-    (*total_distances) = total_tuples;
+    (*total_coordinates) = total_tuples;
+
+    int64_t default_id = 1;
 
     while (moredata == TRUE) {
         SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
         if (total_tuples == 0)
-            pgr_fetch_column_info(info, 5);
+            pgr_fetch_column_info(info, 3);
 
         ntuples = SPI_processed;
         total_tuples += ntuples;
 
         if (ntuples > 0) {
-            if ((*distances) == NULL)
-                (*distances) = (Matrix_cell_t *)palloc0(total_tuples * sizeof(Matrix_cell_t));
+            if ((*coordinates) == NULL)
+                (*coordinates) = (Coordinate_t *)
+                    palloc0(total_tuples * sizeof(Coordinate_t));
             else
-                (*distances) = (Matrix_cell_t *)repalloc((*distances), total_tuples * sizeof(Matrix_cell_t));
+                (*coordinates) = (Coordinate_t *)
+                    repalloc((*coordinates),
+                            total_tuples * sizeof(Coordinate_t));
 
-            if ((*distances) == NULL) {
+            if ((*coordinates) == NULL) {
                 elog(ERROR, "Out of memory");
             }
 
             SPITupleTable *tuptable = SPI_tuptable;
             TupleDesc tupdesc = SPI_tuptable->tupdesc;
-            PGR_DBG("processing %d edge tupĺes", ntuples);
+            PGR_DBG("Processing %ld coordinates tupĺes", ntuples);
 
             size_t t;
             for (t = 0; t < ntuples; t++) {
                 HeapTuple tuple = tuptable->vals[t];
-                pgr_fetch_distance(&tuple, &tupdesc, info,
-                        &(*distances)[total_tuples - ntuples + t]);
+                pgr_fetch_row(&tuple, &tupdesc, info,
+                        &default_id,
+                        &(*coordinates)[total_tuples - ntuples + t]);
             }
             SPI_freetuptable(tuptable);
         } else {
@@ -120,11 +135,11 @@ void pgr_get_distances(
 
 
     if (total_tuples == 0) {
-        (*total_distances) = 0;
-        PGR_DBG("NO distances");
+        (*total_coordinates) = 0;
+        PGR_DBG("NO coordinates");
         return;
     }
 
-    (*total_distances) = total_tuples;
-    PGR_DBG("Finish reading %ld edges, %ld", total_tuples, (*total_distances));
+    (*total_coordinates) = total_tuples;
+    time_msg(" reading coordinates:", start_t, clock());
 }
diff --git a/src/tsp/src/distances_input.h b/src/common/src/coordinates_input.h
similarity index 75%
copy from src/tsp/src/distances_input.h
copy to src/common/src/coordinates_input.h
index b5401ea..f9a8cfe 100644
--- a/src/tsp/src/distances_input.h
+++ b/src/common/src/coordinates_input.h
@@ -1,5 +1,6 @@
 /*PGR-GNU*****************************************************************
 File: distances_input.h
+#include "./pgr_types.h"
 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
 vicky_vergara at hotmail.com
@@ -21,17 +22,20 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-
+#ifndef SRC_COMMON_SRC_COORDINATES_INPUT_H_
+#define SRC_COMMON_SRC_COORDINATES_INPUT_H_
 #pragma once
 
-#include "./../../common/src/pgr_types.h"
+#include "./pgr_types.h"
 
 /*!
-  bigint start_vid,
-  bigint end_vid,
-  float agg_cost,
+  bigint id,
+  float x,
+  float y,
   */
-void pgr_get_distances(
+void pgr_get_coordinates(
         char *sql,
-        Matrix_cell_t **distaces,
-        size_t *total_distances);
+        Coordinate_t **coordinates,
+        size_t *total_coordinates);
+
+#endif  // SRC_COMMON_SRC_COORDINATES_INPUT_H_
diff --git a/src/common/src/debug_macro.h b/src/common/src/debug_macro.h
index 62af333..63bb809 100644
--- a/src/common/src/debug_macro.h
+++ b/src/common/src/debug_macro.h
@@ -23,13 +23,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_DEBUG_MACRO_H_
+#define SRC_COMMON_SRC_DEBUG_MACRO_H_
 #pragma once
 
-#ifdef DEBUG
-#include "postgres.h"
+#ifndef NDEBUG
+#include <postgres.h>
+
 #define PGR_DBG(...) \
-    elog(NOTICE, __VA_ARGS__)
+    elog(DEBUG2, __VA_ARGS__)
 #else
 #define PGR_DBG(...) do { ; } while (0)
 #endif
 
+#endif  // SRC_COMMON_SRC_DEBUG_MACRO_H_
diff --git a/src/common/src/edges_input.c b/src/common/src/edges_input.c
index acb0db3..f5cd114 100644
--- a/src/common/src/edges_input.c
+++ b/src/common/src/edges_input.c
@@ -30,10 +30,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./edges_input.h"
 #include "./time_msg.h"
 
+static
+void fetch_basic_edge(
+    HeapTuple *tuple,
+    TupleDesc *tupdesc,
+    Column_info_t info[5],
+    int64_t *default_id,
+    pgr_basic_edge_t *edge,
+    size_t *valid_edges) {
+    if (column_found(info[0].colNumber)) {
+        edge->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
+    } else {
+        edge->id = *default_id;
+        ++(*default_id);
+    }
 
+    edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
+    edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
+    edge->going = pgr_SPI_getFloat8(tuple, tupdesc, info[3]) > 0 ? true : false;
+    edge->coming = (column_found(info[4].colNumber) && pgr_SPI_getFloat8(tuple, tupdesc, info[4]) > 0) ? true : false;
+
+    (*valid_edges)++;
+}
 
 static
-void pgr_fetch_edge(
+void fetch_edge(
         HeapTuple *tuple,
         TupleDesc *tupdesc,
         Column_info_t info[5],
@@ -63,8 +84,158 @@ void pgr_fetch_edge(
 }
 
 static
+void fetch_edge_with_xy(
+        HeapTuple *tuple,
+        TupleDesc *tupdesc,
+        Column_info_t info[9],
+        int64_t *default_id,
+        float8 default_rcost,
+        Pgr_edge_xy_t *edge,
+        size_t *valid_edges,
+        bool normal) {
+    if (column_found(info[0].colNumber)) {
+        edge->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
+    } else {
+        edge->id = *default_id;
+        ++(*default_id);
+    }
+
+    if (normal) {
+        edge->source = pgr_SPI_getBigInt(tuple, tupdesc,  info[1]);
+        edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
+    } else {
+        edge->target = pgr_SPI_getBigInt(tuple, tupdesc,  info[1]);
+        edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
+    }
+    edge->cost = pgr_SPI_getFloat8(tuple, tupdesc, info[3]);
+
+    if (column_found(info[4].colNumber)) {
+        edge->reverse_cost = pgr_SPI_getFloat8(tuple, tupdesc, info[4]);
+    } else {
+        edge->reverse_cost = default_rcost;
+    }
+
+    edge->x1 = pgr_SPI_getFloat8(tuple, tupdesc, info[5]);
+    edge->y1 = pgr_SPI_getFloat8(tuple, tupdesc, info[6]);
+    edge->x2 = pgr_SPI_getFloat8(tuple, tupdesc, info[7]);
+    edge->y2 = pgr_SPI_getFloat8(tuple, tupdesc, info[8]);
+
+    *valid_edges = edge->cost < 0? *valid_edges: *valid_edges + 1;
+    *valid_edges = edge->reverse_cost < 0? *valid_edges: *valid_edges + 1;
+}
+
+static
 void
-get_data_5_columns(
+get_edges_9_columns(
+        char *sql,
+        Pgr_edge_xy_t **edges,
+        size_t *total_edges,
+        bool normal) {
+    clock_t start_t = clock();
+
+    const int tuple_limit = 1000000;
+
+    size_t ntuples;
+    size_t total_tuples;
+    size_t valid_edges;
+
+    Column_info_t info[9];
+
+    info[0].name = strdup("id");
+    info[1].name = strdup("source");
+    info[2].name = strdup("target");
+    info[3].name = strdup("cost");
+    info[4].name = strdup("reverse_cost");
+    info[5].name = strdup("x1");
+    info[6].name = strdup("y1");
+    info[7].name = strdup("x2");
+    info[8].name = strdup("y2");
+
+    int i;
+    for (i = 0; i < 3; ++i) {
+        info[i].colNumber = -1;
+        info[i].type = 0;
+        info[i].strict = true;
+        info[i].eType = ANY_INTEGER;
+    }
+    for (i = 3; i < 9; ++i) {
+        info[i].colNumber = -1;
+        info[i].type = 0;
+        info[i].strict = true;
+        info[i].eType = ANY_NUMERICAL;
+    }
+    /*
+     * reverse_cost is optional
+     */
+    info[4].strict = false;
+
+
+    void *SPIplan;
+    SPIplan = pgr_SPI_prepare(sql);
+
+    Portal SPIportal;
+    SPIportal = pgr_SPI_cursor_open(SPIplan);
+
+
+    bool moredata = TRUE;
+    (*total_edges) = total_tuples = valid_edges = 0;
+
+
+    int64_t default_id = 0;
+    while (moredata == TRUE) {
+        SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
+        if (total_tuples == 0)
+            pgr_fetch_column_info(info, 9);
+
+        ntuples = SPI_processed;
+        total_tuples += ntuples;
+
+        if (ntuples > 0) {
+            if ((*edges) == NULL)
+                (*edges) = (Pgr_edge_xy_t *)
+                    palloc0(total_tuples * sizeof(Pgr_edge_xy_t));
+            else
+                (*edges) = (Pgr_edge_xy_t *)
+                    repalloc((*edges), total_tuples * sizeof(Pgr_edge_xy_t));
+
+            if ((*edges) == NULL) {
+                elog(ERROR, "Out of memory");
+            }
+
+            size_t t;
+            SPITupleTable *tuptable = SPI_tuptable;
+            TupleDesc tupdesc = SPI_tuptable->tupdesc;
+            PGR_DBG("processing %ld edge tupĺes", ntuples);
+
+            for (t = 0; t < ntuples; t++) {
+                HeapTuple tuple = tuptable->vals[t];
+                fetch_edge_with_xy(&tuple, &tupdesc, info,
+                        &default_id, -1,
+                        &(*edges)[total_tuples - ntuples + t],
+                        &valid_edges, normal);
+            }
+            SPI_freetuptable(tuptable);
+        } else {
+            moredata = FALSE;
+        }
+    }
+
+
+    if (total_tuples == 0 || valid_edges == 0) {
+        PGR_DBG("NO edges found");
+        return;
+    }
+
+    (*total_edges) = total_tuples;
+    PGR_DBG("Finish reading %ld edges, %ld", total_tuples, (*total_edges));
+    time_msg(" reading Edges with xy", start_t, clock());
+}
+
+
+
+static
+void
+get_edges_5_columns(
         char *sql,
         pgr_edge_t **edges,
         size_t *totalTuples,
@@ -121,9 +292,11 @@ get_data_5_columns(
 
         if (ntuples > 0) {
             if ((*edges) == NULL)
-                (*edges) = (pgr_edge_t *)palloc0(total_tuples * sizeof(pgr_edge_t));
+                (*edges) = (pgr_edge_t *)
+                    palloc0(total_tuples * sizeof(pgr_edge_t));
             else
-                (*edges) = (pgr_edge_t *)repalloc((*edges), total_tuples * sizeof(pgr_edge_t));
+                (*edges) = (pgr_edge_t *)
+                    repalloc((*edges), total_tuples * sizeof(pgr_edge_t));
 
             if ((*edges) == NULL) {
                 elog(ERROR, "Out of memory");
@@ -132,11 +305,11 @@ get_data_5_columns(
             size_t t;
             SPITupleTable *tuptable = SPI_tuptable;
             TupleDesc tupdesc = SPI_tuptable->tupdesc;
-            PGR_DBG("processing %d edge tupĺes", ntuples);
+            PGR_DBG("processing %ld edge tupĺes", ntuples);
 
             for (t = 0; t < ntuples; t++) {
                 HeapTuple tuple = tuptable->vals[t];
-                pgr_fetch_edge(&tuple, &tupdesc, info,
+                fetch_edge(&tuple, &tupdesc, info,
                         &default_id, -1,
                         &(*edges)[total_tuples - ntuples + t],
                         &valid_edges);
@@ -154,6 +327,195 @@ get_data_5_columns(
         return;
     }
 
+    (*totalTuples) = total_tuples;
+    PGR_DBG("Finish reading %ld edges, %ld", total_tuples, (*totalTuples));
+    time_msg(" reading Edges", start_t, clock());
+}
+
+static
+void
+get_edges_flow(
+    char *sql,
+    pgr_edge_t **edges,
+    size_t *totalTuples,
+    bool ignore_id) {
+    clock_t start_t = clock();
+
+    const int tuple_limit = 1000000;
+
+    size_t ntuples;
+    size_t total_tuples;
+    size_t valid_edges;
+
+    Column_info_t info[5];
+
+    int i;
+    for (i = 0; i < 5; ++i) {
+        info[i].colNumber = -1;
+        info[i].type = 0;
+        info[i].strict = true;
+        info[i].eType = ANY_INTEGER;
+    }
+    info[0].name = strdup("id");
+    info[1].name = strdup("source");
+    info[2].name = strdup("target");
+    info[3].name = strdup("capacity");
+    info[4].name = strdup("reverse_capacity");
+
+    info[0].strict = !ignore_id;
+    info[4].strict = false;
+
+    void *SPIplan;
+    SPIplan = pgr_SPI_prepare(sql);
+
+    Portal SPIportal;
+    SPIportal = pgr_SPI_cursor_open(SPIplan);
+
+
+    bool moredata = TRUE;
+    (*totalTuples) = total_tuples = valid_edges = 0;
+
+
+    int64_t default_id = 0;
+    while (moredata == TRUE) {
+        SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
+        if (total_tuples == 0)
+            pgr_fetch_column_info(info, 5);
+
+        ntuples = SPI_processed;
+        total_tuples += ntuples;
+
+        if (ntuples > 0) {
+            if ((*edges) == NULL)
+                (*edges) = (pgr_edge_t *)palloc0(total_tuples * sizeof(pgr_flow_t));
+            else
+                (*edges) = (pgr_edge_t *)repalloc((*edges), total_tuples * sizeof(pgr_flow_t));
+
+            if ((*edges) == NULL) {
+                elog(ERROR, "Out of memory");
+            }
+
+            size_t t;
+            SPITupleTable *tuptable = SPI_tuptable;
+            TupleDesc tupdesc = SPI_tuptable->tupdesc;
+            PGR_DBG("processing %lu edge tupĺes", ntuples);
+
+            for (t = 0; t < ntuples; t++) {
+                HeapTuple tuple = tuptable->vals[t];
+                fetch_edge(&tuple, &tupdesc, info,
+                           &default_id, -1,
+                           &(*edges)[total_tuples - ntuples + t],
+                           &valid_edges);
+            }
+            SPI_freetuptable(tuptable);
+        } else {
+            moredata = FALSE;
+        }
+    }
+
+
+    if (total_tuples == 0 || valid_edges == 0) {
+        (*totalTuples) = 0;
+        PGR_DBG("NO edges");
+        return;
+    }
+
+    (*totalTuples) = total_tuples;
+    PGR_DBG("Finish reading %ld edges, %ld", total_tuples, (*totalTuples));
+    time_msg(" reading Edges", start_t, clock());
+}
+
+static
+void
+get_edges_basic(
+    char *sql,
+    pgr_basic_edge_t **edges,
+    size_t *totalTuples,
+    bool ignore_id) {
+    clock_t start_t = clock();
+
+    const int tuple_limit = 1000000;
+
+    size_t ntuples;
+    size_t total_tuples;
+    size_t valid_edges;
+
+    Column_info_t info[5];
+
+    int i;
+    for (i = 0; i < 5; ++i) {
+        info[i].colNumber = -1;
+        info[i].type = 0;
+        info[i].strict = true;
+        info[i].eType = ANY_INTEGER;
+    }
+    info[0].name = strdup("id");
+    info[1].name = strdup("source");
+    info[2].name = strdup("target");
+    info[3].name = strdup("going");
+    info[4].name = strdup("coming");
+
+    info[0].strict = !ignore_id;
+    info[4].strict = false;
+
+    info[3].eType = ANY_NUMERICAL;
+    info[4].eType = ANY_NUMERICAL;
+
+
+    void *SPIplan;
+    SPIplan = pgr_SPI_prepare(sql);
+
+    Portal SPIportal;
+    SPIportal = pgr_SPI_cursor_open(SPIplan);
+
+
+    bool moredata = TRUE;
+    (*totalTuples) = total_tuples = valid_edges = 0;
+
+
+    int64_t default_id = 0;
+    while (moredata == TRUE) {
+        SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
+        if (total_tuples == 0)
+            pgr_fetch_column_info(info, 5);
+
+        ntuples = SPI_processed;
+        total_tuples += ntuples;
+
+        if (ntuples > 0) {
+            if ((*edges) == NULL)
+                (*edges) = (pgr_basic_edge_t *)palloc0(total_tuples * sizeof(pgr_basic_edge_t));
+            else
+                (*edges) = (pgr_basic_edge_t *)repalloc((*edges), total_tuples * sizeof(pgr_basic_edge_t));
+
+            if ((*edges) == NULL) {
+                elog(ERROR, "Out of memory");
+            }
+
+            size_t t;
+            SPITupleTable *tuptable = SPI_tuptable;
+            TupleDesc tupdesc = SPI_tuptable->tupdesc;
+            PGR_DBG("processing %ld edge tupĺes", ntuples);
+
+            for (t = 0; t < ntuples; t++) {
+                HeapTuple tuple = tuptable->vals[t];
+                fetch_basic_edge(&tuple, &tupdesc, info,
+                           &default_id,
+                           &(*edges)[total_tuples - ntuples + t],
+                           &valid_edges);
+            }
+            SPI_freetuptable(tuptable);
+        } else {
+            moredata = FALSE;
+        }
+    }
+
+
+    if (total_tuples == 0 || valid_edges == 0) {
+        (*totalTuples) = 0;
+        PGR_DBG("NO edges");
+        return;
+    }
 
     (*totalTuples) = total_tuples;
     PGR_DBG("Finish reading %ld edges, %ld", total_tuples, (*totalTuples));
@@ -161,19 +523,52 @@ get_data_5_columns(
 }
 
 void
-pgr_get_data_5_columns(
-        char *sql,
+pgr_get_flow_edges(
+    char *sql,
+    pgr_edge_t **edges,
+    size_t *total_edges) {
+    bool ignore_id = false;
+    get_edges_flow(sql, edges, total_edges, ignore_id);
+}
+
+void
+pgr_get_edges(
+        char *edges_sql,
         pgr_edge_t **edges,
-        size_t *totalTuples) {
+        size_t *total_edges) {
     bool ignore_id = false;
-    get_data_5_columns(sql, edges, totalTuples, ignore_id);
+    get_edges_5_columns(edges_sql, edges, total_edges, ignore_id);
 }
 
 void
-pgr_get_data_4_columns(
-        char *sql,
+pgr_get_edges_no_id(
+        char *edges_sql,
         pgr_edge_t **edges,
-        size_t *totalTuples) {
+        size_t *total_edges) {
     bool ignore_id = true;
-    get_data_5_columns(sql, edges, totalTuples, ignore_id);
+    get_edges_5_columns(edges_sql, edges, total_edges, ignore_id);
+}
+
+void
+pgr_get_edges_xy(
+        char *edges_sql,
+        Pgr_edge_xy_t **edges,
+        size_t *total_edges) {
+    get_edges_9_columns(edges_sql, edges, total_edges, true);
+}
+void
+pgr_get_edges_xy_reversed(
+        char *edges_sql,
+        Pgr_edge_xy_t **edges,
+        size_t *total_edges) {
+    get_edges_9_columns(edges_sql, edges, total_edges, false);
+}
+
+void
+pgr_get_basic_edges(
+    char *sql,
+    pgr_basic_edge_t **edges,
+    size_t *total_edges) {
+    bool ignore_id = false;
+    get_edges_basic(sql, edges, total_edges, ignore_id);
 }
diff --git a/src/common/src/edges_input.h b/src/common/src/edges_input.h
index a17c5b9..5585f7d 100644
--- a/src/common/src/edges_input.h
+++ b/src/common/src/edges_input.h
@@ -22,31 +22,216 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_EDGES_INPUT_H_
+#define SRC_COMMON_SRC_EDGES_INPUT_H_
 #pragma once
 
 #include "./pgr_types.h"
 
-/*!
-  Signature 1:
-  bigint source,
-  bigint target,
-  float cost
-  float reverse_cost
-  */
-void pgr_get_data_4_columns(
-        char *sql,
+
+/*! @brief edges_sql without id parameter
+ 
+~~~~{.c}
+SELECT source, target, cost, [reverse_cost]
+FROM edge_table;
+~~~~
+
+Currently used in: allpairs
+
+ at param[in] edges_sql
+ at param[out] edges
+ at param[out] total_edges
+*/
+void pgr_get_edges_no_id(
+        char *edges_sql,
         pgr_edge_t **edges,
-        size_t *total_tuples);
-
-/*!
-  Signature 1:
-  bigint id,
-  bigint source,
-  bigint target,
-  float cost
-  float reverse_cost
-  */
-void pgr_get_data_5_columns(
-        char *sql,
+        size_t *total_edges);
+
+
+
+
+
+/*! @brief basic edge_sql
+
+For queries of the type:
+~~~~{.c}
+SELECT id, source, target, cost, [reverse_cost]
+FROM edge_table;
+~~~~
+
+ at param[in] edges_sql
+ at param[out] edges
+ at param[out] total_edges
+*/
+void pgr_get_edges(
+        char *edges_sql,
         pgr_edge_t **edges,
-        size_t *total_tuples);
+        size_t *total_edges);
+
+
+
+/*! @brief Edges with x, y vertices values
+
+For queries of the type:
+~~~~{.c}
+SELECT id, source, target, cost, [reverse_cost], x1, y1, x2, y2
+FROM edge_table;
+~~~~
+
+ at param[in] edges_sql
+ at param[out] edges
+ at param[out] total_edges
+*/
+void pgr_get_edges_xy(
+        char *edges_sql,
+        Pgr_edge_xy_t **edges,
+        size_t *total_edges);
+
+/*! @brief for many to 1 on aStar
+
+Used internally
+
+Transforms queries of the type:
+~~~~{.c}
+SELECT id, source, target, cost, [reverse_cost], x1, y1, x2, y2
+FROM edge_table;
+~~~~
+
+to
+~~~~{.c}
+SELECT id, target, source, cost, [reverse_cost], x1, y1, x2, y2
+FROM edge_table;
+~~~~
+
+ at param[in] edges_sql
+ at param[out] edges
+ at param[out] total_edges
+*/
+void pgr_get_edges_xy_reversed(
+        char *edges_sql,
+        Pgr_edge_xy_t **edges,
+        size_t *total_edges);
+
+
+/*! @brief read edges for flow
+
+Edges:
+
+bigint id,
+bigint source,
+bigint target,
+bigint capacity,
+bigint reverse_capacity
+
+ at param[in] sql
+ at param[out] edges
+ at param[out] total_edges
+*/
+void pgr_get_flow_edges(
+    char *sql,
+    pgr_edge_t **edges,
+    size_t *total_edges);
+
+/*! @brief read basic edges
+
+Edges:
+
+bigint id,
+bigint source,
+bigint target
+
+ at param[in] sql
+ at param[out] edges
+ at param[out] total_edges
+*/
+void pgr_get_basic_edges(
+    char *sql,
+    pgr_basic_edge_t **edges,
+    size_t *total_edges);
+
+/* **************** FOR USERS DOCUMENTATION
+basic_edges_sql_start
+
+Description of the edges_sql query
+...............................................................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+================  ===================   ======== =================================================
+Column            Type                  Default  Description
+================  ===================   ======== =================================================
+**id**            ``ANY-INTEGER``                Identifier of the edge.
+**source**        ``ANY-INTEGER``                Identifier of the first end point vertex of the edge.
+**target**        ``ANY-INTEGER``                Identifier of the second end point vertex of the edge.
+**cost**          ``ANY-NUMERICAL``              Weight of the edge  `(source, target)`
+                                                   - When negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
+**reverse_cost**  ``ANY-NUMERICAL``       -1     Weight of the edge `(target, source)`,
+                                                   - When negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
+================  ===================   ======== =================================================
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+
+basic_edges_sql_end
+
+no_id_edges_sql_start
+
+Description of the edges_sql query
+...............................................................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+================  ===================   ======== =================================================
+Column            Type                  Default  Description
+================  ===================   ======== =================================================
+**source**        ``ANY-INTEGER``                Identifier of the first end point vertex of the edge.
+**target**        ``ANY-INTEGER``                Identifier of the second end point vertex of the edge.
+**cost**          ``ANY-NUMERICAL``              Weight of the edge  `(source, target)`
+                                                  * When negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
+**reverse_cost**  ``ANY-NUMERICAL``       -1     Weight of the edge `(target, source)`,
+                                                  - When negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
+================  ===================   ======== =================================================
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+
+no_id_edges_sql_end
+
+
+xy_edges_sql_start
+
+Description of the edges_sql query
+...............................................................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+================  ===================   ======== =================================================
+Column            Type                  Default  Description
+================  ===================   ======== =================================================
+**id**            ``ANY-INTEGER``                Identifier of the edge.
+**source**        ``ANY-INTEGER``                Identifier of the first end point vertex of the edge.
+**target**        ``ANY-INTEGER``                Identifier of the second end point vertex of the edge.
+**cost**          ``ANY-NUMERICAL``              Weight of the edge  `(source, target)`
+                                                   - When negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
+**reverse_cost**  ``ANY-NUMERICAL``       -1     Weight of the edge `(target, source)`,
+                                                   - When negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
+
+**x1**            ``ANY-NUMERICAL``              X coordinate of `source` vertex.
+**y1**            ``ANY-NUMERICAL``              Y coordinate of `source` vertex.
+**x2**            ``ANY-NUMERICAL``              X coordinate of `target` vertex.
+**y2**            ``ANY-NUMERICAL``              Y coordinate of `target` vertex.
+================  ===================   ======== =================================================
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+
+xy_edges_sql_end
+*/
+
+#endif  // SRC_COMMON_SRC_EDGES_INPUT_H_
diff --git a/src/common/src/get_check_data.c b/src/common/src/get_check_data.c
index 7aa4f1c..62e1144 100644
--- a/src/common/src/get_check_data.c
+++ b/src/common/src/get_check_data.c
@@ -22,14 +22,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "./pgr_types.h"
-#include "postgres.h"
-
+#include <postgres.h>
 #include "catalog/pg_type.h"
 #include "executor/spi.h"
 
 
 // #define DEBUG
+#include "./pgr_types.h"
 #include "./debug_macro.h"
 #include "./get_check_data.h"
 
@@ -60,7 +59,7 @@ fetch_column_info(
         if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
             elog(ERROR, "Type of column '%s' not Found", info->name);
         }
-        PGR_DBG("Column %s found: %llu", info->name, info->type);
+        PGR_DBG("Column %s found: %lu", info->name, info->type);
         return true;
     }
     PGR_DBG("Column %s not found", info->name);
@@ -182,7 +181,7 @@ pgr_SPI_getBigInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
                     "Unexpected Column type of %s. Expected ANY-INTEGER",
                     info.name);
     }
-    PGR_DBG("Variable: %s Value: %lld", info.name, value);
+    PGR_DBG("Variable: %s Value: %ld", info.name, value);
     return value;
 }
 
diff --git a/src/common/src/get_check_data.h b/src/common/src/get_check_data.h
index 69313c2..85ac8a8 100644
--- a/src/common/src/get_check_data.h
+++ b/src/common/src/get_check_data.h
@@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_GET_CHECK_DATA_H_
+#define SRC_COMMON_SRC_GET_CHECK_DATA_H_
 #pragma once
 
 bool column_found(int colNumber);
@@ -34,6 +36,8 @@ void pgr_check_any_integer_type(Column_info_t info);
 void pgr_check_any_numerical_type(Column_info_t info);
 void pgr_check_text_type(Column_info_t info);
 void pgr_check_char_type(Column_info_t info);
+void pgr_check_boolean_type(Column_info_t info);
+
 
 char pgr_SPI_getChar(
         HeapTuple *tuple,
@@ -58,3 +62,5 @@ char* pgr_SPI_getText(
         Column_info_t info);
 
 char* pgr_stradd(const char *a, const char *b);
+
+#endif  // SRC_COMMON_SRC_GET_CHECK_DATA_H_
diff --git a/src/common/src/identifiers.hpp b/src/common/src/identifiers.hpp
new file mode 100644
index 0000000..fef8b60
--- /dev/null
+++ b/src/common/src/identifiers.hpp
@@ -0,0 +1,350 @@
+/*PGR-GNU*****************************************************************
+
+File: identifiers.hpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+#pragma once
+#include <set>
+#include <algorithm>
+#include <sstream>
+#include <iterator>
+#include <iostream>
+#include <stdexcept>
+
+template <typename T>
+class Identifiers {
+ public:
+    Identifiers<T>() = default;
+    Identifiers<T>(T* container, size_t size) {
+        for (size_t i = 0; i < size; ++i) {
+            m_ids.insert(container[i]);
+        }
+    }
+    const std::set<T>& ids() const;
+    size_t size() const { return m_ids.size(); }
+    typedef typename std::set<T>::iterator iterator;
+    typedef typename std::set<T>::const_iterator const_iterator;
+    //! \brief Returns true when the set is empty
+    inline bool empty() const { return m_ids.empty(); }
+    inline void clear() { m_ids.clear(); }
+    bool has(const T other) const;
+    bool isDisjoint(const T other) const;
+    bool isDisjoint(const Identifiers<T> &other) const;
+    void insert(const Identifiers<T> &other);
+    void insert(const T &other);
+    iterator begin() { return m_ids.begin(); }
+    const_iterator begin() const { return m_ids.begin(); }
+    iterator end() { return m_ids.end(); }
+    const_iterator end() const { return m_ids.end(); }
+    bool operator ==(const Identifiers<T> &other) const;
+    const T& operator[](size_t index) const;
+    Identifiers<T> operator +(const T &other) const;
+    Identifiers<T> operator *(const T &other) const;
+    Identifiers<T> operator -(const T &other) const;
+    Identifiers<T> operator +(const Identifiers<T> &other) const;
+    Identifiers<T> operator *(const Identifiers<T> &other) const;
+    Identifiers<T> operator -(const Identifiers<T> &other) const;
+    Identifiers<T>& operator +=(const T &other);
+    Identifiers<T>& operator *=(const T &other);
+    Identifiers<T>& operator -=(const T &other);
+    Identifiers<T>& operator +=(const Identifiers<T> &other);
+    Identifiers<T>& operator *=(const Identifiers<T> &other);
+    Identifiers<T>& operator -=(const Identifiers<T> &other);
+    template<T>
+    friend std::ostream& operator<<(
+            std::ostream& os,
+            const Identifiers<T>& identifiers);
+
+ private:
+    std::set<T> m_ids;
+};
+
+
+
+
+//! \brief Returns a set of identifiers of type *set<T>*
+template <typename T>
+const std::set<T>& Identifiers<T>::ids() const {
+    return m_ids;
+}
+
+//! \brief Returns a boolean value true or false
+/*!
+  @param [in] other Identifier of type *T*
+  Returns:
+  true: If other is in this set
+  false: Otherwise
+  */
+template <typename T>
+bool Identifiers<T>::has(const T other) const {
+    return (m_ids.find(other) != m_ids.end());
+}
+
+//! \brief Returns a boolean value true or false
+/*!
+  @param [in] other is an identifier of type *T*
+  Returns:
+  true: If other is not in this set
+  false: Otherwise
+  */
+template <typename T>
+bool Identifiers<T>::isDisjoint(const T other) const {
+    return (m_ids.find(other) == m_ids.end());
+}
+
+//! \brief Returns a boolean value true or false
+/*!
+  @param [in] other is set of identifiers of type *Identifiers<T>*
+  Returns:
+  true: If other and this set are disjoint
+  false: otherwise
+  */
+template <typename T>
+bool Identifiers<T>::isDisjoint(const Identifiers<T> &other) const {
+    for (auto identifier : other.ids()) {
+        if (!(m_ids.find(identifier) == m_ids.end())) {
+            return false;
+        }
+    }
+    return true;
+}
+
+//! \brief Inserts a set of identifiers of type *Identifiers<T>* to this set
+/*!
+  @param [in] other is a set of identifiers
+  */
+template <typename T>
+void Identifiers<T>::insert(const Identifiers<T> &other) {
+    m_ids.insert(other.ids().begin(), other.ids().end());
+}
+
+//! \brief Inserts an identifier of type *T* to this set
+/*!
+  @param [in] other is an identifier of type *T*
+  */
+template <typename T>
+void Identifiers<T>::insert(const T &other) {
+    m_ids.insert(other);
+}
+
+//! \brief Returns a boolean value
+/*!
+  @param [in] other is a set of identifiers of type *Identifiers<T>*
+  Returns:
+  true: If other and this set are equivalent
+  false: Otherwise
+  */
+template <typename T>
+bool Identifiers<T>::operator ==(const Identifiers<T> &other) const {
+    return std::equal(m_ids.begin(), m_ids.end(), other.ids().begin());
+}
+
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>*
+/*!
+  @param [in] other is an identifier of type *T*
+  Returns the set union of other with this set
+  */
+template <typename T>
+Identifiers<T> Identifiers<T>::operator +(const T &other) const {
+    Identifiers<T> union_ids;
+    union_ids.insert(*this);
+    union_ids.insert(other);
+    return union_ids;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>*
+/*!
+  @param [in] other is an identifier of type *T*
+  Returns the set intersection of other with this set
+  */
+template <typename T>
+Identifiers<T> Identifiers<T>::operator *(const T &other) const {
+    Identifiers<T> intersect_ids;
+    intersect_ids.insert(*this);
+    intersect_ids *= other;
+    return intersect_ids;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>*
+/*!
+  @param [in] other is an identifier of type *T*
+  Returns the set difference between this set and other
+  */
+template <typename T>
+Identifiers<T> Identifiers<T>::operator -(const T &other) const {
+    Identifiers<T> diff_ids;
+    diff_ids.insert(*this);
+    diff_ids -= other;
+    return diff_ids;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>*
+/*!
+  @param [in] other is a set of identifiers of type *Identifiers<T>*
+  Returns the set union of other with this set
+  */
+template <typename T>
+Identifiers<T> Identifiers<T>::operator +(const Identifiers<T> &other) const {
+    Identifiers<T> union_ids;
+    union_ids.insert(*this);
+    union_ids.insert(other);
+    return union_ids;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>*
+/*!
+  @param [in] other is a set of identifiers of type *Identifiers<T>*
+  Returns the set intersection of other with this set
+  */
+template <typename T>
+Identifiers<T> Identifiers<T>::operator *(const Identifiers<T> &other) const {
+    Identifiers<T> intersect_ids;
+    intersect_ids.insert(*this);
+    intersect_ids *= other;
+    return intersect_ids;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>*
+/*!
+  @param [in] other is a set of identifiers of type *Identifiers<T>*
+  Returns the set difference between this set and other
+  */
+template <typename T>
+Identifiers<T> Identifiers<T>::operator -(const Identifiers<T> &other) const {
+    Identifiers<T> diff_ids;
+    diff_ids.insert(*this);
+    diff_ids -= other;
+    return diff_ids;
+}
+
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>&*
+/*!
+  @param [in] other is an identifiers of type *T*
+  Replaces this set with the set union of other with this set
+  */
+template <typename T>
+Identifiers<T>& Identifiers<T>::operator +=(const T &other) {
+    this->insert(other);
+    return *this;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>&*
+/*!
+  @param [in] other is an identifiers of type *T*
+  Replaces this set with the set intersection of other with this set
+  */
+template <typename T>
+Identifiers<T>& Identifiers<T>::operator *=(const T &other) {
+    if (m_ids.find(other) != m_ids.end()) {
+        m_ids.clear();
+        m_ids.insert(other);
+    } else {
+        m_ids.clear();
+    }
+    return *this;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>&*
+/*!
+  @param [in] other is a set of identifiers of type *T*
+  Replaces this set with the set difference between this set and other
+  */
+template <typename T>
+Identifiers<T>& Identifiers<T>::operator -=(const T &other) {
+    if (m_ids.find(other) != m_ids.end()) {
+        m_ids.erase(m_ids.find(other));
+    }
+    return *this;
+}
+
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>&*
+/*!
+  @param [in] other is a set of identifiers of type *Identifiers<T>*
+  Replaces this set with the set union of other with this set
+  */
+template <typename T>
+Identifiers<T>& Identifiers<T>::operator +=(const Identifiers<T> &other) {
+    this->insert(other);
+    return *this;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>&*
+/*!
+  @param [in] other is a set of identifiers of type *Identifiers<T>*
+  Replaces this set with the set intersection of other with this set
+  */
+template <typename T>
+Identifiers<T>& Identifiers<T>::operator *=(const Identifiers<T> &other) {
+    for (auto identifier : m_ids) {
+        if (other.ids().find(identifier) == other.ids().end()) {
+            m_ids.erase(m_ids.find(identifier));
+        }
+    }
+    return *this;
+}
+
+//! \brief Returns a set of identifiers of type *Identifiers<T>&*
+/*!
+  @param [in] other is a set of identifiers of type *Identifiers<T>*
+  Replaces this set with the set difference between this set and other
+  */
+template <typename T>
+Identifiers<T>& Identifiers<T>::operator -=(const Identifiers<T> &other) {
+    for (auto identifier : m_ids) {
+        if (other.ids().find(identifier) != other.ids().end()) {
+            m_ids.erase(m_ids.find(identifier));
+        }
+    }
+    return *this;
+}
+
+//! \brief Prints the set of identifiers
+template <typename T>
+std::ostream& operator<<(std::ostream& os, const Identifiers<T>& identifiers) {
+    os << "{";
+    for (auto identifier : identifiers.ids()) {
+        os << identifier << ", ";
+    }
+    os << "}";
+    return os;
+}
+
+//! \brief Returns an identifier of type *T* at position *index* in the set
+/*!
+  @param [in] index is of type size_t 
+  */
+template <typename T>
+const T& Identifiers<T>::operator[](size_t index) const {
+        if (index >= size()) {
+            throw std::out_of_range("Index out of bounds");
+        }
+        return *std::next(m_ids.begin(), index);
+}
diff --git a/src/tsp/src/distances_input.c b/src/common/src/matrixRows_input.c
similarity index 71%
rename from src/tsp/src/distances_input.c
rename to src/common/src/matrixRows_input.c
index 01a8989..e227af0 100644
--- a/src/tsp/src/distances_input.c
+++ b/src/common/src/matrixRows_input.c
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: distances_input.c
+File: matrixRows_input.c
 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
 vicky_vergara at hotmail.com
@@ -24,20 +24,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 // #define DEBUG
 #include "./debug_macro.h"
-#include "./../../common/src/pgr_types.h"
-#include "./../../common/src/postgres_connection.h"
-#include "./../../common/src/get_check_data.h"
-#include "./distances_input.h"
+#include "./pgr_types.h"
+#include "./postgres_connection.h"
+#include "./get_check_data.h"
+#include "./time_msg.h"
+#include "./matrixRows_input.h"
 
 
 
 static
-void pgr_fetch_distance(
+void pgr_fetch_row(
         HeapTuple *tuple,
         TupleDesc *tupdesc,
         Column_info_t info[3],
         Matrix_cell_t *distance) {
-
     distance->from_vid = pgr_SPI_getBigInt(tuple, tupdesc,  info[0]);
     distance->to_vid = pgr_SPI_getBigInt(tuple, tupdesc,  info[1]);
     distance->cost = pgr_SPI_getFloat8(tuple, tupdesc, info[2]);
@@ -48,10 +48,11 @@ void pgr_fetch_distance(
  * bigint end_vid,
  * float agg_cost,
  */
-void pgr_get_distances(
+void pgr_get_matrixRows(
         char *sql,
-        Matrix_cell_t **distances,
-        size_t *total_distances) {
+        Matrix_cell_t **rows,
+        size_t *total_rows) {
+    clock_t start_t = clock();
 
     const int tuple_limit = 1000000;
 
@@ -82,35 +83,37 @@ void pgr_get_distances(
 
 
     bool moredata = TRUE;
-    (*total_distances) = total_tuples;
+    (*total_rows) = total_tuples;
 
     while (moredata == TRUE) {
         SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
         if (total_tuples == 0)
-            pgr_fetch_column_info(info, 5);
+            pgr_fetch_column_info(info, 3);
 
         ntuples = SPI_processed;
         total_tuples += ntuples;
 
         if (ntuples > 0) {
-            if ((*distances) == NULL)
-                (*distances) = (Matrix_cell_t *)palloc0(total_tuples * sizeof(Matrix_cell_t));
+            if ((*rows) == NULL)
+                (*rows) = (Matrix_cell_t *)palloc0(
+                        total_tuples * sizeof(Matrix_cell_t));
             else
-                (*distances) = (Matrix_cell_t *)repalloc((*distances), total_tuples * sizeof(Matrix_cell_t));
+                (*rows) = (Matrix_cell_t *)repalloc(
+                        (*rows), total_tuples * sizeof(Matrix_cell_t));
 
-            if ((*distances) == NULL) {
+            if ((*rows) == NULL) {
                 elog(ERROR, "Out of memory");
             }
 
             SPITupleTable *tuptable = SPI_tuptable;
             TupleDesc tupdesc = SPI_tuptable->tupdesc;
-            PGR_DBG("processing %d edge tupĺes", ntuples);
+            PGR_DBG("processing %ld edge tupĺes", ntuples);
 
             size_t t;
             for (t = 0; t < ntuples; t++) {
                 HeapTuple tuple = tuptable->vals[t];
-                pgr_fetch_distance(&tuple, &tupdesc, info,
-                        &(*distances)[total_tuples - ntuples + t]);
+                pgr_fetch_row(&tuple, &tupdesc, info,
+                        &(*rows)[total_tuples - ntuples + t]);
             }
             SPI_freetuptable(tuptable);
         } else {
@@ -120,11 +123,11 @@ void pgr_get_distances(
 
 
     if (total_tuples == 0) {
-        (*total_distances) = 0;
-        PGR_DBG("NO distances");
+        (*total_rows) = 0;
+        PGR_DBG("NO rows");
         return;
     }
 
-    (*total_distances) = total_tuples;
-    PGR_DBG("Finish reading %ld edges, %ld", total_tuples, (*total_distances));
+    (*total_rows) = total_tuples;
+    time_msg(" reading Edges", start_t, clock());
 }
diff --git a/src/tsp/src/distances_input.h b/src/common/src/matrixRows_input.h
similarity index 85%
rename from src/tsp/src/distances_input.h
rename to src/common/src/matrixRows_input.h
index b5401ea..8ce6675 100644
--- a/src/tsp/src/distances_input.h
+++ b/src/common/src/matrixRows_input.h
@@ -22,16 +22,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_MATRIXROWS_INPUT_H_
+#define SRC_COMMON_SRC_MATRIXROWS_INPUT_H_
 #pragma once
 
-#include "./../../common/src/pgr_types.h"
+#include "./pgr_types.h"
 
 /*!
   bigint start_vid,
   bigint end_vid,
   float agg_cost,
   */
-void pgr_get_distances(
+void pgr_get_matrixRows(
         char *sql,
         Matrix_cell_t **distaces,
         size_t *total_distances);
+
+#endif  // SRC_COMMON_SRC_MATRIXROWS_INPUT_H_
diff --git a/src/common/src/memory_func.hpp b/src/common/src/pgr_alloc.hpp
similarity index 67%
rename from src/common/src/memory_func.hpp
rename to src/common/src/pgr_alloc.hpp
index 8b4066d..72a28af 100644
--- a/src/common/src/memory_func.hpp
+++ b/src/common/src/pgr_alloc.hpp
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: memory_func.hpp
+File: pgr_palloc.hpp
 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
 Mail: vicky_vergara at hotmail.com
@@ -21,27 +21,39 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
+#pragma once
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
+
 #include <stdlib.h>
 
+/*! \fn pgr_alloc(std::size_t size, T *ptr)
+ 
+\brief allocates memory
+
+- Does a malloc or realloc depending on the ptr value
+- To be used only on C++ code
+- To be used when returning results to postgres
+- free must occur in the C code
+
+\param[in] size
+\param[in] ptr
+\returns pointer to the first byte of allocated space
+
+ */
 
 template <typename T>
 T*
-get_memory(std::size_t size, T *ptr){
-    if( !ptr ){
+pgr_alloc(std::size_t size, T *ptr) {
+    if (!ptr) {
         ptr = (T*) malloc(size * sizeof(T));
     } else {
         ptr = (T*) realloc(ptr, size * sizeof(T));
     }
     return (T*) ptr;
 }
-
-
-template <typename T>
-T*
-noResult(std::size_t *count, T *ptr) {
-    (*count) = 0;
-    if (ptr)
-        free(ptr);
-    return NULL;
-}
-
diff --git a/src/common/src/pgr_assert.cpp b/src/common/src/pgr_assert.cpp
index 550cede..4f2d77d 100644
--- a/src/common/src/pgr_assert.cpp
+++ b/src/common/src/pgr_assert.cpp
@@ -10,8 +10,17 @@
  *
  *****************************************************************PGR-MIT*/
 #include "./pgr_assert.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+#ifdef __linux__
+#include <execinfo.h>
+#endif
+#include <string>
 #include <exception>
 
+#if 0
 #ifdef assert
 #undef assert
 #endif
@@ -21,13 +30,39 @@
 #endif
 
 #define __TOSTRING(x) __STRING(x)
+#endif
+
+std::string get_backtrace() {
+#ifdef __linux__
+        void *trace[16];
+        int i, trace_size = 0;
+
+        trace_size = backtrace(trace, 16);
+        char** funcNames = backtrace_symbols(trace, trace_size);
+
 
+        std::string message = "\n*** Execution path***\n";
+        for (i = 0; i < trace_size; ++i) {
+            message += "[bt]" + static_cast<std::string>(funcNames[i]) + "\n";
+        }
 
-const char *AssertFailedException::what() const throw() {
-  return str;
+        free(funcNames);
+        return message;
+#else
+        return "";
+#endif
+}
+
+std::string get_backtrace(const std::string &msg) {
+    return std::string("\n") + msg + "\n" + get_backtrace();
 }
 
-AssertFailedException::AssertFailedException(const char *_str) :
-    str(_str) {}
 
 
+const char* AssertFailedException::what() const throw() {
+    return str.c_str();
+}
+
+AssertFailedException::AssertFailedException(std::string msg) :
+    str(msg) {}
+
diff --git a/src/common/src/pgr_assert.h b/src/common/src/pgr_assert.h
index 11ba97e..129f0e1 100644
--- a/src/common/src/pgr_assert.h
+++ b/src/common/src/pgr_assert.h
@@ -10,48 +10,57 @@
  *  
  *****************************************************************PGR-MIT*/
 
-
-
-/*! \file vrp_assert.h
- * \brief An assert functionality that uses C++ throw().
- *
- * This file provides an alternative to assert functionality that will
- * convert all assert() into C++ throw using an AssertFailedException class.
- * This allows us to catch these errors and do appropriate clean up and
- * re-throw if needed so we can catch errors in the postgresql environment
- * so we do not crash the backend server.
- */
 #ifndef  SRC_COMMON_SRC_PGR_ASSERT_H_
 #define  SRC_COMMON_SRC_PGR_ASSERT_H_
+#pragma once
 
+#include <string>
 #include <exception>
 
 #ifdef assert
 #undef assert
 #endif
 
+
+/*! @file
+ *
+ * Assertions Handling
+ *
+ * @brief An assert functionality that uses C++ throw().
+ *
+ * This file provides an alternative to assert functionality that will
+ * convert all pgassert() into C++ throw using an AssertFailedException class.
+ *
+ * This allows catching errors and do appropriate clean up 
+ * re-throw if needed to catch errors in the postgresql environment
+ *
+ * **Do not crash the backend server.**
+ */
+
+
 #ifndef __STRING
 #define __STRING(x) #x
 #endif
 
 #define __TOSTRING(x) __STRING(x)
 
-/*! \def assert(expr)
- * \brief Uses the standard assert syntax.
+
+/*! @def pgassert(expr)
+ * @brief Uses the standard assert syntax.
  *
  * When an assertion fails it will throw \ref AssertFailedException and what()
  * will return a string like "AssertFailedException(2+2 == 5) at t.cpp:11"
  *
- * Here is an example of using it:
- * \code
+ * Example:
+ * @code
     #include <iostream>
-    #include "vrp_assert.h"
+    #include "pgr_assert.h"
 
     int main() {
 
         try {
-            assert(2+2 == 4);
-            assert(2+2 == 5);
+            pgassert(2+2 == 4);
+            pgassert(2+2 == 5);
         }
         catch (AssertFailedException &e) {
             std::cout << e.what() << "\n";
@@ -64,28 +73,64 @@
         }
         return 0;
     }
-\endcode
+    @endcode
  */
 #ifdef NDEBUG
-#define assert(expr) ((void)0)
+#define pgassert(expr) ((void)0)
+#else
+#define pgassert(expr) \
+    ((expr) \
+     ? static_cast<void>(0) \
+     : throw AssertFailedException( \
+         "AssertFailedException: " __STRING(expr) \
+         " at " __FILE__ ":" __TOSTRING(__LINE__) + get_backtrace() ) )
+#endif
+
+/*! @def pgassertwm(expr, msg)
+  @brief Adds a message to the assertion.
+ 
+ Example:
+ @code
+    pgassert(2+2 == 5, "Expected a 4 as result");
+    std::ostringstream log;
+    log << "Expected a 4 as result"
+    pgassert(2+2 == 5, log.str());
+ @endcode
+*/
+
+#ifdef NDEBUG
+#define pgassertwm(expr, msg) ((void)0)
 #else
-#define assert(expr) \
+#define pgassertwm(expr, msg) \
     ((expr) \
      ? static_cast<void>(0) \
-     : throw AssertFailedException("AssertFailedException: " __STRING(expr) " at " __FILE__ ":" __TOSTRING(__LINE__) ))
+     : throw AssertFailedException( \
+         "AssertFailedException: " __STRING(expr) \
+         " at " __FILE__ ":" __TOSTRING(__LINE__) + get_backtrace(msg) ) )
 #endif
 
+/*! @brief returns the execution path of the trace
+ 
+  In case of a failed exception the backtrace can be is shown in the error message.
+
+  Does not work for windows, please read:
+  http://stackoverflow.com/questions/27639931/can-not-find-execinfo-h-when-setup-malpack
+ 
+ */
+std::string get_backtrace();
+std::string get_backtrace(const std::string &);
 
-/*! \class AssertFailedException
- * \brief Extends std::exception and is the exception that we throw if an assert fails.
+/*! @class AssertFailedException
+ * @brief Extends std::exception and is the exception that we throw if an assert fails.
  */
 class AssertFailedException : public std::exception {
  private:
-  const char *str;    ///< str Holds the what() string for the exception.
+     const std::string str;   ///< Holds what() we got as message
 
  public:
-  virtual const char *what() const throw();
-  explicit AssertFailedException(const char *_str);
+     virtual const char *what() const throw();
+     explicit AssertFailedException(std::string msg);
+     virtual ~AssertFailedException() throw() {}
 };
 
 #endif  //  SRC_COMMON_SRC_PGR_ASSERT_H_
diff --git a/src/common/src/pgr_base_graph.hpp b/src/common/src/pgr_base_graph.hpp
new file mode 100644
index 0000000..25c5153
--- /dev/null
+++ b/src/common/src/pgr_base_graph.hpp
@@ -0,0 +1,843 @@
+/*PGR-GNU*****************************************************************
+ *
+
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+vicky_vergara at hotmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#pragma once
+#if defined(__MinGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#undef min
+#undef max
+#ifdef open
+#undef open
+#endif
+#endif
+
+
+
+#include <boost/graph/iteration_macros.hpp>
+#include <boost/config.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/graph_utility.hpp>
+
+#include <deque>
+#include <vector>
+#include <set>
+#include <map>
+#include <limits>
+
+#include "./pgr_types.h"  // for pgr_edge_t
+
+#include "./ch_vertex.h"
+#include "./ch_edge.h"
+#include "./basic_vertex.h"
+#include "./xy_vertex.h"
+
+#include "./basic_edge.h"
+#include "./pgr_assert.h"
+
+/*! @brief boost::graph simplified to pgRouting needs
+
+  This class gives the handling basics of a boost::graph of kind G
+  where G:
+  can be an undirected graph or a directed graph.
+
+Requiremets:
+============
+
+A vertex class T_V
+------------------
+
+Current Available vertex classes:
+- Basic_vertex
+- XY_vertex
+
+
+An edge class T_E
+-----------------
+
+Current Available edge classes:
+- Basic_edge
+
+extract_vertices function
+-------------------------
+
+Data obtained from postgresql is stored in
+A C array of pgr_edge_t type.
+
+~~~~{.c}
+std::vector< T_V > 
+extract_vertices(pgr_edge_t *, size_t)
+~~~~
+
+
+Data obtained from postgresql is stored in
+o a vector container.
+
+~~~~{.c}
+std::vector< T_V > 
+extract_vertices(std::vector< pgr_edge_t >)
+~~~~
+
+Boost Graph
+-------------
+
+The code is prepared to be used for:
+- boost::adjacency_list graph type
+- boost::undirectedS when the graph is UNDIRECTED
+- boost::bidirectionalS when the graph is DIRECTED
+
+
+~~~~{.c}
+boost::adjacency_list
+< boost::vecS,  // not tested with other values
+boost::vecS,  // not tested with other values
+boost::undirectedS,  // USinG UNDIRECTED 
+Basic_vertex,  // the vertex class
+Basic_edge >   // the edge class
+~~~~
+
+
+
+Eample Usage:
+=============
+
+For this example we will use:
+- Basic_vertex
+- Basic_edge 
+- pgr_edge_t
+
+
+Create Graph type
+-----------------
+
+~~~~{.c}
+typedef typename
+graph::Pgr_base_graph <
+boost::adjacency_list < 
+boost::vecS,
+    boost::vecS,
+    boost::bidirectionalS,
+    Basic_vertex,
+    Basic_edge >,
+    Basic_vertex,
+    Basic_edge >
+
+    DirectedGraph;
+~~~~
+
+
+Initializing the graph
+------------------------------
+
+Graph initialization is for seting the Vertices of the graph.
+
+//TODO discuss if also the edges
+
+Vector of unique vertices of the graph
+~~~~{.c}
+size_t total_edges;
+pgr_edge_t *my_edges = NULL;
+pgr_get_edges(edges_sql, &my_edges, &total_tuples); 
+std::vector< Basic_Vertex > vertices(pgrouting::extract_vertices(my_edges));
+~~~~
+
+There are several ways to initialize the graph
+
+~~~~{.c}
+// 1. Initializes an empty graph
+pgrouting::DirectedGraph digraph(gType);
+
+// 2. Initializes a graph based on the vertices
+pgrouting::DirectedGraph digraph(
+    verices,
+    gType);
+vertices.clear();
+
+3. Initializes a graph based on the extracted vertices
+pgrouting::DirectedGraph digraph(
+    pgrouting::extract_vertices(my_edges, total_edges);
+    gType);
+
+4. Initializes a graph based on the extracted vertices
+pgrouting::DirectedGraph digraph(
+    pgrouting::extract_vertices(my_edges);
+    gType);
+~~~~
+
+1. Initializes an empty graph
+  - vertices vector size is 0
+
+2. Initializes a graph based on the vertices:
+  - vertices vector size is vertices.size()
+  - the vertices are inserted
+  - vertices container can be clared to free memory
+
+3. Initializes a graph based on the vertices extracted
+  - from edges stored on a C array
+  - the vertices are inserted
+
+4. Initializes a graph based on the vertices extracted
+  - from edges stored on a vector
+  - the vertices are inserted
+
+
+Fill the graph 
+---------------------
+
+After initializing the graph with the vertices, the edges can be added.
+
+~~~~{.c}
+// inserting edges from a C array
+digraph.graph_insert_data(my_edges, total_edges);
+
+// adding more edges to the graph from a vector container
+digraph.graph_insert_data(new_edges);
+~~~~
+
+*/
+namespace pgrouting {
+
+namespace graph {
+template <class G, typename Vertex, typename Edge>
+class Pgr_base_graph;
+
+}  // namespace graph
+
+
+/** @name Graph types 
+  Type      |   pgRouting
+  :---------: | :---------------------
+  UndirectedGraph | Basic undirected graph
+  DirectedGraph | Basic directed graph
+  xyUndirectedGraph | X & Y values stored on the vertex 
+  xyDirectedGraph | X & Y values stored on the vertex 
+  */
+//@{
+typedef graph::Pgr_base_graph <
+boost::adjacency_list < boost::vecS, boost::vecS,
+    boost::undirectedS,
+    Basic_vertex, Basic_edge >,
+    Basic_vertex, Basic_edge > UndirectedGraph;
+
+typedef graph::Pgr_base_graph <
+boost::adjacency_list < boost::vecS, boost::vecS,
+    boost::bidirectionalS,
+    Basic_vertex, Basic_edge >,
+    Basic_vertex, Basic_edge > DirectedGraph;
+
+typedef graph::Pgr_base_graph <
+boost::adjacency_list < boost::listS, boost::vecS,
+    boost::undirectedS,
+    XY_vertex, Basic_edge >,
+    XY_vertex, Basic_edge > xyUndirectedGraph;
+
+typedef graph::Pgr_base_graph <
+boost::adjacency_list < boost::listS, boost::vecS,
+    boost::bidirectionalS,
+    XY_vertex, Basic_edge >,
+    XY_vertex, Basic_edge > xyDirectedGraph;
+
+#if 0
+// TODO(Rohith) this is only used on internal query tests
+typedef graph::Pgr_base_graph <
+boost::adjacency_list < boost::listS, boost::vecS,
+    boost::undirectedS,
+    contraction::Vertex, Basic_edge >,
+    contraction::Vertex, Basic_edge > CUndirectedGraph;
+
+typedef graph::Pgr_base_graph <
+boost::adjacency_list < boost::listS, boost::vecS,
+    boost::bidirectionalS,
+    contraction::Vertex, Basic_edge >,
+    contraction::Vertex, Basic_edge > CDirectedGraph;
+#endif
+//@}
+
+
+namespace graph {
+
+template <class G, typename T_V, typename T_E>
+class Pgr_base_graph {
+ public:
+     /** @name Graph related types
+       Type      |     boost meaning     |   pgRouting meaning
+       :---------: | :-------------------- | :----------------------
+       G        | boost::adjacency_list |   Graph
+       V        | vertex_descriptor     |   Think of it as local ID of a vertex
+       E        | edge_descriptor       |   Think of it as local ID of an edge
+       V_i      | vertex_iterator       |   To cycle the vertices of the Graph
+       E_i      | edge_iterator         |   To cycle the edges of the Graph
+       EO_i     | out_edge_iterator     |   To cycle the out going edges of a vertex
+       EI_i     | in_edge_iterator      |   To cycle the in coming edges of a vertex (only in bidirectional graphs)
+       */
+     //@{
+     typedef G B_G;
+     typedef typename boost::graph_traits < G >::vertex_descriptor V;
+     typedef typename boost::graph_traits < G >::edge_descriptor E;
+     typedef typename boost::graph_traits < G >::vertex_iterator V_i;
+     typedef typename boost::graph_traits < G >::edge_iterator E_i;
+     typedef typename boost::graph_traits < G >::out_edge_iterator EO_i;
+     typedef typename boost::graph_traits < G >::in_edge_iterator EI_i;
+
+     typedef typename boost::graph_traits < G >::vertices_size_type
+         vertices_size_type;
+     typedef typename boost::graph_traits < G >::edges_size_type
+         edges_size_type;
+     typedef typename boost::graph_traits < G >::degree_size_type
+         degree_size_type;
+
+     //@}
+
+     /** @name Id handling related types
+       Type      |  Meaning       |   pgRouting Meaning
+       :---------: | :------------- | :----------------------
+       id_to_V  | maps id -> V   | given an id store the V
+       LI       | Left Iterator  | iterates over id_to_V
+       */
+     //@{
+
+     typedef typename std::map< int64_t, V > id_to_V;
+     typedef typename id_to_V::const_iterator LI;
+
+     //@}
+
+     //! @name The Graph
+     //@{
+     G graph;                //!< The graph
+     size_t m_num_vertices;  //!< local count.
+     graphType m_gType;      //!< type (DIRECTED or UNDIRECTED)
+     //@}
+
+     //! @name Id mapping handling
+     //@{
+
+     id_to_V  vertices_map;   //!< id -> graph id
+
+     //@}
+
+     //! @name Graph Modification
+     //@{
+     //! Used for storing the removed_edges
+
+     std::deque< T_E > removed_edges;
+
+     //@}
+
+
+
+     //! @name The Graph
+     //@{
+     //! @brief Constructor
+     /*!
+       - Prepares the graph to be of type gtype
+       - inserts the vertices
+       - The vertices must be checked (if necessary)  before calling the constructor
+       */
+     Pgr_base_graph< G , T_V, T_E >(
+             const std::vector< T_V > &vertices, graphType gtype)
+         : graph(vertices.size()),
+         m_num_vertices(vertices.size()),
+         m_gType(gtype) {
+             pgassert(boost::num_vertices(graph) == num_vertices());
+             pgassert(boost::num_vertices(graph) == vertices.size());
+#if 0
+             // This code does not work with contraction
+             pgassert(pgrouting::check_vertices(vertices) == 0);
+#endif
+             size_t i = 0;
+             for (auto vi = boost::vertices(graph).first;
+                     vi != boost::vertices(graph).second; ++vi) {
+                 vertices_map[vertices[i].id] = (*vi);
+                 graph[(*vi)].cp_members(vertices[i++]);
+             }
+         }
+
+     /*!
+       Prepares the _graph_ to be of type gtype with 0 vertices
+       */
+     explicit Pgr_base_graph< G , T_V, T_E >(graphType gtype)
+         : graph(0),
+         m_num_vertices(0),
+         m_gType(gtype) {
+         }
+
+
+     //! @name Insert data
+     //@{
+     /*! @brief Inserts *count* edges of type *T* into the graph
+      *  
+      *  Converts the edges to a std::vector<T> & calls the overloaded
+      *  twin function.
+      *
+      *  @param edges
+      *  @param count
+      */
+     template < typename T >
+         void graph_insert_data(const T *edges, int64_t count) {
+             graph_insert_data(std::vector < T >(edges, edges + count));
+         }
+     /*! @brief Inserts *count* edges of type *pgr_edge_t* into the graph
+
+        The set of edges should not have an illegal vertex defined
+        
+        When the graph is empty calls:
+        - @b extract_vertices
+        and throws an exception if there are illegal vertices.
+        
+        
+        When developing:
+          - if an illegal vertex is found an exception is thrown
+          - That means that the set of vertices should be checked in the
+            code that is being developed
+        
+        No edge is inserted when there is an error on the vertices
+
+        @param edges
+      */
+     template < typename T >
+         void graph_insert_data(const std::vector < T > &edges) {
+#if 0
+             // This code does not work with contraction
+             if (num_vertices() == 0) {
+                 auto vertices = pgrouting::extract_vertices(edges);
+                 pgassert(pgrouting::check_vertices(vertices) == 0);
+                 add_vertices(vertices);
+             }
+#endif
+             for (const auto edge : edges) {
+                 graph_add_edge(edge);
+             }
+         }
+     //@}
+
+ private:
+     /*! @brief adds the vertices into the graph
+      *
+      * PRECONDITIONS:
+      * ~~~~~{.c}
+      * precondition(boost::num_vertices(graph) == 0);
+      * for (vertex : vertices) 
+      *    precondition(!has_vertex(vertex.id));
+      * ~~~~~
+      *
+      * POSTCONDITIONS:
+      * ~~~~~{.c}
+      * postcondition(boost::num_vertices(graph) == vertices.size());
+      * for (vertex : vertices) 
+      *    precondition(has_vertex(vertex.id));
+      * ~~~~~
+      */
+     void add_vertices(std::vector< T_V > vertices);
+
+ public:
+     //! @name boost wrappers
+     //@{
+     //! @brief get the out-degree  of a vertex
+
+     /*!
+       @returns 0: The out degree of a vertex that its not in the graph
+
+       @param [in] vertex_id original vertex id
+       */
+     degree_size_type out_degree(int64_t vertex_id) const {
+         if (!has_vertex(vertex_id)) {
+             return 0;
+         }
+         return out_degree(get_V(vertex_id));
+     }
+
+
+     /*! @brief get the vertex descriptor of the vertex
+
+       When the vertex does not exist
+       - creates a new vetex
+
+       @return V: The vertex descriptor of the vertex
+       */
+     V get_V(const T_V &vertex) {
+         auto vm_s(vertices_map.find(vertex.id));
+         if (vm_s == vertices_map.end()) {
+             auto v =  add_vertex(graph);
+             graph[v].cp_members(vertex);
+             vertices_map[vertex.id] =  v;
+             return v;
+         }
+         return vm_s->second;
+     }
+
+     /*! @brief get the vertex descriptor of the vid
+
+       Call has_vertex(vid) before calling this function
+
+       @return V: The vertex descriptor of the vertex
+       */
+     V get_V(int64_t vid) const {
+         pgassert(has_vertex(vid));
+         return vertices_map.find(vid)->second;
+     }
+
+     //! @brief True when vid is in the graph
+     bool has_vertex(int64_t vid) const {
+         return vertices_map.find(vid) != vertices_map.end();
+     }
+
+     //! @brief True when vid is in the graph
+     degree_size_type in_degree(V &v) const {
+         return boost::in_degree(v, graph);
+     }
+
+     //! @brief True when vid is in the graph
+     degree_size_type out_degree(V &v) const {
+         return boost::out_degree(v, graph);
+     }
+
+     //@}
+
+
+     //! @name edge disconection/reconnection
+     //@{
+     //! @brief Disconnects all edges from p_from to p_to
+     /*!
+
+       - No edge is disconnected if the vertices id's do not exist in the graph
+       - All removed edges are stored for future reinsertion
+       - All parallel edges are disconnected (automatically by boost)
+
+       ![disconnect_edge(2,3) on an UNDIRECTED graph](disconnectEdgeUndirected.png)
+       ![disconnect_edge(2,3) on a DIRECTED graph](disconnectEdgeDirected.png)
+
+       @param [in] p_from original vertex id of the starting point of the edge
+       @param [in] p_to   original vertex id of the ending point of the edge
+       */
+     void disconnect_edge(int64_t p_from, int64_t p_to);
+
+
+     //! @brief Disconnects the outgoing edges of a vertex
+     /*!
+
+       - No edge is disconnected if it doesn't exist in the graph
+       - Removed edges are stored for future reinsertion
+       - all outgoing edges with the edge_id are removed if they exist
+
+       @param [in] vertex_id original vertex
+       @param [in] edge_id original edge_id
+       */
+     void disconnect_out_going_edge(int64_t vertex_id, int64_t edge_id);
+
+
+
+
+     //! @brief Disconnects all incoming and outgoing edges from the vertex
+     /*!
+       boost::graph doesn't recommend th to insert/remove vertices, so a vertex removal is
+       simulated by disconnecting the vertex from the graph
+
+       - No edge is disconnected if the vertices id's do not exist in the graph
+       - All removed edges are stored for future reinsertion
+       - All parallel edges are disconnected (automatically by boost)
+
+       ![disconnect_vertex(2) on an UNDIRECTED graph](disconnectVertexUndirected.png)
+       ![disconnect_vertex(2) on a DIRECTED graph](disconnectVertexDirected.png)
+
+       @param [in] p_vertex original vertex id of the starting point of the edge
+       */
+     void disconnect_vertex(int64_t p_vertex);
+     void disconnect_vertex(V vertex);
+
+
+     //! @brief Reconnects all edges that were removed
+     void restore_graph();
+
+     //@}
+
+     //! @name only for stand by program
+     //@{
+
+     friend std::ostream& operator<<(
+             std::ostream &log, const Pgr_base_graph< G, T_V, T_E > &g) {
+         typename Pgr_base_graph< G, T_V, T_E >::EO_i out, out_end;
+
+         for (auto vi = vertices(g.graph).first;
+                 vi != vertices(g.graph).second; ++vi) {
+             if ((*vi) >= g.m_num_vertices) break;
+             log << (*vi) << ": " << " out_edges_of(" << g.graph[(*vi)] << "):";
+             for (boost::tie(out, out_end) = out_edges(*vi, g.graph);
+                     out != out_end; ++out) {
+                 log << ' '
+                     << g.graph[*out].id << "=("
+                     << g.graph[source(*out, g.graph)].id << ", "
+                     << g.graph[target(*out, g.graph)].id << ") = "
+                     << g.graph[*out].cost <<"@t";
+             }
+             log << std::endl;
+         }
+         return log;
+     }
+
+     //@}
+
+
+     int64_t get_edge_id(V from, V to, double &distance) const;
+
+     size_t num_vertices() const { return boost::num_vertices(graph);}
+
+     T_V operator[](V v) const {
+         return graph[v];
+     }
+
+
+     void graph_add_edge(const T_E &edge);
+
+     template < typename T >
+         void graph_add_edge(const T &edge);
+};
+
+
+
+
+template < class G, typename T_V, typename T_E >
+void
+Pgr_base_graph< G, T_V, T_E >::disconnect_edge(int64_t p_from, int64_t p_to) {
+    T_E d_edge;
+
+    // nothing to do, the vertex doesn't exist
+    if (!has_vertex(p_from) || !has_vertex(p_to)) return;
+
+    EO_i out, out_end;
+    V g_from(get_V(p_from));
+    V g_to(get_V(p_to));
+
+    // store the edges that are going to be removed
+    for (boost::tie(out, out_end) = out_edges(g_from, graph);
+            out != out_end; ++out) {
+        if (target(*out, graph) == g_to) {
+            d_edge.id = graph[*out].id;
+            d_edge.source = graph[source(*out, graph)].id;
+            d_edge.target = graph[target(*out, graph)].id;
+            d_edge.cost = graph[*out].cost;
+            removed_edges.push_back(d_edge);
+        }
+    }
+    // the actual removal
+    boost::remove_edge(g_from, g_to, graph);
+}
+
+
+
+template < class G, typename T_V, typename T_E >
+void
+Pgr_base_graph< G, T_V, T_E >::disconnect_out_going_edge(
+        int64_t vertex_id, int64_t edge_id) {
+    T_E d_edge;
+
+    // nothing to do, the vertex doesn't exist
+    if (!has_vertex(vertex_id)) return;
+    auto v_from(get_V(vertex_id));
+
+    EO_i out, out_end;
+    bool change = true;
+    // store the edge that are going to be removed
+    while (change) {
+        change = false;
+        for (boost::tie(out, out_end) = out_edges(v_from, graph);
+                out != out_end; ++out) {
+            if (graph[*out].id  == edge_id) {
+                d_edge.id = graph[*out].id;
+                d_edge.source = graph[source(*out, graph)].id;
+                d_edge.target = graph[target(*out, graph)].id;
+                d_edge.cost = graph[*out].cost;
+                removed_edges.push_back(d_edge);
+                boost::remove_edge((*out), graph);
+                change = true;
+                break;
+            }
+        }
+    }
+}
+
+
+template < class G, typename T_V, typename T_E >
+void
+Pgr_base_graph< G, T_V, T_E >::disconnect_vertex(int64_t vertex) {
+    if (!has_vertex(vertex)) return;
+    disconnect_vertex(get_V(vertex));
+}
+
+template < class G, typename T_V, typename T_E >
+void
+Pgr_base_graph< G, T_V, T_E >::disconnect_vertex(V vertex) {
+    T_E d_edge;
+
+    EO_i out, out_end;
+    // store the edges that are going to be removed
+    for (boost::tie(out, out_end) = out_edges(vertex, graph);
+            out != out_end; ++out) {
+        d_edge.id = graph[*out].id;
+        d_edge.source = graph[source(*out, graph)].id;
+        d_edge.target = graph[target(*out, graph)].id;
+        d_edge.cost = graph[*out].cost;
+        removed_edges.push_back(d_edge);
+    }
+
+    // special case
+    if (m_gType == DIRECTED) {
+        EI_i in, in_end;
+        for (boost::tie(in, in_end) = in_edges(vertex, graph);
+                in != in_end; ++in) {
+            d_edge.id = graph[*in].id;
+            d_edge.source = graph[source(*in, graph)].id;
+            d_edge.target = graph[target(*in, graph)].id;
+            d_edge.cost = graph[*in].cost;
+            removed_edges.push_back(d_edge);
+        }
+    }
+
+    // delete incoming and outgoing edges from the vertex
+    boost::clear_vertex(vertex, graph);
+}
+
+template < class G, typename T_V, typename T_E >
+void
+Pgr_base_graph< G, T_V, T_E >::restore_graph() {
+    while (removed_edges.size() != 0) {
+        graph_add_edge(removed_edges[0]);
+        removed_edges.pop_front();
+    }
+}
+
+
+template < class G, typename T_V, typename T_E >
+int64_t
+Pgr_base_graph< G, T_V, T_E >::get_edge_id(
+        V from,
+        V to,
+        double &distance) const {
+    E e;
+    EO_i out_i, out_end;
+    V v_source, v_target;
+    double minCost =  std::numeric_limits<double>::max();
+    int64_t minEdge = -1;
+    for (boost::tie(out_i, out_end) = boost::out_edges(from, graph);
+            out_i != out_end; ++out_i) {
+        e = *out_i;
+        v_target = target(e, graph);
+        v_source = source(e, graph);
+        if ((from == v_source) && (to == v_target)
+                && (distance == graph[e].cost))
+            return graph[e].id;
+        if ((from == v_source) && (to == v_target)
+                && (minCost > graph[e].cost)) {
+            minCost = graph[e].cost;
+            minEdge = graph[e].id;
+        }
+    }
+    distance = minEdge == -1? 0: minCost;
+    return minEdge;
+}
+
+
+template < class G, typename T_V, typename T_E >
+void
+Pgr_base_graph< G, T_V, T_E >::graph_add_edge(const T_E &edge ) {
+    bool inserted;
+    typename Pgr_base_graph< G, T_V, T_E >::LI vm_s, vm_t;
+    typename Pgr_base_graph< G, T_V, T_E >::E e;
+
+    vm_s = vertices_map.find(edge.source);
+    if (vm_s == vertices_map.end()) {
+        vertices_map[edge.source]=  m_num_vertices;
+        vm_s = vertices_map.find(edge.source);
+    }
+
+    vm_t = vertices_map.find(edge.target);
+    if (vm_t == vertices_map.end()) {
+        vertices_map[edge.target]=  m_num_vertices;
+        vm_t = vertices_map.find(edge.target);
+    }
+
+    if (edge.cost >= 0) {
+        boost::tie(e, inserted) =
+            boost::add_edge(vm_s->second, vm_t->second, graph);
+        graph[e].cp_members(edge);
+    }
+}
+
+
+template < class G, typename T_V, typename T_E >
+template < typename T>
+void
+Pgr_base_graph< G, T_V, T_E >::graph_add_edge(const T &edge) {
+    bool inserted;
+    typename Pgr_base_graph< G, T_V, T_E >::E e;
+    if ((edge.cost < 0) && (edge.reverse_cost < 0))
+        return;
+
+    /*
+     * true: for source
+     * false: for target
+     */
+    auto vm_s = get_V(T_V(edge, true));
+    auto vm_t = get_V(T_V(edge, false));
+
+    pgassert(vertices_map.find(edge.source) != vertices_map.end());
+    pgassert(vertices_map.find(edge.target) != vertices_map.end());
+    if (edge.cost >= 0) {
+        boost::tie(e, inserted) =
+            boost::add_edge(vm_s, vm_t, graph);
+        graph[e].cost = edge.cost;
+        graph[e].id = edge.id;
+        graph[e].first = true;
+    }
+
+    if (edge.reverse_cost >= 0) {
+        boost::tie(e, inserted) =
+            boost::add_edge(vm_t, vm_s, graph);
+
+        graph[e].cost = edge.reverse_cost;
+        graph[e].id = edge.id;
+        graph[e].first = false;
+    }
+}
+
+/******************  PRIVATE *******************/
+
+template < class G, typename T_V, typename T_E >
+void
+Pgr_base_graph< G, T_V, T_E >::add_vertices(
+        std::vector< T_V > vertices) {
+    pgassert(m_num_vertices == 0);
+    for (const auto vertex : vertices) {
+        pgassert(vertices_map.find(vertex.id) == vertices_map.end());
+
+        auto v =  add_vertex(graph);
+        vertices_map[vertex.id] =  m_num_vertices++;
+        graph[v].cp_members(vertex);
+
+        pgassert(boost::num_vertices(graph) == num_vertices());
+    }
+    return;
+}
+
+}  // namespace graph
+}  // namespace pgrouting
diff --git a/src/common/src/pgr_logger.h b/src/common/src/pgr_logger.h
index 9afced3..089ca25 100644
--- a/src/common/src/pgr_logger.h
+++ b/src/common/src/pgr_logger.h
@@ -25,7 +25,7 @@
     // override the default log file "/tmp/pgr_logger.log"
     #define PGR_LOGGER_FILE "mylogger.log"
 
-    #undef PGR_LOGGER_LOC  // dont log filename and line number
+    #undef PGR_LOGGER_LOC  // don't log filename and line number
     #define PGR_LOGGER_LOC  // log filename and line number with log message
 
     // include the logger macros and configure based on defines above
diff --git a/src/common/src/pgr_types.h b/src/common/src/pgr_types.h
index 1626988..0615cd2 100644
--- a/src/common/src/pgr_types.h
+++ b/src/common/src/pgr_types.h
@@ -22,26 +22,52 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_PGR_TYPES_H_
+#define SRC_COMMON_SRC_PGR_TYPES_H_
 #pragma once
 
+
 #ifndef __cplusplus
-#include "postgres.h"
+
+// for bool
+#include <postgres.h>
+
+// For NULL & size_t
+#include <stdlib.h>
 #endif
+
+// For int64_t etc
 #include <stdint.h>
 
-typedef struct edge_astar
-{
-  int id;
-  int source;
-  int target;
-  double cost;
-  double reverse_cost;
-  double s_x;
-  double s_y;
-  double t_x;
-  double t_y;
+typedef struct  {
+    int64_t id;
+    double x;
+    double y;
+} Coordinate_t;
+
+typedef struct edge_astar {
+    int id;
+    int source;
+    int target;
+    double cost;
+    double reverse_cost;
+    double s_x;
+    double s_y;
+    double t_x;
+    double t_y;
 } edge_astar_t;
 
+typedef struct {
+    int64_t id;
+    int64_t source;
+    int64_t target;
+    double cost;
+    double reverse_cost;
+    double x1;
+    double y1;
+    double x2;
+    double y2;
+} Pgr_edge_xy_t;
 
 
 typedef struct {
@@ -62,7 +88,7 @@ typedef struct {
 
 /*
  * This ones are for returning the info to postgres
-     */
+ */
 
 typedef struct {
     int seq;
@@ -75,7 +101,7 @@ typedef struct {
 } General_path_element_t;
 
 
-typedef struct{
+typedef struct {
     int route_id;
     int path_id;
     int path_seq;
@@ -90,6 +116,15 @@ typedef struct{
 
 
 typedef struct {
+  int64_t id;
+  int64_t source;
+  int64_t target;
+  bool going;
+  bool coming;
+  int64_t edge_id;
+} pgr_basic_edge_t;
+
+typedef struct {
     int64_t id;
     int64_t source;
     int64_t target;
@@ -98,6 +133,14 @@ typedef struct {
 } pgr_edge_t;
 
 typedef struct {
+  int64_t edge;
+  int64_t source;
+  int64_t target;
+  int64_t flow;
+  int64_t residual_capacity;
+} pgr_flow_t;
+
+typedef struct {
     int seq;
     int64_t source;
     int64_t edge;
@@ -113,8 +156,7 @@ typedef struct matrix_cell {
 // Restrictions used in pgr_turnRestrictions
 
 #define  MAX_RULE_LENGTH 5
-typedef struct 
-{
+typedef struct {
     int64_t target_id;
     double to_cost;
     int64_t via[MAX_RULE_LENGTH];
@@ -126,7 +168,7 @@ typedef struct {
     int64_t edge_id;
     char side;  // 'r', 'l', 'b' (default is both)
     double fraction;
-    int64_t vertex_id; // number is negative and is used for processing
+    int64_t vertex_id;  // number is negative and is used for processing
 } Point_on_edge_t;
 
 // used for getting the data
@@ -145,28 +187,12 @@ struct {
     bool strict;
     char *name;
     expectType eType;
-
 } Column_info_t;
 
-// used in boost
-struct boost_vertex_t {
-    int64_t id;
-};
+enum graphType {UNDIRECTED = 0, DIRECTED};
 
-struct boost_edge_t{
-    int64_t id;
-    double cost;
-    int64_t source;
-    int64_t target;
-    bool first;  // originally was true (source, target) false (target, source)
-};
-
-
-enum graphType { UNDIRECTED= 0, DIRECTED};
-
-#if 0
 /**************************************************************************
- * VRPPDTW types
+ * pickDelivery types
  * ***********************************************************************/
 typedef struct {
     int64_t id;
@@ -179,14 +205,31 @@ typedef struct {
     int64_t Pindex;
     int64_t Dindex;
     double Ddist;
-} Customer;
+} Customer_t;
+
+/*
+    OUT seq INTEGER,        done in the .c code
+    OUT vehicle_seq INTEGER,
+    OUT vehicle_id INTEGER,
+    OUT order_id BIGINT,
+    OUT travelTime FLOAT,
+    OUT arrivalTime FLOAT,
+    OUT waitTime FLOAT,
+    OUT serviceTime FLOAT,
+    OUT departureTime FLOAT,
+*/
 
 typedef struct  {
-    int seq;
-    int64_t rid;
-    int64_t nid;
-    double cost;
-} path_element;
+    int vehicle_id;
+    int vehicle_seq;
+    int64_t order_id;
+    double travelTime;
+    double arrivalTime;
+    double waitTime;
+    double serviceTime;
+    double departureTime;
+} General_vehicle_orders_t;
 
 /*************************************************************************/
-#endif
+
+#endif  // SRC_COMMON_SRC_PGR_TYPES_H_
diff --git a/src/common/src/points_input.c b/src/common/src/points_input.c
index 31bbc45..18b3f2d 100644
--- a/src/common/src/points_input.c
+++ b/src/common/src/points_input.c
@@ -22,12 +22,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-// #define DEBUG
 #include "./debug_macro.h"
-#include "pgr_types.h"
-#include "postgres_connection.h"
-#include "get_check_data.h"
-#include "points_input.h"
+#include "./pgr_types.h"
+#include "./postgres_connection.h"
+#include "./get_check_data.h"
+#include "./points_input.h"
+
 
 
 static
@@ -112,9 +112,11 @@ pgr_get_points(
 
         if (ntuples > 0) {
             if ((*points) == NULL)
-                (*points) = (Point_on_edge_t *)palloc0(total_tuples * sizeof(Point_on_edge_t));
+                (*points) = (Point_on_edge_t *)
+                    palloc0(total_tuples * sizeof(Point_on_edge_t));
             else
-                (*points) = (Point_on_edge_t *)repalloc((*points), total_tuples * sizeof(Point_on_edge_t));
+                (*points) = (Point_on_edge_t *)
+                    repalloc((*points), total_tuples * sizeof(Point_on_edge_t));
 
             if ((*points) == NULL) {
                 elog(ERROR, "Out of memory");
diff --git a/src/common/src/points_input.h b/src/common/src/points_input.h
index 8e03fbc..d54115f 100644
--- a/src/common/src/points_input.h
+++ b/src/common/src/points_input.h
@@ -22,11 +22,62 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_POINTS_INPUT_H_
+#define SRC_COMMON_SRC_POINTS_INPUT_H_
 #pragma once
 
 #include "./pgr_types.h"
 
+/*! @brief pgr_get_points 
+
+For queries of the type:
+~~~~{.c}
+SELECT pid, edge_id, fraction, [side]
+FROM edge_table;
+~~~~
+
+ at param[in] points_sql
+ at param[out] points
+ at param[out] total_points
+*/
 void pgr_get_points(
         char *points_sql,
         Point_on_edge_t **points,
         size_t *total_points);
+
+
+/* ******************** FOR USERS DOCUMENTATION
+
+points_sql_start
+
+Description of the Points SQL query
+...............................................................................
+
+:points_sql: an SQL query, which should return a set of rows with the following columns:
+
+============ ================= =================================================
+Column            Type              Description
+============ ================= =================================================
+**pid**      ``ANY-INTEGER``   (optional) Identifier of the point.
+                                 - If column present, it can not be NULL. 
+                                 - If column not present, a sequential identifier will be given automatically.
+
+**edge_id**  ``ANY-INTEGER``   Identifier of the "closest" edge to the point.
+**fraction** ``ANY-NUMERICAL`` Value in <0,1> that indicates the relative postition from the first end point of the edge.
+**side**     ``CHAR``          (optional) Value in ['b', 'r', 'l', NULL] indicating if the point is:
+                                 - In the right, left of the edge or
+                                 - If it doesn't matter with 'b' or NULL.
+                                 - If column not present 'b' is considered.
+============ ================= =================================================
+
+Where:
+
+:ANY-INTEGER: smallint, int, bigint
+:ANY-NUMERICAL: smallint, int, bigint, real, float
+
+points_sql_end
+
+*/
+
+
+#endif  // SRC_COMMON_SRC_POINTS_INPUT_H_
diff --git a/src/common/src/postgres_connection.c b/src/common/src/postgres_connection.c
index 478c604..9137bf3 100644
--- a/src/common/src/postgres_connection.c
+++ b/src/common/src/postgres_connection.c
@@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "postgres.h"
+#include <postgres.h>
 #include "catalog/pg_type.h"
 #include "executor/spi.h"
 
@@ -35,10 +35,12 @@ void
 pgr_send_error(int errcode) {
     switch (errcode) {
         case 1:
-            elog(ERROR, "Unexpected point(s) with same pid but different edge/fraction/side combination found.");
+            elog(ERROR, "Unexpected point(s) with same pid but different"
+                   " edge/fraction/side combination found.");
             break;
         case 2:
-            elog(ERROR, "Internal: Unexpected mismatch count and sequence number on results");
+            elog(ERROR, "Internal: Unexpected mismatch "
+                   "count and sequence number on results");
             break;
         default:
             elog(ERROR, "Unknown exception");
diff --git a/src/common/src/postgres_connection.h b/src/common/src/postgres_connection.h
index a7306bf..0e89b40 100644
--- a/src/common/src/postgres_connection.h
+++ b/src/common/src/postgres_connection.h
@@ -21,13 +21,13 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-
+#ifndef SRC_COMMON_SRC_POSTGRES_CONNECTION_H_
+#define SRC_COMMON_SRC_POSTGRES_CONNECTION_H_
 #pragma once
 
-#include "postgres.h"
+#include <postgres.h>
 #include "executor/spi.h"
 
-// #include "./pgr_types.h"
 
 void pgr_send_error(int errcode);
 void pgr_SPI_finish(void);
@@ -35,3 +35,5 @@ void pgr_SPI_connect(void);
 SPIPlanPtr pgr_SPI_prepare(char* sql);
 Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan);
 char* pgr_text2char(text *in);
+
+#endif  // SRC_COMMON_SRC_POSTGRES_CONNECTION_H_
diff --git a/src/common/src/restrictions_input.c b/src/common/src/restrictions_input.c
index 4a36165..a39a193 100644
--- a/src/common/src/restrictions_input.c
+++ b/src/common/src/restrictions_input.c
@@ -22,7 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "postgres.h"
+
+#include <postgres.h>
 #include "executor/spi.h"
 
 #include "./debug_macro.h"
@@ -41,21 +42,22 @@ void fetch_restriction(
         Restrict_t *restriction) {
     restriction->target_id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
     restriction->to_cost = pgr_SPI_getFloat8(tuple, tupdesc,  info[1]);
-    char *str = DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info[2].colNumber));
-// TODO because its  text, there is no garanee that the text read is correct
+    char *str = DatumGetCString(
+            SPI_getvalue(*tuple, *tupdesc, info[2].colNumber));
+
+// TODO(someone) because its text, no guarantee the text read is correct
 // move this code to c++ to tokenize the integers.
 
     int i = 0;
-    for(i = 0; i < MAX_RULE_LENGTH; ++i) restriction->via[i] = -1;
+    for (i = 0; i < MAX_RULE_LENGTH; ++i) restriction->via[i] = -1;
 
     if (str != NULL) {
         char *token = NULL;
         int i = 0;
 
-        token = (char *)strtok(str," ,");
+        token = (char *)strtok(str, " ,");
 
-        while (token != NULL && i < MAX_RULE_LENGTH)
-        {
+        while (token != NULL && i < MAX_RULE_LENGTH) {
             restriction->via[i] = atoi(token);
             i++;
             token = (char *)strtok(NULL, " ,");
@@ -115,9 +117,12 @@ pgr_get_restriction_data(
         PGR_DBG("SPI_processed %ld", ntuples);
         if (ntuples > 0) {
             if ((*restrictions) == NULL)
-                (*restrictions) = (Restrict_t *)palloc0(total_tuples * sizeof(Restrict_t));
+                (*restrictions) = (Restrict_t *)palloc0(
+                        total_tuples * sizeof(Restrict_t));
             else
-                (*restrictions) = (Restrict_t *)repalloc((*restrictions), total_tuples * sizeof(Restrict_t));
+                (*restrictions) = (Restrict_t *)repalloc(
+                        (*restrictions),
+                        total_tuples * sizeof(Restrict_t));
 
             if ((*restrictions) == NULL) {
                 elog(ERROR, "Out of memory");
@@ -145,7 +150,9 @@ pgr_get_restriction_data(
     }
 
     (*total_restrictions) = total_tuples;
-    PGR_DBG("Finish reading %ld data, %ld", total_tuples, (*total_restrictions));
+    PGR_DBG("Finish reading %ld data, %ld",
+            total_tuples,
+            (*total_restrictions));
     clock_t end_t = clock();
     time_msg(" reading Restrictions", start_t, end_t);
 }
diff --git a/src/common/src/restrictions_input.h b/src/common/src/restrictions_input.h
index c9f7da3..9243973 100644
--- a/src/common/src/restrictions_input.h
+++ b/src/common/src/restrictions_input.h
@@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_COMMON_SRC_RESTRICTIONS_INPUT_H_
+#define SRC_COMMON_SRC_RESTRICTIONS_INPUT_H_
 #pragma once
 
 #include "./pgr_types.h"
@@ -30,3 +32,5 @@ void pgr_get_restriction_data(
         char *restrictions_sql,
         Restrict_t **restructions,
         size_t *total_restrictions);
+
+#endif  // SRC_COMMON_SRC_RESTRICTIONS_INPUT_H_
diff --git a/src/common/src/signalhandler.h b/src/common/src/signalhandler.h
index 7508047..5ea9bde 100644
--- a/src/common/src/signalhandler.h
+++ b/src/common/src/signalhandler.h
@@ -34,8 +34,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #ifndef SRC_COMMON_SRC_SIGNALHANDLER_H_
 #define SRC_COMMON_SRC_SIGNALHANDLER_H_
+#pragma once
 
-#include <stddef.h>     // defines NULL
+// defines NULL
+#include <stddef.h>
 #include <csignal>
 #include <exception>
 
diff --git a/src/common/src/time_msg.c b/src/common/src/time_msg.c
index 6afcf4e..81c10ce 100644
--- a/src/common/src/time_msg.c
+++ b/src/common/src/time_msg.c
@@ -1,12 +1,38 @@
+/*PGR-GNU*****************************************************************
 
+FILE: time_msg.c
 
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
 
-#include "postgres.h"
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#include "./time_msg.h"
 #include <time.h>
+#include <postgres.h>
 
-#include "time_msg.h"
 
 void time_msg(char *msg, clock_t start_t, clock_t end_t) {
     double elapsed_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
-    elog(DEBUG1, "Elapsed time for %s: %lfsec = (%lf - %f) / CLOCKS_PER_SEC ", msg, elapsed_t, (double) end_t, (double) start_t);
-};
+    elog(DEBUG1, "Elapsed time for %s: %lfsec = (%lf - %f) / CLOCKS_PER_SEC ",
+            msg,
+            elapsed_t,
+            (double) end_t,
+            (double) start_t);
+}
diff --git a/src/common/src/time_msg.h b/src/common/src/time_msg.h
index 377b34f..0e96a45 100644
--- a/src/common/src/time_msg.h
+++ b/src/common/src/time_msg.h
@@ -1,5 +1,35 @@
+/*PGR-GNU*****************************************************************
+
+FILE: time_msg.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#ifndef SRC_COMMON_SRC_TIME_MSG_H_
+#define SRC_COMMON_SRC_TIME_MSG_H_
+#pragma once
 
 #include <time.h>
 #include <stdio.h>
 
 void time_msg(char *msg, clock_t start_t, clock_t end_t);
+
+#endif  // SRC_COMMON_SRC_TIME_MSG_H_
diff --git a/src/common/src/xy_vertex.cpp b/src/common/src/xy_vertex.cpp
new file mode 100644
index 0000000..802b281
--- /dev/null
+++ b/src/common/src/xy_vertex.cpp
@@ -0,0 +1,147 @@
+/*PGR-GNU*****************************************************************
+ *
+
+ Copyright (c) 2015 Celia Virginia Vergara Castillo
+ vicky_vergara at hotmail.com
+
+ ------
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
+
+
+#include <vector>
+#include <algorithm>
+
+#include "./xy_vertex.h"
+#include "./pgr_types.h"
+#include "./pgr_assert.h"
+
+
+namespace pgrouting {
+
+
+std::ostream& operator<<(std::ostream& log, const XY_vertex &v) {
+    log << v.id << "(" << v.point.x() << "," << v.point.y() << ")";
+    return log;
+}
+
+bool
+XY_vertex::operator==(const XY_vertex &rhs) const {
+    if (&rhs == this) return true;
+    return this->id == rhs.id && point == rhs.point;
+}
+
+
+size_t
+check_vertices(
+    std::vector < XY_vertex > vertices) {
+    auto count(vertices.size());
+    std::stable_sort(
+        vertices.begin(), vertices.end(),
+        [](const XY_vertex &lhs, const XY_vertex &rhs)
+        {return lhs.id < rhs.id;});
+    vertices.erase(
+        std::unique(
+            vertices.begin(), vertices.end(),
+            [](const XY_vertex &lhs, const XY_vertex &rhs)
+            {return lhs.id == rhs.id;}), vertices.end());
+
+    return count - vertices.size();
+}
+
+std::vector < XY_vertex >
+extract_vertices(
+    const std::vector <Pgr_edge_xy_t > &data_edges) {
+
+    std::vector< XY_vertex > vertices;
+    if (data_edges.empty()) return vertices;
+
+    vertices.reserve(data_edges.size() * 2);
+
+    for (const auto edge : data_edges) {
+        XY_vertex v_source(edge, true);
+        vertices.push_back(v_source);
+
+        XY_vertex v_target(edge, false);
+        vertices.push_back(v_target);
+    }
+
+    /*
+     * sort and delete duplicates
+     */
+    std::stable_sort(
+        vertices.begin(), vertices.end(),
+        [](const XY_vertex &lhs, const XY_vertex &rhs)
+        {return lhs.id < rhs.id;});
+    vertices.erase(
+        std::unique(
+            vertices.begin(), vertices.end(),
+            [](const XY_vertex &lhs, const XY_vertex &rhs)
+            {return lhs.id == rhs.id;}), vertices.end());
+    return vertices;
+}
+
+std::vector < XY_vertex >
+extract_vertices(
+    const Pgr_edge_xy_t *data_edges, int64_t count) {
+    return extract_vertices(
+        std::vector < Pgr_edge_xy_t >(data_edges, data_edges + count));
+}
+
+#if 0
+/* the following might be needed when using withPoints */
+std::vector < XY_vertex > extract_vertices(
+    std::vector < XY_vertex > vertices,
+    const std::vector < Pgr_edge_xy_t > data_edges) {
+    if (data_edges.empty()) return vertices;
+
+    vertices.reserve(vertices.size() + data_edges.size() * 2);
+
+    for (const auto edge : data_edges) {
+        vertices.push_back(XY_vertex(edge.source, edge.x1, edge.y1));
+        vertices.push_back(XY_vertex(edge.target, edge.x2, edge.y2));
+    }
+
+    /*
+     * sort and delete duplicates
+     */
+    std::stable_sort(vertices.begin(), vertices.end(),
+                     [](const XY_vertex &lhs, const XY_vertex &rhs)
+                     {return lhs.id < rhs.id;});
+
+    vertices.erase(
+        std::unique(vertices.begin(), vertices.end(),
+                    [](const XY_vertex &lhs, const XY_vertex &rhs)
+                    {return lhs.id == rhs.id;}), vertices.end());
+    return vertices;
+}
+std::vector < XY_vertex > extract_vertices(
+    std::vector < XY_vertex > vertices,
+    const Pgr_edge_xy_t *data_edges, int64_t count) {
+    return extract_vertices(vertices,
+            std::vector < Pgr_edge_xy_t >(data_edges, data_edges + count));
+}
+#endif
+
+}  // namespace pgrouting
diff --git a/src/common/src/xy_vertex.h b/src/common/src/xy_vertex.h
new file mode 100644
index 0000000..dccdf8a
--- /dev/null
+++ b/src/common/src/xy_vertex.h
@@ -0,0 +1,95 @@
+/*PGR-GNU*****************************************************************
+ *
+
+ Copyright (c) 2015 Celia Virginia Vergara Castillo
+ vicky_vergara at hotmail.com
+
+ ------
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#ifndef SRC_COMMON_SRC_XY_VERTEX_H_
+#define SRC_COMMON_SRC_XY_VERTEX_H_
+#pragma once
+
+#include <CGAL/Simple_cartesian.h>
+#include <vector>
+
+#include "./pgr_types.h"
+
+
+namespace pgrouting {
+
+// typedef boost::geometry::model::d2::point_xy<double> Point;
+typedef CGAL::Simple_cartesian<double> Simple_cartasian;
+typedef Simple_cartasian::Point_2  Point;
+
+
+class XY_vertex {
+ public:
+  XY_vertex() = default;
+  XY_vertex(const XY_vertex &) = default;
+  XY_vertex(const int64_t _id, double _x, double _y) :
+      id(_id), point(_x, _y) {
+      }
+
+  XY_vertex(const Pgr_edge_xy_t &other, bool is_source) :
+      id(is_source? other.source : other.target),
+      point(is_source? Point(other.x1, other.y1) : Point(other.x2, other.y2))
+      {}
+
+
+  double x() const {return point.x();}
+  double y() const {return point.y();}
+
+  inline void cp_members(const XY_vertex &other) {
+      this->id = other.id;
+      this->point = other.point;
+  }
+
+  friend std::ostream& operator<<(std::ostream& log, const XY_vertex &v);
+  bool operator==(const XY_vertex &rhs) const;
+
+ public:
+  int64_t id;
+  Point point;
+};
+
+size_t
+check_vertices(std::vector < XY_vertex > vertices);
+
+std::vector < XY_vertex >
+extract_vertices(
+    const Pgr_edge_xy_t *data_edges, int64_t count);
+
+std::vector < XY_vertex >
+extract_vertices(
+    const std::vector < Pgr_edge_xy_t > &data_edges);
+
+#if 0
+std::vector < XY_vertex > extract_vertices(
+    std::vector < XY_vertex > vertices,
+    const Pgr_edge_xy_t *data_edges, int64_t count);
+
+std::vector < XY_vertex > extract_vertices(
+    std::vector < XY_vertex > vertices,
+    const std::vector < Pgr_edge_xy_t > data_edges);
+#endif
+
+}  // namespace pgrouting
+
+#endif  // SRC_COMMON_SRC_XY_VERTEX_H_
diff --git a/src/contraction/demo/dead_end_demo.sql b/src/contraction/demo/dead_end_demo.sql
new file mode 100644
index 0000000..09f2250
--- /dev/null
+++ b/src/contraction/demo/dead_end_demo.sql
@@ -0,0 +1,56 @@
+DROP TABLE IF EXISTS edge_table;
+CREATE TABLE edge_table (
+    id SERIAL,
+    source INTEGER,
+    target INTEGER,
+    cost FLOAT
+);
+
+\echo 'Examples of dead end contraction for directed graphs'
+
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 7);
+
+SELECT * FROM edge_table;
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost FROM edge_table ',
+    ARRAY[]::BIGINT[], ARRAY[0]::integer[], 1, true);
+
+DELETE FROM edge_table;
+
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (3, 1, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (4, 1, 7);
+
+SELECT * FROM edge_table;
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost FROM edge_table ',
+    ARRAY[]::BIGINT[], ARRAY[0]::integer[], 1, true);
+
+DELETE FROM edge_table;
+
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 3);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 4);
+
+SELECT * FROM edge_table;
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost FROM edge_table ',
+    ARRAY[]::BIGINT[], ARRAY[0]::integer[], 1, false);
+
+DELETE FROM edge_table;
+
+\echo 'Examples of dead end contraction for undirected graphs'
+
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 3);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 4);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 3, 1);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 4, 2);
+
+SELECT * FROM edge_table;
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost FROM edge_table ',
+    ARRAY[]::BIGINT[], ARRAY[0]::integer[], 1, false);
+
+DELETE FROM edge_table;
+
diff --git a/src/contraction/demo/linear_demo.sql b/src/contraction/demo/linear_demo.sql
new file mode 100644
index 0000000..7cf5635
--- /dev/null
+++ b/src/contraction/demo/linear_demo.sql
@@ -0,0 +1,44 @@
+DROP TABLE IF EXISTS edge_table;
+CREATE TABLE edge_table (
+    id SERIAL,
+    source INTEGER,
+    target INTEGER,
+    cost FLOAT
+);
+
+\echo 'Examples of linear contraction for directed graphs'
+
+INSERT INTO edge_table (source, target, cost) VALUES (1, 2, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 3, 4);
+
+SELECT * FROM edge_table;
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost FROM edge_table ',
+    ARRAY[]::BIGINT[], ARRAY[1]::integer[], 1, true);
+
+DELETE FROM edge_table;
+
+INSERT INTO edge_table (source, target, cost) VALUES (1, 2, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 3, 4);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (3, 2, 4);
+
+SELECT * FROM edge_table;
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost FROM edge_table ',
+    ARRAY[]::BIGINT[], ARRAY[1]::integer[], 1, true);
+
+DELETE FROM edge_table;
+
+INSERT INTO edge_table (source, target, cost) VALUES (1, 2, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (1, 2, 3);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 3, 4);
+INSERT INTO edge_table (source, target, cost) VALUES (2, 1, 7);
+INSERT INTO edge_table (source, target, cost) VALUES (3, 2, 4);
+
+SELECT * FROM edge_table;
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost FROM edge_table ',
+    ARRAY[]::BIGINT[], ARRAY[1]::integer[], 1, true);
+
+DELETE FROM edge_table;
\ No newline at end of file
diff --git a/src/contraction/doc/contraction.rst b/src/contraction/doc/contraction.rst
index 680e196..dca8433 100644
--- a/src/contraction/doc/contraction.rst
+++ b/src/contraction/doc/contraction.rst
@@ -13,402 +13,510 @@
 Contraction
 ===============================================================================
 
-Contracting a graph becomes a crucial operation when talking about big graphs like
-the graphs involved in routing across cities, countries, continents or the whole world.
 
-The contraction level and contraction operations can become very complex, as the complexity
-of the graphs grows.
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
 
-For this proposal, we are making our contraction algorithm simple as possible so that
-more contraction operations can be added in the future.
+:ref:`pgr_contractGraph`
 
-We are not aiming with this work to implement all the possible contraction operations
-but to give a framework such that adding a contraction operation can be easily achieved.
+Introduction
+-------------
 
-For this contraction proposal I am only making 2 operations:
+In big graphs, like the road graphs, or electric networks, graph contraction can be used to speed up some graph algorithms. Contraction reduces the size of the graph by removing some of the vertices and edges and, for example, might add edges that represent a sequence of original edges decreasing the total time and space used in graph algorithms.
 
- 1. dead end contraction: vertices have one incoming edge
- 2. linear contraction: vertices have one incomming and one outgoing edge
-   
+This implementation gives a flexible framework for adding contraction algorithms in the future, currently, it supports two algorithms:
 
-And with the additional characteristics:
+ 1. Dead end contraction
+ 2. Linear contraction
 
-  - The user can forbid to contract a particular set of nodes or edges.
-  - The user can decide how many times the cycle can be done.
-  - If possible, the user can decide the order of the operations on a cycle.
+Allowing the user to:
 
-.. note:: Work on progress in contraction branch
+  - Forbid contraction on a set of nodes.
+  - Decide the order of the contraction algorithms and set the maximum number of times they are to be executed.
 
+.. note:: UNDER DISCUSSION:  Forbid contraction on a set of edges
 
-The contraction skeleton
+Dead end contraction
 -------------------------------------------------------------------------------
+In the algorithm, dead end contraction is represented by 1.
 
-In general we have an initial set up that may involve analizing the graph given as input and setting the
-non contractable nodes or edges. We have a cycle that will go and perform a contraction operation
-until while possible, and then move to the next contraction operation.
-Adding a new operation then becomes an "easy" task; more things might be involved, because the
-charachteristics of the graph change each time its contracted, so some interaction between contractions
-has to be implemented also.
+Dead end nodes
+......................
 
-Procedure
----------
+The definition of a dead end node is different for a directed and an undirected graph.
 
-* For contracting, we are going to cycle as follows
+In case of a undirected graph, a node is considered a dead end node if
 
-.. code-block:: none
+ - The number of adjacent vertices is 1.
+
+In case of an directed graph, a node is considered a dead end node if
+
+ - There are no outgoing edges and has at least one incoming edge.
+ - There is one incoming and one outgoing edge with the same identifier.
 
-    input: G(V,E);
-    removed_vertices = {};
+.. rubric:: Examples
 
+- The green node ``B`` represents a dead end node
+- The node ``A`` is the only node connecting to ``B``.
+- Node ``A`` is part of the rest of the graph and has an unlimited number of incoming and outgoing edges.
+- Directed graph
 
-    <initial set up>
-    do N times {
+.. graphviz::
 
-        while ( <conditions for 1> ) {
-            < contraction operation 1 >
-        }
-       
-        while ( <conditions for 2> ) {
-            < contraction operation 2>
-        }
-        .....
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        B [style=filled; color=green];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
+
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        A -> B;
     }
 
-    output: G'(V',E'), removed_vertices
 
+Operation: Dead End Contraction
+.....................................
 
+The dead end contraction will stop until there are no more dead end nodes.
+For example from the following graph:
 
-Contraction operations for this implementation
--------------------------------------------------------------------------------
+- Node ``A`` is connected to the rest of the graph by an unlimited number of edges.
+- Node ``B`` is connected to the rest of the graph with one incoming edge.
+- Node ``B`` is the only node connecting to ``C``.
+- The green node ``C`` represents a `Dead End` node
 
-Dead end contraction
-+++++++++++++++++++++
+.. graphviz::
 
-Characteristics:
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        B [style=filled; color=deepskyblue];
+        C [style=filled; color=green];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
 
-  - :math:`V1`: set of vertices with 1 incoming edge in increasing order of id:
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        A -> B;
+        B -> C;
+    }
 
-    - Edges with the same identifier are considered the same edge
-      and if it has the `reverse_cost` valid the outgoing edge is ignored
 
-.. code-block:: none
+After contracting ``C``, node ``B`` is now a `Dead End` node and is contracted:
 
+.. graphviz::
 
-    while ( V1 is not empty ) {
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        B [style=filled; color=green;label="B {C}";];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
 
-        delete vertex of V1
-        the deleted vertex add it to removed_vertices
-        vertex that leads to removed vertex, inherits the removed vertex
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        A -> B;
+    }
+
+Node ``B`` gets contracted
+
+.. graphviz::
 
-        <adjust any conditions that might affect other contraction operation>
+    digraph G {
+        A [style=filled;color=deepskyblue;label="A {B, C}";];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
+
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
     }
 
+Nodes ``B`` and ``C`` belong to node ``A``.
+
+
+
+Not Dead End nodes
+......................
+
+In this graph ``B`` is not a `dead end` node.
+
+.. graphviz::
 
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        B [style=filled; color=red];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
+
+        G -> A [dir=none, weight=1, penwidth=3];
+        B -> A;
+    }
 
 Linear contraction
-+++++++++++++++++++++
+-------------------------------------------------------------------------------
+In the algorithm, linear contraction is represented by 2.
 
-Characteristics:
+Linear nodes
+......................
 
-  - :math:`V2`: vertex with 1 incoming edge and 1 outgoing edge:
+A node is considered a linear node if satisfies the following:
 
-    - The outgoing edge must have different identifier of the incomming edge
+- The number of adjacent vertices are 2.
+- Should have at least one incoming edge and one outgoing edge.
 
-.. code-block:: none
+.. rubric:: Examples
+
+- The green node ``B`` represents a linear node
+- The nodes ``A`` and ``C`` are the only nodes connecting to ``B``.
+- Node ``A`` is part of the rest of the graph and has an unlimited number of incoming and outgoing edges.
+- Node ``C`` is part of the rest of the graph and has an unlimited number of incoming and outgoing edges.
+- Directed graph
 
-    while ( V2 is not empty ) {
+.. graphviz::
 
-        delete vertex of V2
-        create edge (shortcut)
-        the deleted vertex add it to removed_vertices
-        inewly created edge, inherits the removed vertex
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        B [style=filled; color=green];
+        C [style=filled;color=deepskyblue];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
 
-        <adjust any conditions that might affect other contraction operations>
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        G -> C [dir=none, weight=1, penwidth=3];
+        A -> B;
+        B -> C;
     }
 
+Operation: Linear Contraction
+.....................................
 
-Notation
-++++++++++
+The linear contraction will stop until there are no more linear nodes.
+For example from the following graph:
 
-* V: is the set of vertices
-* E: is the set of edges
-* G: is the graph
-* :math:`V1`: is the set of *dead end* vertices 
-* :math:`V2`: is the set of *linear* vertices
-* removed_vertices: is the set of removed vertices
+- Node ``A`` is connected to the rest of the graph by an unlimited number of edges.
+- Node ``B`` is connected to the rest of the graph with one incoming edge and one outgoing edge.
+- Node ``C`` is connected to the rest of the graph with one incoming edge and one outgoing edge.
+- Node ``D`` is connected to the rest of the graph by an unlimited number of edges.
+- The green nodes ``B`` and ``C`` represents `Linear` nodes.
 
-The contracted graph will be represented with two parameters, the modified Graph, and the removed_vertices set.
+.. graphviz::
 
-removed_vertices = {(v,1):{2}, (e,-1):{3}}.
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        B [style=filled; color=green];
+        C [style=filled; color=green];
+        D [style=filled; color=deepskyblue];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
 
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        G -> D [dir=none, weight=1, penwidth=3];
+        A -> B;
+        B -> C;
+        C -> D;
 
-The above notation indicates:
-  - Vertex 2 is removed, and belongs to vertex 1 subgraph
-  - Vertex 3 is removed, and belongs to edge -1 subgraph
+    }
 
+After contracting ``B``, a new edge gets inserted between ``A`` and ``C`` which is represented by red color.
 
-Examples
--------------------------------------------------------------------------------
+.. graphviz::
 
-For simplicity all the edges in the examples have unit weight.
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        C [style=filled; color=green];
+        D [style=filled; color=deepskyblue];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
 
-Dead End
-+++++++++++++++++
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        G -> D [dir=none, weight=1, penwidth=3];
+        A -> C [label="{B}";color=red]
+        C -> D;
 
-* Perform dead end contraction operation first and then linear contraction
-* 1 cycle of contraction.
+    }
 
-.. image:: images/twoNodesoneEdge_a.png
+Node ``C`` is `linear node` and gets contracted.
 
-:Input:  G = {V:{1, 2}, E:{(1, 2)}}
+.. graphviz::
 
-:initial set up:
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        D [style=filled; color=deepskyblue];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
 
-.. code-block:: none
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        G -> D [dir=none, weight=1, penwidth=3];
+        A -> D [label="{B, C}";color=red];
 
-    removed_vertices={}
-    V1 = {2}
-    V2 = {}
+    }
+
+Nodes ``B`` and ``C`` belong to edge connecting ``A`` and ``D`` which is represented by red color.
+
+Not Linear nodes
+......................
+
+In this graph ``B`` is not a `linear` node.
+
+.. graphviz::
 
+    digraph G {
+        A [style=filled;color=deepskyblue];
+        B [style=filled; color=red];
+        C [style=filled;color=deepskyblue];
+        "G" [shape=tripleoctagon;
+        style=filled;color=deepskyblue;
+        label = "Rest of the Graph"];
 
-:procedure:
+        rankdir=LR;
+        G -> A [dir=none, weight=1, penwidth=3];
+        G -> C [dir=none, weight=1, penwidth=3];
+        A -> B;
+        C -> B;
+    }
+
+
+The cycle
+---------
+
+Contracting a graph, can be done with more than one operation. The order of the operations affect the resulting contracted graph, after applying one operation, the set of vertices that can be contracted by another operation changes.
+
+This implementation, cycles ``max_cycles`` times through ``operations_order`` .
 
 .. code-block:: none
 
-    V1 = {2} is not empty
+    <input>
+    do max_cycles times {
+        for (operation in operations_order) 
+         { do operation }
+    }
+    <output>
+
+
+Contracting Sample Data
+-------------------------------------------------------------
 
-        V1 = {}
-        V2 = {}
-        G = {V:{1}, E:{}}
-        removed_vertices = {(v, 1):{2}}.
+In this section, building and using a contracted graph will be shown by example.
 
-    V1 is empty
+- The :ref:`sampledata` for an undirected graph is used
+- a dead end operation first followed by a linear operation.
 
-Since V1 is empty we go on to the next contraction operation
+The original graph:
+
+.. image:: images/undirected_sampledata_a.png
+
+After doing a dead end contraction operation:
     
-.. code-block:: none
+.. image:: images/undirected_sampledata_b.png
 
-    V2 is empty
+Doing a linear contraction operation to the graph above
     
+.. image:: images/undirected_sampledata_c.png
 
-So we do not perform any linear contraction operation.
 
-:Results:
+There are five cases, in this documentation, which arise when calculating the shortest path between a given source and target.
+In this examples, ``pgr_dijkstra`` is used.
 
-.. code-block:: none
+- **Case 1**: Both source and target belong to the contracted graph.
+- **Case 2**: Source belongs to a contracted graph, while target belongs to a edge subgraph.
+- **Case 3**: Source belongs to a vertex subgraph, while target belongs to an edge subgraph.
+- **Case 4**: Source belongs to a contracted graph, while target belongs to an vertex subgraph.
+- **Case 5**: The path contains a new edge added by the contraction algorithm.
 
-    G = {V:{1}, E:{}}
-    removed_vertices = {(v, 1):{2}}
+Construction of the graph in the database
+..........................................
 
-Visualy the results are
-    
-.. image:: images/twoNodesoneEdge_b.png
+.. rubric:: Original Data
 
+The following query shows the original data involved in the contraction operation.
 
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q00
+   :end-before: -- q01
 
-Linear contraction
-++++++++++++++++++++
+.. rubric:: Contraction Results
 
-* Perform linear contraction operation first and then dead end contraction
-* 1 cycle of contraction.
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q2
+   :end-before: -- q3
 
-.. image:: images/threeNodestwoEdges_a.png
+The above results do not represent the contracted graph. They represent the changes done to the graph after applying the contraction algorithm. We can see that vertices like 6 and 11 do not appear in the contraction results because they were not affected by the contraction algorithm.
 
+.. rubric:: step 1
 
-:Input: G = {V:{1, 2, 3}, E:{(1, 2), (2, 3)}}
+Adding extra columns to the ``edge_table`` and ``edge_table_vertices_pgr`` tables:
 
+=======================  ==================================================
+Column                    Description
+=======================  ==================================================
+**contracted_vertices**    The vertices set belonging to the vertex/edge
+**is_contracted**          On a `vertex` table: when ``true`` the vertex is contracted, so is not part of the contracted graph.
+**is_contracted**          On an `edge` table: when ``true`` the edge was generated by the contraction algorithm.
+=======================  ==================================================
 
-:initial set up:
+Using the following queries:
 
-.. code-block:: none
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q1
+   :end-before: -- q2
 
-    removed_vertices={}
-    V1 = {3}
-    V2 = {2}
+.. rubric:: step 2
 
-:procedure:
+For simplicity, in this documentation, store the results of the call to pgr_contractGraph in a temporary table
 
-.. code-block:: none
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q3
+   :end-before: -- q4
 
-    V2 = {2} is not empty
+.. rubric:: step 3
 
-        V1 = {3}
-        removed_vertices = {(e, -1):{2}}
-        V2 = {}
-        G = {V:{1, 3}, E:{-1(1,3,c=2)}}
+Update the `vertex` and `edge` tables using the results of the call to pgr_contraction
 
-    V2 is empty
+- In `edge_table_vertices_pgr.is_contracted` indicate the vertices that are contracted.
 
-.. image:: images/threeNodestwoEdges_b.png
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q4
+   :end-before: -- q5
 
-Since V2 is empty we go on to the next contraction operation
-    
-.. code-block:: none
+- Add to `edge_table_vertices_pgr.contracted_vertices`  the contracted vertices belonging to the vertices.
 
-    V1 = {3} is not empty
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q6
+   :end-before: -- q7
 
-        V1 = {}
-        V2 = {}
-        removed_vertices = {(v, 1):{3, 2}}.
-        G = {V:{1}, E:{}}
+- Insert the new edges generated by  pgr_contractGraph.
 
-    V1 is empty
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q8
+   :end-before: -- q9
 
+.. rubric:: step 3.1
 
-:Results:
+Verify visually the updates.
 
-.. code-block:: none
+- On the `edge_table_vertices_pgr`
 
-    removed_vertices = {(v, 1):{3, 2}}.
-    G = {V:{1}, E:{}}
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q7
+   :end-before: -- q8
 
-Visualy the results are
-    
-.. image:: images/threeNodestwoEdges_c.png
- 
+- On the `edge_table`
 
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q9
+   :end-before: -- q10
 
-Sample Data
-++++++++++++++++++++++++
+- vertices that belong to the contracted graph are the non contracted vertices 
 
-* Perform dead end contraction operation first and then linear contraction
-* 1 cycle of contraction.
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q10
+   :end-before: -- case1
 
-.. image:: images/undirected_sampledata_a.png
+.. rubric:: case 1: Both source and target belong to the contracted graph. 
 
-:Input:  G = {V:{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}, 
-         E:{1(1, 2), 2(2,3), 3(3,4), 4(2,5), 5(3,6), 6(7,8), 7(8,5), 8(5,6),
-         9(6,9), 10(5,10), 11(6,11), 12(10,11), 13(11,12), 14(10,13), 15(9,12),
-         16(4,9), 17(14,15), 18(16,17)}}
+Inspecting the contracted graph above, vertex 3 and vertex 11 are part of the contracted graph. In the following query:
+ 
+ - vertices_in_graph hold the vertices that belong to the contracted graph.
+ - when selecting the edges, only edges that have the source and the target in that set are the edges belonging to the contracted graph, that is done in the WHERE clause.
 
-:initial set up:
+Visually, looking at the original graph, going from 3 to 11: 3 -> 6 -> 11, and in the contracted graph, it is also 3 -> 6 -> 11.
+The results, on the contracted graph match the results as if it was done on the original graph.
 
-.. code-block:: none
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- case1
+   :end-before: -- case2
 
-    removed_vertices={}
-    V1 = {1,7,13,14,15,16,17}
-    V2 = {4,8,12}
+.. rubric:: case 2: Source belongs to the contracted graph, while target belongs to a edge subgraph.
 
+Inspecting the contracted graph above, vertex 3 is part of the contracted graph and vertex 1 belongs to the contracted subgraph of edge 19. In the following query:
+  - expand1 holds the contracted vertices of the edge where vertex 1 belongs. (belongs to edge 19).
+  - vertices_in_graph hold the vertices that belong to the contracted graph and also the contracted vertices of edge 19.
+  - when selecting the edges, only edges that have the source and the target in that set are the edges belonging to the contracted graph, that is done in the WHERE clause.
 
-:procedure:
+Visually, looking at the original graph, going from 3 to 1: 3 -> 2 -> 1, and in the contracted graph, it is also 3 -> 2 -> 1.
+The results, on the contracted graph match the results as if it was done on the original graph.
 
-.. code-block:: none
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- case2
+   :end-before: -- case3
 
-    V1 = {1,7,13,14,15,16,17} is not empty
 
-        V1 = {7,13,14,15,16,17}
-        V2 = {2,4,8,12}
-        G = {V:{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}, 
-        E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 6(7,8), 7(8,5), 8(5,6), 9(6,9),
-            10(5,10), 11(6,11), 12(10,11), 13(11,12), 14(10,13), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
-        removed_vertices = {(v, 2):{1}}.
+.. rubric:: case 3: Source belongs to a vertex subgraph, while target belongs to an edge subgraph.
 
-    
-    V1 = {7,13,14,15,16,17} is not empty
-
-        V1 = {8,13,14,15,16,17}
-        V2 = {2,4,12}
-        G = {V:{2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}, 
-        E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 7(8,5), 8(5,6), 9(6,9), 10(5,10),
-            11(6,11), 12(10,11), 13(11,12), 14(10,13), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
-        removed_vertices = {(v, 2):{1}, (v,8):{7}}.
-
-    V1 = {8,13,14,15,16,17} is not empty
-
-        V1 = {13,14,15,16,17}
-        V2 = {2,4,12}
-        G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17}, 
-        E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
-             11(6,11), 12(10,11), 13(11,12), 14(10,13), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
-        removed_vertices = {(v, 2):{1}, (v,5):{8,7}}.
-
-    V1 = {13,14,15,16,17} is not empty
-
-        V1 = {14,15,16,17}
-        V2 = {2,4,10,12}
-        G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 14, 15, 16, 17}, 
-        E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
-             11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
-        removed_vertices = {(v, 2):{1}, (v,5):{8,7}, (v,10):{13}}.
-
-    V1 = {14,15,16,17} is not empty
-
-        V1 = {16,17}
-        V2 = {2,4,10,12}
-        G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 15, 16, 17}, 
-        E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
-             11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9)}, 18(16,17)}
-        removed_vertices = {(v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}}.
-
-    V1 = {16,17} is not empty
-
-        V1 = {}
-        V2 = {2,4,10,12}
-        G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 15, 17}, 
-        E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
-             11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9)}}
-        removed_vertices = {(v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}, (v,17):{16}}.
-
-    Since V1 is empty we go on to the next contraction operation
-    
-.. image:: images/undirected_sampledata_b.png
+Inspecting the contracted graph above, vertex 7 belongs to the contracted subgraph of vertex 5 and vertex 13 belongs to the contracted subgraph of edge 21. In the following query:
 
-.. code-block:: none
+ - expand7 holds the contracted vertices of vertex where vertex 7 belongs. (belongs to vertex 5)
+ - expand13 holds the contracted vertices of edge where vertex 13 belongs. (belongs to edge 21)
+ - vertices_in_graph hold the vertices that belong to the contracted graph, contracted vertices of vertex 5 and contracted vertices of edge 21.
+ - when selecting the edges, only edges that have the source and the target in that set are the edges belonging to the contracted graph, that is done in the WHERE clause.
 
-    V2 = {2,4,10,12} is not empty
+Visually, looking at the original graph, going from 7 to 13: 7 -> 8 -> 5 -> 10 -> 13, and in the contracted graph, it is also 7 -> 8 -> 5 -> 10 -> 13.
+The results, on the contracted graph match the results as if it was done on the original graph.
 
-        V1 = {}
-        V2 = {4,10,12}
-        G = {V:{3, 4, 5, 6, 9, 10, 11, 12, 15, 17}, 
-        E:{-1(3,5), 3(3,4), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
-             11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9)}}
-        removed_vertices = {(e, -1):{1,2}, (v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}, (v,17):{16}}.
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- case3
+   :end-before: -- case4
 
-    V2 = {4,10,12} is not empty
 
-        V1 = {}
-        V2 = {10,12}
-        G = {V:{3, 5, 6, 9, 10, 11, 12, 15, 17}, 
-        E:{-1(3,5),-2(3,9), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
-             11(6,11), 12(10,11), 13(11,12), 15(9,12)}}
-        removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}, (v,17):{16}}.
+.. rubric:: case 4: Source belongs to the contracted graph, while target belongs to an vertex subgraph.
 
-    V2 = {10,12} is not empty
+Inspecting the contracted graph above, vertex 3 is part of the contracted graph and vertex 7 belongs to the contracted subgraph of vertex 5. In the following query:
+ 
+ - expand7 holds the contracted vertices of vertex where vertex 7 belongs. (belongs to vertex 5)
+ - vertices_in_graph hold the vertices that belong to the contracted graph and the contracted vertices of vertex 5.
+ - when selecting the edges, only edges that have the source and the target in that set are the edges belonging to the contracted graph, that is done in the WHERE clause.
 
-        V1 = {}
-        V2 = {12}
-        G = {V:{3, 5, 6, 9, 11, 12, 15, 17}, 
-        E:{-1(3,5),-2(3,9), -3(5,11), 5(3,6), 8(5,6), 9(6,9),
-             11(6,11), 13(11,12), 15(9,12)}}
-        removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (e,-3):{10,13}, (v, 2):{1}, (v,5):{8,7}, (v,15):{14}, (v,17):{16}}.
+Visually, looking at the original graph, going from 3 to 7: 3 -> 2 -> 5 -> 8 -> 7, but in the contracted graph, it is 3 -> 5 -> 8 -> 7.
+The results, on the contracted graph do not match the results as if it was done on the original graph. This is because the path contains edge 19 which is added by the contraction algorithm.
 
-    V2 = {12} is not empty
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- case4
+   :end-before: -- case5q1
 
-        V1 = {}
-        V2 = {}
-        G = {V:{3, 5, 6, 9, 11, 15, 17}, 
-        E:{-1(3,5),-2(3,9), -3(5,11), -4(9,11), 5(3,6), 8(5,6), 9(6,9), 11(6,11)}}
-        removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (e,-3):{10,13}, (e, -4):{12},
-             (v, 2):{1}, (v,5):{8,7}, (v,15):{14}, (v,17):{16}}.
+.. rubric:: case 5: The path contains an edge added by the contraction algorithm.
 
-Since V1 and V2 are empty we stop our contraction here. 
+In the previous example we can see that the path from vertex 3 to vertex 7 contains an edge which is added by the contraction algorithm.
 
-:Results:
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- case5q1
+   :end-before: -- case5q2
 
-.. code-block:: none
+Inspecting the contracted graph above, edge 19 should be expanded. In the following query:
 
-    G = {V:{3, 5, 6, 9, 11, 15, 17}, 
-    E:{-1(3,5),-2(3,9), -3(5,11), -4(9,11), 5(3,6), 8(5,6), 9(6,9), 11(6,11)}}
-    removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (e,-3):{10,13}, (e, -4):{12},
-         (v, 2):{1}, (v,5):{8,7}, (v,15):{14}, (v,17):{16}}.
+ - first_dijkstra holds the results of the dijkstra query.
+ - edges_to_expand holds the edges added by the contraction algorithm and included in the path.
+ - vertices_in_graph hold the vertices that belong to the contracted graph, vertices of the contracted solution and the contracted vertices of the edges added by the contraction algorithm and included in the contracted solution.
+ - when selecting the edges, only edges that have the source and the target in that set are the edges belonging to the contracted graph, that is done in the WHERE clause.
 
-Visualy the results are
-    
-.. image:: images/undirected_sampledata_c.png
+Visually, looking at the original graph, going from 3 to 7: 3 -> 2 -> 5 -> 8 -> 7, and in the contracted graph, it is also 3 -> 2 -> 5 -> 8 -> 7.
+The results, on the contracted graph match the results as if it was done on the original graph.
 
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- case5q2
+   :end-before: -- end
 
-References
-++++++++++++++++++++++++++
+See Also
+-------------
 
 * http://www.cs.cmu.edu/afs/cs/academic/class/15210-f12/www/lectures/lecture16.pdf
 * http://algo2.iti.kit.edu/documents/routeplanning/geisberger_dipl.pdf
+* The queries use :ref:`pgr_contractGraph` function and the :ref:`sampledata` network. 
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/contraction/doc/doc-contractGraph.queries b/src/contraction/doc/doc-contractGraph.queries
new file mode 100644
index 0000000..247c655
--- /dev/null
+++ b/src/contraction/doc/doc-contractGraph.queries
@@ -0,0 +1,56 @@
+-- q1
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1, 2]);
+ seq | type | id | contracted_vertices | source | target | cost 
+-----+------+----+---------------------+--------+--------+------
+   1 | v    |  5 | {7,8}               |     -1 |     -1 |   -1
+   2 | v    | 15 | {14}                |     -1 |     -1 |   -1
+   3 | v    | 17 | {16}                |     -1 |     -1 |   -1
+   4 | e    | -1 | {1,2}               |      3 |      5 |    2
+   5 | e    | -2 | {4}                 |      9 |      3 |    2
+   6 | e    | -3 | {10,13}             |      5 |     11 |    2
+   7 | e    | -4 | {12}                |     11 |      9 |    2
+(7 rows)
+
+-- q2
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1, 2], forbidden_vertices:=ARRAY[2]);
+ seq | type | id | contracted_vertices | source | target | cost 
+-----+------+----+---------------------+--------+--------+------
+   1 | v    |  2 | {1}                 |     -1 |     -1 |   -1
+   2 | v    |  5 | {7,8}               |     -1 |     -1 |   -1
+   3 | v    | 15 | {14}                |     -1 |     -1 |   -1
+   4 | v    | 17 | {16}                |     -1 |     -1 |   -1
+   5 | e    | -1 | {4}                 |      9 |      3 |    2
+   6 | e    | -2 | {10,13}             |      5 |     11 |    2
+   7 | e    | -3 | {12}                |     11 |      9 |    2
+(7 rows)
+
+-- q3
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]);
+ seq | type | id | contracted_vertices | source | target | cost 
+-----+------+----+---------------------+--------+--------+------
+   1 | v    |  2 | {1}                 |     -1 |     -1 |   -1
+   2 | v    |  5 | {7,8}               |     -1 |     -1 |   -1
+   3 | v    | 10 | {13}                |     -1 |     -1 |   -1
+   4 | v    | 15 | {14}                |     -1 |     -1 |   -1
+   5 | v    | 17 | {16}                |     -1 |     -1 |   -1
+(5 rows)
+
+-- q4
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[2]);
+ seq | type | id | contracted_vertices | source | target | cost 
+-----+------+----+---------------------+--------+--------+------
+   1 | e    | -1 | {4}                 |      9 |      3 |    2
+   2 | e    | -2 | {8}                 |      5 |      7 |    2
+   3 | e    | -3 | {8}                 |      7 |      5 |    2
+   4 | e    | -4 | {12}                |     11 |      9 |    2
+(4 rows)
+
+-- q5
diff --git a/src/contraction/doc/doc-contraction.queries b/src/contraction/doc/doc-contraction.queries
new file mode 100644
index 0000000..46cbaf3
--- /dev/null
+++ b/src/contraction/doc/doc-contraction.queries
@@ -0,0 +1,354 @@
+-- q00
+SELECT id, source, target, cost, reverse_cost FROM edge_table;
+ id | source | target | cost | reverse_cost 
+----+--------+--------+------+--------------
+  1 |      1 |      2 |    1 |            1
+  2 |      2 |      3 |   -1 |            1
+  3 |      3 |      4 |   -1 |            1
+  4 |      2 |      5 |    1 |            1
+  5 |      3 |      6 |    1 |           -1
+  6 |      7 |      8 |    1 |            1
+  7 |      8 |      5 |    1 |            1
+  8 |      5 |      6 |    1 |            1
+  9 |      6 |      9 |    1 |            1
+ 10 |      5 |     10 |    1 |            1
+ 11 |      6 |     11 |    1 |           -1
+ 12 |     10 |     11 |    1 |           -1
+ 13 |     11 |     12 |    1 |           -1
+ 14 |     10 |     13 |    1 |            1
+ 15 |      9 |     12 |    1 |            1
+ 16 |      4 |      9 |    1 |            1
+ 17 |     14 |     15 |    1 |            1
+ 18 |     16 |     17 |    1 |            1
+(18 rows)
+
+-- q01
+SET client_min_messages TO error;
+SET
+-- q1
+ALTER TABLE edge_table ADD contracted_vertices BIGINT[];
+ALTER TABLE
+ALTER TABLE edge_table_vertices_pgr ADD contracted_vertices BIGINT[];
+ALTER TABLE
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false;
+ALTER TABLE
+ALTER TABLE edge_table_vertices_pgr ADD is_contracted BOOLEAN DEFAULT false;
+ALTER TABLE
+-- q2
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    array[1,2], directed:=true);
+ seq | type | id | contracted_vertices | source | target | cost 
+-----+------+----+---------------------+--------+--------+------
+   1 | v    |  5 | {7,8}               |     -1 |     -1 |   -1
+   2 | v    | 15 | {14}                |     -1 |     -1 |   -1
+   3 | v    | 17 | {16}                |     -1 |     -1 |   -1
+   4 | e    | -1 | {1,2}               |      3 |      5 |    2
+   5 | e    | -2 | {4}                 |      9 |      3 |    2
+   6 | e    | -3 | {10,13}             |      5 |     11 |    2
+   7 | e    | -4 | {12}                |     11 |      9 |    2
+(7 rows)
+
+-- q3
+SELECT * INTO contraction_results
+FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    array[1,2], directed:=true);
+SELECT 7
+-- q4
+UPDATE edge_table_vertices_pgr
+SET is_contracted = true
+WHERE id IN (SELECT  unnest(contracted_vertices) FROM  contraction_results);
+UPDATE 10
+-- q5
+SELECT id, is_contracted
+FROM edge_table_vertices_pgr
+ORDER BY id;
+ id | is_contracted 
+----+---------------
+  1 | t
+  2 | t
+  3 | f
+  4 | t
+  5 | f
+  6 | f
+  7 | t
+  8 | t
+  9 | f
+ 10 | t
+ 11 | f
+ 12 | t
+ 13 | t
+ 14 | t
+ 15 | f
+ 16 | t
+ 17 | f
+(17 rows)
+
+-- q6
+UPDATE edge_table_vertices_pgr
+SET contracted_vertices = contraction_results.contracted_vertices
+FROM contraction_results
+WHERE type = 'v' AND edge_table_vertices_pgr.id = contraction_results.id;
+UPDATE 3
+-- q7
+SELECT id, contracted_vertices, is_contracted 
+FROM edge_table_vertices_pgr
+ORDER BY id;
+ id | contracted_vertices | is_contracted 
+----+---------------------+---------------
+  1 |                     | t
+  2 |                     | t
+  3 |                     | f
+  4 |                     | t
+  5 | {7,8}               | f
+  6 |                     | f
+  7 |                     | t
+  8 |                     | t
+  9 |                     | f
+ 10 |                     | t
+ 11 |                     | f
+ 12 |                     | t
+ 13 |                     | t
+ 14 |                     | t
+ 15 | {14}                | f
+ 16 |                     | t
+ 17 | {16}                | f
+(17 rows)
+
+-- q8
+INSERT INTO edge_table(source, target, cost, reverse_cost, contracted_vertices, is_contracted)
+SELECT source, target, cost, -1, contracted_vertices, true
+FROM contraction_results
+WHERE type = 'e';
+INSERT 0 4
+-- q9
+SELECT id, source, target, cost, reverse_cost, contracted_vertices, is_contracted 
+FROM edge_table
+ORDER BY id;
+ id | source | target | cost | reverse_cost | contracted_vertices | is_contracted 
+----+--------+--------+------+--------------+---------------------+---------------
+  1 |      1 |      2 |    1 |            1 |                     | f
+  2 |      2 |      3 |   -1 |            1 |                     | f
+  3 |      3 |      4 |   -1 |            1 |                     | f
+  4 |      2 |      5 |    1 |            1 |                     | f
+  5 |      3 |      6 |    1 |           -1 |                     | f
+  6 |      7 |      8 |    1 |            1 |                     | f
+  7 |      8 |      5 |    1 |            1 |                     | f
+  8 |      5 |      6 |    1 |            1 |                     | f
+  9 |      6 |      9 |    1 |            1 |                     | f
+ 10 |      5 |     10 |    1 |            1 |                     | f
+ 11 |      6 |     11 |    1 |           -1 |                     | f
+ 12 |     10 |     11 |    1 |           -1 |                     | f
+ 13 |     11 |     12 |    1 |           -1 |                     | f
+ 14 |     10 |     13 |    1 |            1 |                     | f
+ 15 |      9 |     12 |    1 |            1 |                     | f
+ 16 |      4 |      9 |    1 |            1 |                     | f
+ 17 |     14 |     15 |    1 |            1 |                     | f
+ 18 |     16 |     17 |    1 |            1 |                     | f
+ 19 |      3 |      5 |    2 |           -1 | {1,2}               | t
+ 20 |      9 |      3 |    2 |           -1 | {4}                 | t
+ 21 |      5 |     11 |    2 |           -1 | {10,13}             | t
+ 22 |     11 |      9 |    2 |           -1 | {12}                | t
+(22 rows)
+
+-- q10
+SELECT id  FROM edge_table_vertices_pgr
+WHERE is_contracted = false
+ORDER BY id;
+ id 
+----
+  3
+  5
+  6
+  9
+ 11
+ 15
+ 17
+(7 rows)
+
+-- case1
+SELECT * FROM pgr_dijkstra(
+    $$
+    WITH
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false)
+    SELECT id, source, target, cost, reverse_cost 
+    FROM edge_table 
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    3, 11, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |    5 |    1 |        0
+   2 |        2 |    6 |   11 |    1 |        1
+   3 |        3 |   11 |   -1 |    0 |        2
+(3 rows)
+
+-- case2
+SELECT * FROM pgr_dijkstra(
+    $$
+    WITH
+    expand_edges AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table),
+    expand1 AS (SELECT contracted_vertices FROM edge_table
+        WHERE id IN (SELECT id FROM expand_edges WHERE vertex = 1)),
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand1)
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    3, 1, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |    2 |    1 |        0
+   2 |        2 |    2 |    1 |    1 |        1
+   3 |        3 |    1 |   -1 |    0 |        2
+(3 rows)
+
+-- case3
+SELECT * FROM pgr_dijkstra(
+    $$
+    WITH
+
+    expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+    expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+        WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+
+    expand_edges AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table),
+    expand13 AS (SELECT contracted_vertices FROM edge_table
+        WHERE id IN (SELECT id FROM expand_edges WHERE vertex = 13)),
+
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand13
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand7)
+
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    7, 13, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    7 |    6 |    1 |        0
+   2 |        2 |    8 |    7 |    1 |        1
+   3 |        3 |    5 |   10 |    1 |        2
+   4 |        4 |   10 |   14 |    1 |        3
+   5 |        5 |   13 |   -1 |    0 |        4
+(5 rows)
+
+-- case4
+SELECT * FROM  pgr_dijkstra(
+    $$
+    WITH
+    expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+    expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+        WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand7)
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    3, 7, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |   19 |    2 |        0
+   2 |        2 |    5 |    7 |    1 |        2
+   3 |        3 |    8 |    6 |    1 |        3
+   4 |        4 |    7 |   -1 |    0 |        4
+(4 rows)
+
+-- case5q1
+WITH
+first_dijkstra AS (
+    SELECT * FROM  pgr_dijkstra(
+        $$
+        WITH
+        expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+        expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+            WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+        vertices_in_graph AS (
+            SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+            UNION
+            SELECT unnest(contracted_vertices) FROM expand7)
+        SELECT id, source, target, cost, reverse_cost
+        FROM edge_table
+        WHERE source IN (SELECT * FROM vertices_in_graph)
+        AND target IN (SELECT * FROM vertices_in_graph)
+        $$,
+        3, 7, false))
+SELECT edge, contracted_vertices
+    FROM first_dijkstra JOIN edge_table
+    ON (edge = id)
+    WHERE is_contracted = true;
+ edge | contracted_vertices 
+------+---------------------
+   19 | {1,2}
+(1 row)
+
+-- case5q2
+SELECT * FROM pgr_dijkstra($$
+    WITH
+    -- This returns the results from case 2
+    first_dijkstra AS (
+        SELECT * FROM  pgr_dijkstra(
+            '
+            WITH
+            expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+            expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+                WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+            vertices_in_graph AS (
+                SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+                UNION
+                SELECT unnest(contracted_vertices) FROM expand7)
+            SELECT id, source, target, cost, reverse_cost
+            FROM edge_table
+            WHERE source IN (SELECT * FROM vertices_in_graph)
+            AND target IN (SELECT * FROM vertices_in_graph)
+            ',
+            3, 7, false)),
+
+    -- edges that need expansion and the vertices to be expanded.
+    edges_to_expand AS (
+        SELECT edge, contracted_vertices
+        FROM first_dijkstra JOIN edge_table
+        ON (edge = id)
+        WHERE is_contracted = true),
+
+    vertices_in_graph AS (
+        -- the nodes of the contracted solution
+        SELECT node FROM first_dijkstra
+        UNION
+        -- the nodes of the expanding sections
+        SELECT unnest(contracted_vertices) FROM edges_to_expand)
+
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    -- not including the expanded edges
+    AND id NOT IN (SELECT edge FROM edges_to_expand)
+    $$,
+    3, 7, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |    2 |    1 |        0
+   2 |        2 |    2 |    4 |    1 |        1
+   3 |        3 |    5 |    7 |    1 |        2
+   4 |        4 |    8 |    6 |    1 |        3
+   5 |        5 |    7 |   -1 |    0 |        4
+(5 rows)
+
+-- end
diff --git a/src/contraction/doc/pgr_contractGraph.rst b/src/contraction/doc/pgr_contractGraph.rst
new file mode 100644
index 0000000..e511bec
--- /dev/null
+++ b/src/contraction/doc/pgr_contractGraph.rst
@@ -0,0 +1,175 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+   INSTRUCTIONS
+   - if section consists of only one value then use this file as index.rst
+   - change [...] (including the square braquets) to appropriate values
+   - one file / function,  may signatures of the same function go in the same file
+
+.. _pgr_contractGraph:
+
+pgr_contractGraph - Proposed
+===============================================================================
+
+``pgr_contractGraph`` — Performs graph contraction and returns the contracted vertices and edges. 
+
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph
+
+   Boost Graph Inside
+
+
+Synopsis
+-------------
+
+Contraction reduces the size of the graph by removing some of the vertices and edges and, for example, might add edges that represent a sequence of original edges decreasing the total time and space used in graph algorithms.
+
+Characteristics
+-------------------------------------------------------------------------------
+
+The main Characteristics are:
+  - Process is done only on edges with positive costs.
+  
+  - There are two types of contraction methods used namely,
+
+    - Dead End Contraction
+    - Linear Contraction
+  
+  - The values returned include the added edges and contracted vertices.
+
+  - The returned values are ordered as follows:
+
+    - column `id` ascending when type = `v`
+    - column `id` descending when type = `e`
+
+
+
+Signature Summary:
+------------------
+
+The pgr_contractGraph function has the following signatures:
+
+.. code-block:: none
+    
+    pgr_contractGraph(edges_sql, contraction_order)
+    pgr_contractGraph(edges_sql, contraction_order, max_cycles, forbidden_vertices, directed)
+
+    RETURNS SETOF (seq, type, id, contracted_vertices, source, target, cost)
+
+
+Signatures
+-------------------------------------------------------------------------------
+
+.. index::
+    single: contractGraph(Minimal Use)
+
+Minimal signature
+.......................................
+
+.. code-block:: none
+       
+    pgr_contractGraph(edges_sql, contraction_order)
+
+:Example: Making a dead end contraction and a linear contraction.
+
+.. literalinclude:: doc-contractGraph.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+Complete signature
+.......................................
+
+.. code-block:: none
+       
+    pgr_contractGraph(edges_sql, contraction_order, max_cycles, forbidden_vertices, directed)
+
+:Example: Making a dead end contraction and a linear contraction and vertex 2 is forbidden from contraction
+
+.. literalinclude:: doc-contractGraph.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
+
+
+Description of the parameters of the signatures
+-------------------------------------------------------------------------------
+
+======================= ====================== =================================================
+Column                  Type                   Description
+======================= ====================== =================================================
+**edges_sql**           ``TEXT``               SQL query as described above.
+**contraction_order**   ``ARRAY[ANY-INTEGER]`` Ordered contraction operations.
+                                                -  1 = Dead end contraction
+                                                -  2 = Linear contraction
+**forbidden_vertices**  ``ARRAY[ANY-INTEGER]`` (optional). Identifiers of vertices forbidden from contraction. Default is an empty array.
+**max_cycles**          ``INTEGER``            (optional). Number of times the contraction operations on `contraction_order` will be performed. Default is 1.
+**directed**            ``BOOLEAN``            * When ``true`` the graph is considered as `Directed`.
+                                               * When ``false`` the graph is considered as `Undirected`.
+======================= ====================== =================================================
+
+
+Description of the return values
+-------------------------------------------------------------------------------
+
+RETURNS SETOF  (seq, type, id, contracted_vertices, source, target, cost)
+
+The function returns a single row. The columns of the row are:
+
+============================ =================   ===================================================================
+Column                       Type                Description
+============================ =================   ===================================================================
+**seq**                      ``INTEGER``         Sequential value starting from **1**.
+**type**                     ``TEXT``            Type of the `id`. 
+                                                  - 'v' when `id` is an identifier of a vertex.
+                                                  - 'e' when `id` is an identifier of an edge.
+**id**                       ``BIGINT``          Identifier of:
+                                                  * the  vertex when `type = 'v'`.
+
+                                                    - The vertex belongs to the edge_table passed as a parameter.
+                                                  * the edge when `type = 'e'`.
+                                                  
+                                                    - The `id` is a decreasing sequence starting from **-1**.
+
+                                                    - Representing a pseudo `id` as is not incorporated into the edge_table.
+**contracted_vertices**      ``ARRAY[BIGINT]``   Array of contracted vertex identifiers.
+**source**                   ``BIGINT``          Identifier of the source vertex of the current edge `id`. Valid values when `type = 'e'`.
+**target**                   ``BIGINT``          Identifier of the target vertex of the current edge `id`. Valid values when `type = 'e'`.
+**cost**                     ``FLOAT``           Weight of the edge (`source`, `target`). Valid values when `type = 'e'`.
+============================ =================   ===================================================================
+
+Examples
+========
+
+:Example: Only dead end contraction
+
+.. literalinclude:: doc-contractGraph.queries
+   :start-after: -- q3
+   :end-before: -- q4
+
+:Example: Only linear contraction
+
+.. literalinclude:: doc-contractGraph.queries
+   :start-after: -- q4
+   :end-before: -- q5
+
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/contraction/doc/proof_of_concept.queries b/src/contraction/doc/proof_of_concept.queries
new file mode 100644
index 0000000..84f0558
--- /dev/null
+++ b/src/contraction/doc/proof_of_concept.queries
@@ -0,0 +1,106 @@
+Adding an additional column to store if its part of the contracted graph
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false;
+ALTER TABLE
+Adding a new edges joining vertices 3 and 5 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (3, 5, 2, 2, true);
+INSERT 0 1
+Adding a new edges joining vertices 3 and 9 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (3, 9, 2, 2, true);
+INSERT 0 1
+Adding a new edges joining vertices 5 and 11 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (5, 11, 2, 2, true);
+INSERT 0 1
+Adding a new edges joining vertices 9 and 11 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (9, 11, 2, 2, true);
+INSERT 0 1
+Case 1: Both source and target belong to the contracted graph.
+We are going to route from 3 to 11
+Since 3 and 11 both are in the contracted graph we need not add any vertices.
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17) AND target IN (3, 5, 6, 9, 11, 15, 17)',
+3, 11, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |    5 |    1 |        0
+   2 |        2 |    6 |   11 |    1 |        1
+   3 |        3 |   11 |   -1 |    0 |        2
+(3 rows)
+
+Case 2: source belongs to a contracted graph, while target belongs to a vertex subgraph.
+We are going to route from 3 to 7
+Since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 11, 15, 17)
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17,   7, 8)	 AND target IN (3, 5, 6, 9, 11, 15, 17,   7, 8)',
+3, 7, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |   19 |    2 |        0
+   2 |        2 |    5 |    7 |    1 |        2
+   3 |        3 |    8 |    6 |    1 |        3
+   4 |        4 |    7 |   -1 |    0 |        4
+(4 rows)
+
+Case 3: source belongs to a contracted graph, while target belongs to a edge subgraph.
+We are going to route from 3 to 13
+Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17)
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17,    10, 13) AND target IN (3, 5, 6, 9, 11, 15, 17,    10, 13)',
+3, 13, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |    5 |    1 |        0
+   2 |        2 |    6 |   11 |    1 |        1
+   3 |        3 |   11 |   12 |    1 |        2
+   4 |        4 |   10 |   14 |    1 |        3
+   5 |        5 |   13 |   -1 |    0 |        4
+(5 rows)
+
+Case 4: source belongs to a vertex subgraph, while target belongs to a edge subgraph.
+We are going to route from 7 to 13
+Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, and since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex sets (3, 5, 6, 7, 8, 9, 11, 15, 17)
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17,    7, 8,   10, 13) AND target IN (3, 5, 6, 9, 11, 15, 17,    7, 8,   10, 13)',
+7, 13, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    7 |    6 |    1 |        0
+   2 |        2 |    8 |    7 |    1 |        1
+   3 |        3 |    5 |   10 |    1 |        2
+   4 |        4 |   10 |   14 |    1 |        3
+   5 |        5 |   13 |   -1 |    0 |        4
+(5 rows)
+
+Case 5: The path contains a shortcut.
+
+We are going to route from 3 to 9
+Since 3 and 9 both are in the contracted graph we need not add any vertices.
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 7, 8, 9, 11, 15, 17) AND target IN (3, 5, 6, 7, 8, 9, 11, 15, 17)',
+3, 9, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |   20 |    2 |        0
+   2 |        2 |    9 |   -1 |    0 |        2
+(2 rows)
+
+SELECT is_contracted FROM edge_table WHERE id=20;
+ is_contracted 
+---------------
+ t
+(1 row)
+
+This implies that it is a shortcut and should be expanded
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 7, 8, 9, 11, 15, 17) AND target IN (3, 5, 6, 7, 8, 9, 11, 15, 17) AND is_contracted=false',
+3, 9, false);
+ seq | path_seq | node | edge | cost | agg_cost 
+-----+----------+------+------+------+----------
+   1 |        1 |    3 |    5 |    1 |        0
+   2 |        2 |    6 |    9 |    1 |        1
+   3 |        3 |    9 |   -1 |    0 |        2
+(3 rows)
+
diff --git a/src/astar/sql/CMakeLists.txt b/src/contraction/sql/CMakeLists.txt
similarity index 63%
copy from src/astar/sql/CMakeLists.txt
copy to src/contraction/sql/CMakeLists.txt
index d34e55b..04645d4 100644
--- a/src/astar/sql/CMakeLists.txt
+++ b/src/contraction/sql/CMakeLists.txt
@@ -1,6 +1,5 @@
-# Append in local scope
 LIST(APPEND PACKAGE_SQL_FILES
-    ${CMAKE_CURRENT_SOURCE_DIR}/astar.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/contractGraph.sql
 )
 
 # set in parent scope
diff --git a/src/dijkstra/sql/dijkstraVia.sql b/src/contraction/sql/contractGraph.sql
similarity index 64%
copy from src/dijkstra/sql/dijkstraVia.sql
copy to src/contraction/sql/contractGraph.sql
index f18a54b..4c77ff1 100644
--- a/src/dijkstra/sql/dijkstraVia.sql
+++ b/src/contraction/sql/contractGraph.sql
@@ -1,11 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: dijkstraViaVertex.sql
+File: contractGraph.sql
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
 
 Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
+Copyright (c) 2016 Rohith Reddy
+Mail: 
 
 ------
 
@@ -25,27 +27,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-CREATE OR REPLACE FUNCTION pgr_dijkstraVia(
+CREATE OR REPLACE FUNCTION pgr_contractGraph(
     edges_sql TEXT,
-    via_vertices ANYARRAY,
-    directed BOOLEAN DEFAULT TRUE,
-    strict BOOLEAN DEFAULT FALSE,
-    U_turn_on_edge BOOLEAN DEFAULT TRUE,
-
-
-    OUT seq INTEGER,
-    OUT path_id INTEGER,
-    OUT path_seq INTEGER,
-    OUT start_vid BIGINT,
-    OUT end_vid BIGINT,
-    OUT node BIGINT,
-    OUT edge BIGINT,
-    OUT cost FLOAT,
-    OUT agg_cost FLOAT,
-    OUT route_agg_cost FLOAT)
+    contraction_order BIGINT[],
+    max_cycles integer DEFAULT 1,
+    forbidden_vertices BIGINT[] DEFAULT ARRAY[]::BIGINT[],
+    directed BOOLEAN DEFAULT true,
+    OUT seq integer,
+    OUT type TEXT,
+    OUT id BIGINT,
+    OUT contracted_vertices BIGINT[],
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT cost float)
 
   RETURNS SETOF RECORD AS
- '$libdir/${PGROUTING_LIBRARY_NAME}', 'dijkstraVia'
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'contractGraph'
     LANGUAGE c IMMUTABLE STRICT;
 
-
diff --git a/src/contraction/src/CMakeLists.txt b/src/contraction/src/CMakeLists.txt
new file mode 100644
index 0000000..b436328
--- /dev/null
+++ b/src/contraction/src/CMakeLists.txt
@@ -0,0 +1,4 @@
+ADD_LIBRARY(contraction OBJECT 
+    contractGraph.c 
+    contractGraph_driver.cpp
+    )
diff --git a/src/contraction/src/contractGraph.c b/src/contraction/src/contractGraph.c
new file mode 100644
index 0000000..c2e51d6
--- /dev/null
+++ b/src/contraction/src/contractGraph.c
@@ -0,0 +1,267 @@
+/*PGR-GNU*****************************************************************
+File: contractGraph.c
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#include "postgres.h"
+#include "executor/spi.h"
+#include "funcapi.h"
+#include "utils/array.h"
+#include "catalog/pg_type.h"
+#if PGSQL_VERSION > 92
+#include "access/htup_details.h"
+#endif
+#include "utils/lsyscache.h"
+#include "utils/builtins.h"
+#include "fmgr.h"
+
+#ifndef INT8ARRAYOID
+#define INT8ARRAYOID    1016
+#endif
+/*
+  Uncomment when needed
+*/
+
+// #define DEBUG
+#include "./../../common/src/debug_macro.h"
+#include "./../../common/src/pgr_types.h"
+#include "./structs.h"
+#include "./../../common/src/postgres_connection.h"
+#include "./../../common/src/edges_input.h"
+#include "./../../common/src/arrays_input.h"
+#include "./contractGraph_driver.h"
+
+PGDLLEXPORT Datum contractGraph(PG_FUNCTION_ARGS);
+
+
+/********************************************************************/
+/*                          MODIFY AS NEEDED                        */
+static
+void
+process(char* edges_sql,
+        int64_t *forbidden_vertices,
+        int64_t *contraction_order,
+        size_t size_forbidden_vertices,
+        size_t size_contraction_order,
+        int num_cycles,
+        bool directed,
+        pgr_contracted_blob **result_tuples,
+        size_t *result_count) {
+    pgr_SPI_connect();
+    PGR_DBG("num_cycles %d ", num_cycles);
+    PGR_DBG("directed %d ", directed);
+    PGR_DBG("edges_sql %s", edges_sql);
+    PGR_DBG("Load data");
+    pgr_edge_t *edges = NULL;
+    size_t total_tuples = 0;
+    // TODO (Rohith) decide if is a requirement (ERROR) or not
+    if (num_cycles < 1) {
+        // TODO (Rohith) if ERROR free edges_sql, and the arrays
+        PGR_DBG("Required: at least one cycle\n");
+        (*result_count) = 0;
+        (*result_tuples) = NULL;
+        pgr_SPI_finish();
+        return;
+    }
+    for (size_t i = 0; i < size_contraction_order; ++i) {
+            if (is_valid_contraction(contraction_order[i]) != 1) {
+                PGR_DBG("Error: Enter a valid Contraction Type\n");
+                (*result_count) = 0;
+                (*result_tuples) = NULL;
+                pgr_SPI_finish();
+                return;
+            }
+    }
+    pgr_get_edges(edges_sql, &edges, &total_tuples);
+    PGR_DBG("finished Loading");
+    if (total_tuples == 0) {
+        PGR_DBG("No edges found");
+        (*result_count) = 0;
+        (*result_tuples) = NULL;
+        pgr_SPI_finish();
+        return;
+    }
+    PGR_DBG("Total %ld tuples in query:", total_tuples);
+    PGR_DBG("Starting processing");
+    char *err_msg = NULL;
+#if 1
+    do_pgr_contractGraph(
+            edges,
+            total_tuples,
+            forbidden_vertices,
+            size_forbidden_vertices,
+            contraction_order,
+            size_contraction_order,
+            num_cycles,
+            directed,
+            result_tuples,
+            result_count,
+            &err_msg);
+#endif
+    PGR_DBG("Returning %ld tuples\n", *result_count);
+    PGR_DBG("Returned message = %s\n", err_msg);
+    free(err_msg);
+    pfree(edges);
+    pgr_SPI_finish();
+}
+/*                                                                            */
+/******************************************************************************/
+
+PG_FUNCTION_INFO_V1(contractGraph);
+PGDLLEXPORT Datum
+contractGraph(PG_FUNCTION_ARGS) {
+    FuncCallContext     *funcctx;
+    size_t              call_cntr;
+    size_t               max_calls;
+    TupleDesc            tuple_desc;
+    pgr_contracted_blob  *result_tuples = NULL;
+    size_t result_count = 0;
+    int64_t* contraction_order;
+    int64_t* forbidden_vertices;
+    size_t size_contraction_order;
+    size_t size_forbidden_vertices;
+    if (SRF_IS_FIRSTCALL()) {
+        MemoryContext   oldcontext;
+        funcctx = SRF_FIRSTCALL_INIT();
+        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
+        /**********************************************************************/
+        /*                          MODIFY AS NEEDED                          */
+        /*
+            edges_sql TEXT,
+            contraction_order BIGINT[],
+            max_cycles integer DEFAULT 1,
+            forbidden_vertices BIGINT[] DEFAULT ARRAY[]::BIGINT[],
+            directed BOOLEAN DEFAULT true
+         **********************************************************************/ 
+
+        forbidden_vertices = (int64_t*)
+            pgr_get_bigIntArray_allowEmpty(&size_forbidden_vertices , PG_GETARG_ARRAYTYPE_P(3));
+        PGR_DBG("size_forbidden_vertices %ld", size_forbidden_vertices);
+
+        contraction_order = (int64_t*)
+            pgr_get_bigIntArray(&size_contraction_order, PG_GETARG_ARRAYTYPE_P(1));
+        PGR_DBG("size_contraction_order %ld ", size_contraction_order);
+#if 1
+        PGR_DBG("Calling process");
+        process(
+                pgr_text2char(PG_GETARG_TEXT_P(0)),
+                forbidden_vertices,
+                contraction_order,
+                size_forbidden_vertices,
+                size_contraction_order,
+                PG_GETARG_INT32(2),
+                PG_GETARG_BOOL(4),
+                &result_tuples,
+                &result_count);
+#endif
+        PGR_DBG("Cleaning arrays");
+        free(contraction_order);
+        free(forbidden_vertices);
+        PGR_DBG("Returned %d tuples\n", (int)result_count);
+        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->user_fctx = result_tuples;
+        if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
+            ereport(ERROR,
+                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                     errmsg("function returning record called in context "
+                         "that cannot accept type record")));
+        funcctx->tuple_desc = tuple_desc;
+        MemoryContextSwitchTo(oldcontext);
+    }
+    funcctx = SRF_PERCALL_SETUP();
+    call_cntr = funcctx->call_cntr;
+    max_calls = funcctx->max_calls;
+    tuple_desc = funcctx->tuple_desc;
+    result_tuples = (pgr_contracted_blob*) funcctx->user_fctx;
+    if (call_cntr < max_calls) {
+        HeapTuple   tuple;
+        Datum       result;
+        Datum       *values;
+        Datum       *contracted_vertices_array;
+        char        *nulls;
+        ArrayType * arrayType;
+        int16 typlen;
+        bool typbyval;
+        char typalign;
+        values =(Datum *)palloc(7 * sizeof(Datum));
+        nulls = palloc(7 * sizeof(bool));
+        size_t i;
+        for (i = 0; i < 7; ++i) {
+            nulls[i] = false;
+        }
+        int contracted_vertices_size =
+            (int)result_tuples[call_cntr].contracted_vertices_size;
+        contracted_vertices_array = (Datum *)palloc(sizeof(Datum) *
+                (size_t)contracted_vertices_size);
+        for (i = 0; i < contracted_vertices_size; ++i) {
+            PGR_DBG("Storing contracted vertex %ld", result_tuples[call_cntr].contracted_vertices[i]);
+            contracted_vertices_array[i] =
+                Int64GetDatum(result_tuples[call_cntr].contracted_vertices[i]);
+        }
+        get_typlenbyvalalign(INT8OID, &typlen, &typbyval, &typalign);
+        arrayType =  construct_array(contracted_vertices_array,
+                contracted_vertices_size,
+                INT8OID,  typlen, typbyval, typalign);
+        TupleDescInitEntry(tuple_desc, (AttrNumber) 4, "contracted_vertices",
+                INT8ARRAYOID, -1, 0);
+
+#if 1
+        PGR_DBG("%ld | %s | %ld | %ld | %f | %d",
+        result_tuples[call_cntr].id,
+        result_tuples[call_cntr].type,
+        result_tuples[call_cntr].source,
+        result_tuples[call_cntr].target,
+        result_tuples[call_cntr].cost,
+        result_tuples[call_cntr].contracted_vertices_size);
+#endif
+        PGR_DBG("Storing complete\n");
+        // postgres starts counting from 1
+        values[0] = Int32GetDatum(call_cntr + 1);
+        values[1] = CStringGetTextDatum(result_tuples[call_cntr].type);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].id);
+        values[3] = PointerGetDatum(arrayType);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].source);
+        values[5] = Int64GetDatum(result_tuples[call_cntr].target);
+        values[6] = Float8GetDatum(result_tuples[call_cntr].cost);
+        // values[7] = Int32GetDatum(result_tuples[call_cntr].contracted_vertices_size);
+        /*********************************************************************/
+        tuple = heap_form_tuple(tuple_desc, values, nulls);
+        result = HeapTupleGetDatum(tuple);
+        // cleaning up the contracted vertices array
+        if (result_tuples[call_cntr].contracted_vertices) {
+            free(result_tuples[call_cntr].contracted_vertices);
+        }
+        SRF_RETURN_NEXT(funcctx, result);
+    } else {
+        // cleanup
+        PGR_DBG("Freeing values");
+        if (result_tuples) free(result_tuples);
+        SRF_RETURN_DONE(funcctx);
+    }
+    PGR_DBG("End of Function");
+}
+
diff --git a/src/contraction/src/contractGraph_driver.cpp b/src/contraction/src/contractGraph_driver.cpp
new file mode 100644
index 0000000..a920fe9
--- /dev/null
+++ b/src/contraction/src/contractGraph_driver.cpp
@@ -0,0 +1,278 @@
+/*PGR-GNU*****************************************************************
+File: contractGraph_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+
+#ifdef unlink
+#undef unlink
+#endif
+
+#endif
+
+
+// #define DEBUG
+#include <string.h>
+#include <sstream>
+#include <deque>
+#include <vector>
+#include "./contractGraph_driver.h"
+
+#include "./pgr_contract.hpp"
+
+#include "./../../common/src/pgr_types.h"
+#include "./structs.h"
+
+#include "./../../common/src/pgr_alloc.hpp"
+#include "./../../common/src/debug_macro.h"
+#include "./../../common/src/identifiers.hpp"
+
+
+/************************************************************
+    edges_sql TEXT,
+    contraction_order BIGINT[],
+    forbidden_vertices BIGINT[] DEFAULT ARRAY[]::BIGINT[],
+    max_cycles integer DEFAULT 1,
+    directed BOOLEAN DEFAULT true
+ ***********************************************************/
+    void
+    do_pgr_contractGraph(
+        pgr_edge_t  *data_edges,
+        size_t total_edges,
+        int64_t *forbidden_vertices,
+        size_t size_forbidden_vertices,
+        int64_t *contraction_order,
+        size_t size_contraction_order,
+        int64_t max_cycles,
+        bool directed,
+        pgr_contracted_blob **return_tuples,
+        size_t *return_count,
+        char ** err_msg) {
+        std::ostringstream log;
+        try {
+            std::ostringstream debug;
+            graphType gType = directed? DIRECTED: UNDIRECTED;
+            std::vector< pgr_edge_t > edges(data_edges, data_edges + total_edges);
+            std::vector < pgrouting::contraction::Vertex > vertices(pgrouting::contraction::extract_vertices(edges));
+            Identifiers<int64_t> remaining_vertices;
+            std::vector< pgrouting::contraction::Edge > shortcut_edges;
+
+            log << "Original Graph: \n" <<
+            std::setprecision(32);
+            for (const auto edge : edges) {
+                log << "id = " << edge.id
+                << "\tsource = " << edge.source
+                << "\ttarget = " << edge.target
+                << "\tcost = " << edge.cost
+                << "\treverse_cost = " << edge.reverse_cost
+                << ")\n";
+            }
+            log << "size_contraction_order " << size_contraction_order << "\n";
+            log << "contraction_order: " <<"{ ";
+            for (size_t i = 0; i < size_contraction_order; ++i) {
+                log << contraction_order[i] << ", ";
+            }
+            log << " }\n";
+
+            log << "size_forbidden_vertices " << size_forbidden_vertices << "\n";
+            log << "forbidden_vertices" << "{ ";
+            for (size_t i = 0; i < size_forbidden_vertices; ++i) {
+                log << forbidden_vertices[i] << ", ";
+            }
+            log << " }\n";
+            log << "max_cycles " << max_cycles << "\n";
+            log << "directed " << gType << "\n";
+
+            if (directed) {
+                log << "Working with directed Graph\n";
+                pgrouting::CHDirectedGraph digraph(vertices, gType);
+                digraph.graph_insert_data(data_edges, total_edges);
+                log << "Checking for valid forbidden vertices\n";
+                for (size_t i = 0; i < size_forbidden_vertices; ++i) {
+                    if (!digraph.has_vertex(forbidden_vertices[i])) {
+                        log << "Invalid forbidden vertex: " << forbidden_vertices[i] << "\n";
+                        *err_msg = strdup(log.str().c_str());
+                        return;
+                    }
+                }
+                Identifiers<int64_t> forbid_vertices(forbidden_vertices,
+                    size_forbidden_vertices);
+                log << "Before contraction\n";
+                digraph.print_graph(log);
+                /* Function call to get the contracted graph. */
+                pgr_contractGraph(digraph,
+                    forbid_vertices,
+                    contraction_order, size_contraction_order,
+                    max_cycles, remaining_vertices,
+                    shortcut_edges, debug);
+
+                log << "After contraction\n";
+                digraph.print_graph(log);
+                log << debug.str().c_str() << "\n";
+                (*return_tuples) = pgr_alloc(remaining_vertices.size()+shortcut_edges.size(), (*return_tuples));
+                size_t sequence = 0;
+                int i = 1;
+                log << "Remaining Vertices:" << "\n";
+                for (const auto vertex : remaining_vertices) {
+                    log << vertex << "\n";
+                }
+                char *type;
+                for (auto id : remaining_vertices) {
+                    type = strdup("v");
+                    int64_t *contracted_vertices = NULL;
+                    int contracted_vertices_size = 0;
+                    digraph.get_contracted_vertices(&contracted_vertices,
+                        contracted_vertices_size, id);
+                    (*return_tuples)[sequence] = {i, id, type, -1, -1, -1.00,
+                        contracted_vertices, contracted_vertices_size};
+                        i++;
+                        ++sequence;
+                    }
+                    log << "Added Edges:" << "\n";
+                    for (const auto edge : shortcut_edges) {
+                        log << edge << "\n";
+                    }
+                    for (auto edge : shortcut_edges) {
+                        type = strdup("e");
+                        int64_t *contracted_vertices = NULL;
+                        int contracted_vertices_size = 0;
+                        digraph.get_ids(&contracted_vertices,
+                            contracted_vertices_size, edge.contracted_vertices());
+                        (*return_tuples)[sequence] = {i, edge.id, type,
+                            edge.source, edge.target, edge.cost,
+                            contracted_vertices, contracted_vertices_size};
+                            i++;
+                            ++sequence;
+                        }
+
+                        (*return_count) = sequence;
+                        log << "Returning from driver\n";
+                    } else {
+                        log << "Working with Undirected Graph\n";
+
+                        pgrouting::CHUndirectedGraph undigraph(vertices, gType);
+                        undigraph.graph_insert_data(data_edges, total_edges);
+                        log << "Checking for valid forbidden vertices\n";
+                        for (size_t i = 0; i < size_forbidden_vertices; ++i) {
+                            if (!undigraph.has_vertex(forbidden_vertices[i])) {
+                                log << "Invalid forbidden vertex: " << forbidden_vertices[i] << "\n";
+                                *err_msg = strdup(log.str().c_str());
+                                return;
+                            }
+                        }
+                        Identifiers<int64_t> forbid_vertices(forbidden_vertices,
+                            size_forbidden_vertices);
+                        log << "Before contraction\n";
+                        undigraph.print_graph(log);
+                        /* Function call to get the contracted graph. */
+                        pgr_contractGraph(undigraph,
+                            forbid_vertices,
+                            contraction_order, size_contraction_order,
+                            max_cycles, remaining_vertices,
+                            shortcut_edges, debug);
+                        log << debug.str().c_str() << "\n";
+                        log << "After contraction\n";
+                        undigraph.print_graph(log);
+                        log << "Size of remaining_vertices: " << remaining_vertices.size() << std::endl;
+                        (*return_tuples) = pgr_alloc(remaining_vertices.size()+shortcut_edges.size(), (*return_tuples));
+                        size_t sequence = 0;
+                        int i = 1;
+                        log << "Remaining Vertices:" << "\n";
+                        for (const auto vertex : remaining_vertices) {
+                            log << vertex << "\n";
+                        }
+                        char *type;
+                        for (auto id : remaining_vertices) {
+                            type = strdup("v");
+                            int64_t *contracted_vertices = NULL;
+                            int contracted_vertices_size = 0;
+                            undigraph.get_contracted_vertices(&contracted_vertices,
+                                contracted_vertices_size, id);
+                            (*return_tuples)[sequence] = {i, id, type, -1, -1, -1.00,
+                                contracted_vertices, contracted_vertices_size};
+                                i++;
+                                ++sequence;
+                            }
+                            log << "Added Edges:" << "\n";
+                            for (const auto edge : shortcut_edges) {
+                                log << edge << "\n";
+                            }
+                            for (auto edge : shortcut_edges) {
+                                type = strdup("e");
+                                int64_t *contracted_vertices = NULL;
+                                int contracted_vertices_size = 0;
+                                undigraph.get_ids(&contracted_vertices,
+                                    contracted_vertices_size, edge.contracted_vertices());
+                                (*return_tuples)[sequence] = {i, edge.id, type,
+                                    edge.source, edge.target, edge.cost,
+                                    contracted_vertices, contracted_vertices_size};
+                                    i++;
+                                    ++sequence;
+                                }
+                                (*return_count) = sequence;
+                            }
+#ifndef DEBUG
+                            *err_msg = strdup("OK");
+#else
+                            *err_msg = strdup(log.str().c_str());
+#endif
+                        }
+                        catch (AssertFailedException &except) {
+                            log << except.what() << "\n";
+                            *err_msg = strdup(log.str().c_str());
+                        } catch (std::exception& except) {
+                            log << except.what() << "\n";
+                            *err_msg = strdup(log.str().c_str());
+                        } catch(...) {
+                            log << "Caught unknown exception!\n";
+                            *err_msg = strdup(log.str().c_str());
+                        }
+                    }
+
+                    int is_valid_contraction(int64_t number) {
+                        switch (number) {
+                            case 1:
+                            return 1;
+                            break;
+                            case 2:
+                            return 1;
+                            break;
+                            default:
+                            return -1;
+                            break;
+                        }
+                    }
+
+
+
+
+
+
diff --git a/tools/template/src/function1_driver.h b/src/contraction/src/contractGraph_driver.h
similarity index 56%
copy from tools/template/src/function1_driver.h
copy to src/contraction/src/contractGraph_driver.h
index 08661ce..d6724af 100644
--- a/tools/template/src/function1_driver.h
+++ b/src/contraction/src/contractGraph_driver.h
@@ -1,12 +1,12 @@
 /*PGR-GNU*****************************************************************
-File: MY_FUNCTION_NAME_driver.h
+File: contractGraph_driver.h
 
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer: 
-Copyright (c) YEAR DEVELOPER_NAME
-Mail: DEVELOPER_EMAIL
+Copyright (c) 2016 Rohith Reddy
+Mail: 
 
 ------
 
@@ -26,33 +26,40 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_MY_FUNCTION_NAME_UPPER_SRC_MY_FUNCTION_NAME_UPPER_DRIVER_H_
-#define SRC_MY_FUNCTION_NAME_UPPER_SRC_MY_FUNCTION_NAME_UPPER_DRIVER_H_
+#ifndef SRC_CONTRACTION_SRC_CONTRACTGRAPH_DRIVER_H_
+#define SRC_CONTRACTION_SRC_CONTRACTGRAPH_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
+#include "./structs.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
     /*********************************************************
-      MY_QUERY_LINE1
+        edges_sql TEXT,
+        contraction_order BIGINT[],
+        forbidden_vertices BIGINT[] DEFAULT ARRAY[]::BIGINT[],
+        max_cycles integer DEFAULT 1,
+        directed BOOLEAN DEFAULT true
      ********************************************************/
     void
-        do_pgr_MY_FUNCTION_NAME(
-                pgr_edge_t  *data_edges,
-                size_t total_tuples,
-                int64_t start_vid,
-                int64_t  *end_vidsArr,
-                int size_end_vidsArr,
-                bool directed,
-                MY_RETURN_VALUE_TYPE **return_tuples,
-                size_t *return_count,
-                char ** err_msg);
-
+        do_pgr_contractGraph(
+               pgr_edge_t  *data_edges,
+        size_t total_tuples,
+        int64_t *forbidden_vertices,
+        size_t size_forbidden_vertices,
+        int64_t *contraction_order,
+        size_t size_contraction_order,
+        int64_t max_cycles,
+        bool directed,
+        pgr_contracted_blob **return_tuples,
+        size_t *return_count,
+        char ** err_msg);
+    int is_valid_contraction(int64_t number);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_MY_FUNCTION_NAME_UPPER_SRC_MY_FUNCTION_NAME_UPPER_DRIVER_H_
+#endif  // SRC_CONTRACTION_SRC_CONTRACTGRAPH_DRIVER_H_
diff --git a/src/contraction/src/contraction.dox b/src/contraction/src/contraction.dox
new file mode 100644
index 0000000..3ae0672
--- /dev/null
+++ b/src/contraction/src/contraction.dox
@@ -0,0 +1,579 @@
+/*! @page Contraction
+
+
+ at section contraction_intro Introduction
+
+ at note This documentation is focused on the developer of pgr_contraction.
+ at note This documentation might include documentation used for the user.
+ at note The developer should also read the documentation for the user.
+
+
+Contracting a graph becomes a crucial operation when talking about big graphs like
+the graphs involved in routing across cities, countries, continents or the whole world.
+
+The contraction level and contraction operations can become very complex, as the complexity
+of the graphs grows.
+
+For this proposal, we are making our contraction algorithm simple as possible so that
+more contraction operations can be added in the future.
+
+We are not aiming with this work to implement all the possible contraction operations
+but to give a framework such that adding a contraction operation can be easily achieved.
+
+For this contraction implementation, there are two operations:
+
+ 1. dead end contraction: vertices have one incoming edge
+ 2. linear contraction: vertices have one incoming and one outgoing edge
+
+
+And with the additional characteristics:
+
+  - The user can forbid to contract a particular set of nodes or edges.
+  - The user can decide how many times the cycle can be done.
+  - If possible, the user can decide the order of the operations on a cycle.
+
+
+
+ at subsection contraction_skeleton The contraction skeleton
+
+In general we have an initial set up that may involve analizing the graph given as input and setting the
+non contractable nodes or edges. We have a cycle that will go and perform a contraction operation
+until while possible, and then move to the next contraction operation.
+Adding a new operation then becomes an "easy" task but more things might be involved, because the
+charachteristics of the graph change each time its contracted, so some interaction between contractions
+has to be implemented also.
+
+Procedure
+---------
+
+* For contracting, we are going to cycle as follows
+
+~~~~{.c}
+input: G(V,E)
+removed_vertices = {}
+
+
+<initial set up>
+do N times {
+
+    while ( <conditions for 1> ) {
+        < contraction operation 1 >
+    }
+
+    while ( <conditions for 2> ) {
+        < contraction operation 2>
+    }
+    .....
+}
+
+output: G'(V',E'), removed_vertices
+~~~~
+
+ at subsection contraction_notation Notation for this documentation
+
+- V: is the set of vertices
+- E: is the set of edges
+- G: is the graph
+- V1: is the set of *dead end* vertices
+- V2: is the set of *linear* vertices
+- removed_vertices: is the set of removed vertices
+
+The contracted graph will be represented with two parameters, the modified Graph, and the removed_vertices set.
+
+~~~~{.c}
+removed_vertices = {(v,1):{2}, (e,-1):{3}}.
+~~~~
+
+
+The above notation indicates:
+  - Vertex 2 is removed, and belongs to vertex 1 subgraph
+  - Vertex 3 is removed, and belongs to edge -1 subgraph
+
+
+
+ at subsection contraction_dead_end Dead End Contraction
+
+
+Characteristics:
+
+  - Contraction code: **1**
+  - `V1`: set of vertices with 1 incoming edge in increasing order of id:
+  - Edges with the same identifier are considered the same edge and if it has the `reverse_cost` valid the outgoing edge is ignored
+
+~~~~{.c}
+while ( V1 is not empty ) {
+
+    delete vertex of V1
+    the deleted vertex add it to removed_vertices
+    vertex that leads to removed vertex, inherits the removed vertex
+
+    <adjust any conditions that might affect other contraction operation>
+}
+~~~~
+
+
+
+ at subsection contraction_linear Linear Contraction
+
+Characteristics:
+
+  - Contraction code: **2**
+  - `V2`: vertex with 1 incoming edge and 1 outgoing edge:
+  - The outgoing edge must have different identifier of the incoming edge
+
+
+~~~~{.c}
+while ( V2 is not empty ) {
+
+    delete vertex of V2
+    create edge (shortcut)
+    the deleted vertex add it to removed_vertices
+    newly created edge, inherits the removed vertex
+
+    <adjust any conditions that might affect other contraction operations>
+    }
+~~~~
+
+
+ at section contraction_examples Contraction examples
+
+ at subsection contraction_examples_dead_end Dead End Contraction
+
+
+- For simplicity all the edges in the examples have unit weight.
+- Perform dead end contraction
+- One cycle of contractions.
+
+
+Input:
+
+~~~~{.c}
+G = {E:{1(1, 2)}, V:{1, 2} }
+~~~~
+
+Visually the graph is
+
+
+ at todo (Rohith) practice a little graphviz  :)
+
+ at image html  twoNodesoneEdge_a.png
+
+ at dot
+digraph G { 
+    1 -> 2 [label="id = 1"];
+    2 [color = lightblue,style=filled];
+}
+
+ at enddot
+
+
+Initial set up:
+----------------
+
+~~~~{.c}
+removed_vertices={}
+V1 = {2}
+V2 = {}
+~~~~
+
+
+
+Procedure:
+----------------
+
+~~~~{.c}
+    V1 = {2} is not empty
+
+        V1 = {}
+        V2 = {}
+        G = {V:{1}, E:{}}
+        removed_vertices = {(v, 1):{2}}.
+
+    V1 is empty
+~~~~
+
+
+Results:
+-----------------
+
+~~~~{.c}
+
+    G = {V:{1}, E:{}}
+    removed_vertices = {(v, 1):{2}}
+~~~~{.c}
+
+Visually the graph is
+
+ at image html  ../doc/images/twoNodesoneEdge_b.png
+
+
+ at subsection contraction_examples_linear Linear Contraction
+
+ at subsection contraction_examples_linear_dead_end Linear and Dead End Contraction
+
+- For simplicity all the edges in the example have unit weight.
+- A weight different than 1 will be expressed explicitly.
+* Perform linear contraction operation followed by a dead end operation.
+* 1 cycle of contraction.
+
+
+1. Input: G = {V:{1, 2, 3}, E:{(1, 2), (2, 3)}}
+
+Visually the graph is
+ at image html  ../doc/images/threeNodestwoEdges_a.png
+
+
+2. initial set up
+~~~~{.c}
+removed_vertices={}
+V1 = {3}
+V2 = {2}
+~~~~
+
+3. Procedure
+~~~~{.c}
+V2 = {2} is not empty
+
+    V1 = {3}
+    removed_vertices = {(e, -1):{2}}
+    V2 = {}
+    G = {V:{1, 3}, E:{-1(1,3,c=2)}}
+
+V2 is empty
+~~~~
+
+Visually the graph is
+ at image html  threeNodestwoEdges_b.png
+
+4. Since V2 is empty we go on to the next contraction operation
+~~~~{.c}
+V1 = {3} is not empty
+
+    V1 = {}
+    V2 = {}
+    removed_vertices = {(v, 1):{3, 2}}.
+    G = {V:{1}, E:{}}
+
+V1 is empty
+~~~~
+
+
+5. Results
+~~~~{.c}
+removed_vertices = {(v, 1):{3, 2}}.
+G = {V:{1}, E:{}}
+~~~~
+
+Visually the graph is
+ at image html  threeNodestwoEdges_c.png
+
+
+
+ at subsection contraction_examples_Sample  Contraction of Sample Data
+
+- A weight different than 1 will be expressed explicitly.
+* Perform dead end operation follwed with a linear operation.
+* 1 cycle of contraction.
+
+
+2. initial set up
+~~~~{.c}
+G = { V:{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17},
+E:{ 1(1, 2),  2(2,3),     3(3,4),   4(2,5),
+    5(3,6),   6(7,8),     7(8,5),   8(5,6),
+    9(6,9),  10(5,10),   11(6,11), 12(10,11),
+   13(11,12), 14(10,13), 15(9,12), 16(4,9),
+   17(14,15), 18(16,17) }
+~~~~
+
+ at todo (Rohith) add the id of each edge to the image
+
+Visually the graph is
+ at image html  undirected_sampledata_a.png
+
+1. Initial set up:
+~~~~{.c}
+removed_vertices={}
+V1 = {1,7,13,14,15,16,17}
+V2 = {4,8,12}
+~~~~
+
+
+2. Dead end Contraction
+
+The dead end vertices can visually be seen in the next graph.
+- The contraction is done in ascending order of the elements of V1
+
+ at todo (Rohith): add the id of each edge to the image, put a color to the dead end vertices
+
+ at image html  undirected_sampledata_a.png
+
+~~~~{.c}
+V1 = {1,7,13,14,15,16,17} // is not empty
+    // Contracting Vertex 1
+    V1 = {7,13,14,15,16,17}
+    V2 = {2,4,8,12}
+    G = {V:{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17},
+    E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 6(7,8), 7(8,5), 8(5,6), 9(6,9),
+        10(5,10), 11(6,11), 12(10,11), 13(11,12), 14(10,13), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
+    removed_vertices = {(v, 2):{1}}.
+
+
+V1 = {7,13,14,15,16,17} // is not empty
+
+    // Contracting Vertex 7
+    V1 = {8,13,14,15,16,17}
+    V2 = {2,4,12}
+    G = {V:{2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17},
+    E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 7(8,5), 8(5,6), 9(6,9), 10(5,10),
+        11(6,11), 12(10,11), 13(11,12), 14(10,13), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
+    removed_vertices = {(v, 2):{1}, (v,8):{7}}.
+
+V1 = {8,13,14,15,16,17} // is not empty
+
+    // Contracting Vertex 8
+    V1 = {13,14,15,16,17}
+    V2 = {2,4,12}
+    G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17},
+    E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
+         11(6,11), 12(10,11), 13(11,12), 14(10,13), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
+    removed_vertices = {(v, 2):{1}, (v,5):{8,7}}.
+
+V1 = {13,14,15,16,17} // is not empty
+
+    // Contracting Vertex 13
+    V1 = {14,15,16,17}
+    V2 = {2,4,10,12}
+    G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 14, 15, 16, 17},
+    E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
+         11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9), 17(14,15), 18(16,17)}}
+    removed_vertices = {(v, 2):{1}, (v,5):{8,7}, (v,10):{13}}.
+
+V1 = {14,15,16,17} // is not empty
+
+    // Contracting Vertex 14
+    V1 = {16,17} // vertex 15 now is not a Dead End vertex
+    V2 = {2,4,10,12}
+    G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 15, 16, 17},
+    E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
+         11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9)}, 18(16,17)}
+    removed_vertices = {(v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}}.
+
+V1 = {16,17} // is not empty
+
+    // Contracting Vertex 14
+    V1 = {}  // vertex 17 now is not a Dead End vertex
+    V2 = {2,4,10,12}
+    G = {V:{2, 3, 4, 5, 6, 9, 10, 11, 12, 15, 17},
+    E:{2(2,3), 3(3,4), 4(2,5), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
+         11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9)}}
+    removed_vertices = {(v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}, (v,17):{16}}.
+~~~~
+
+3- Since V1 is empty, linear contraction is performed
+
+The linear vertices can visually be seen in the next graph.
+  - The contraction is done in ascending order of the elements of V2
+
+ at todo (Rohith) add the id of each edge to the image, put a color to the linear vertices
+
+ at image html  undirected_sampledata_b.png
+
+~~~~{.c}
+V2 = {2,4,10,12} // is not empty
+
+    // Contracting Vertex 2
+    V1 = {}
+    V2 = {4,10,12}
+    G = {V:{3, 4, 5, 6, 9, 10, 11, 12, 15, 17},
+    E:{-1(3,5), 3(3,4), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
+         11(6,11), 12(10,11), 13(11,12), 15(9,12), 16(4,9)}}
+    removed_vertices = {(e, -1):{1,2}, (v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}, (v,17):{16}}.
+
+V2 = {4,10,12} // is not empty
+
+    // Contracting Vertex 4
+    V1 = {}
+    V2 = {10,12}
+    G = {V:{3, 5, 6, 9, 10, 11, 12, 15, 17},
+    E:{-1(3,5),-2(3,9), 5(3,6), 8(5,6), 9(6,9), 10(5,10),
+         11(6,11), 12(10,11), 13(11,12), 15(9,12)}}
+    removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (v, 2):{1}, (v,5):{8,7}, (v,10):{13}, (v,15):{14}, (v,17):{16}}.
+
+V2 = {10,12} // is not empty
+
+    // Contracting Vertex 10
+    V1 = {}
+    V2 = {12}
+    G = {V:{3, 5, 6, 9, 11, 12, 15, 17},
+    E:{-1(3,5),-2(3,9), -3(5,11), 5(3,6), 8(5,6), 9(6,9),
+         11(6,11), 13(11,12), 15(9,12)}}
+    removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (e,-3):{10,13}, (v, 2):{1}, (v,5):{8,7}, (v,15):{14}, (v,17):{16}}.
+
+V2 = {12} // is not empty
+
+    // Contracting Vertex 12
+    V1 = {}
+    V2 = {}
+    G = {V:{3, 5, 6, 9, 11, 15, 17},
+    E:{-1(3,5),-2(3,9), -3(5,11), -4(9,11), 5(3,6), 8(5,6), 9(6,9), 11(6,11)}}
+    removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (e,-3):{10,13}, (e, -4):{12},
+         (v, 2):{1}, (v,5):{8,7}, (v,15):{14}, (v,17):{16}}.
+~~~~
+
+
+4. Results:
+~~~~{.c}
+G = {V:{3, 5, 6, 9, 11, 15, 17},
+E:{-1(3,5),-2(3,9), -3(5,11), -4(9,11), 5(3,6), 8(5,6), 9(6,9), 11(6,11)}}
+removed_vertices = {(e, -1):{1,2}, (e, -2):{4}, (e,-3):{10,13}, (e, -4):{12},
+     (v, 2):{1}, (v,5):{8,7}, (v,15):{14}, (v,17):{16}}.
+~~~~
+Visually the graph is
+ at image html  undirected_sampledata_b.png
+
+
+ at section contraction_examples_Detailed Generating the contracted graph
+
+Original Data:
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+:Addition of new columns:
+
+.. code-block:: sql
+
+~~~~{.c}
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false
+ALTER TABLE edge_table ADD contracted_vertices BIGINT[]
+~~~~
+
+Data After Adding Columns:
+
+~~~~{.c}
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q4
+   :end-before: -- q5
+~~~~
+
+
+Addition of new edges by the algorithm:
+
+.. code-block:: sql
+
+~~~~{.c}
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted, contracted_vertices) VALUES (-1, 3, 5, 2, 2, true, ARRAY[1, 2])
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted, contracted_vertices) VALUES (-2, 3, 9, 2, 2, true, ARRAY[4])
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted, contracted_vertices) VALUES (-3, 5, 11, 2, 2, true, ARRAY[10, 13])
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted, contracted_vertices) VALUES (-4, 9, 11, 2, 2, true, ARRAY[12])
+~~~~
+
+Data after addition of new edges:
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q9
+   :end-before: -- q10
+
+Contracted Graph Data:
+
+
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q10
+   :end-before: -- q11
+
+
+
+ at section contraction_examples_dijkstra Dijkstra on contracted graph
+
+There are five cases which arise when calculating the shortest path between a given source and target,
+
+**Case 1**: Both source and target belong to the contracted graph.
+
+**Case 2**: Source belongs to a contracted graph, while target belongs to a vertex subgraph.
+
+**Case 3**: Source belongs to a contracted graph, while target belongs to an edge subgraph.
+
+**Case 4**: Source belongs to a vertex subgraph, while target belongs to an edge subgraph.
+
+**Case 5**: The path contains a new edge added by the contraction algorithm.
+
+
+
+
+ at subsection contraction_examples_dijkstra1 source and target belong to the contracted graph
+Routing from 3 to 11. Since 3 and 11 both are in the contracted graph it is not necessary expand the graph.
+
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q11
+   :end-before: -- q12
+
+ at subsection contraction_examples_dijkstra2 Source belongs to a contracted graph, while target belongs to a vertex subgraph.
+
+Routing from 3 to 7. Since 7 is in the contracted subgraph of vertex 5, it is necessary to expand that vertex by adding {7, 8} to the vertex set, so the vertex set becomes {3, 5, 6, 9, 11, 15, 17 , 7, 8}
+
+
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q12
+   :end-before: -- q13
+
+ at subsection contraction_examples_dijkstra3 Source belongs to a contracted graph, while target belongs to an edge subgraph.
+
+Routing from 3 to 13. Since 13 is in the contracted subgraph of edge (5, 11),  it is necessary to expand that edge by adding {10, 13} to the vertex set, so the vertex set becomes {3, 5, 6, 9, 10, 11, 13, 15, 17}.
+
+
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q13
+   :end-before: -- q14
+
+
+ at subsection contraction_examples_dijkstra4 Source belongs to a vertex subgraph, while target belongs to an edge subgraph.
+
+Routing from 7 to 13.i
+ - Since 13 is in the contracted subgraph of edge (5, 11), it is necessary to expand that edge by adding {10, 13} to the vertex set,
+ - and since 7 is in the contracted subgraph of vertex 5, it is necessary to expand that vertex by adding {7, 8} vertex set,
+ - so the vertex set becomes {3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17}
+
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q14
+   :end-before: -- q15
+
+
+ at subsection contraction_examples_dijkstra5 The path contains a new edge added by the contraction algorithm.
+
+
+Routing from 3 to 9. Since 3 and 9 both are in the contracted graph it is not necessary expand the graph.
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q15
+   :end-before: -- q16
+
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q16
+   :end-before: -- q17
+
+- This implies that it is a shortcut and should be expanded.
+- The contracted subgraph of edge 20(3, 9, c=2) is {4}.
+- It is necessary to expand the edge by adding {4} to the vertex set,
+- so the vertex set becomes {3, 4, 5, 6, 9, 11, 15, 17}.
+
+
+.. literalinclude:: doc-contraction.queries
+   :start-after: -- q17
+   :end-before: -- q18
+
+
+ at section contraction_examples_references References
+
+* http://www.cs.cmu.edu/afs/cs/academic/class/15210-f12/www/lectures/lecture16.pdf
+
+* http://algo2.iti.kit.edu/documents/routeplanning/geisberger_dipl.pdf
+
+*/
diff --git a/src/contraction/src/pgr_contract.hpp b/src/contraction/src/pgr_contract.hpp
new file mode 100644
index 0000000..28512aa
--- /dev/null
+++ b/src/contraction/src/pgr_contract.hpp
@@ -0,0 +1,444 @@
+/*PGR-GNU*****************************************************************
+File: pgr_contract.hpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#pragma once
+#include <stack>
+#include <iostream>
+#include <sstream>
+#include <deque>
+#include <queue>
+#include <string>
+#include <utility>
+#include <functional>
+#include <vector>
+#include <map>
+
+#include "./pgr_contractionGraph.hpp"
+#include "./pgr_deadEndContraction.hpp"
+#include "./pgr_linearContraction.hpp"
+#include "../../common/src/pgr_assert.h"
+
+
+template < class G > class Pgr_contract;
+
+template < class G >
+void perform_deadEnd(G &graph,
+    Identifiers<int64_t> forbidden_vertices,
+    std::ostringstream& debug) {
+    pgrouting::Pgr_deadEndContraction<G> deadendContractor;
+    debug << "Setting forbidden_vertices";
+    deadendContractor.setForbiddenVertices(graph, forbidden_vertices
+        , debug);
+
+    deadendContractor.calculateVertices(graph, debug);
+    try {
+        deadendContractor.doContraction(graph, debug);
+    }
+    catch ( ... ) {
+        debug << "Caught unknown exception!\n";
+    }
+}
+
+#if 1
+
+template < class G >
+void perform_linear(G &graph,
+    Identifiers<int64_t>& forbidden_vertices,
+    std::ostringstream& debug) {
+    std::ostringstream linear_debug;
+    pgrouting::Pgr_linearContraction<G> linearContractor;
+    linearContractor.setForbiddenVertices(graph, forbidden_vertices
+        , linear_debug);
+    linearContractor.calculateVertices(graph, linear_debug);
+    try {
+        linearContractor.doContraction(graph, linear_debug);
+    }
+    catch ( ... ) {
+        linear_debug << "Caught unknown exception!\n";
+    }
+    debug << linear_debug.str().c_str() << "\n";
+}
+#endif
+
+
+template < class G >
+void pgr_contractGraph(
+    G &graph, Identifiers<int64_t> forbidden_vertices,
+    int64_t *contraction_order,
+    size_t size_contraction_order,
+    int64_t max_cycles,
+    Identifiers<int64_t> &remaining_vertices,
+    std::vector<pgrouting::contraction::Edge> &shortcut_edges,
+    std::ostringstream& debug) {
+    std::deque<int64_t> contract_order;
+    //  push -1 to indicate the start of the queue
+    contract_order.push_back(-1);
+    for (size_t i = 0; i < size_contraction_order; ++i) {
+        contract_order.push_back(contraction_order[i]);
+    }
+    for (int64_t i = 0; i < max_cycles; ++i) {
+        int64_t front = contract_order.front();
+        debug << "Starting cycle " << i+1 << "\n";
+        contract_order.pop_front();
+        contract_order.push_back(front);
+        front = contract_order.front();
+        while (front != -1) {
+            switch (front) {
+                case -1:
+                debug << "Finished cycle " << i+1 << std::endl;
+                break;
+                default:
+                debug << "contraction "<< front << " asked" << std::endl;
+                if (front == 1) {
+                    debug << "Graph before dead end contraction" << std::endl;
+                    graph.print_graph(debug);
+                    debug << "Performing dead end contraction" << std::endl;
+                    perform_deadEnd(graph, forbidden_vertices, debug);
+                    debug << "Graph after dead end contraction" << std::endl;
+                    graph.print_graph(debug);
+                } else if (front == 2) {
+                    debug << "Graph before linear contraction" << std::endl;
+                    graph.print_graph(debug);
+                    debug << "Performing linear contraction" << std::endl;
+                    perform_linear(graph, forbidden_vertices, debug);
+                    debug << "Graph after linear contraction" << std::endl;
+                    graph.print_graph(debug);
+                }
+                contract_order.pop_front();
+                contract_order.push_back(front);
+                front = contract_order.front();
+            }
+        }
+    }
+    graph.get_changed_vertices(remaining_vertices);
+    debug << "Printing shortcuts\n";
+    for (auto shortcut : graph.shortcuts) {
+        debug << shortcut;
+        shortcut_edges.push_back(shortcut);
+    }
+}
+
+bool is_valid_contraction_number(int number) {
+    switch (number) {
+        case -2:
+        return false;
+        break;
+        case -1:
+        return false;
+        break;
+        case 0:
+        return true;
+        break;
+        case 1:
+        return true;
+        break;
+        default:
+        return false;
+        break;
+    }
+}
+
+template < class G >
+class Pgr_contract {
+ public:
+    /** @name Graph related types
+       Type      |     boost meaning     |   pgRouting meaning
+       :---------: | :-------------------- | :----------------------
+       G        | boost::adjacency_list |   Graph
+       V        | vertex_descriptor     |   Think of it as local ID of a vertex
+       E        | edge_descriptor       |   Think of it as local ID of an edge
+       V_i      | vertex_iterator       |   To cycle the vertices of the Graph
+       E_i      | edge_iterator         |   To cycle the edges of the Graph
+       EO_i     | out_edge_iterator     |   To cycle the out going edges of a vertex
+       EI_i     | in_edge_iterator      |   To cycle the in coming edges of a vertex (only in bidirectional graphs)
+    */
+     // @{
+    typedef typename G::V V;
+    typedef typename G::E E;
+    typedef typename G::V_i V_i;
+    typedef typename G::E_i E_i;
+    typedef typename G::EO_i EO_i;
+    #if 0
+    typedef typename G::degree_to_V_i degree_to_V_i;
+    #endif
+    typedef typename G::EI_i EI_i;
+    // @}
+    // ! @name Framework related functions
+    // @{
+    /*! \brief Disconnects all incoming and outgoing edges from the vertex
+     *  Calls the disconnect_vertex function of the graph with assertions
+     *  @param graph
+     *  @param vertex_id
+     */
+    void disconnectVertex(G &graph, int64_t vertex_id);
+    /*! \brief Stores the ids of those vertices forbidden from contraction in a set
+     *  Stores them in the set *forbidden_vertices*
+     *  @param forbidden_vertices
+     *  @param size_forbidden_vertices
+     */
+    void setForbiddenVertices(int64_t *forbidden_vertices,
+    size_t size_forbidden_vertices);
+
+    /*! \brief Stores ids of all the vertices of the graph in a set
+     *  Stores them in the set *all_vertices*
+     *  @param graph
+     */
+    void getAllVertices(G &graph);
+
+    /*! \brief Stores the set of ids of those vertices which are not contracted
+     *  Stores them in the set *non_contracted*
+     */
+    void getNonContractedVertices();
+
+    /*! \brief Returns a set of ids of all those vertices adjacent to vertex 
+     *  with id *vertex_id* 
+     *  Calls the disconnect_vertex function of the graph with assertions
+     *  @param graph
+     *  @param vertex_id
+     */
+    Identifiers<int64_t> getAdjacentVertices(G &graph, int64_t vertex_id);
+    /*! \brief Writes the string form of identifier class to the *stream*
+     *  @param stream
+     *  @param identifiers
+     */
+    void print_identifiers(std::ostringstream& stream, Identifiers<int64_t> identifiers);
+
+    /*! \brief Writes the string form of forbidden vertices to the *stream*
+     *  @param stream
+     */
+    void print_forbidden_vertices(std::ostringstream& stream);
+
+    /*! \brief Writes the string form of all vertices to the *stream*
+     *  @param stream
+     */
+    void print_all_vertices(std::ostringstream& stream);
+
+    /*! \brief Writes the string form of non contracted vertices to the *stream*
+     *  @param stream
+     */
+    void print_non_contracted_vertices(std::ostringstream& stream);
+
+    // @}
+    // ! @name Dead end contraction related functions
+    // @{
+
+    /*! \brief Checks whether a vertex is a dead end vertex
+     *  @param graph
+     *  @param vertex_id
+     */
+    bool is_dead_end(G &graph, int64_t vertex_id) const;
+
+    /*! \brief Stores ids of dead end vertices of the graph in a set
+     *  Stores them in the set *dead_end_vertices*
+     *  @param graph
+     */
+    void getDeadEndSet(G &graph);
+
+    /*! \brief Writes the string form of dead end vertices to the *stream*
+     *  @param stream
+     */
+    void print_dead_end_vertices(std::ostringstream& stream);
+
+    // @}
+
+    // bool is_connected(G &graph, V v) const;
+    #if 0
+    void contract_to_level(
+        G &graph,
+        int64_t level);
+    #endif
+
+    #if 0
+    void dead_end_contraction(G &graph);
+    void remove_2_degree_vertices(G &graph);
+
+
+    void calculateDegrees(G &graph);
+
+    void degreeMap(G &graph, std::ostringstream& dmap);
+
+    void getGraphName(std::ostringstream& name, Contraction_type ctype);
+
+    int64_t getGraph_string(G &graph, std::ostringstream& estring);
+
+    void getRemovedE_string(G &graph, std::ostringstream& estring);
+
+    void getRemovedV_string(std::ostringstream& vstring);
+
+    void getPseudoE_string(std::ostringstream& pstring);
+
+    typedef typename std::map<V, std::deque<Edge> > removed_V;
+    typedef typename std::map<V, std::deque<Edge> >::iterator removed_V_i;
+    typedef typename std::map<int64_t, std::pair<int64_t, int64_t> > psuedo_E;
+    typedef typename std::map<int64_t, std::pair<int64_t, int64_t> >::iterator psuedo_E_i;
+    typedef std::map< int, std::priority_queue<int64_t, std::vector<int64_t>, std::greater<int64_t> > > degree_to_V;
+    //  typedef std::map< int, std::vector<int64_t> > degree_to_V;
+    typedef typename std::vector<V>::iterator Q_i;
+    #endif
+
+ private:
+    int64_t last_edge_id;
+    // ! Used for storing the ids of all vertices of the graph
+    Identifiers<int64_t> all;
+    // ! Used for storing the ids of dead end vertices of the graph
+    Identifiers<int64_t> dead_end;
+    // ! Used for storing the ids of vertices of the graph which are not contracted
+    Identifiers<int64_t> non_contracted;
+    // ! Used for storing the ids of vertices forbidden from contraction
+    Identifiers<int64_t> forbidden;
+    #if 0
+    removed_V removedVertices;
+    psuedo_E pseudoEdges;
+    degree_to_V degree_to_V_map;
+    #endif
+    // set of dead_end_vertices;
+    // Identifiers<V> dead_end_vertices;
+};
+
+
+/******************** IMPLEMENTATION ******************/
+template < class G >
+void Pgr_contract< G >::disconnectVertex(G &graph, int64_t vertex_id) {
+    pgassert(graph.is_connected(vertex_id));
+    pgassert(is_dead_end(vertex_id));
+    graph.disconnect_vertex(vertex_id);
+    pgassert(!graph.is_connected(vertex_id));
+}
+
+template < class G >
+void Pgr_contract< G >::setForbiddenVertices(int64_t *forbidden_vertices,
+    size_t size_forbidden_vertices ) {
+    for (int64_t i = 0; i < size_forbidden_vertices; ++i) {
+            forbidden += forbidden_vertices[i];
+        }
+}
+
+template <class G>
+void Pgr_contract< G >::getAllVertices(G &graph) {
+    // Identifiers<int64_t> dead_end_vertices;
+    V_i vi;
+    for (vi = vertices(graph.graph).first; vi != vertices(graph.graph).second; ++vi) {
+        //  debug << "Checking vertex " << graph.graph[(*vi)].id << '\n';
+            all += graph.graph[(*vi)].id;
+    }
+}
+
+template <class G>
+void Pgr_contract< G >::getNonContractedVertices() {
+    non_contracted = all - dead_end;
+}
+
+template < class G >
+Identifiers<int64_t> Pgr_contract< G >::getAdjacentVertices(G &graph, int64_t vertex_id) {
+    EO_i out, out_end;
+    EI_i in, in_end;
+    V v;
+    Identifiers<int64_t> adjacent_vertices_set;
+    if (!graph.has_vertex(vertex_id)) {
+            return adjacent_vertices_set;
+    }
+    v = graph.get_V(vertex_id);
+    for (boost::tie(out, out_end) = out_edges(v, graph.graph);
+            out != out_end; ++out) {
+            adjacent_vertices_set += graph.graph[target(*out, graph.graph)].id;
+        }
+    for (boost::tie(in, in_end) = in_edges(v, graph.graph);
+            in != in_end; ++in) {
+            adjacent_vertices_set += graph.graph[source(*in, graph.graph)].id;
+        }
+    return adjacent_vertices_set;
+}
+
+template <class G>
+void Pgr_contract< G >::print_identifiers(std::ostringstream& stream, Identifiers<int64_t> identifiers) {
+    stream << identifiers << '\n';
+}
+
+template <class G>
+void Pgr_contract< G >::print_forbidden_vertices(std::ostringstream& stream) {
+    stream << forbidden << '\n';
+}
+
+template <class G>
+void Pgr_contract< G >::print_all_vertices(std::ostringstream& stream) {
+    stream << all << '\n';
+}
+
+
+template <class G>
+void Pgr_contract< G >::print_non_contracted_vertices(std::ostringstream& stream) {
+    stream << non_contracted << '\n';
+}
+
+template < class G >
+bool Pgr_contract< G >::is_dead_end(G &graph, int64_t vertex_id) const {
+    // debug << "in_degree: " << graph.in_degree(vertex_id) << '\n';
+    // debug << "out_degree: " << graph.out_degree(vertex_id) << '\n';
+    V v;
+    if (!graph.has_vertex(vertex_id)) {
+            return false;
+    }
+    v = graph.get_V(vertex_id);
+    if (graph.out_degree(v) == 1 && graph.in_degree(v) == 0) return true;
+    if (graph.out_degree(v) == 0 && graph.in_degree(v) == 1) return true;
+    if (graph.out_degree(v) == 1 && graph.in_degree(v) == 1) {
+        int64_t incoming_edge_id, outgoing_edge_id;
+        EO_i out, out_end;
+        EI_i in, in_end;
+        for (boost::tie(out, out_end) = out_edges(v, graph.graph);
+                        out != out_end; ++out) {
+            outgoing_edge_id = graph.graph[*out].id;
+        }
+        for (boost::tie(in, in_end) = in_edges(v, graph.graph);
+                        in != in_end; ++in) {
+            incoming_edge_id = graph.graph[*in].id;
+        }
+        if (incoming_edge_id == outgoing_edge_id)
+            return true;
+        return false;
+    }
+    return false;
+}
+
+template <class G>
+void Pgr_contract< G >::getDeadEndSet(G &graph) {
+    V_i vi;
+    for (vi = vertices(graph.graph).first; vi != vertices(graph.graph).second; ++vi) {
+        //  debug << "Checking vertex " << graph.graph[(*vi)].id << '\n';
+        if (is_dead_end(graph, graph.graph[(*vi)].id)) {
+            //  debug << "Adding " << graph.graph[(*vi)].id << "to dead end" << '\n';
+            dead_end += graph.graph[(*vi)].id;
+        }
+    }
+}
+
+template <class G>
+void Pgr_contract< G >::print_dead_end_vertices(std::ostringstream& stream) {
+    stream << dead_end << '\n';
+}
diff --git a/src/contraction/src/pgr_contractionGraph.hpp b/src/contraction/src/pgr_contractionGraph.hpp
new file mode 100644
index 0000000..4b607a8
--- /dev/null
+++ b/src/contraction/src/pgr_contractionGraph.hpp
@@ -0,0 +1,530 @@
+/*PGR-GNU*****************************************************************
+File: pgr_contractionGraph.hpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#pragma once
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+
+#ifdef open
+#undef open
+#endif
+
+#ifdef unlink
+#undef unlink
+#endif
+
+#endif
+
+
+#include <limits>
+#include <algorithm>
+#include <vector>
+#include <map>
+#include "../../common/src/pgr_base_graph.hpp"
+
+
+namespace pgrouting {
+
+namespace graph {
+template <class G, typename T_V, typename T_E>
+class Pgr_contractionGraph;
+}
+
+    typedef  graph::Pgr_contractionGraph <
+    boost::adjacency_list < boost::listS, boost::vecS,
+    boost::undirectedS,
+    contraction::Vertex, contraction::Edge >,
+    contraction::Vertex, contraction::Edge > CHUndirectedGraph;
+
+    typedef  graph::Pgr_contractionGraph <
+    boost::adjacency_list < boost::listS, boost::vecS,
+    boost::bidirectionalS,
+    contraction::Vertex, contraction::Edge >,
+    contraction::Vertex, contraction::Edge > CHDirectedGraph;
+
+namespace graph {
+
+template <class G, typename T_V, typename T_E>
+class Pgr_contractionGraph : public Pgr_base_graph<G, T_V, T_E> {
+ public:
+            typedef typename boost::graph_traits < G >::vertex_descriptor V;
+            typedef typename boost::graph_traits < G >::edge_descriptor E;
+            typedef typename boost::graph_traits < G >::vertex_iterator V_i;
+            typedef typename boost::graph_traits < G >::edge_iterator E_i;
+            typedef typename boost::graph_traits < G >::out_edge_iterator EO_i;
+            typedef typename boost::graph_traits < G >::in_edge_iterator EI_i;
+            typedef typename std::map< int64_t, V > id_to_V;
+            typedef typename id_to_V::const_iterator LI;
+            Identifiers<V> removed_vertices;
+            std::vector< T_E > shortcuts;
+            typedef typename boost::graph_traits < G >::degree_size_type       degree_size_type;
+
+                    /*! @brief Binary function that accepts two elements , and returns a value convertible to bool.
+                        Used as a compare function to sort the edges in increasing order of edge id 
+                    */
+                        static bool compareById(const T_E &edge1, const T_E &edge2) {
+                            return edge1.id > edge2.id;
+                        }
+
+                    /*!
+                    Prepares the _graph_ to be of type *gtype* with vertices as *vertices*
+                    */
+                    Pgr_contractionGraph< G , T_V, T_E >(const std::vector< T_V > &vertices, graphType gtype)
+                    : Pgr_base_graph< G , T_V, T_E >(vertices, gtype) {
+                    }
+
+                    /*!
+                    Prepares the _graph_ to be of type *gtype*
+                    */
+                    explicit Pgr_contractionGraph< G , T_V, T_E >(graphType gtype)
+                    : Pgr_base_graph< G , T_V, T_E >(gtype) {
+                    }
+
+                    // ! @name Insert data
+                    // @{
+                    /*! \brief Inserts *count* edges of type *T* into the graph
+                    *  
+                    *  Converts the edges to a std::vector<T> & calls the overloaded
+                    *  twin function.
+                    *
+                    *  @param edges
+                    *  @param count
+                    */
+                    template < typename T >
+                    void graph_insert_data(const T *edges, int64_t count) {
+                        graph_insert_data(std::vector < T >(edges, edges + count));
+                    }
+                    /*! \brief Inserts vector of edges of type *T* into the graph
+                    *  
+                    *  @param edges
+                    */
+                    template < typename T >
+                    void graph_insert_data(const std::vector < T > &edges) {
+                        for (const auto edge : edges) {
+                            graph_add_edge(edge);
+                        }
+                    }
+                    // @}
+
+                    // ! @brief True when *v* is in the graph
+                    /*!
+                    True when 
+                        - Indegree of *v* is 0 &
+                        - Outdegree of *v* is 0
+                    @param [in] v vertex_id
+                    */
+                    bool is_connected(int64_t v) const {
+                        if (this->in_degree(this->get_V(v)) == 0 && this->out_degree(this->get_V(v)) == 0) {
+                            return false;
+                        }
+                        return true;
+                    }
+
+                    // ! @brief get the vertex descriptor of the vertex adjacent to *v*
+                    /*!
+                    - Degree of *v* is 1                    
+                    @param [in] v vertex_descriptor
+                    @return V: The vertex descriptor of the vertex adjacent to *v*
+                    */
+                    V find_adjacent_vertex(V v) const {
+                        EO_i out, out_end;
+                        EI_i in, in_end;
+                        V out_vertex, in_vertex;
+                        out_vertex = in_vertex = -1;
+                        for (boost::tie(out, out_end) = out_edges(v, this->graph);
+                            out != out_end; ++out) {
+                            out_vertex = target(*out, this->graph);
+                    }
+                    for (boost::tie(in, in_end) = in_edges(v, this->graph);
+                        in != in_end; ++in) {
+                        in_vertex = source(*in, this->graph);
+                }
+                if (in_vertex == -1)
+                    return out_vertex;
+                else if (out_vertex == -1)
+                    return in_vertex;
+                else if (out_vertex == in_vertex)
+                    return in_vertex;
+                return out_vertex;
+            }
+
+                    /*! @brief get the vertex descriptors of adjacent vertices of *v*
+                    @param [in] v vertex_descriptor
+                    @return Identifiers<V>: The set of vertex descriptors adjacent to the given vertex *v*
+                    */
+                    Identifiers<V> find_adjacent_vertices(V v) const {
+                        EO_i out, out_end;
+                        EI_i in, in_end;
+                        Identifiers<V> adjacent_vertices;
+                        V out_vertex, in_vertex;
+                        out_vertex = in_vertex = -1;
+                        for (boost::tie(out, out_end) = out_edges(v, this->graph);
+                            out != out_end; ++out) {
+                            out_vertex = target(*out, this->graph);
+                        adjacent_vertices += out_vertex;
+                    }
+                    for (boost::tie(in, in_end) = in_edges(v, this->graph);
+                        in != in_end; ++in) {
+                        in_vertex = source(*in, this->graph);
+                    adjacent_vertices += in_vertex;
+                }
+                return adjacent_vertices;
+            }
+
+            T_V& operator[](V v) {
+                return this->graph[v];
+            }
+
+            T_E& operator[](E e) {
+                return this->graph[e];
+            }
+
+                    /*! @brief get the user ids given the boost graph ids in string format
+                    @param [in] log string
+                    @param [in] boost_ids The set of boost graph ids of vertices
+                    */
+                    void get_ids(std::ostringstream &log,
+                        Identifiers<int64_t> boost_ids) {
+                        log << "{";
+                        for (auto id : boost_ids) {
+                            log << this->graph[id].id << ", ";
+                        }
+                        log << "}";
+                    }
+
+                    /*! @brief get the user ids given the boost graph ids in array format
+                    @param [in] boost_ids The set of boost graph ids of vertices
+                    @param [in] contracted_vertices The array of contracted vertices
+                    @param [in] contracted_vertices_size The size of the array of contracted vertices
+                    */
+                    void get_ids(int64_t **contracted_vertices,
+                        int &contracted_vertices_size,
+                        Identifiers<int64_t> boost_ids) {
+                        contracted_vertices_size = (int)boost_ids.size();
+                        (*contracted_vertices) = (int64_t*)malloc(sizeof(int64_t)*contracted_vertices_size);
+                        int64_t count = 0;
+                        for (auto id : boost_ids) {
+                            (*contracted_vertices)[count++] = this->graph[id].id;
+                        }
+                    }
+
+                    /*! @brief get the remaining vertices of the graph after contraction
+                    @param [in] remaining_vertices The vector of vertices remaining after contraction
+                    */
+                    void get_remaining_vertices(std::vector<T_V>& remaining_vertices) {
+                        for (auto vi = vertices(this->graph).first; vi != vertices(this->graph).second; ++vi) {
+                            if (!removed_vertices.has(*vi)) {
+                                remaining_vertices.push_back(this->graph[*vi]);
+                            }
+                        }
+                    }
+
+                    /*! @brief get the vertices of the graph with atleast one contracted vertex 
+                    @param [in] remaining_vertices The set of vertices with atleast one contracted vertex
+                    */
+                    void get_changed_vertices(Identifiers<int64_t>& remaining_vertices) {
+                        // log << "remaining_vertices\n";
+                        for (auto vi = vertices(this->graph).first; vi != vertices(this->graph).second; ++vi) {
+                            if (!removed_vertices.has(*vi) && this->graph[*vi].has_contracted_vertices()) {
+                                remaining_vertices += this->graph[*vi].id;
+                            }
+                        }
+                    }
+
+                    /*! @brief get the edges of the graph that are added during contraction
+                    @param [in] shortcut_edges The vector of edges added during contraction
+                    */
+                    void get_shortcuts(std::vector<T_E>& shortcut_edges) {
+                        // log << "Getting shortcuts\n";
+                        for (auto shortcut : shortcuts) {
+                            // log << shortcut;
+                            shortcut_edges.push_back(shortcut);
+                        }
+                        std::sort(shortcut_edges.begin(), shortcut_edges.end(), compareById);
+                    }
+
+                    /*! @brief get the edge with minimum cost between two vertices
+                    @param [in] source vertex_descriptor of source vertex
+                    @param [in] destination vertex_descriptor of target vertex
+                    @return E: The edge descriptor of the edge with minimum cost
+                    */
+                    E get_min_cost_edge(V source, V destination) {
+                        E e;
+                        EO_i out_i, out_end;
+                        E min_cost_edge;
+                        double min_cost = std::numeric_limits<double>::max();
+                        for (boost::tie(out_i, out_end) = boost::out_edges(source, this->graph);
+                            out_i != out_end; ++out_i) {
+                            e = *out_i;
+                        if (target(e, this->graph) == destination) {
+                            if (this->graph[e].cost < min_cost) {
+                                min_cost = this->graph[e].cost;
+                                min_cost_edge = e;
+                            }
+                        }
+                    }
+                        // log << "Min cost edge from " << this->graph[source].id << " to " << this->graph[destination].id << std::endl;
+                        // log << this->graph[min_cost_edge];
+                    return min_cost_edge;
+                }
+
+                    /*! @brief get the in-degree of a vertex from its neighbor
+                    @param [in] vertex vertex_descriptor of the given vertex
+                    @param [in] neighbor vertex_descriptor of neighbor 
+                    @return degree_size_type: The in-degree of *vertex* from *neighbor*
+                    */
+                    degree_size_type in_degree_from_vertex(V vertex, V neighbor) {
+                        degree_size_type degree = 0;
+                        EI_i in_i, in_end;
+                        E e;
+                        for (boost::tie(in_i, in_end) = boost::in_edges(vertex, this->graph);
+                            in_i != in_end; ++in_i) {
+                            e = *in_i;
+
+                        if (source(e, this->graph) == neighbor) {
+                            degree++;
+                        }
+                    }
+                    return degree;
+                }
+                    /*! @brief get the out-degree of a vertex to its neighbor
+                    @param [in] vertex vertex_descriptor of the given vertex
+                    @param [in] neighbor vertex_descriptor of neighbor 
+                    @return degree_size_type: The out-degree of *vertex* to *neighbor*
+                    */
+                    degree_size_type out_degree_to_vertex(V vertex, V neighbor) {
+                        degree_size_type degree = 0;
+                        EO_i out_i, out_end;
+                        E e;
+                        for (boost::tie(out_i, out_end) = boost::out_edges(vertex, this->graph);
+                            out_i != out_end; ++out_i) {
+                            e = *out_i;
+
+                        if (target(e, this->graph) == neighbor) {
+                            degree++;
+                        }
+                    }
+                    return degree;
+                }
+
+                    /*! @brief print the edges added during contraction
+                    */
+                void print_shortcuts(std::ostringstream& log) {
+                    log << "Printing shortcuts\n";
+                    for (auto shortcut : shortcuts) {
+                        log << shortcut;
+                    }
+                }
+
+                    /*! @brief print the graph with contracted vertices of
+                        all vertices and edges
+                    */
+                        void print_graph(std::ostringstream &log) {
+                            EO_i out, out_end;
+                            for (auto vi = vertices(this->graph).first; vi != vertices(this->graph).second; ++vi) {
+                                if ((*vi) >= this->m_num_vertices) break;
+                                log << this->graph[(*vi)].id << "(" << (*vi) << ")"
+                                << this->graph[(*vi)].contracted_vertices() << std::endl;
+                                log << " out_edges_of(" << this->graph[(*vi)].id << "):";
+                                for (boost::tie(out, out_end) = out_edges(*vi, this->graph);
+                                    out != out_end; ++out) {
+                                    log << ' ' << this->graph[*out].id << "=(" << this->graph[source(*out, this->graph)].id
+                                << ", " << this->graph[target(*out, this->graph)].id << ") = "
+                                <<  this->graph[*out].cost <<"\t";
+                            }
+                            log << std::endl;
+                        }
+                    }
+
+                    /*! @brief get the contracted vertex ids of a given vertex in string format
+                    @param [in] vid vertex_id
+                    @param [in] log stringstream which stores the vertex ids of contracted vertices of *vid*
+                    */
+                    void get_contracted_vertices(std::ostringstream &log, int64_t vid) {
+                        if (!this->has_vertex(vid)) return;
+                        V v = this->get_V(vid);
+                        log << "{";
+                        for (auto vertex : this->graph[v].contracted_vertices()) {
+                            log << this->graph[vertex].id << ", ";
+                        }
+                        log << "}";
+                    }
+
+
+                    /*! @brief get the contracted vertex ids of a given vertex in string format
+                    @param [in] vid vertex_id
+                    @param [in] contracted_vertices The array of contracted vertices of *vid*
+                    @param [in] contracted_vertices_size The size of the array of contracted vertices of *vid*
+                    */
+                    void get_contracted_vertices(int64_t **contracted_vertices,
+                        int &contracted_vertices_size, int64_t vid) {
+                        if (!this->has_vertex(vid)) return;
+                        V v = this->get_V(vid);
+                        contracted_vertices_size = (int)this->graph[v].contracted_vertices().size();
+                        (*contracted_vertices) = (int64_t*)malloc(sizeof(int64_t)*contracted_vertices_size);
+                        int64_t count = 0;
+                        for (auto vertex : this->graph[v].contracted_vertices()) {
+                            (*contracted_vertices)[count++] = this->graph[vertex].id;
+                        }
+                    }
+
+                    /*! @brief add the contracted vertices of an edge *e* to the vertex *v*
+                    @param [in] v vertex_descriptor
+                    @param [in] e Edge of type *T_E*
+                    */
+                    void add_contracted_edge_vertices(V v, T_E &e) {
+                        for (auto vid : e.contracted_vertices()) {
+                            this->graph[v].add_vertex_id(vid);
+                        }
+                        e.clear_contracted_vertices();
+                    }
+
+                    /*! \brief Inserts an edge of type *T* into the graph
+                     *  @param edge
+                     */
+                    template < typename T>
+                     void graph_add_edge(const T &edge) {
+                        bool inserted;
+                        E e;
+                        if ((edge.cost < 0) && (edge.reverse_cost < 0))
+                            return;
+                            /*
+                             * true: for source
+                             * false: for target
+                             */
+                             auto vm_s = this->get_V(T_V(edge, true));
+                             auto vm_t = this->get_V(T_V(edge, false));
+                             pgassert(this->vertices_map.find(edge.source) != this->vertices_map.end());
+                             pgassert(this->vertices_map.find(edge.target) != this->vertices_map.end());
+                             if (edge.cost >= 0) {
+                                boost::tie(e, inserted) =
+                                boost::add_edge(vm_s, vm_t, this->graph);
+                                this->graph[e].cost = edge.cost;
+                                this->graph[e].id = edge.id;
+                                this->graph[e].first = true;
+                                this->graph[e].source = edge.source;
+                                this->graph[e].target = edge.target;
+                            }
+                            if (edge.reverse_cost >= 0) {
+                                boost::tie(e, inserted) =
+                                boost::add_edge(vm_t, vm_s, this->graph);
+
+                                this->graph[e].cost = edge.reverse_cost;
+                                this->graph[e].id = edge.id;
+                                this->graph[e].first = false;
+                                this->graph[e].target = edge.source;
+                                this->graph[e].source = edge.target;
+                            }
+                        }
+
+                    /*! \brief add edges(shortuct) to the graph during contraction
+                    @param [in] edge of type *T_E* is to be added
+                    @param [in] log string stream used for debugging purposes
+                    */  
+                    void graph_add_shortcut(const T_E &edge, std::ostringstream& log) {
+                        bool inserted;
+                        E e;
+                        if (edge.cost < 0)
+                            return;
+                        /*
+                         * true: for source
+                         * false: for target
+                         */
+                         log << "Graph before adding shortcut\n";
+                         print_graph(log);
+                         pgassert(this->vertices_map.find(edge.source) != this->vertices_map.end());
+                         pgassert(this->vertices_map.find(edge.target) != this->vertices_map.end());
+                         auto vm_s = this->get_V(edge.source);
+                         auto vm_t = this->get_V(edge.target);
+                         log << "Adding edge between " << this->graph[vm_s] << ", "
+                         << this->graph[vm_t] << std::endl;
+
+                         if (edge.cost >= 0) {
+                            boost::tie(e, inserted) =
+                            boost::add_edge(vm_s, vm_t, this->graph);
+                            log << "inserted: " << inserted << std::endl;
+                            this->graph[e].cp_members(edge, log);
+                            log << this->graph[e];
+                            // this->graph[e].id = this->graph[e].eid;
+                            log << "Graph after adding shortcut\n";
+                            print_graph(log);
+                            T_E shortcut;
+                            shortcut.cp_members(edge, log);
+                            shortcuts.push_back(shortcut);
+                        }
+                    }
+
+                    /*! \brief Disconnects all incoming and outgoing edges from the vertex
+                    boost::graph doesn't recommend th to insert/remove vertices, so a vertex removal is
+                    simulated by disconnecting the vertex from the graph
+                    - No edge is disconnected if the vertices id's do not exist in the graph
+                    - All removed edges are stored for future reinsertion
+                    - All parallel edges are disconnected (automatically by boost)
+                    @param [in] vertex original vertex id of the starting point of the edge
+                    @param [in] log string stream used for debugging purposes
+                    */   
+                    void disconnect_vertex(std::ostringstream &log, V vertex) {
+                        T_E d_edge;
+                        EO_i out, out_end;
+                        log << "Disconnecting current vertex " << this->graph[vertex].id << "\n";
+                        removed_vertices += vertex;
+                        //  store the edges that are going to be removed
+                        for (boost::tie(out, out_end) = out_edges(vertex, this->graph);
+                            out != out_end; ++out) {
+                            d_edge.id = this->graph[*out].id;
+                        d_edge.source = this->graph[source(*out, this->graph)].id;
+                        d_edge.target = this->graph[target(*out, this->graph)].id;
+                        d_edge.cost = this->graph[*out].cost;
+                        this->removed_edges.push_back(d_edge);
+                    }
+
+                        //  special case
+                    if (this->m_gType == DIRECTED) {
+                        EI_i in, in_end;
+                        for (boost::tie(in, in_end) = in_edges(vertex, this->graph);
+                            in != in_end; ++in) {
+                            d_edge.id = this->graph[*in].id;
+                        d_edge.source = this->graph[source(*in, this->graph)].id;
+                        d_edge.target = this->graph[target(*in, this->graph)].id;
+                        d_edge.cost = this->graph[*in].cost;
+                        this->removed_edges.push_back(d_edge);
+                    }
+                }
+                try {
+                    boost::clear_vertex(vertex, this->graph);
+                }
+                catch ( ... ) {
+                    log << "Caught unknown exception!\n";
+                }
+            }
+};
+}  // namespace graph
+}  // namespace pgrouting
diff --git a/src/contraction/src/pgr_deadEndContraction.hpp b/src/contraction/src/pgr_deadEndContraction.hpp
new file mode 100644
index 0000000..c1aac90
--- /dev/null
+++ b/src/contraction/src/pgr_deadEndContraction.hpp
@@ -0,0 +1,229 @@
+/*PGR-GNU*****************************************************************
+File: pgr_contractionGraph.c
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#pragma once
+#ifdef __MINGW32__
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
+
+#include <queue>
+#include <functional>
+#include <vector>
+#include "../../common/src/identifiers.hpp"
+namespace pgrouting {
+template < class G >
+class Pgr_deadEndContraction {
+ public:
+                typedef typename G::V V;
+                typedef typename G::E E;
+                typedef typename G::V_i V_i;
+                typedef typename G::E_i E_i;
+                typedef typename G::EO_i EO_i;
+                typedef typename G::EI_i EI_i;
+                void setForbiddenVertices(G &graph,
+                        Identifiers<int64_t> forbidden_vertices,
+                        std::ostringstream& debug);
+                void setForbiddenVertices(G &graph, int64_t *forbidden_vertices,
+                        size_t size_forbidden_vertices,
+                        std::ostringstream& debug);
+                void calculateVertices(G &graph,
+                        std::ostringstream& debug);
+                bool is_dead_end(G &graph, V v,
+                        std::ostringstream& debug);
+                void add_if_dead_end(G &graph, V v,
+                        std::ostringstream& debug);
+                void doContraction(G &graph,
+                        std::ostringstream& debug);
+
+ private:
+                Identifiers<V> deadendVertices;
+                Identifiers<V> forbiddenVertices;
+};
+
+    template < class G >
+        void Pgr_deadEndContraction< G >::setForbiddenVertices(G &graph,
+                Identifiers<int64_t> forbidden_vertices,
+                std::ostringstream& debug) {
+            debug << "Setting forbidden vertices\n";
+            for (auto forbiddenVertex : forbidden_vertices) {
+                forbiddenVertices += graph.get_V(forbiddenVertex);
+            }
+        }
+
+    template < class G >
+        void Pgr_deadEndContraction< G >::setForbiddenVertices(G &graph,
+                int64_t *forbidden_vertices,
+                size_t size_forbidden_vertices,
+                std::ostringstream& debug) {
+            debug << "Setting forbidden vertices\n";
+            for (int64_t i = 0; i < size_forbidden_vertices; ++i) {
+                forbiddenVertices += graph.get_V(forbidden_vertices[i]);
+            }
+        }
+
+    template < class G >
+        void Pgr_deadEndContraction<G>::calculateVertices(G &graph,
+                std::ostringstream& debug) {
+            debug << "Calculating vertices\n";
+            V_i vi;
+            for (vi = vertices(graph.graph).first; vi != vertices(graph.graph).second; ++vi) {
+                debug << "Checking vertex " << graph.graph[(*vi)].id << '\n';
+                if (is_dead_end(graph, *vi, debug)) {
+                    debug << "Adding " << graph.graph[(*vi)].id << " to dead end" << '\n';
+                    deadendVertices += (*vi);
+                }
+            }
+            deadendVertices -= forbiddenVertices;
+        }
+
+    template < class G >
+        bool Pgr_deadEndContraction<G>::is_dead_end(G &graph, V v,
+                std::ostringstream& debug) {
+            debug << "Is dead end: " << graph.graph[v].id << "?\n";
+            // debug << "in_degree: " << graph.in_degree(vertex_id) << '\n';
+            // debug << "out_degree: " << graph.out_degree(vertex_id) << '\n';
+            // if(graph.out_degree(v) == 1 && graph.in_degree(v) == 0) return true;
+            // if(graph.out_degree(v) == 0 && graph.in_degree(v) == 1) return true;
+            if (graph.m_gType == UNDIRECTED) {
+                /* the condition in case of undirected graph
+                   is all incoming edges come from a single vertex
+                */
+                debug << "undirected\nAdjacent Vertices\n";
+                Identifiers<V> adjacent_vertices = graph.find_adjacent_vertices(v);
+                debug << adjacent_vertices;
+                //  only one adjacent vertex
+                if (adjacent_vertices.size() == 1)
+                    return true;
+                else
+                    return false;
+            } else {
+            if (graph.out_degree(v) == 1 && graph.in_degree(v) == 1) {
+                int64_t incoming_edge_id = -1;
+                int64_t outgoing_edge_id = -2;
+                EO_i out, out_end;
+                EI_i in, in_end;
+                for (boost::tie(out, out_end) = out_edges(v, graph.graph);
+                        out != out_end; ++out) {
+                    outgoing_edge_id = graph.graph[*out].id;
+                }
+                for (boost::tie(in, in_end) = in_edges(v, graph.graph);
+                        in != in_end; ++in) {
+                    incoming_edge_id = graph.graph[*in].id;
+                }
+                if (incoming_edge_id == outgoing_edge_id) {
+                    debug << "Yes\n";
+                    return true;
+                }
+                debug << "No\n";
+                return false;
+            }
+            //  additional cases
+            if (graph.out_degree(v) == 0 && graph.in_degree(v) > 0) {
+                return true;
+             }
+             /*  dead start
+             if (graph.in_degree(v) == 0 && graph.out_degree(v) > 0) {
+                return true;
+             }
+             */
+            debug << "No\n";
+            return false;
+        }
+        return false;
+        }
+
+    template < class G >
+        void Pgr_deadEndContraction<G>::add_if_dead_end(G &graph, V v,
+                std::ostringstream& debug) {
+            debug << "Adding if dead end\n";
+            if (is_dead_end(graph, v, debug)) {
+                deadendVertices += v;
+            } else {
+                debug << "Not dead end\n";
+            }
+        }
+
+    template < class G >
+        void Pgr_deadEndContraction<G>::doContraction(G &graph,
+                std::ostringstream& debug) {
+            debug << "Performing contraction\n";
+            std::priority_queue<V, std::vector<V>, std::greater<V> > deadendPriority;
+            for (V deadendVertex : deadendVertices) {
+                deadendPriority.push(deadendVertex);
+            }
+            // debug << "Dead end vertices" << std::endl;
+            // debug << deadendVertices;
+            while (!deadendPriority.empty()) {
+                V current_vertex = deadendPriority.top();
+                deadendPriority.pop();
+                if (!is_dead_end(graph, current_vertex, debug)) {
+                    continue;
+                }
+                Identifiers<V> adjacent_vertices = graph.find_adjacent_vertices(current_vertex);
+                for (auto adjacent_vertex : adjacent_vertices) {
+                    // debug << "Current Vertex: "<< graph[current_vertex].id << std::endl;
+                    // debug << "Adjacent Vertex: "<< graph[adjacent_vertex].id << std::endl;
+                debug << "Contracting current vertex "<< graph[current_vertex].id << std::endl;
+                graph[adjacent_vertex].add_contracted_vertex(graph[current_vertex], current_vertex);
+                //  Adding contracted vertices of the edge
+                EO_i out, out_end;
+                EI_i in, in_end;
+                debug << "Adding contracted vertices of the edge\n";
+                for (boost::tie(out, out_end) = out_edges(current_vertex, graph.graph);
+                        out != out_end; ++out) {
+                        debug << graph.graph[*out];
+                        graph.add_contracted_edge_vertices(adjacent_vertex, graph.graph[*out]);
+                    }
+                for (boost::tie(in, in_end) = in_edges(current_vertex, graph.graph);
+                        in != in_end; ++in) {
+                        debug << graph.graph[*in];
+                        graph.add_contracted_edge_vertices(adjacent_vertex, graph.graph[*in]);
+                    }
+                debug << "Current Vertex:\n";
+                debug << graph[current_vertex];
+                // debug << graph.graph[current_vertex].print_vertex(debug, graph.graph);
+                debug << "Adjacent Vertex:\n";
+                // debug << graph.graph[adjacent_vertex].print_vertex(debug, graph.graph);
+                debug << graph[adjacent_vertex];
+                graph.disconnect_vertex(debug, current_vertex);
+                deadendVertices -= current_vertex;
+                debug << "Adjacent vertex dead_end?: " << is_dead_end(graph, adjacent_vertex, debug) << std::endl;
+                if (is_dead_end(graph, adjacent_vertex, debug)
+                 && !forbiddenVertices.has(adjacent_vertex)) {
+                    deadendVertices += adjacent_vertex;
+                    deadendPriority.push(adjacent_vertex);
+                }
+                }
+            }
+        }
+
+}  // namespace pgrouting
diff --git a/src/contraction/src/pgr_linearContraction.hpp b/src/contraction/src/pgr_linearContraction.hpp
new file mode 100644
index 0000000..a72e164
--- /dev/null
+++ b/src/contraction/src/pgr_linearContraction.hpp
@@ -0,0 +1,259 @@
+/*PGR-GNU*****************************************************************
+File: pgr_contractionGraph.c
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2016 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#pragma once
+#ifdef __MINGW32__
+#include <winsock2.h>
+#include <windows.h>
+#ifdef open
+#undef open
+#endif
+#endif
+#include <functional>
+#include <queue>
+#include <vector>
+#include "../../common/src/identifiers.hpp"
+namespace pgrouting {
+template < class G >
+class Pgr_linearContraction {
+ public:
+                typedef typename G::V V;
+                typedef typename G::E E;
+                typedef typename G::V_i V_i;
+                typedef typename G::E_i E_i;
+                typedef typename G::EO_i EO_i;
+                typedef typename G::EI_i EI_i;
+                typedef typename G::degree_size_type degree_size_type;
+                Pgr_linearContraction():last_edge_id(0) {}
+                void setForbiddenVertices(G &graph,
+                        Identifiers<int64_t> forbidden_vertices,
+                        std::ostringstream& debug);
+                void setForbiddenVertices(G &graph, int64_t *forbidden_vertices,
+                        size_t size_forbidden_vertices,
+                        std::ostringstream& debug);
+                void calculateVertices(G &graph,
+                        std::ostringstream& debug);
+                void doContraction(G &graph,
+                        std::ostringstream& debug);
+
+ private:
+                Identifiers<V> linearVertices;
+                Identifiers<V> forbiddenVertices;
+                int64_t last_edge_id;
+                bool is_linear(G &graph, V v,
+                        std::ostringstream& debug);
+                void add_if_linear(G &graph, V v,
+                        std::ostringstream& debug);
+                void add_edge_pair(V vertex, int64_t &incoming_eid,
+                        int64_t &outgoing_eid,
+                        std::ostringstream& debug);
+                void add_shortcut(G &graph, V vertex,
+                        E incoming_edge,
+                        E outgoing_edge,
+                        std::ostringstream& debug);
+                void add_shortcut(G &graph,
+                        pgrouting::contraction::Edge &shortcut,
+                        std::ostringstream& debug);
+                int64_t& get_next_id() {
+                    return --last_edge_id;
+                }
+};
+
+    template < class G >
+        void Pgr_linearContraction< G >::setForbiddenVertices(G &graph,
+                Identifiers<int64_t> forbidden_vertices,
+                std::ostringstream& debug) {
+            debug << "Setting forbidden vertices\n";
+            for (auto forbiddenVertex : forbidden_vertices) {
+                forbiddenVertices += graph.get_V(forbiddenVertex);
+            }
+        }
+
+    template < class G >
+        void Pgr_linearContraction< G >::setForbiddenVertices(G &graph,
+                int64_t *forbidden_vertices,
+                size_t size_forbidden_vertices,
+                std::ostringstream& debug) {
+            debug << "Setting forbidden vertices\n";
+            for (int64_t i = 0; i < size_forbidden_vertices; ++i) {
+                forbiddenVertices += graph.get_V(forbidden_vertices[i]);
+            }
+        }
+
+    template < class G >
+        bool Pgr_linearContraction<G>::is_linear(G &graph, V v,
+                std::ostringstream& debug) {
+            degree_size_type in_degree, out_degree;
+            in_degree = graph.in_degree(v);
+            out_degree = graph.out_degree(v);
+            Identifiers<V> adjacent_vertices = graph.find_adjacent_vertices(v);
+            if (adjacent_vertices.size() == 2) {
+                if (in_degree > 0 && out_degree > 0) {
+                    debug << graph.graph[v].id << " is linear " << std::endl;
+                    return true;
+                }
+            }
+            debug << graph.graph[v].id << " is not linear " << std::endl;
+            return false;
+        }
+
+    template < class G >
+        void Pgr_linearContraction<G>::calculateVertices(G &graph,
+                std::ostringstream& debug) {
+            debug << "Calculating vertices\n";
+            V_i vi;
+            for (vi = vertices(graph.graph).first; vi != vertices(graph.graph).second; ++vi) {
+                debug << "Checking vertex " << graph.graph[(*vi)].id << '\n';
+                if (is_linear(graph, *vi, debug)) {
+                    // debug << "Adding " << graph.graph[(*vi)].id << " to linear" << '\n';
+                    linearVertices += (*vi);
+                }
+            }
+            linearVertices -= forbiddenVertices;
+        }
+
+
+
+    template < class G >
+        void Pgr_linearContraction<G>::doContraction(G &graph,
+                std::ostringstream& debug) {
+            std::ostringstream contraction_debug;
+            contraction_debug << "Performing contraction\n";
+            std::priority_queue<V, std::vector<V>, std::greater<V> > linearPriority;
+            for (V linearVertex : linearVertices) {
+                linearPriority.push(linearVertex);
+            }
+            contraction_debug << "Linear vertices" << std::endl;
+            for (auto v : linearVertices) {
+                contraction_debug << graph[v].id << ", ";
+            }
+            contraction_debug << std::endl;
+            while (!linearPriority.empty()) {
+                V current_vertex = linearPriority.top();
+                linearPriority.pop();
+                if (!is_linear(graph, current_vertex, debug)) {
+                    linearVertices -= current_vertex;
+                    continue;
+                }
+                Identifiers<V> adjacent_vertices = graph.find_adjacent_vertices(current_vertex);
+                pgassert(adjacent_vertices.size() == 2);
+                V vertex_1 = adjacent_vertices[0];
+                V vertex_2 = adjacent_vertices[1];
+                contraction_debug << "Adjacent vertices\n";
+                contraction_debug << graph[vertex_1].id << ", " << graph[vertex_2].id << std::endl;
+                
+                if (graph.m_gType == DIRECTED) {
+                    if (graph.out_degree_to_vertex(vertex_1, current_vertex) > 0
+                            && graph.in_degree_from_vertex(vertex_2, current_vertex) > 0) {
+                        E e1 = graph.get_min_cost_edge(vertex_1,
+                                current_vertex);
+                        E e2 = graph.get_min_cost_edge(current_vertex,
+                                vertex_2);
+                        add_shortcut(graph, current_vertex, e1, e2, contraction_debug);
+                    }
+
+                    if (graph.out_degree_to_vertex(vertex_2, current_vertex) > 0
+                            && graph.in_degree_from_vertex(vertex_1, current_vertex) > 0) {
+                        E e1 = graph.get_min_cost_edge(vertex_2,
+                                current_vertex);
+                        E e2 = graph.get_min_cost_edge(current_vertex,
+                                vertex_1);
+                        add_shortcut(graph, current_vertex, e1, e2, contraction_debug);
+                    }
+                } else if (graph.m_gType == UNDIRECTED) {
+                    if (graph.out_degree_to_vertex(vertex_1, current_vertex) > 0
+                            && graph.in_degree_from_vertex(vertex_2, current_vertex) > 0) {
+                        contraction_debug << "UNDIRECTED graph before contraction\n";
+                        graph.print_graph(contraction_debug);
+                        E e1 = graph.get_min_cost_edge(vertex_1,
+                                current_vertex);
+                        E e2 = graph.get_min_cost_edge(current_vertex,
+                                vertex_2);
+                        add_shortcut(graph, current_vertex, e1, e2, contraction_debug);
+                    }
+                }
+
+                graph.disconnect_vertex(contraction_debug, current_vertex);
+                linearVertices -= current_vertex;
+                if (is_linear(graph, vertex_1, debug)
+                        && !forbiddenVertices.has(vertex_1)) {
+                    linearPriority.push(vertex_1);
+                    linearVertices += vertex_1;
+                }
+                if (is_linear(graph, vertex_2, debug)
+                        && !forbiddenVertices.has(vertex_2)) {
+                    linearPriority.push(vertex_2);
+                    linearVertices += vertex_2;
+                }
+            }
+            debug << contraction_debug.str().c_str() << "\n";
+        }
+
+
+
+    template < class G >
+        void Pgr_linearContraction<G>::add_shortcut(G &graph, V vertex,
+                E incoming_edge,
+                E outgoing_edge,
+                std::ostringstream& debug) {
+            if (graph.m_gType == UNDIRECTED) {
+                Identifiers<V> adjacent_vertices = graph.find_adjacent_vertices(vertex);
+                V vertex_1 = adjacent_vertices[0];
+                V vertex_2 = adjacent_vertices[1];
+                E shortcut_E;
+                contraction::Edge shortcut(get_next_id(), graph[vertex_1].id,
+                        graph[vertex_2].id,
+                        graph[incoming_edge].cost + graph[outgoing_edge].cost);
+                shortcut.add_contracted_vertex(graph[vertex], vertex);
+                shortcut.add_contracted_edge_vertices(graph[incoming_edge]);
+                shortcut.add_contracted_edge_vertices(graph[outgoing_edge]);
+                debug << "Adding shortcut\n";
+                debug << shortcut;
+                graph.graph_add_shortcut(shortcut, debug);
+                debug << "Added shortcut\n";
+            } else if (graph.m_gType == DIRECTED) {
+                contraction::Edge shortcut(get_next_id(), graph[incoming_edge].source,
+                        graph[outgoing_edge].target,
+                        graph[incoming_edge].cost + graph[outgoing_edge].cost);
+                shortcut.add_contracted_vertex(graph[vertex], vertex);
+                shortcut.add_contracted_edge_vertices(graph[incoming_edge]);
+                shortcut.add_contracted_edge_vertices(graph[outgoing_edge]);
+                debug << "Adding shortcut\n";
+                debug << shortcut;
+                graph.graph_add_shortcut(shortcut, debug);
+                debug << "Added shortcut\n";
+            }
+        }
+        template < class G >
+        void Pgr_linearContraction<G>::add_shortcut(G &graph,
+                pgrouting::contraction::Edge &shortcut,
+                std::ostringstream& debug) {
+                graph.graph_add_shortcut(shortcut, debug);
+        }
+
+}  // namespace pgrouting
diff --git a/src/withPoints/src/get_new_queries.h b/src/contraction/src/structs.h
similarity index 68%
copy from src/withPoints/src/get_new_queries.h
copy to src/contraction/src/structs.h
index 147c05e..6be78fb 100644
--- a/src/withPoints/src/get_new_queries.h
+++ b/src/contraction/src/structs.h
@@ -1,11 +1,11 @@
 /*PGR-GNU*****************************************************************
-File: get_new_queries.h
+File: structs.h
 
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
+Copyright (c) 2016 Rohith Reddy
 Mail: 
 
 ------
@@ -25,21 +25,24 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
+#ifndef SRC_CONTRACTION_SRC_STRUCTS_H_
+#define SRC_CONTRACTION_SRC_STRUCTS_H_
 
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
+#ifndef __cplusplus
+#include "postgres.h"
 #endif
+#include <stdint.h>
 
-    void get_new_queries(
-            char *edges_sql,
-            char *points_sql, 
-            char **edges_of_points_query,
-            char **edges_no_points_query);
-
+typedef struct {
+    int64_t seq;
+    int64_t id;
+    char *type;
+    int64_t source;
+    int64_t target;
+    double cost;
+    int64_t *contracted_vertices;
+    int contracted_vertices_size;
+} pgr_contracted_blob;
 
-#ifdef __cplusplus
-}
-#endif
 
+#endif  // SRC_CONTRACTION_SRC_STRUCTS_H_
diff --git a/src/contraction/test/directed-development.result b/src/contraction/test/directed-development.result
new file mode 100644
index 0000000..952269c
--- /dev/null
+++ b/src/contraction/test/directed-development.result
@@ -0,0 +1,50 @@
+--q0 Checking for valid contraction
+--q1 Checking dead end contraction for single edge
+1|v|2|{1}|-1|-1|-1
+--q2 Checking dead end contraction for two edges
+1|v|3|{1,2}|-1|-1|-1
+--q3 Checking dead end contraction for sample data
+1|v|2|{1}|-1|-1|-1
+2|v|5|{7,8}|-1|-1|-1
+3|v|10|{13}|-1|-1|-1
+4|v|15|{14}|-1|-1|-1
+5|v|17|{16}|-1|-1|-1
+--q5 Checking dead end contraction for a graph with no dead end vertex
+--q6 Checking for linear vertices case 1
+1|e|-1|{3}|4|6|2
+--q7 Checking for linear vertices case 2
+1|e|-1|{5}|6|10|2
+2|e|-2|{5}|10|6|2
+--q8 Checking for linear vertices case 3
+1|e|-1|{2}|3|5|2
+--q9 Checking for linear vertices case 4
+1|e|-1|{6}|3|9|2
+--q10 Checking linear contraction for sample data
+1|e|-1|{4}|9|3|2
+2|e|-2|{8}|5|7|2
+3|e|-3|{8}|7|5|2
+4|e|-4|{12}|11|9|2
+--q11 Checking dead end, linear contraction for sample data
+1|v|5|{7,8}|-1|-1|-1
+2|v|15|{14}|-1|-1|-1
+3|v|17|{16}|-1|-1|-1
+4|e|-1|{1,2}|3|5|2
+5|e|-2|{4}|9|3|2
+6|e|-3|{10,13}|5|11|2
+7|e|-4|{12}|11|9|2
+--q12 Checking linear contraction, dead end for sample data
+1|v|2|{1}|-1|-1|-1
+2|v|10|{13}|-1|-1|-1
+3|v|15|{14}|-1|-1|-1
+4|v|17|{16}|-1|-1|-1
+5|e|-1|{4}|9|3|2
+6|e|-2|{8}|5|7|2
+7|e|-3|{8}|7|5|2
+8|e|-4|{12}|11|9|2
+--q13 Checking linear contraction for a square like graph
+1|e|-1|{2}|3|5|2
+2|e|-2|{2,5}|3|6|3
+--q14 Checking linear contraction, dead end for a square like graph
+1|v|3|{2,5,6}|-1|-1|-1
+2|e|-1|{2}|3|5|2
+3|e|-2|{2,5}|3|6|3
\ No newline at end of file
diff --git a/src/contraction/test/directed-development.test.sql b/src/contraction/test/directed-development.test.sql
new file mode 100644
index 0000000..e527df4
--- /dev/null
+++ b/src/contraction/test/directed-development.test.sql
@@ -0,0 +1,107 @@
+BEGIN;
+SET client_min_messages TO WARNING;
+
+
+\echo --q0 Checking for valid contraction
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[-1]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q0 -------------------------------------------
+
+\echo --q1 Checking dead end contraction for single edge
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q1 -------------------------------------------
+
+\echo --q2 Checking dead end contraction for two edges
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id < 3',
+    ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q2 -------------------------------------------
+
+\echo --q3 Checking dead end contraction for sample data
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q3 -------------------------------------------
+
+/*
+-- this test fails becuse parameter is wrong
+\echo --q4 Checking that forbidden vertices can only be one dimensional or empty
+SELECT * FROM pgr_contractGraph(
+	'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+	ARRAY[ [2,3,4,5], [4,5,6,7] ]::BIGINT[][], ARRAY[0]::integer[], 1, true);
+-- \echo --q4 -------------------------------------------
+*/
+
+\echo --q5 Checking dead end contraction for a graph with no dead end vertex
+SELECT * FROM pgr_contractGraph(
+	'SELECT id, source, target, cost, reverse_cost FROM edge_table 
+	WHERE id = 2 OR id = 4 OR id = 5 OR id = 8',
+	ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q5 -------------------------------------------
+
+\echo --q6 Checking for linear vertices case 1
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table 
+    WHERE id = 3 OR id = 5',
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q6 -------------------------------------------
+
+
+\echo --q7 Checking for linear vertices case 2
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table 
+    WHERE id = 8 OR id = 10',
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q7 -------------------------------------------
+
+
+\echo --q8 Checking for linear vertices case 3
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table 
+    WHERE id = 2 OR id = 4',
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q8 -------------------------------------------
+
+\echo --q9 Checking for linear vertices case 4
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table 
+    WHERE id = 5 OR id = 9',
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q9 -------------------------------------------
+
+\echo --q10 Checking linear contraction for sample data
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table' ,
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q10 -------------------------------------------
+
+\echo --q11 Checking dead end, linear contraction for sample data
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table' ,
+    ARRAY[1, 2]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q11 -------------------------------------------
+
+\echo --q12 Checking linear contraction, dead end for sample data
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table' ,
+     ARRAY[2, 1]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q12 -------------------------------------------
+\echo --q13 Checking linear contraction for a square like graph
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table 
+    WHERE id = 2 OR id = 4 OR id = 5 OR id = 8',
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+-- \echo --q13 -------------------------------------------
+
+\echo --q14 Checking linear contraction, dead end for a square like graph
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table 
+    WHERE id = 2 OR id = 4 OR id = 5 OR id = 8',
+    ARRAY[2, 1]::integer[], 1, ARRAY[]::BIGINT[], true);
+
+
+
+ROLLBACK;
diff --git a/src/contraction/test/doc-contractGraph.result b/src/contraction/test/doc-contractGraph.result
new file mode 100644
index 0000000..e94997e
--- /dev/null
+++ b/src/contraction/test/doc-contractGraph.result
@@ -0,0 +1,28 @@
+-- q1
+1|v|5|{7,8}|-1|-1|-1
+2|v|15|{14}|-1|-1|-1
+3|v|17|{16}|-1|-1|-1
+4|e|-1|{1,2}|3|5|2
+5|e|-2|{4}|9|3|2
+6|e|-3|{10,13}|5|11|2
+7|e|-4|{12}|11|9|2
+-- q2
+1|v|2|{1}|-1|-1|-1
+2|v|5|{7,8}|-1|-1|-1
+3|v|15|{14}|-1|-1|-1
+4|v|17|{16}|-1|-1|-1
+5|e|-1|{4}|9|3|2
+6|e|-2|{10,13}|5|11|2
+7|e|-3|{12}|11|9|2
+-- q3
+1|v|2|{1}|-1|-1|-1
+2|v|5|{7,8}|-1|-1|-1
+3|v|10|{13}|-1|-1|-1
+4|v|15|{14}|-1|-1|-1
+5|v|17|{16}|-1|-1|-1
+-- q4
+1|e|-1|{4}|9|3|2
+2|e|-2|{8}|5|7|2
+3|e|-3|{8}|7|5|2
+4|e|-4|{12}|11|9|2
+-- q5
\ No newline at end of file
diff --git a/src/contraction/test/doc-contractGraph.test.sql b/src/contraction/test/doc-contractGraph.test.sql
new file mode 100644
index 0000000..7715be9
--- /dev/null
+++ b/src/contraction/test/doc-contractGraph.test.sql
@@ -0,0 +1,21 @@
+\echo -- q1
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1, 2]);
+
+\echo -- q2
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1, 2], forbidden_vertices:=ARRAY[2]);
+
+\echo -- q3
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]);
+
+\echo -- q4
+ SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[2]);
+
+\echo -- q5
\ No newline at end of file
diff --git a/src/contraction/test/doc-contraction.result b/src/contraction/test/doc-contraction.result
new file mode 100644
index 0000000..131b60f
--- /dev/null
+++ b/src/contraction/test/doc-contraction.result
@@ -0,0 +1,128 @@
+-- q00
+1|1|2|1|1
+2|2|3|-1|1
+3|3|4|-1|1
+4|2|5|1|1
+5|3|6|1|-1
+6|7|8|1|1
+7|8|5|1|1
+8|5|6|1|1
+9|6|9|1|1
+10|5|10|1|1
+11|6|11|1|-1
+12|10|11|1|-1
+13|11|12|1|-1
+14|10|13|1|1
+15|9|12|1|1
+16|4|9|1|1
+17|14|15|1|1
+18|16|17|1|1
+-- q01
+-- q1
+-- q2
+1|v|5|{7,8}|-1|-1|-1
+2|v|15|{14}|-1|-1|-1
+3|v|17|{16}|-1|-1|-1
+4|e|-1|{1,2}|3|5|2
+5|e|-2|{4}|9|3|2
+6|e|-3|{10,13}|5|11|2
+7|e|-4|{12}|11|9|2
+-- q3
+-- q4
+-- q5
+1|t
+2|t
+3|f
+4|t
+5|f
+6|f
+7|t
+8|t
+9|f
+10|t
+11|f
+12|t
+13|t
+14|t
+15|f
+16|t
+17|f
+-- q6
+-- q7
+1||t
+2||t
+3||f
+4||t
+5|{7,8}|f
+6||f
+7||t
+8||t
+9||f
+10||t
+11||f
+12||t
+13||t
+14||t
+15|{14}|f
+16||t
+17|{16}|f
+-- q8
+-- q9
+1|1|2|1|1||f
+2|2|3|-1|1||f
+3|3|4|-1|1||f
+4|2|5|1|1||f
+5|3|6|1|-1||f
+6|7|8|1|1||f
+7|8|5|1|1||f
+8|5|6|1|1||f
+9|6|9|1|1||f
+10|5|10|1|1||f
+11|6|11|1|-1||f
+12|10|11|1|-1||f
+13|11|12|1|-1||f
+14|10|13|1|1||f
+15|9|12|1|1||f
+16|4|9|1|1||f
+17|14|15|1|1||f
+18|16|17|1|1||f
+23|3|5|2|-1|{1,2}|t
+24|9|3|2|-1|{4}|t
+25|5|11|2|-1|{10,13}|t
+26|11|9|2|-1|{12}|t
+-- q10
+3
+5
+6
+9
+11
+15
+17
+-- case1
+1|1|3|5|1|0
+2|2|6|11|1|1
+3|3|11|-1|0|2
+-- case2
+1|1|3|2|1|0
+2|2|2|1|1|1
+3|3|1|-1|0|2
+-- case3
+1|1|7|6|1|0
+2|2|8|7|1|1
+3|3|5|10|1|2
+4|4|10|14|1|3
+5|5|13|-1|0|4
+-- case4
+1|1|3|23|2|0
+2|2|5|7|1|2
+3|3|8|6|1|3
+4|4|7|-1|0|4
+-- case5q1
+23|{1,2}
+-- case5q2
+1|1|3|2|1|0
+2|2|2|4|1|1
+3|3|5|7|1|2
+4|4|8|6|1|3
+5|5|7|-1|0|4
+-- end
diff --git a/src/contraction/test/doc-contraction.test.sql b/src/contraction/test/doc-contraction.test.sql
new file mode 100644
index 0000000..7731ced
--- /dev/null
+++ b/src/contraction/test/doc-contraction.test.sql
@@ -0,0 +1,212 @@
+\echo -- q00
+SELECT id, source, target, cost, reverse_cost FROM edge_table;
+\echo -- q01
+
+SET client_min_messages TO error;
+\echo -- q1
+ALTER TABLE edge_table ADD contracted_vertices BIGINT[];
+ALTER TABLE edge_table_vertices_pgr ADD contracted_vertices BIGINT[];
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false;
+ALTER TABLE edge_table_vertices_pgr ADD is_contracted BOOLEAN DEFAULT false;
+
+\echo -- q2
+-- showing original results
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    array[1,2], directed:=true);
+
+\echo -- q3
+SELECT * INTO contraction_results
+FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    array[1,2], directed:=true);
+
+\echo -- q4
+UPDATE edge_table_vertices_pgr
+SET is_contracted = true
+WHERE id IN (SELECT  unnest(contracted_vertices) FROM  contraction_results);
+
+\echo -- q5
+SELECT id, is_contracted
+FROM edge_table_vertices_pgr
+ORDER BY id;
+
+\echo -- q6
+UPDATE edge_table_vertices_pgr
+SET contracted_vertices = contraction_results.contracted_vertices
+FROM contraction_results
+WHERE type = 'v' AND edge_table_vertices_pgr.id = contraction_results.id;
+
+\echo -- q7
+SELECT id, contracted_vertices, is_contracted 
+FROM edge_table_vertices_pgr
+ORDER BY id;
+
+\echo -- q8
+INSERT INTO edge_table(source, target, cost, reverse_cost, contracted_vertices, is_contracted)
+SELECT source, target, cost, -1, contracted_vertices, true
+FROM contraction_results
+WHERE type = 'e';
+
+\echo -- q9
+SELECT id, source, target, cost, reverse_cost, contracted_vertices, is_contracted 
+FROM edge_table
+ORDER BY id;
+
+\echo -- q10
+SELECT id  FROM edge_table_vertices_pgr
+WHERE is_contracted = false
+ORDER BY id;
+
+\echo -- case1
+SELECT * FROM pgr_dijkstra(
+    $$
+    WITH
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false)
+    SELECT id, source, target, cost, reverse_cost 
+    FROM edge_table 
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    3, 11, false);
+
+
+\echo -- case2
+SELECT * FROM pgr_dijkstra(
+    $$
+    WITH
+    expand_edges AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table),
+    expand1 AS (SELECT contracted_vertices FROM edge_table
+        WHERE id IN (SELECT id FROM expand_edges WHERE vertex = 1)),
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand1)
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    3, 1, false);
+
+\echo -- case3
+SELECT * FROM pgr_dijkstra(
+    $$
+    WITH
+
+    expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+    expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+        WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+
+    expand_edges AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table),
+    expand13 AS (SELECT contracted_vertices FROM edge_table
+        WHERE id IN (SELECT id FROM expand_edges WHERE vertex = 13)),
+
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand13
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand7)
+
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    7, 13, false);
+
+\echo -- case4
+
+SELECT * FROM  pgr_dijkstra(
+    $$
+    WITH
+    expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+    expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+        WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+    vertices_in_graph AS (
+        SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+        UNION
+        SELECT unnest(contracted_vertices) FROM expand7)
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    $$,
+    3, 7, false);
+
+
+\echo -- case5q1
+-- Edges that need expansion and the vertices to be expanded.
+WITH
+first_dijkstra AS (
+    SELECT * FROM  pgr_dijkstra(
+        $$
+        WITH
+        expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+        expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+            WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+        vertices_in_graph AS (
+            SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+            UNION
+            SELECT unnest(contracted_vertices) FROM expand7)
+        SELECT id, source, target, cost, reverse_cost
+        FROM edge_table
+        WHERE source IN (SELECT * FROM vertices_in_graph)
+        AND target IN (SELECT * FROM vertices_in_graph)
+        $$,
+        3, 7, false))
+
+SELECT edge, contracted_vertices
+    FROM first_dijkstra JOIN edge_table
+    ON (edge = id)
+    WHERE is_contracted = true;
+
+\echo -- case5q2 
+
+SELECT * FROM pgr_dijkstra($$
+    WITH
+    -- This returns the results from case 2
+    first_dijkstra AS (
+        SELECT * FROM  pgr_dijkstra(
+            '
+            WITH
+            expand_vertices AS (SELECT id, unnest(contracted_vertices) AS vertex FROM edge_table_vertices_pgr),
+            expand7 AS (SELECT contracted_vertices FROM edge_table_vertices_pgr
+                WHERE id IN (SELECT id FROM expand_vertices WHERE vertex = 7)),
+            vertices_in_graph AS (
+                SELECT id  FROM edge_table_vertices_pgr WHERE is_contracted = false
+                UNION
+                SELECT unnest(contracted_vertices) FROM expand7)
+            SELECT id, source, target, cost, reverse_cost
+            FROM edge_table
+            WHERE source IN (SELECT * FROM vertices_in_graph)
+            AND target IN (SELECT * FROM vertices_in_graph)
+            ',
+            3, 7, false)),
+
+    -- edges that need expansion and the vertices to be expanded.
+    edges_to_expand AS (
+        SELECT edge, contracted_vertices
+        FROM first_dijkstra JOIN edge_table
+        ON (edge = id)
+        WHERE is_contracted = true),
+
+    vertices_in_graph AS (
+        -- the nodes of the contracted solution
+        SELECT node FROM first_dijkstra
+        UNION
+        -- the nodes of the expanding sections
+        SELECT unnest(contracted_vertices) FROM edges_to_expand)
+
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (SELECT * FROM vertices_in_graph)
+    AND target IN (SELECT * FROM vertices_in_graph)
+    -- not including the expanded edges
+    AND id NOT IN (SELECT edge FROM edges_to_expand)
+    $$,
+    3, 7, false);
+
+\echo -- end
diff --git a/src/contraction/test/expand_graph.result b/src/contraction/test/expand_graph.result
new file mode 100644
index 0000000..f6f4086
--- /dev/null
+++ b/src/contraction/test/expand_graph.result
@@ -0,0 +1,78 @@
+step 1: Initial edge table
+1|1|2|1|1
+2|2|3|-1|1
+3|3|4|-1|1
+4|2|5|1|1
+5|3|6|1|-1
+6|7|8|1|1
+7|8|5|1|1
+8|5|6|1|1
+9|6|9|1|1
+10|5|10|1|1
+11|6|11|1|-1
+12|10|11|1|-1
+13|11|12|1|-1
+14|10|13|1|1
+15|9|12|1|1
+16|4|9|1|1
+17|14|15|1|1
+18|16|17|1|1
+step 2: Initial vertex table
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+step 3: Adding is_contracted column to edge_table......
+step 4: Adding contracted_vertices column to edge_table.....
+step 5: Adding is_contracted column to edge_table......
+step 6: Adding contracted_vertices column to edge_table.....
+step 7: Edge table after adding columns
+1|1|2|1|1|f|
+2|2|3|-1|1|f|
+3|3|4|-1|1|f|
+4|2|5|1|1|f|
+5|3|6|1|-1|f|
+6|7|8|1|1|f|
+7|8|5|1|1|f|
+8|5|6|1|1|f|
+9|6|9|1|1|f|
+10|5|10|1|1|f|
+11|6|11|1|-1|f|
+12|10|11|1|-1|f|
+13|11|12|1|-1|f|
+14|10|13|1|1|f|
+15|9|12|1|1|f|
+16|4|9|1|1|f|
+17|14|15|1|1|f|
+18|16|17|1|1|f|
+step 8: Vertex table after adding columns
+1|f|
+2|f|
+3|f|
+4|f|
+5|f|
+6|f|
+7|f|
+8|f|
+9|f|
+10|f|
+11|f|
+12|f|
+13|f|
+14|f|
+15|f|
+16|f|
+17|f|
diff --git a/src/contraction/test/expand_graph.test.sql b/src/contraction/test/expand_graph.test.sql
new file mode 100644
index 0000000..1acf978
--- /dev/null
+++ b/src/contraction/test/expand_graph.test.sql
@@ -0,0 +1,220 @@
+BEGIN;
+
+\echo 'step 1: Initial edge table'
+
+SELECT id, source, target, cost, reverse_cost FROM edge_table;
+
+\echo 'step 2: Initial vertex table'
+
+SELECT id FROM edge_table_vertices_pgr;
+
+
+-- add extra columns to the edges and vertices table
+\echo 'step 3: Adding is_contracted column to edge_table......'
+
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false;
+
+\echo 'step 4: Adding contracted_vertices column to edge_table.....'
+
+ALTER TABLE edge_table ADD contracted_vertices integer[];
+
+\echo 'step 5: Adding is_contracted column to edge_table......'
+
+ALTER TABLE edge_table_vertices_pgr ADD is_contracted BOOLEAN DEFAULT false;
+
+\echo 'step 6: Adding contracted_vertices column to edge_table.....'
+
+ALTER TABLE edge_table_vertices_pgr ADD contracted_vertices integer[];
+
+\echo 'step 7: Edge table after adding columns'
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM edge_table;
+
+\echo 'step 8: Vertex table after adding columns'
+
+SELECT id, is_contracted, contracted_vertices FROM edge_table_vertices_pgr;
+
+
+-- update the added columns to the above tables 
+-- based on the results of contraction query
+CREATE OR REPLACE FUNCTION pgr_update_contraction_columns(
+	edge_table text,
+	forbidden_vertices BIGINT[],
+	contraction_order integer[],
+	max_cycles integer,
+	directed BOOLEAN
+)
+RETURNS integer AS $total$
+declare
+total integer;
+contracted_vertex integer;
+query text;
+update_query text;
+split_query text;
+insert_query text;
+row record;
+split_row record;
+BEGIN
+total := 0;
+query := 'SELECT * FROM pgr_contractGraph('|| quote_literal(edge_table)||', ' || quote_literal(forbidden_vertices)||', ' || quote_literal(contraction_order)||', ' || quote_literal(max_cycles)||', ' || quote_literal(directed) || ')';
+    FOR row IN EXECUTE(query)
+    LOOP
+        
+        -- contracted_vertices_array := row.contracted_vertices;
+        -- If it is a vertex we update the two columns of the vertex table 
+        IF row.type = 'v' THEN
+            total := total + 1;
+            -- raise notice 'vertex';
+            update_query := 'UPDATE edge_table_vertices_pgr SET contracted_vertices = array_append(contracted_vertices, ';  
+            FOREACH contracted_vertex IN ARRAY row.contracted_vertices
+            LOOP
+                EXECUTE update_query || quote_literal(contracted_vertex) 
+                || ') WHERE id = ' || quote_literal(row.id);
+                EXECUTE 'UPDATE edge_table_vertices_pgr SET is_contracted = true WHERE id = '
+                || quote_literal(contracted_vertex);
+                -- raise notice 'cv: %', contracted_vertex;
+            END LOOP;
+        -- If it is an edge we insert a new entry to the edge table 
+        ELSEIF row.type = 'e' THEN
+            total := total + 1;
+            -- raise notice 'edge';
+            insert_query := 'INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted, contracted_vertices) VALUES ('
+            || quote_literal(row.id)|| ', '
+            || quote_literal(row.source)|| ', '
+            || quote_literal(row.target)|| ', '
+            || quote_literal(row.cost)|| ', '
+            || quote_literal(-1)|| ', '
+            || quote_literal(true)|| ', '
+            || quote_literal(row.contracted_vertices)
+            || ')';
+            EXECUTE insert_query;
+            FOREACH contracted_vertex IN ARRAY row.contracted_vertices
+            LOOP
+            EXECUTE 'UPDATE edge_table_vertices_pgr SET is_contracted = true WHERE id = '
+                || quote_literal(contracted_vertex);
+            END LOOP;
+        END IF;
+        -- raise notice 'id: %, type: %, cv: %',row.id, row.type, row.contracted_vertices;
+    END LOOP;
+
+   RETURN total;
+   END;
+   $total$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION pgr_expand_contracted_graph(
+    original_edge_table text,
+    original_vertex_table text,
+    contracted_edge_table text,
+    contracted_vertex_table text
+)
+RETURNS integer AS $total$
+declare
+total integer;
+contracted_vertex integer;
+query text;
+row record;
+BEGIN
+    total := 0;
+    query := 'SELECT * FROM '
+    || quote_ident(contracted_edge_table)
+    ||' WHERE id < 0 ';
+    FOR row IN EXECUTE(query)
+    LOOP
+        -- Inserting the contracted vertices into the vertex table
+        FOREACH contracted_vertex IN ARRAY row.contracted_vertices
+        LOOP
+            EXECUTE 'INSERT INTO ' || quote_ident(contracted_vertex_table) || '(id, is_contracted)' ||' VALUES ('
+            || quote_literal(contracted_vertex) || ', false);';   
+        END LOOP;
+        -- Adding the edges(id < 0) between these vertices to the edge table
+        EXECUTE 'INSERT INTO ' 
+        || quote_ident(contracted_edge_table) 
+        || ' SELECT * FROM ' || quote_ident(original_edge_table)
+        || ' WHERE source = ANY(' || quote_literal(row.contracted_vertices) || ')'
+        || ' OR target = ANY(' || quote_literal(row.contracted_vertices) || ')'
+        || ' AND id > 0';
+
+    END LOOP;
+
+    -- Removing all those edges with id < 0
+    EXECUTE 'DELETE FROM ' 
+    || quote_ident(contracted_edge_table)
+    || ' WHERE id < 0';
+
+    query := 'SELECT * FROM '|| quote_ident(contracted_vertex_table)||' WHERE array_length(contracted_vertices, 1) > 0';
+    FOR row IN EXECUTE(query)
+    LOOP
+        -- Inserting the contracted vertices into the vertex table
+        FOREACH contracted_vertex IN ARRAY row.contracted_vertices
+        LOOP
+            EXECUTE 'INSERT INTO ' || quote_ident(contracted_vertex_table) || '(id, is_contracted)' ||' VALUES ('
+            || quote_literal(contracted_vertex) || ', false);';    
+        END LOOP;
+        -- Adding the edges(id < 0) between these vertices to the edge table
+        EXECUTE 'INSERT INTO ' 
+        || quote_ident(contracted_edge_table) 
+        || ' SELECT * FROM ' || quote_ident(original_edge_table)
+        || ' WHERE source = ANY(' || quote_literal(row.contracted_vertices) || ')'
+        || ' OR target = ANY(' || quote_literal(row.contracted_vertices) || ')'
+        || ' AND id > 0';
+    EXECUTE 'UPDATE '
+    || quote_ident(contracted_vertex_table)
+    || ' SET contracted_vertices = NULL' 
+    || ' WHERE array_length(contracted_vertices, 1) > 0 ';
+    END LOOP;
+
+RETURN total;
+END;
+   $total$ LANGUAGE plpgsql;
+
+
+/*
+-- Testing the update function
+   SELECT * FROM pgr_update_contraction_columns(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[]::BIGINT[], ARRAY[0, 1]::integer[], 1, true );
+
+SELECT  'step 9: Creating the edge table and vertex table of the contracted graph';
+
+CREATE TABLE contracted_edge_table_vertices_pgr AS
+SELECT *
+FROM edge_table_vertices_pgr WHERE is_contracted = false;
+
+CREATE TABLE contracted_edge_table AS
+SELECT *
+FROM edge_table WHERE source IN (SELECT id FROM contracted_edge_table_vertices_pgr)
+AND target IN (SELECT id FROM contracted_edge_table_vertices_pgr);
+
+SELECT 'step 10: Edge table after modification';
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM edge_table ORDER BY id;
+
+SELECT 'step 11: Vertex table after modification';
+
+SELECT id, is_contracted, contracted_vertices FROM edge_table_vertices_pgr  ORDER BY id;
+
+SELECT 'step 12: Edge table representing the contracted graph';
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM contracted_edge_table  ORDER BY id;
+
+SELECT 'step 13: Vertex table representing the contracted graph';
+
+SELECT id, is_contracted, contracted_vertices FROM contracted_edge_table_vertices_pgr  ORDER BY id;
+
+SELECT 'step 14: Expanding the contracted graph......';
+
+-- Testing the expand function
+   SELECT * FROM pgr_expand_contracted_graph(
+    'edge_table', 'edge_table_vertices_pgr',
+    'contracted_edge_table', 'contracted_edge_table_vertices_pgr');
+
+SELECT 'step 15: Edge table representing the expanded graph';
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM contracted_edge_table  ORDER BY id;
+
+SELECT 'step 16: Vertex table representing the expanded graph';
+
+SELECT id, is_contracted, contracted_vertices FROM contracted_edge_table_vertices_pgr  ORDER BY id;
+*/
+
+ROLLBACK;
diff --git a/src/contraction/test/expand_graph_without_function.result b/src/contraction/test/expand_graph_without_function.result
new file mode 100644
index 0000000..4cb2078
--- /dev/null
+++ b/src/contraction/test/expand_graph_without_function.result
@@ -0,0 +1,78 @@
+step 1: Initial edge table
+1|1|2|1|1
+2|2|3|-1|1
+3|3|4|-1|1
+4|2|5|1|1
+5|3|6|1|-1
+6|7|8|1|1
+7|8|5|1|1
+8|5|6|1|1
+9|6|9|1|1
+10|5|10|1|1
+11|6|11|1|-1
+12|10|11|1|-1
+13|11|12|1|-1
+14|10|13|1|1
+15|9|12|1|1
+16|4|9|1|1
+17|14|15|1|1
+18|16|17|1|1
+step 2: Initial vertex table
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+step 3: Adding is_contracted column to edge_table......
+step 4: Adding contracted_vertices column to edge_table.....
+step 5: Adding is_contracted column to edge_table......
+step 6: Adding contracted_vertices column to edge_table.....
+step 7: Edge table after adding columns
+1|1|2|1|1|f|
+2|2|3|-1|1|f|
+3|3|4|-1|1|f|
+4|2|5|1|1|f|
+5|3|6|1|-1|f|
+6|7|8|1|1|f|
+7|8|5|1|1|f|
+8|5|6|1|1|f|
+9|6|9|1|1|f|
+10|5|10|1|1|f|
+11|6|11|1|-1|f|
+12|10|11|1|-1|f|
+13|11|12|1|-1|f|
+14|10|13|1|1|f|
+15|9|12|1|1|f|
+16|4|9|1|1|f|
+17|14|15|1|1|f|
+18|16|17|1|1|f|
+step 8: Vertex table after adding columns
+1|f|
+2|f|
+3|f|
+4|f|
+5|f|
+6|f|
+7|f|
+8|f|
+9|f|
+10|f|
+11|f|
+12|f|
+13|f|
+14|f|
+15|f|
+16|f|
+17|f|
\ No newline at end of file
diff --git a/src/contraction/test/expand_graph_without_function.test.sql b/src/contraction/test/expand_graph_without_function.test.sql
new file mode 100644
index 0000000..a4bfbf5
--- /dev/null
+++ b/src/contraction/test/expand_graph_without_function.test.sql
@@ -0,0 +1,86 @@
+BEGIN;
+
+SELECT 'step 1: Initial edge table';
+
+SELECT id, source, target, cost, reverse_cost FROM edge_table;
+
+SELECT 'step 2: Initial vertex table';
+
+SELECT id FROM edge_table_vertices_pgr;
+
+
+-- add extra columns to the edges and vertices table
+SELECT 'step 3: Adding is_contracted column to edge_table......';
+
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false;
+
+SELECT 'step 4: Adding contracted_vertices column to edge_table.....';
+
+ALTER TABLE edge_table ADD contracted_vertices integer[];
+
+SELECT 'step 5: Adding is_contracted column to edge_table......';
+
+ALTER TABLE edge_table_vertices_pgr ADD is_contracted BOOLEAN DEFAULT false;
+
+SELECT 'step 6: Adding contracted_vertices column to edge_table.....';
+
+ALTER TABLE edge_table_vertices_pgr ADD contracted_vertices integer[];
+
+SELECT 'step 7: Edge table after adding columns';
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM edge_table;
+
+SELECT 'step 8: Vertex table after adding columns';
+
+SELECT id, is_contracted, contracted_vertices FROM edge_table_vertices_pgr;
+
+
+/*
+-- Testing the update function
+   SELECT * FROM pgr_update_contraction_columns(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[]::BIGINT[], ARRAY[0, 1]::integer[], 1, true );
+
+SELECT  'step 9: Creating the edge table and vertex table of the contracted graph';
+
+CREATE TABLE contracted_edge_table_vertices_pgr AS
+SELECT *
+FROM edge_table_vertices_pgr WHERE is_contracted = false;
+
+CREATE TABLE contracted_edge_table AS
+SELECT *
+FROM edge_table WHERE source IN (SELECT id FROM contracted_edge_table_vertices_pgr)
+AND target IN (SELECT id FROM contracted_edge_table_vertices_pgr);
+
+SELECT 'step 10: Edge table after modification';
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM edge_table ORDER BY id;
+
+SELECT 'step 11: Vertex table after modification';
+
+SELECT id, is_contracted, contracted_vertices FROM edge_table_vertices_pgr  ORDER BY id;
+
+SELECT 'step 12: Edge table representing the contracted graph';
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM contracted_edge_table  ORDER BY id;
+
+SELECT 'step 13: Vertex table representing the contracted graph';
+
+SELECT id, is_contracted, contracted_vertices FROM contracted_edge_table_vertices_pgr  ORDER BY id;
+
+SELECT 'step 14: Expanding the contracted graph......';
+
+-- Testing the expand function
+   SELECT * FROM pgr_expand_contracted_graph(
+    'edge_table', 'edge_table_vertices_pgr',
+    'contracted_edge_table', 'contracted_edge_table_vertices_pgr');
+
+SELECT 'step 15: Edge table representing the expanded graph';
+
+SELECT id, source, target, cost, reverse_cost, is_contracted, contracted_vertices FROM contracted_edge_table  ORDER BY id;
+
+SELECT 'step 16: Vertex table representing the expanded graph';
+
+SELECT id, is_contracted, contracted_vertices FROM contracted_edge_table_vertices_pgr  ORDER BY id;
+*/
+ROLLBACK;
diff --git a/src/contraction/test/pgtap/contraction-types-check.sql b/src/contraction/test/pgtap/contraction-types-check.sql
new file mode 100644
index 0000000..40827db
--- /dev/null
+++ b/src/contraction/test/pgtap/contraction-types-check.sql
@@ -0,0 +1,237 @@
+\i setup.sql
+SELECT plan(44);
+SET client_min_messages TO WARNING;
+SELECT has_function('pgr_contractgraph');
+
+SELECT has_function('pgr_contractgraph', ARRAY[
+    'text', 'bigint[]',
+    'integer', 'bigint[]', 'boolean'
+    ]);
+
+SELECT function_returns('pgr_contractgraph', ARRAY[
+    'text', 'bigint[]',
+    'integer', 'bigint[]', 'boolean'
+    ], 'setof record');
+
+
+
+PREPARE parameters AS
+SELECT array[
+'edges_sql',
+'contraction_order',
+'max_cycles',
+'forbidden_vertices',
+'directed',
+'seq',
+'type',
+'id',
+'contracted_vertices',
+'source',
+'target',
+'cost'];
+
+SELECT set_has(
+    $$SELECT proargnames FROM pg_proc WHERE proname = 'pgr_contractgraph'$$,
+    'parameters');
+
+
+CREATE OR REPLACE FUNCTION test_anyInteger(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+        FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+    END IF;
+    start_sql = start_sql || p || ', ';
+END LOOP;
+end_sql = ' FROM edge_table $$, ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true)';
+
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+
+    query := start_sql || parameter || '::TEXT ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION test_anyNumerical(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+        FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+    END IF;
+    start_sql = start_sql || p || ', ';
+END LOOP;
+end_sql = ' FROM edge_table $$, ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true)';
+
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+-- CHECKING INNER QUERY
+
+--id ANY-INTEGER
+SELECT test_anyInteger('pgr_contractgraph',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost'],
+    'id');
+
+--source is only integer
+SELECT test_anyInteger('pgr_contractgraph',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost'],
+    'source');
+
+--target is only integer
+SELECT test_anyInteger('pgr_contractgraph',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost'],
+    'target');
+
+--cost is any numerical
+SELECT test_anyNumerical('pgr_contractgraph',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost'],
+    'cost');
+
+--reverse cost is any numerical
+SELECT test_anyNumerical('pgr_contractgraph',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost'],
+    'reverse_cost');
+
+-- Minimal Signature
+PREPARE q10 AS
+SELECT *
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[]);
+
+
+PREPARE q11 AS
+SELECT *
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], directed:= true);
+
+PREPARE q12 AS
+SELECT *
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], directed:= false);
+
+
+PREPARE q13 AS
+SELECT *
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], max_cycles:= 1, directed:= false);
+
+
+
+-- Forbidden vertices array dimension should be 0 or 1
+PREPARE q1 AS
+SELECT *
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], 1, ARRAY[ [2,3,4,5], [4,5,6,7] ]::integer[][], true);
+
+-- Contraction order array cannot be empty
+PREPARE q2 AS
+SELECT *
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[]::integer[], 1, ARRAY[]::integer[], true);
+
+-- Forbidden vertices should be an integer array
+PREPARE q3 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]::integer[], 1, ARRAY[ ]::integer[], true);
+
+PREPARE q4 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]::integer[], 1, ARRAY[ ]::bigint[], true);
+
+PREPARE q5 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]::integer[], 1, ARRAY[ ]::smallint[], true);
+
+/*
+PREPARE q5 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[ ]::bigint[], ARRAY[0]::FLOAT8[], 1, true);
+*/
+
+-- Contraction order array should be an integer array
+PREPARE q7 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]::bigint[], 1, ARRAY[ ]::bigint[], true);
+
+PREPARE q8 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]::integer[], 1, ARRAY[ ]::bigint[]);
+
+PREPARE q9 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+ARRAY[1]::smallint[], 1, ARRAY[ ]::bigint[]);
+
+SELECT throws_ok('q1', 'XX000', 'Expected less than two dimension',
+'Throws because forbidden_vertices is BIGINT[][]');
+
+SELECT throws_ok('q2', 'XX000', 'One dimension expected',
+'Throws because contraction_order is ARRAY[]');
+
+
+SELECT lives_ok('q3');
+SELECT lives_ok('q4');
+SELECT lives_ok('q5');
+SELECT lives_ok('q7');
+SELECT lives_ok('q8');
+SELECT lives_ok('q9');
+SELECT lives_ok('q10');
+SELECT lives_ok('q11');
+SELECT lives_ok('q12');
+SELECT lives_ok('q13');
+
+SELECT finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/src/contraction/test/pgtap/contraction_cycle_directed.sql b/src/contraction/test/pgtap/contraction_cycle_directed.sql
new file mode 100644
index 0000000..283b6fd
--- /dev/null
+++ b/src/contraction/test/pgtap/contraction_cycle_directed.sql
@@ -0,0 +1,228 @@
+\i setup.sql
+
+SELECT plan(30);
+
+SET client_min_messages TO WARNING; 
+
+PREPARE qempty AS
+SELECT * FROM ( VALUES (-1, 'v', -1, '{}', -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost) WHERE 1 != 1 ;
+
+-- TESTING CONTRACTION CYCLE WITH ONLY DEAD END CONTRACTION
+
+-- SINGLE EDGE
+
+PREPARE v2e1q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v2e1q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v2e1q10', 'v2e1q11', '1: Directed graph with single edge');
+
+PREPARE v2e1q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v2e1q10', 'v2e1q12', '1: Directed graph with single edge');
+
+SELECT set_eq('v2e1q11', 'v2e1q12', '1: Directed graph with single edge');
+
+-- TWO EDGES
+
+PREPARE v3e2q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v3e2q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v2e1q10', 'v2e1q11', '1: Directed graph with two edges');
+
+PREPARE v3e2q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v3e2q10', 'v3e2q12', '1: Directed graph with two edges');
+
+SELECT set_eq('v3e2q11', 'v3e2q12', '1: Directed graph with two edges');
+
+
+-- THREE EDGES
+
+PREPARE v4e3q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e3q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e3q10', 'v4e3q11', '1: Directed graph with three edges');
+
+PREPARE v4e3q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e3q10', 'v4e3q12', '1: Directed graph with three edges');
+SELECT set_eq('v4e3q11', 'v4e3q12', '1: Directed graph with three edges');
+
+PREPARE v4e3q13 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e3q14 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e3q13', 'v4e3q14', '1: Directed graph with three edges');
+
+PREPARE v4e3q15 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e3q13', 'v4e3q15', '1: Directed graph with three edges');
+SELECT set_eq('v4e3q14', 'v4e3q15', '1: Directed graph with three edges');
+
+-- FOUR EDGES
+
+PREPARE v4e4q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6 or id = 8',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e4q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6 or id = 8',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e4q10', 'v4e4q11', '9: Directed graph with four edges ');
+
+PREPARE v4e4q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6 or id = 8',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e4q10', 'v4e4q12', '9: Directed graph with four edges ');
+SELECT set_eq('v4e4q11', 'v4e4q12', '9: Directed graph with four edges ');
+
+PREPARE v6e4q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v6e4q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v6e4q10', 'v6e4q11', '11: Directed graph with four edges and no forbidden vertices');
+
+PREPARE v6e4q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v6e4q10', 'v6e4q12', '11: Directed graph with four edges and no forbidden vertices');
+SELECT set_eq('v6e4q11', 'v6e4q12', '11: Directed graph with four edges and no forbidden vertices');
+
+-- TESTING CONTRACTION CYCLE WITH ONLY LINEAR CONTRACTION
+
+-- TWO EDGES
+PREPARE v3e2q20 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v3e2q21 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v3e2q20', 'v3e2q21', '1: Directed graph with two edges and no forbidden vertices');
+
+PREPARE v3e2q22 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v3e2q20', 'v3e2q22', '1: Directed graph with two edges and no forbidden vertices');
+SELECT set_eq('v3e2q21', 'v3e2q22', '1: Directed graph with two edges and no forbidden vertices');
+
+
+-- THREE EDGES
+
+PREPARE v4e3q20 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e3q21 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e3q20', 'v4e3q21', '5: Directed graph with three edges and no forbidden vertices');
+
+PREPARE v4e3q22 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e3q20', 'v4e3q22', '5: Directed graph with three edges and no forbidden vertices');
+SELECT set_eq('v4e3q21', 'v4e3q22', '5: Directed graph with three edges and no forbidden vertices');
+
+-- FOUR EDGES
+PREPARE v4e4q20 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 9 or id = 10 or id = 11',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e4q21 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 9 or id = 10 or id = 11',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e4q20', 'v4e4q21', '5: Directed graph with four edges and no forbidden vertices');
+
+PREPARE v4e4q22 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 9 or id = 10 or id = 11',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e4q20', 'v4e4q22', '5: Directed graph with four edges and no forbidden vertices');
+SELECT set_eq('v4e4q21', 'v4e4q22', '5: Directed graph with four edges and no forbidden vertices');
+
+PREPARE v4e4q23 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 9 or id = 12 or id = 13',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e4q24 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 9 or id = 12 or id = 13',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e4q23', 'v4e4q24', '5: Directed graph with four edges and no forbidden vertices');
+
+PREPARE v4e4q25 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 9 or id = 12 or id = 13',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], true);
+
+SELECT set_eq('v4e4q23', 'v4e4q25', '5: Directed graph with four edges and no forbidden vertices');
+SELECT set_eq('v4e4q24', 'v4e4q25', '5: Directed graph with four edges and no forbidden vertices');
\ No newline at end of file
diff --git a/src/contraction/test/pgtap/contraction_cycle_undirected.sql b/src/contraction/test/pgtap/contraction_cycle_undirected.sql
new file mode 100644
index 0000000..730a4a3
--- /dev/null
+++ b/src/contraction/test/pgtap/contraction_cycle_undirected.sql
@@ -0,0 +1,265 @@
+\i setup.sql
+
+SELECT plan(36);
+
+SET client_min_messages TO WARNING; 
+
+PREPARE qempty AS
+SELECT * FROM ( VALUES (-1, 'v', -1, '{}', -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost) WHERE 1 != 1 ;
+
+-- TESTING CONTRACTION CYCLE WITH ONLY DEAD END CONTRACTION
+
+-- SINGLE EDGE
+PREPARE v2e1q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v2e1q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v2e1q10', 'v2e1q11', '1: Undirected graph with single edge and no forbidden vertices');
+
+PREPARE v2e1q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v2e1q10', 'v2e1q12', '1: Undirected graph with single edge and no forbidden vertices');
+SELECT set_eq('v2e1q11', 'v2e1q12', '1: Undirected graph with single edge and no forbidden vertices');
+
+-- TWO EDGES
+PREPARE v3e2q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v3e2q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q10', 'v3e2q11', '1: Undirected graph with single edge and no forbidden vertices');
+
+PREPARE v3e2q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q10', 'v3e2q12', '1: Undirected graph with single edge and no forbidden vertices');
+SELECT set_eq('v3e2q11', 'v3e2q12', '1: Undirected graph with single edge and no forbidden vertices');
+
+PREPARE v3e2q13 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v3e2q14 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q13', 'v3e2q14', '4: Undirected graph with two edges and no forbidden vertices');
+
+PREPARE v3e2q15 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q13', 'v3e2q15', '4: Undirected graph with two edges and no forbidden vertices');
+SELECT set_eq('v3e2q14', 'v3e2q15', '4: Undirected graph with two edges and no forbidden vertices');
+
+-- THREE EDGES
+PREPARE v4e3q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e3q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e3q10', 'v4e3q11', '5: Undirected graph with three edges and no forbidden vertices');
+
+PREPARE v4e3q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e3q10', 'v4e3q12', '5: Undirected graph with three edges and no forbidden vertices');
+SELECT set_eq('v4e3q11', 'v4e3q12', '5: Undirected graph with three edges and no forbidden vertices');
+
+PREPARE v4e3q13 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e3q14 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e3q13', 'v4e3q14', '7: Undirected graph with three edges and no forbidden vertices');
+
+PREPARE v4e3q15 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e3q13', 'v4e3q15', '7: Undirected graph with three edges and no forbidden vertices');
+SELECT set_eq('v4e3q14', 'v4e3q15', '7: Undirected graph with three edges and no forbidden vertices');
+
+-- FOUR EDGES
+
+PREPARE v4e4q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6 or id = 8',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e4q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6 or id = 8',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e4q10', 'v4e4q11', '9: Undirected graph with four edges and no forbidden vertices');
+
+PREPARE v4e4q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5 or id = 6 or id = 8',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e4q10', 'v4e4q12', '9: Undirected graph with four edges and no forbidden vertices');
+SELECT set_eq('v4e4q11', 'v4e4q12', '9: Undirected graph with four edges and no forbidden vertices');
+
+PREPARE v6e4q10 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v6e4q11 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1, 1]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v6e4q10', 'v6e4q11', '11: Directed graph with four edges and no forbidden vertices');
+
+PREPARE v6e4q12 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v6e4q10', 'v6e4q12', '11: Directed graph with four edges and no forbidden vertices');
+SELECT set_eq('v6e4q11', 'v6e4q12', '11: Directed graph with four edges and no forbidden vertices');
+
+
+-- TESTING CONTRACTION CYCLE WITH ONLY LINEAR CONTRACTION
+
+-- TWO EDGES
+PREPARE v3e2q20 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v3e2q21 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q20', 'v3e2q21', '1: Undirected graph with two edges and no forbidden vertices');
+
+PREPARE v3e2q22 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q20', 'v3e2q22', '1: Undirected graph with two edges and no forbidden vertices');
+SELECT set_eq('v3e2q21', 'v3e2q22', '1: Undirected graph with two edges and no forbidden vertices');
+
+PREPARE v3e2q23 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v3e2q24 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q23', 'v3e2q24', '1: Undirected graph with two edges and no forbidden vertex');
+
+PREPARE v3e2q25 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 4 or id = 5',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v3e2q23', 'v3e2q25', '1: Undirected graph with two edges and no forbidden vertex');
+SELECT set_eq('v3e2q24', 'v3e2q25', '1: Undirected graph with two edges and no forbidden vertex');
+
+-- THREE EDGES
+
+PREPARE v4e3q20 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e3q21 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e3q20', 'v4e3q21', '5: Undirected graph with three edges and no forbidden vertices');
+
+PREPARE v4e3q22 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e3q20', 'v4e3q22', '5: Undirected graph with three edges and no forbidden vertices');
+SELECT set_eq('v4e3q21', 'v4e3q22', '5: Undirected graph with three edges and no forbidden vertices');
+
+
+-- FOUR EDGES
+PREPARE v4e4q20 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 9 or id = 10 or id = 11',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e4q21 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 9 or id = 10 or id = 11',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e4q20', 'v4e4q21', '5: Undirected graph with four edges and no forbidden vertices');
+
+PREPARE v4e4q22 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 9 or id = 10 or id = 11',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e4q20', 'v4e4q22', '5: Undirected graph with four edges and no forbidden vertices');
+SELECT set_eq('v4e4q21', 'v4e4q22', '5: Undirected graph with four edges and no forbidden vertices');
+
+PREPARE v4e4q23 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 9 or id = 12 or id = 13',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e4q24 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 9 or id = 12 or id = 13',
+    ARRAY[2, 2]::integer[], 1, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e4q23', 'v4e4q24', '5: Directed graph with four edges and no forbidden vertices');
+
+PREPARE v4e4q25 AS
+SELECT * FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 9 or id = 12 or id = 13',
+    ARRAY[2]::integer[], 2, ARRAY[]::integer[], false);
+
+SELECT set_eq('v4e4q23', 'v4e4q25', '5: Directed graph with four edges and no forbidden vertices');
+SELECT set_eq('v4e4q24', 'v4e4q25', '5: Directed graph with four edges and no forbidden vertices');
+
+
diff --git a/src/contraction/test/pgtap/directed_dead_end.sql b/src/contraction/test/pgtap/directed_dead_end.sql
new file mode 100644
index 0000000..a06416c
--- /dev/null
+++ b/src/contraction/test/pgtap/directed_dead_end.sql
@@ -0,0 +1,440 @@
+\i setup.sql
+
+SELECT plan(39);
+
+SET client_min_messages TO WARNING;
+-- TESTING ONE CYCLE OF DEAD END CONTRACTION FOR A DIRECTED GRAPH 
+
+PREPARE qempty AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  
+FROM ( VALUES (-1, 'v', -1, ARRAY[]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost )
+WHERE 1 != 1;
+
+-- SINGLE EDGE
+-- no forbidden vertices
+PREPARE v2e1q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost 
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v2e1q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  
+FROM ( VALUES (1, 'v', 2, ARRAY[1]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost ) ;
+
+SELECT set_eq('v2e1q10', 'v2e1q11', '1: Directed graph with single edge and no forbidden vertices');
+
+-- 1 is forbidden vertex
+
+PREPARE v2e1q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost 
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 1, ARRAY[1]::INTEGER[], true);
+
+PREPARE v2e1q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  
+FROM ( VALUES (1, 'v', 1, ARRAY[2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost ) ;
+
+
+SELECT set_eq('v2e1q20', 'v2e1q21', '1: Directed graph with single edge and 1 as forbidden vertex');
+
+
+-- TWO EDGES
+-- no forbidden vertices
+PREPARE v3e2q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost 
+FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 OR id = 3',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v3e2q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  
+FROM ( VALUES (1, 'v', 4, ARRAY[2, 3]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost ) ;
+
+SELECT set_eq('v3e2q10', 'v3e2q11', '1: Directed graph two edges and no forbidden vertices');
+
+-- 3 is forbidden
+PREPARE v3e2q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 OR id = 3',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3]::integer[], true);
+
+PREPARE v3e2q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  
+FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost ) ;
+
+SELECT set_eq('v3e2q20', 'v3e2q21', '2: Directed graph with two edges and vertex 3 as forbidden vertex');
+
+-- 2 is forbidden
+PREPARE v3e2q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 OR id = 3',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2]::integer[], true);
+
+SELECT set_eq('v3e2q30', 'qempty', '2: Directed graph with two edges and vertex 2 as forbidden vertex');
+
+-- no forbidden vertices
+PREPARE v3e2q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 11 or id = 12',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v3e2q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 6, ARRAY[11]::bigint[], -1, -1, -1), (2, 'v', 10, ARRAY[11]::integer[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+SELECT set_eq('v3e2q40', 'v3e2q41', '3: Directed graph with two edges and no forbidden vertices');
+
+-- 11 is forbidden
+PREPARE v3e2q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 11 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[11]::integer[], true);
+
+SELECT set_eq('v3e2q50', 'qempty', '3: Directed graph with two edges and vertex 11 as forbidden vertex');
+
+-- no forbidden
+PREPARE v3e2q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 12',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v3e2q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1), (2, 'v', 10, ARRAY[11]::integer[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v3e2q60', 'v3e2q61', '4: Directed graph with two edges and no forbidden vertices');
+
+-- 2 is forbidden
+PREPARE v3e2q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2]::integer[], true);
+
+PREPARE v3e2q71 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 10, ARRAY[11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v3e2q70', 'v3e2q71', '4: Directed graph with two edges and 2 is forbidden vertex');
+
+-- 11 is forbidden
+PREPARE v3e2q80 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[11]::integer[], true);
+
+PREPARE v3e2q81 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v3e2q80', 'v3e2q81', '4: Directed graph with two edges and 11 is forbidden vertex');
+
+
+-- THREE EDGES
+-- no forbidden vertices
+PREPARE v4e3q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 5 or id = 11 or id = 13',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e3q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[6, 11, 12]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e3q10', 'v4e3q11', '5: Directed graph with three edges and no forbidden vertices');
+
+-- 3 is forbidden
+PREPARE v4e3q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 5 or id = 11 or id = 13',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3]::integer[], true);
+
+PREPARE v4e3q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[6, 11, 12]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e3q20', 'v4e3q21', '5: Directed graph with three edges and 3 is forbidden vertex');
+
+-- 6 is forbidden
+PREPARE v4e3q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 5 or id = 11 or id = 13',
+    ARRAY[1]::INTEGER[], 1, ARRAY[6]::integer[], true);
+
+PREPARE v4e3q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 6, ARRAY[11, 12]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e3q30', 'v4e3q31', '5: Directed graph with three edges and 6 is forbidden vertex');
+
+-- 11 is forbidden
+PREPARE v4e3q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 5 or id = 11 or id = 13',
+    ARRAY[1]::INTEGER[], 1, ARRAY[11]::integer[], true);
+
+PREPARE v4e3q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 11, ARRAY[12]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+SELECT set_eq('v4e3q40', 'v4e3q41', '5: Directed graph with three edges and 11 is forbidden vertex');
+
+-- 12 is forbidden
+PREPARE v4e3q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 5 or id = 11 or id = 13',
+    ARRAY[1]::INTEGER[], 1, ARRAY[12]::integer[], true);
+
+SELECT set_eq('v4e3q50', 'qempty', '5: Directed graph with three edges and 12 is forbidden vertex');
+
+-- no forbidden vertices
+PREPARE v5e3q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 12',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v5e3q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 4, ARRAY[2, 3]::bigint[], -1, -1, -1), (2, 'v', 10, ARRAY[11]::integer[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v5e3q10', 'v5e3q11', '7: Directed graph with three edges and no forbidden vertices');
+
+-- 11 is forbidden
+PREPARE v5e3q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[11]::integer[], true);
+
+PREPARE v5e3q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 4, ARRAY[2, 3]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v5e3q20', 'v5e3q21', '7: Directed graph with three edges and 11 is forbidden vertex');
+
+-- 2 is forbidden
+PREPARE v5e3q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2]::integer[], true);
+
+PREPARE v5e3q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 10, ARRAY[11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v5e3q30', 'v5e3q31', '7: Directed graph with three edges and 2 is forbidden vertex');
+
+-- 3 is forbidden
+PREPARE v5e3q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3]::integer[], true);
+
+PREPARE v5e3q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1), (2, 'v', 10, ARRAY[11]::integer[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v5e3q40', 'v5e3q41', '7: Directed graph with three edges and 3 is forbidden vertex');
+
+-- 2 and 11 are forbidden
+PREPARE v5e3q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2, 11]::integer[], true);
+
+SELECT set_eq('v5e3q50', 'qempty', '7: Directed graph with three edges and 2 and 11 are forbidden vertices');
+
+-- 3 and 11 are forbidden
+PREPARE v5e3q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 12',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3, 11]::integer[], true);
+PREPARE v5e3q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1)) AS t(seq, type, id, contracted_vertices, source, target, cost );
+SELECT set_eq('v5e3q60', 'v5e3q61', '7: Directed graph with three edges and 3 and 11 are forbidden vertices');
+
+-- no forbidden vertices
+PREPARE v6e3q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 3 or id = 6',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v6e3q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1]::bigint[], -1, -1, -1), (2, 'v', 4, ARRAY[3]::integer[], -1, -1, -1), (3, 'v', 8, ARRAY[7]::integer[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v6e3q10', 'v6e3q11', '8: Directed graph with three edges and no forbidden vertices');
+
+-- 1 is forbidden
+PREPARE v6e3q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 3 or id = 6',
+    ARRAY[1]::INTEGER[], 1, ARRAY[1]::integer[], true);
+
+PREPARE v6e3q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 1, ARRAY[2]::bigint[], -1, -1, -1), (2, 'v', 4, ARRAY[3]::integer[], -1, -1, -1), (3, 'v', 8, ARRAY[7]::integer[], -1, -1, -1)  ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v6e3q20', 'v6e3q21', '8: Directed graph with three edges and 1 is forbidden vertex');
+
+-- 3 is forbidden
+PREPARE v6e3q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 3 or id = 6',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3]::integer[], true);
+
+PREPARE v6e3q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1]::bigint[], -1, -1, -1), (2, 'v', 8, ARRAY[7]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v6e3q30', 'v6e3q31', '8: Directed graph with three edges and 3 is forbidden vertex');
+
+-- 7 is forbidden
+PREPARE v6e3q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 3 or id = 6',
+    ARRAY[1]::INTEGER[], 1, ARRAY[7]::integer[], true);
+
+PREPARE v6e3q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1]::bigint[], -1, -1, -1), (2, 'v', 4, ARRAY[3]::integer[], -1, -1, -1), (3, 'v', 7, ARRAY[8]::integer[], -1, -1, -1)  ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v6e3q40', 'v6e3q41', '8: Directed graph with three edges and 7 is forbidden vertex');
+
+-- 1 and 3 are forbidden
+PREPARE v6e3q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 3 or id = 6',
+    ARRAY[1]::INTEGER[], 1, ARRAY[1, 3]::integer[], true);
+
+PREPARE v6e3q51 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 1, ARRAY[2]::bigint[],  -1, -1, -1), (2, 'v', 8, ARRAY[7]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v6e3q50', 'v6e3q51', '8: Directed graph with three edges and 1 and 3 are forbidden vertices');
+
+-- 3 and 7 are forbidden
+PREPARE v6e3q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 3 or id = 6',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3, 7]::integer[], true);
+
+PREPARE v6e3q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1]::bigint[], -1, -1, -1), (2, 'v', 7, ARRAY[8]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v6e3q60', 'v6e3q61', '8: Directed graph with three edges and 3 and 7 are forbidden vertices');
+
+-- 1 and 7 are forbidden
+PREPARE v6e3q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 3 or id = 6',
+    ARRAY[1]::INTEGER[], 1, ARRAY[1, 7]::integer[], true);
+
+PREPARE v6e3q71 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 1, ARRAY[2]::bigint[], -1, -1, -1), (2, 'v', 4, ARRAY[3]::bigint[], -1, -1, -1), (3, 'v', 7, ARRAY[8]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v6e3q70', 'v6e3q71', '8: Directed graph with three edges and 1 and 7 are forbidden vertices');
+
+
+-- FOUR EDGES
+-- no forbidden vertices
+PREPARE v4e4q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], true);
+
+PREPARE v4e4q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 4, ARRAY[2, 3, 6, 11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e4q10', 'v4e4q11', '9: Directed graph with four edges and no forbidden vertices');
+
+-- 2 is forbidden
+PREPARE v4e4q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2]::integer[], true);
+
+PREPARE v4e4q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[6, 11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e4q20', 'v4e4q21', '9: Directed graph with four edges and 2 is forbidden vertex');
+
+-- 3 is forbidden
+PREPARE v4e4q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3]::integer[], true);
+
+PREPARE v4e4q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2, 6, 11]::bigint[], -1, -1, -1)) AS t(seq, type, id, contracted_vertices, source, target, cost );
+SELECT set_eq('v4e4q30', 'v4e4q31', '9: Directed graph with four edges and 3 is forbidden vertex');
+
+-- 6 is forbidden
+PREPARE v4e4q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[6]::integer[], true);
+
+PREPARE v4e4q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1), (2, 'v', 6, ARRAY[11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+SELECT set_eq('v4e4q40', 'v4e4q41', '9: Directed graph with four edges and 6 is forbidden vertex');
+
+-- 11 is forbidden
+PREPARE v4e4q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[11]::integer[], true);
+
+PREPARE v4e4q51 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+SELECT set_eq('v4e4q50', 'v4e4q51', '9: Directed graph with four edges and 11 is forbidden vertex');
+
+
+-- 2,3 are forbidden
+PREPARE v4e4q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2, 3]::integer[], true);
+
+PREPARE v4e4q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[6, 11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e4q60', 'v4e4q61', '9: Directed graph with four edges and 2 and 3 is forbidden vertex');
+
+
+-- 2,6 are forbidden
+PREPARE v4e4q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2, 6]::integer[], true);
+
+PREPARE v4e4q71 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 6, ARRAY[11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e4q70', 'v4e4q71', '9: Directed graph with four edges and 2 and 6 forbidden vertex');
+
+-- 2,11 are forbidden
+PREPARE v4e4q80 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[2, 11]::integer[], true);
+
+SELECT set_eq('v4e4q80', 'qempty', '9: Directed graph with four edges and 2 and 11 forbidden vertex');
+
+-- 3,6 are forbidden
+PREPARE v4e4q90 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3, 6]::integer[], true);
+
+PREPARE v4e4q91 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1), (2, 'v', 6, ARRAY[11]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e4q90', 'v4e4q91', '9: Directed graph with four edges and 3 and 6 forbidden vertex');
+
+-- 3,11 are forbidden
+PREPARE v4e4q100 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[3, 11]::integer[], true);
+
+PREPARE v4e4q101 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e4q100', 'v4e4q101', '9: Directed graph with four edges and 3 and 11 forbidden vertex');
+
+-- 6,11 are forbidden
+PREPARE v4e4q110 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5 or id = 11',
+    ARRAY[1]::INTEGER[], 1, ARRAY[6, 11]::integer[], true);
+
+PREPARE v4e4q111 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost );
+
+SELECT set_eq('v4e4q110', 'v4e4q111', '9: Directed graph with four edges and 6 and 11 forbidden vertex');
+
+
+SELECT finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/src/contraction/test/pgtap/directed_linear.sql b/src/contraction/test/pgtap/directed_linear.sql
new file mode 100644
index 0000000..2d7c9c8
--- /dev/null
+++ b/src/contraction/test/pgtap/directed_linear.sql
@@ -0,0 +1,178 @@
+\i setup.sql
+
+SELECT plan(15);
+
+SET client_min_messages TO WARNING;
+-- TESTING ONE CYCLE OF DEAD END CONTRACTION FOR AN UNDIRECTED GRAPH 
+
+PREPARE qempty AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (-1, 'e', -1, ARRAY[]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost) WHERE 1 != 1 ;
+
+-- TWO EDGES
+-- no forbidden vertices
+PREPARE v3e2q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::integer[], 1, ARRAY[]::INTEGER[], true);
+
+PREPARE v3e2q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[2]::bigint[], 3, 1, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+SELECT set_eq('v3e2q10', 'v3e2q11', '1: Directed graph with two edges and no forbidden vertices');
+
+-- 2 is forbidden
+PREPARE v3e2q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::INTEGER[], 1, ARRAY[2]::integer[], true);
+
+SELECT set_eq('v3e2q20', 'qempty', '1: Directed graph with two edges and 2 is forbidden vertex');
+
+
+-- no forbidden vertices
+PREPARE v3e2q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 11 or id = 12',
+    ARRAY[2]::integer[], 1, ARRAY[]::INTEGER[], true);
+
+SELECT set_eq('v3e2q30', 'qempty', '1: Directed graph with two edges and no forbidden vertex');
+
+-- THREE EDGES
+-- no forbidden vertices
+PREPARE v4e3q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 3 or id = 5 or id = 11',
+    ARRAY[2]::integer[], 1, ARRAY[]::INTEGER[], true);
+
+PREPARE v4e3q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[3]::bigint[], 4, 6, 2), (2, 'e', -2, ARRAY[3, 6]::bigint[], 4, 11, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q10', 'v4e3q11', '5: Directed graph with three edges and no forbidden vertices');
+
+-- 3 is forbidden
+PREPARE v4e3q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 3 or id = 5 or id = 11',
+    ARRAY[2]::INTEGER[], 1, ARRAY[3]::integer[], true);
+
+PREPARE v4e3q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 3, 11, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q20', 'v4e3q21', '5: Directed graph with three edges and 3 is forbidden vertices');
+
+-- 6 is forbidden
+PREPARE v4e3q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 3 or id = 5 or id = 11',
+    ARRAY[2]::INTEGER[], 1, ARRAY[6]::integer[], true);
+
+PREPARE v4e3q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[3]::bigint[], 4, 6, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q30', 'v4e3q31', '5: Directed graph with three edges and 6 is forbidden vertices');
+
+-- 3, 6 are forbidden
+PREPARE v4e3q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 3 or id = 5 or id = 11',
+    ARRAY[2]::INTEGER[], 1, ARRAY[3, 6]::integer[], true);
+
+SELECT set_eq('v4e3q40', 'qempty', '5: Directed graph with three edges and 3, 6 are forbidden vertices');
+
+
+
+
+-- FOUR EDGES
+-- no forbidden vertices
+PREPARE v4e4q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[]::INTEGER[], true);
+
+PREPARE v4e4q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[6, 9]::bigint[], 12, 11, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q10', 'v4e4q11', '5: Directed graph with four edges and no forbidden vertices');
+
+-- 6 is forbidden
+PREPARE v4e4q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::INTEGER[], 1, ARRAY[6]::integer[], true);
+
+PREPARE v4e4q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[9]::bigint[], 6, 12, 2), (2, 'e', -2, ARRAY[9]::bigint[], 12, 6, 2), (3, 'e', -3, ARRAY[11]::bigint[], 6, 12, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q20', 'v4e4q21', '5: Directed graph with four edges and 6 is forbidden vertices');
+
+-- 9 is forbidden
+PREPARE v4e4q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::INTEGER[], 1, ARRAY[9]::integer[], true);
+
+PREPARE v4e4q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[6, 11]::bigint[], 9, 12, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q30', 'v4e4q31', '5: Directed graph with four edges and 9 is forbidden vertices');
+
+-- 11 is forbidden
+PREPARE v4e4q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::INTEGER[], 1, ARRAY[11]::integer[], true);
+
+PREPARE v4e4q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[6, 9]::bigint[], 12, 11, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q40', 'v4e4q41', '5: Directed graph with four edges and 11 is forbidden vertices');
+
+-- 6, 9 are forbidden
+PREPARE v4e4q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::INTEGER[], 1, ARRAY[6, 9]::integer[], true);
+
+PREPARE v4e4q51 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[11]::bigint[], 6, 12, 2), (2, 'e', -2, ARRAY[11, 12]::bigint[], 6, 9, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q50', 'v4e4q51', '5: Directed graph with four edges and 6, 9 are forbidden vertices');
+
+
+-- 9, 11 are forbidden
+PREPARE v4e4q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::INTEGER[], 1, ARRAY[9, 11]::integer[], true);
+
+PREPARE v4e4q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[12]::bigint[], 11, 9, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q60', 'v4e4q61', '5: Directed graph with four edges and 9, 11 are forbidden vertices');
+
+-- 6, 11 are forbidden
+PREPARE v4e4q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::INTEGER[], 1, ARRAY[6, 11]::integer[], true);
+
+PREPARE v4e4q71 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[9]::bigint[], 6, 12, 2), (2, 'e', -2, ARRAY[9]::bigint[], 12, 6, 2), (3, 'e', -3, ARRAY[9, 12]::bigint[], 11, 6, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q70', 'v4e4q71', '5: Directed graph with four edges and 6, 11 are forbidden vertices');
+
+-- 6, 9, 11 are forbidden
+PREPARE v4e4q80 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::INTEGER[], 1, ARRAY[6, 9, 11]::integer[], true);
+
+PREPARE v4e4q81 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'e', -1, ARRAY[12]::bigint[], 11, 9, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q80', 'v4e4q81', '5: Directed graph with four edges and 1, 2, 9 are vertices');
+
+
+
+
+SELECT finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/src/contraction/test/pgtap/undirected_dead_end.sql b/src/contraction/test/pgtap/undirected_dead_end.sql
new file mode 100644
index 0000000..1d869dc
--- /dev/null
+++ b/src/contraction/test/pgtap/undirected_dead_end.sql
@@ -0,0 +1,301 @@
+\i setup.sql
+
+SELECT plan(26);
+
+SET client_min_messages TO WARNING;
+-- TESTING ONE CYCLE OF DEAD END CONTRACTION FOR AN UNDIRECTED GRAPH 
+
+PREPARE qempty AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost 
+FROM ( VALUES (-1, 'v', -1, ARRAY[]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost)
+WHERE 1 != 1;
+
+-- SINGLE EDGE
+-- no forbidden vertices
+PREPARE v2e1q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v2e1q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v2e1q10', 'v2e1q11', '1: Undirected graph with single edge and no forbidden vertices');
+
+
+-- 1 is forbidden vertex
+PREPARE v2e1q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1',
+    ARRAY[1]::integer[], 1, ARRAY[1]::integer[], false);
+
+PREPARE v2e1q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 1, ARRAY[2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+SELECT set_eq('v2e1q20', 'v2e1q21', '1: Undirected graph with single edge and 1 as forbidden vertex');
+
+-- TWO EDGES
+-- no forbidden vertices
+PREPARE v3e2q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v3e2q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[1, 2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v3e2q10', 'v3e2q11', '1: Undirected graph with single edge and no forbidden vertices');
+
+-- 1 is forbidden vertex
+PREPARE v3e2q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[1]::integer[], false);
+PREPARE v3e2q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 1, ARRAY[2, 3]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v3e2q20', 'v3e2q21', '1: Undirected graph with two edges and 1 as forbidden vertex');
+
+-- 2 is forbidden vertex
+PREPARE v3e2q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[2]::integer[], false);
+PREPARE v3e2q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1, 3]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v3e2q30', 'v3e2q31', '1: Undirected graph with two edges and 2 as forbidden vertex');
+
+-- 3 is forbidden vertex
+PREPARE v3e2q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[3]::integer[], false);
+PREPARE v3e2q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[1, 2]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v3e2q40', 'v3e2q41', '1: Undirected graph with two edges and 3 as forbidden vertex');
+
+-- 1,2 are forbidden
+PREPARE v3e2q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[1, 2]::integer[], false);
+PREPARE v3e2q51 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[3]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v3e2q50', 'v3e2q51', '1: Undirected graph with two edges and 1, 2 are forbidden vertices');
+
+-- 3,2 are forbidden
+PREPARE v3e2q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[2, 3]::integer[], false);
+PREPARE v3e2q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v3e2q60', 'v3e2q61', '1: Undirected graph with two edges and 3, 2 are forbidden vertices');
+
+-- 1,3 are forbidden
+PREPARE v3e2q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[1]::integer[], 1, ARRAY[1, 3]::integer[], false);
+
+SELECT set_eq('v3e2q70', 'qempty', '1: Undirected graph with two edges and 3, 1 are forbidden vertices');
+
+-- THREE EDGES
+-- no forbidden vertices
+PREPARE v4e3q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e3q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 4, ARRAY[1, 2, 3]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q10', 'v4e3q11', '5: Undirected graph with three edges and no forbidden vertices');
+
+-- 1 is forbidden
+PREPARE v4e3q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 1, ARRAY[1]::integer[], false);
+
+PREPARE v4e3q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 1, ARRAY[2, 3, 4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q20', 'v4e3q21', '5: Undirected graph with three edges and 1 as forbidden vertex');
+
+-- 2 is forbidden
+PREPARE v4e3q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 1, ARRAY[2]::integer[], false);
+
+PREPARE v4e3q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1, 3, 4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q30', 'v4e3q31', '5: Undirected graph with three edges and 2 as forbidden vertex');
+
+-- 3 is forbidden
+PREPARE v4e3q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[1]::integer[], 1, ARRAY[3]::integer[], false);
+
+PREPARE v4e3q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[1, 2, 4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q40', 'v4e3q41', '5: Undirected graph with three edges and 3 as forbidden vertex');
+
+-- no forbidden vertices
+PREPARE v4e3q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e3q51 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 6, ARRAY[2, 3, 4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q50', 'v4e3q51', '7: Undirected graph with three edges and no forbidden vertices');
+
+-- 2 is forbidden
+PREPARE v4e3q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5',
+    ARRAY[1]::integer[], 1, ARRAY[2]::integer[], false);
+
+PREPARE v4e3q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[3, 4, 6]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q60', 'v4e3q61', '7: Undirected graph with three edges and 2 is forbidden vertex');
+
+-- 6 is forbidden
+PREPARE v4e3q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5',
+    ARRAY[1]::integer[], 1, ARRAY[6]::integer[], false);
+
+PREPARE v4e3q71 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 6, ARRAY[2, 3, 4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q70', 'v4e3q71', '7: Undirected graph with three edges and 6 is forbidden vertex');
+
+-- 4 is forbidden
+PREPARE v4e3q80 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 2 or id = 3 or id = 5',
+    ARRAY[1]::integer[], 1, ARRAY[4]::integer[], false);
+
+PREPARE v4e3q81 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 4, ARRAY[2, 3, 6]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q80', 'v4e3q81', '7: Undirected graph with three edges and 4 is forbidden vertex');
+
+
+-- FOUR EDGES
+
+-- no forbidden vertices
+PREPARE v5e4q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v5e4q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 5, ARRAY[1, 2, 3, 4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q10', 'v5e4q11', '11: Directed graph with four edges and no forbidden vertices');
+
+
+-- 4 is forbidden
+PREPARE v5e4q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[4]::integer[], false);
+
+PREPARE v5e4q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 4, ARRAY[1, 2, 3, 5]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q20', 'v5e4q21', '8: Directed graph with four edges and 5 is forbidden vertex');
+
+-- 1 is forbidden
+PREPARE v5e4q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[1]::integer[], false);
+
+PREPARE v5e4q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 1, ARRAY[2, 3, 4, 5]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q30', 'v5e4q31', '8: Directed graph with four edges and 1 is forbidden vertex');
+
+-- 2 is forbidden
+PREPARE v5e4q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[2]::integer[], false);
+
+PREPARE v5e4q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1, 3, 4, 5]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q40', 'v5e4q41', '8: Directed graph with four edges and 2 is forbidden vertex');
+
+-- 3 is forbidden
+PREPARE v5e4q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[3]::integer[], false);
+
+PREPARE v5e4q51 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 3, ARRAY[1, 2, 4, 5]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q50', 'v5e4q51', '8: Directed graph with four edges and 3 is forbidden vertex');
+
+-- 1, 2 are forbidden
+PREPARE v5e4q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[1, 2]::integer[], false);
+
+PREPARE v5e4q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[3, 4, 5]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q60', 'v5e4q61', '8: Directed graph with four edges and 1, 2 are forbidden vertices');
+
+-- 2, 3 are forbidden
+PREPARE v5e4q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[2, 3]::integer[], false);
+
+PREPARE v5e4q71 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[1, 5]::bigint[], -1, -1, -1), (2, 'v', 3, ARRAY[4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q70', 'v5e4q71', '8: Directed graph with four edges and 2, 3 are forbidden vertices');
+
+
+-- 1, 3 are forbidden
+PREPARE v5e4q80 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[1, 3]::integer[], false);
+
+PREPARE v5e4q81 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[5]::bigint[], -1, -1, -1), (2, 'v', 3, ARRAY[4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q80', 'v5e4q81', '8: Directed graph with four edges and 1, 3 are forbidden vertices');
+
+-- 1, 5 are forbidden
+PREPARE v5e4q90 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3 or id = 4',
+    ARRAY[1]::integer[], 1, ARRAY[1, 5]::integer[], false);
+
+PREPARE v5e4q91 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost  FROM ( VALUES (1, 'v', 2, ARRAY[3, 4]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v5e4q90', 'v5e4q91', '8: Directed graph with four edges and 1, 5 are forbidden vertices');
+
+
+SELECT finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/src/contraction/test/pgtap/undirected_linear.sql b/src/contraction/test/pgtap/undirected_linear.sql
new file mode 100644
index 0000000..65f709b
--- /dev/null
+++ b/src/contraction/test/pgtap/undirected_linear.sql
@@ -0,0 +1,185 @@
+\i setup.sql
+
+SELECT plan(16);
+
+SET client_min_messages TO WARNING;
+-- TESTING ONE CYCLE OF DEAD END CONTRACTION FOR AN UNDIRECTED GRAPH 
+
+PREPARE qempty AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (-1, 'e', -1, ARRAY[]::bigint[], -1, -1, -1) ) AS t(seq, type, id, contracted_vertices, source, target, cost) WHERE 1 != 1 ;
+
+-- TWO EDGES
+-- no forbidden vertices
+PREPARE v3e2q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+PREPARE v3e2q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[2]::bigint[], 1, 3, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+SELECT set_eq('v3e2q10', 'v3e2q11', '1: Undirected graph with two edges and no forbidden vertices');
+
+-- 2 is forbidden
+PREPARE v3e2q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2',
+    ARRAY[2]::integer[], 1, ARRAY[2]::integer[], false);
+
+SELECT set_eq('v3e2q20', 'qempty', '1: Undirected graph with two edges and 2 is forbidden vertex');
+
+-- no forbidden vertices
+PREPARE v3e2q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 11 or id = 12',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+PREPARE v3e2q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[11]::bigint[], 6, 10, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v3e2q30', 'v3e2q31', '1: Undirected graph with two edges and no forbidden vertex');
+
+
+-- 11 is forbidden
+PREPARE v3e2q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 11 or id = 12',
+    ARRAY[2]::integer[], 1, ARRAY[11]::integer[], false);
+
+SELECT set_eq('v3e2q40', 'qempty', '1: Undirected graph with two edges and 11 is forbidden vertex');
+
+
+-- THREE EDGES
+-- no forbidden vertices
+PREPARE v4e3q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e3q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[2]::bigint[], 1, 3, 2), (2, 'e', -2, ARRAY[2, 3]::bigint[], 1, 4, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q10', 'v4e3q11', '5: Undirected graph with three edges and no forbidden vertices');
+
+-- 2 is forbidden
+PREPARE v4e3q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 1, ARRAY[2]::integer[], false);
+
+PREPARE v4e3q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[3]::bigint[], 2, 4, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q20', 'v4e3q21', '5: Undirected graph with three edges and 2 is forbidden vertices');
+
+
+-- 3 is forbidden
+PREPARE v4e3q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 1, ARRAY[3]::integer[], false);
+
+PREPARE v4e3q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[2]::bigint[], 1, 3, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e3q30', 'v4e3q31', '5: Undirected graph with three edges and 3 is forbidden vertices');
+
+-- 2, 3 are forbidden
+PREPARE v4e3q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 1 or id = 2 or id = 3',
+    ARRAY[2]::integer[], 1, ARRAY[2, 3]::integer[], false);
+
+SELECT set_eq('v4e3q40', 'qempty', '5: Undirected graph with three edges and 3 is forbidden vertices');
+
+-- FOUR EDGES
+-- no forbidden vertices
+PREPARE v4e4q10 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[]::integer[], false);
+
+PREPARE v4e4q11 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[6, 9]::bigint[], 11, 12, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q10', 'v4e4q11', '5: Undirected graph with four edges and no forbidden vertices');
+
+
+-- 6 is forbidden
+PREPARE v4e4q20 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[6]::integer[], false);
+
+PREPARE v4e4q21 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[9]::bigint[], 6, 12, 2), (2, 'e', -2, ARRAY[11]::bigint[], 6, 12, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q20', 'v4e4q21', '5: Undirected graph with four edges and 6 is forbidden vertices');
+
+-- 9 is forbidden
+PREPARE v4e4q30 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[9]::integer[], false);
+
+PREPARE v4e4q31 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[6, 11]::bigint[], 9, 12, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q30', 'v4e4q31', '5: Undirected graph with four edges and 9 is forbidden vertices');
+
+-- 11 is forbidden
+PREPARE v4e4q40 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[11]::integer[], false);
+
+PREPARE v4e4q41 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[6, 9]::bigint[], 11, 12, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q40', 'v4e4q41', '5: Undirected graph with four edges and 11 is forbidden vertices');
+
+-- 6, 9 are forbidden
+PREPARE v4e4q50 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[6, 9]::integer[], false);
+
+PREPARE v4e4q51 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[11]::bigint[], 6, 12, 2), (2, 'e', -2, ARRAY[11, 12]::bigint[], 6, 9, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q50', 'v4e4q51', '5: Undirected graph with four edges and 6, 9 are vertices');
+
+-- 9, 11 are forbidden
+PREPARE v4e4q60 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[9, 11]::integer[], false);
+
+PREPARE v4e4q61 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[6]::bigint[], 9, 11, 2), (2, 'e', -2, ARRAY[12]::bigint[], 9, 11, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q60', 'v4e4q61', '5: Undirected graph with four edges and 9, 11 are vertices');
+
+-- 6, 11 are forbidden
+PREPARE v4e4q70 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[6, 11]::integer[], false);
+
+PREPARE v4e4q71 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[9]::bigint[], 6, 12, 2), (2, 'e', -2, ARRAY[9, 12]::bigint[], 6, 11, 3) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q70', 'v4e4q71', '5: Undirected graph with four edges and 6, 11 are vertices');
+
+
+-- 6, 9, 11 are forbidden
+PREPARE v4e4q80 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM pgr_contractgraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table WHERE id = 9 or id = 11 or id = 13 or id = 15',
+    ARRAY[2]::integer[], 1, ARRAY[6, 9, 11]::integer[], false);
+
+PREPARE v4e4q81 AS
+SELECT seq, type, id, unnest(contracted_vertices) AS contracted_vertices, source, target, cost FROM ( VALUES (1, 'e', -1, ARRAY[12]::bigint[], 9, 11, 2) ) AS t(seq, type, id, contracted_vertices, source, target, cost);
+
+SELECT set_eq('v4e4q80', 'v4e4q81', '5: Undirected graph with four edges and 6, 9, 11 are vertices');
+
+
+SELECT finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/src/contraction/test/proof_of_concept.result b/src/contraction/test/proof_of_concept.result
new file mode 100644
index 0000000..480b539
--- /dev/null
+++ b/src/contraction/test/proof_of_concept.result
@@ -0,0 +1,47 @@
+Adding an additional column to store if its part of the contracted graph
+Adding a new edge joining vertices 3 and 5 with cost=2 to the edge table
+Adding a new edge joining vertices 3 and 9 with cost=2 to the edge table
+Adding a new edge joining vertices 5 and 11 with cost=2 to the edge table
+Adding a new edge joining vertices 9 and 11 with cost=2 to the edge table
+Case 1: Both source and target belong to the contracted graph.
+We are going to route from 3 to 11
+Since 3 and 11 both are in the contracted graph we need not add any vertices.
+1|1|3|5|1|0
+2|2|6|11|1|1
+3|3|11|-1|0|2
+Case 2: source belongs to a contracted graph, while target belongs to a vertex subgraph.
+We are going to route from 3 to 7
+Since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 11, 15, 17)
+1|1|3|19|2|0
+2|2|5|7|1|2
+3|3|8|6|1|3
+4|4|7|-1|0|4
+Case 3: source belongs to a contracted graph, while target belongs to a edge subgraph.
+We are going to route from 3 to 13
+Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17)
+1|1|3|5|1|0
+2|2|6|11|1|1
+3|3|11|12|1|2
+4|4|10|14|1|3
+5|5|13|-1|0|4
+Case 4: source belongs to a vertex subgraph, while target belongs to a edge subgraph.
+We are going to route from 7 to 13
+Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, and since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex sets (3, 5, 6, 7, 8, 9, 11, 15, 17)
+1|1|7|6|1|0
+2|2|8|7|1|1
+3|3|5|10|1|2
+4|4|10|14|1|3
+5|5|13|-1|0|4
+Case 5: The path contains a shortcut. 
+We are going to route from 3 to 9
+Since 3 and 9 both are in the contracted graph we need not add any vertices.
+1|1|3|20|2|0
+2|2|9|-1|0|2
+19|3|5|2|2|t
+20|3|9|2|2|t
+21|5|11|2|2|t
+22|9|11|2|2|t
+This implies that it is a shortcut and should be expanded
+1|1|3|5|1|0
+2|2|6|9|1|1
+3|3|9|-1|0|2
\ No newline at end of file
diff --git a/src/contraction/test/proof_of_concept.test.sql b/src/contraction/test/proof_of_concept.test.sql
new file mode 100644
index 0000000..377e306
--- /dev/null
+++ b/src/contraction/test/proof_of_concept.test.sql
@@ -0,0 +1,90 @@
+BEGIN;
+
+\echo Adding an additional column to store if its part of the contracted graph
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false;
+
+\echo Adding a new edge joining vertices 3 and 5 with cost=2 to the edge table
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted) 
+VALUES (19, 3, 5, 2, 2, true);
+
+\echo Adding a new edge joining vertices 3 and 9 with cost=2 to the edge table
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted) 
+VALUES (20, 3, 9, 2, 2, true);
+
+\echo Adding a new edge joining vertices 5 and 11 with cost=2 to the edge table
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted) 
+VALUES (21, 5, 11, 2, 2, true);
+
+\echo Adding a new edge joining vertices 9 and 11 with cost=2 to the edge table
+INSERT INTO edge_table(id, source, target, cost, reverse_cost, is_contracted) 
+VALUES (22, 9, 11, 2, 2, true);
+
+
+
+\echo Case 1: Both source and target belong to the contracted graph.
+\echo We are going to route from 3 to 11
+\echo  Since 3 and 11 both are in the contracted graph we need not add any vertices. 
+SELECT * FROM 
+pgr_dijkstra($$
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (3, 5, 6, 9, 11, 15, 17)
+        AND target IN (3, 5, 6, 9, 11, 15, 17)$$,
+    3, 11, false);
+
+
+\echo Case 2: source belongs to a contracted graph, while target belongs to a vertex subgraph.
+\echo We are going to route from 3 to 7
+\echo  Since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 11, 15, 17)
+SELECT * FROM pgr_dijkstra($$
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (3, 5, 6, 9, 11, 15, 17,   7, 8)
+        AND target IN (3, 5, 6, 9, 11, 15, 17,   7, 8)$$,
+    3, 7, false);
+
+\echo Case 3: source belongs to a contracted graph, while target belongs to a edge subgraph. 
+\echo We are going to route from 3 to 13
+\echo  Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17)
+SELECT * FROM pgr_dijkstra($$
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table
+    WHERE source IN (3, 5, 6, 9, 11, 15, 17,    10, 13) 
+        AND target IN (3, 5, 6, 9, 11, 15, 17,    10, 13)$$,
+    3, 13, false);
+
+\echo Case 4: source belongs to a vertex subgraph, while target belongs to a edge subgraph. 
+\echo We are going to route from 7 to 13
+\echo Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, and since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex sets (3, 5, 6, 7, 8, 9, 11, 15, 17)
+SELECT * FROM pgr_dijkstra($$
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table 
+    WHERE source IN (3, 5, 6, 9, 11, 15, 17,    7, 8,   10, 13) 
+        AND target IN (3, 5, 6, 9, 11, 15, 17,   7, 8,   10, 13)$$,
+    7, 13, false);
+
+\echo Case 5: The path contains a shortcut.
+\echo We are going to route from 3 to 9
+\echo Since 3 and 9 both are in the contracted graph we need not add any vertices. 
+SELECT * FROM pgr_dijkstra($$
+    SELECT id, source, target, cost, reverse_cost 
+    FROM edge_table
+    WHERE source IN (3, 5, 6, 7, 8, 9, 11, 15, 17)
+        AND target IN (3, 5, 6, 7, 8, 9, 11, 15, 17)$$,
+    3, 9, false);
+
+SELECT id, source, target, cost, reverse_cost, is_contracted 
+FROM edge_table 
+WHERE is_contracted = true 
+ORDER BY id;
+
+\echo This implies that it is a shortcut and should be expanded
+SELECT * FROM pgr_dijkstra($$
+    SELECT id, source, target, cost, reverse_cost 
+    FROM edge_table 
+    WHERE source IN (3, 5, 6, 7, 8, 9, 11, 15, 17) 
+        AND target IN (3, 5, 6, 7, 8, 9, 11, 15, 17) 
+        AND is_contracted=false$$,
+    3, 9, false);
+
+ROLLBACK;
diff --git a/src/contraction/test/proof_of_concept_1.result b/src/contraction/test/proof_of_concept_1.result
new file mode 100644
index 0000000..a414eeb
--- /dev/null
+++ b/src/contraction/test/proof_of_concept_1.result
@@ -0,0 +1,68 @@
+Adding an additional column to store if its part of the contracted graph
+Adding a new edges joining vertices 3 and 5 with cost=2 to the edge table
+Adding a new edges joining vertices 3 and 9 with cost=2 to the edge table
+Adding a new edges joining vertices 5 and 11 with cost=2 to the edge table
+Adding a new edges joining vertices 9 and 11 with cost=2 to the edge table
+Case 1: Both source and target belong to the contracted graph.
+We are going to route from 3 to 11
+Since 3 and 11 both are in the contracted graph we need not add any vertices.
+1|1|3|5|1|0
+2|2|6|11|1|1
+3|3|11|-1|0|2
+Case 2: source belongs to a contracted graph, while target belongs to a vertex subgraph.
+We are going to route from 3 to 7
+Since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 11, 15, 17)
+1|1|3|5|1|0
+2|2|6|8|1|1
+3|3|5|7|1|2
+4|4|8|6|1|3
+5|5|7|-1|0|4
+Case 3: source belongs to a contracted graph, while target belongs to a edge subgraph.
+We are going to route from 3 to 13
+Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17)
+1|1|3|5|1|0
+2|2|6|8|1|1
+3|3|5|10|1|2
+4|4|10|14|1|3
+5|5|13|-1|0|4
+Case 4: source belongs to a vertex subgraph, while target belongs to a edge subgraph.
+We are going to route from 7 to 13
+Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, and since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex sets (3, 5, 6, 7, 8, 9, 11, 15, 17)
+1|1|7|6|1|0
+2|2|8|7|1|1
+3|3|5|10|1|2
+4|4|10|14|1|3
+5|5|13|-1|0|4
+Case 5: The path contains a shortcut.
+ 
+We are going to route from 3 to 9
+Since 3 and 9 both are in the contracted graph we need not add any vertices.
+1|1|3|5|1|0
+2|2|6|9|1|1
+3|3|9|-1|0|2
+1|1|2|1|1|f
+2|2|3|-1|1|f
+3|3|4|-1|1|f
+4|2|5|1|1|f
+5|3|6|1|-1|f
+6|7|8|1|1|f
+7|8|5|1|1|f
+8|5|6|1|1|f
+9|6|9|1|1|f
+10|5|10|1|1|f
+11|6|11|1|-1|f
+12|10|11|1|-1|f
+13|11|12|1|-1|f
+14|10|13|1|1|f
+15|9|12|1|1|f
+16|4|9|1|1|f
+17|14|15|1|1|f
+18|16|17|1|1|f
+19|3|5|2|2|t
+20|3|9|2|2|t
+21|5|11|2|2|t
+22|9|11|2|2|t
+This implies that it is a shortcut and should be expanded
+1|1|3|5|1|0
+2|2|6|9|1|1
+3|3|9|-1|0|2
\ No newline at end of file
diff --git a/src/contraction/test/proof_of_concept_1.test.sql b/src/contraction/test/proof_of_concept_1.test.sql
new file mode 100644
index 0000000..dfdbead
--- /dev/null
+++ b/src/contraction/test/proof_of_concept_1.test.sql
@@ -0,0 +1,70 @@
+BEGIN;
+
+\echo Adding an additional column to store if its part of the contracted graph
+ALTER TABLE edge_table ADD is_contracted BOOLEAN DEFAULT false;
+
+\echo Adding a new edges joining vertices 3 and 5 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (3, 5, 2, 2, true);
+
+\echo Adding a new edges joining vertices 3 and 9 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (3, 9, 2, 2, true);
+
+\echo Adding a new edges joining vertices 5 and 11 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (5, 11, 2, 2, true);
+
+\echo Adding a new edges joining vertices 9 and 11 with cost=2 to the edge table
+INSERT INTO edge_table(source, target, cost, reverse_cost, is_contracted) 
+VALUES (9, 11, 2, 2, true);
+
+--\echo --q1
+--SELECT id, source, target, cost, reverse_cost, is_contracted FROM edge_table;
+--select id, source, target, cost, reverse_cost  from edge_table where source in (3,5,6,9,11,15,17) and target in (3,5,6,9,11,15,17);
+
+
+\echo Case 1: Both source and target belong to the contracted graph.
+\echo We are going to route from 3 to 11
+\echo  Since 3 and 11 both are in the contracted graph we need not add any vertices. 
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17) AND target IN (3, 5, 6, 9, 11, 15, 17) AND is_contracted=false',
+3, 11, false);
+
+
+\echo Case 2: source belongs to a contracted graph, while target belongs to a vertex subgraph.
+\echo We are going to route from 3 to 7
+\echo  Since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 11, 15, 17)
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17,   7, 8)	 AND target IN (3, 5, 6, 9, 11, 15, 17,   7, 8) AND is_contracted=false',
+3, 7, false);
+
+\echo Case 3: source belongs to a contracted graph, while target belongs to a edge subgraph. 
+\echo We are going to route from 3 to 13
+\echo  Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, so the vertex set becomes (3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17)
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17,    10, 13) AND target IN (3, 5, 6, 9, 11, 15, 17,    10, 13) AND is_contracted=false',
+3, 13, false);
+
+\echo Case 4: source belongs to a vertex subgraph, while target belongs to a edge subgraph. 
+\echo We are going to route from 7 to 13
+\echo Since 13 is in the contracted subgraph of edge (5, 11) we add {10, 13} to the vertex set, and since 7 is in the contracted subgraph of vertex 5 we add {7, 8} to the vertex sets (3, 5, 6, 7, 8, 9, 11, 15, 17)
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 9, 11, 15, 17,    7, 8,   10, 13) AND target IN (3, 5, 6, 9, 11, 15, 17,    7, 8,   10, 13) AND is_contracted=false',
+7, 13, false);
+
+\echo Case 5: The path contains a shortcut.
+\echo \echo We are going to route from 3 to 9
+\echo Since 3 and 9 both are in the contracted graph we need not add any vertices. 
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 7, 8, 9, 11, 15, 17) AND target IN (3, 5, 6, 7, 8, 9, 11, 15, 17) AND is_contracted=false',
+3, 9, false);
+
+SELECT id, source, target, cost, reverse_cost, is_contracted FROM edge_table ORDER BY id;
+
+\echo This implies that it is a shortcut and should be expanded
+SELECT * FROM 
+pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM edge_table where source IN (3, 5, 6, 7, 8, 9, 11, 15, 17) AND target IN (3, 5, 6, 7, 8, 9, 11, 15, 17) AND is_contracted=false',
+3, 9, false);
+
+ROLLBACK;
diff --git a/src/contraction/test/return_types.result b/src/contraction/test/return_types.result
new file mode 100644
index 0000000..fc9f9f1
--- /dev/null
+++ b/src/contraction/test/return_types.result
@@ -0,0 +1,43 @@
+--q1
+--q2
+--q3
+1|v|100000002|{100000001}|-1|-1|-1
+2|v|100000005|{100000007,100000008}|-1|-1|-1
+3|v|100000010|{100000013}|-1|-1|-1
+4|v|100000015|{100000014}|-1|-1|-1
+5|v|100000017|{100000016}|-1|-1|-1
+--q4
+1|e|-1|{100000004}|100000009|100000003|2
+2|e|-2|{100000008}|100000005|100000007|2
+3|e|-3|{100000008}|100000007|100000005|2
+4|e|-4|{100000012}|100000011|100000009|2
+--q5
+1|v|100000005|{100000007,100000008}|-1|-1|-1
+2|v|100000015|{100000014}|-1|-1|-1
+3|v|100000017|{100000016}|-1|-1|-1
+4|e|-1|{100000001,100000002}|100000003|100000005|2
+5|e|-2|{100000004}|100000009|100000003|2
+6|e|-3|{100000010,100000013}|100000005|100000011|2
+7|e|-4|{100000012}|100000011|100000009|2
+--q6
+--q7
+--q8
+1|v|1000000000002|{1000000000001}|-1|-1|-1
+2|v|1000000000005|{1000000000007,1000000000008}|-1|-1|-1
+3|v|1000000000010|{1000000000013}|-1|-1|-1
+4|v|1000000000015|{1000000000014}|-1|-1|-1
+5|v|1000000000017|{1000000000016}|-1|-1|-1
+--q9
+1|e|-1|{1000000000004}|1000000000009|1000000000003|2
+2|e|-2|{1000000000008}|1000000000005|1000000000007|2
+3|e|-3|{1000000000008}|1000000000007|1000000000005|2
+4|e|-4|{1000000000012}|1000000000011|1000000000009|2
+--q10
+1|v|1000000000005|{1000000000007,1000000000008}|-1|-1|-1
+2|v|1000000000015|{1000000000014}|-1|-1|-1
+3|v|1000000000017|{1000000000016}|-1|-1|-1
+4|e|-1|{1000000000001,1000000000002}|1000000000003|1000000000005|2
+5|e|-2|{1000000000004}|1000000000009|1000000000003|2
+6|e|-3|{1000000000010,1000000000013}|1000000000005|1000000000011|2
+7|e|-4|{1000000000012}|1000000000011|1000000000009|2
+--q11
\ No newline at end of file
diff --git a/src/contraction/test/return_types.test.sql b/src/contraction/test/return_types.test.sql
new file mode 100644
index 0000000..af2afa9
--- /dev/null
+++ b/src/contraction/test/return_types.test.sql
@@ -0,0 +1,71 @@
+
+/*
+bigint (-9,223,372,036,854,775,808) to (9,223,372,036,854,775,807)
+int	(-2,147,483,648) to (2,147,483,647)
+*/
+
+/*
+Testing for ids > 10^8
+*/
+BEGIN;
+
+\echo --q1
+UPDATE edge_table
+SET id = id + POWER(10, 8),
+	source = source + POWER(10, 8),
+	target = target + POWER(10, 8);
+
+\echo --q2
+UPDATE edge_table_vertices_pgr
+SET id = id + POWER(10, 8);
+
+\echo --q3
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true);
+
+\echo --q4
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+
+\echo --q5
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1, 2]::integer[], 1, ARRAY[]::BIGINT[], true);
+
+ROLLBACK;
+
+/*
+Testing for ids > 10^12
+*/
+BEGIN;
+
+\echo --q6
+UPDATE edge_table
+SET id = id + POWER(10, 12),
+	source = source + POWER(10, 12),
+	target = target + POWER(10, 12);
+
+\echo --q7
+UPDATE edge_table_vertices_pgr
+SET id = id + POWER(10, 12);
+
+\echo --q8
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true);
+
+\echo --q9
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[2]::integer[], 1, ARRAY[]::BIGINT[], true);
+
+\echo --q10
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1, 2]::integer[], 1, ARRAY[]::BIGINT[], true);
+
+\echo --q11
+
+ROLLBACK;
\ No newline at end of file
diff --git a/src/contraction/test/sampleData.result b/src/contraction/test/sampleData.result
new file mode 100644
index 0000000..ff145dc
--- /dev/null
+++ b/src/contraction/test/sampleData.result
@@ -0,0 +1,6 @@
+--q0 Checking dead end contraction for workshop data
+1|v|2|{1}|-1|-1|-1
+2|v|5|{7,8}|-1|-1|-1
+3|v|10|{13}|-1|-1|-1
+4|v|15|{14}|-1|-1|-1
+5|v|17|{16}|-1|-1|-1
diff --git a/src/contraction/test/sampleData.test.sql b/src/contraction/test/sampleData.test.sql
new file mode 100644
index 0000000..52a9e74
--- /dev/null
+++ b/src/contraction/test/sampleData.test.sql
@@ -0,0 +1,6 @@
+
+\echo --q0 Checking dead end contraction for workshop data
+SELECT * FROM pgr_contractGraph(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true);
+
diff --git a/src/contraction/test/test.conf b/src/contraction/test/test.conf
new file mode 100644
index 0000000..8459b76
--- /dev/null
+++ b/src/contraction/test/test.conf
@@ -0,0 +1,32 @@
+#!/usr/bin/perl -w
+
+%main::tests = (
+    'any' => {
+        'comment' => 'Contraction test for any versions.',
+        'data' => [ ],
+        'tests' => [qw(
+            sampleData
+            return_types
+            proof_of_concept
+            proof_of_concept_1
+            expand_graph_without_function
+            expand_graph
+            doc-contraction
+            directed-development
+            doc-contractGraph
+            )],
+
+        'documentation' => [qw(
+            doc-contractGraph
+            doc-contraction
+            )],
+		'nottested' => [qw(
+            )]
+    },
+
+#    'vpg-vpgis' => {}, # for version specific tests
+#    '8-1' => {},       # for pg 8.x and postgis 1.x
+#    '9.2-2.1' => {},   # for pg 9.2 and postgis 2.1
+);
+
+1;
diff --git a/src/convinience/doc/doc-conversion.queries b/src/convenience/doc/doc-conversion.queries
similarity index 92%
rename from src/convinience/doc/doc-conversion.queries
rename to src/convenience/doc/doc-conversion.queries
index b03de81..9e78e5e 100644
--- a/src/convinience/doc/doc-conversion.queries
+++ b/src/convenience/doc/doc-conversion.queries
@@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 BEGIN;
 BEGIN
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_pointtoedgenode('edge_table', 'POINT(2 0)'::geometry, 0.02);
  pgr_pointtoedgenode 
@@ -47,6 +49,7 @@ SELECT st_astext(e) FROM (SELECT unnest(pgr_flipedges(ARRAY[
 'LINESTRING(2 1,3 1)'::geometry,
 'LINESTRING(2 0,2 1)'::geometry,
 'LINESTRING(2 0,2 1)'::geometry]::geometry[])) AS e) AS foo;
+NOTICE:  Deperecated function: pgr_flipEdges
       st_astext      
 ---------------------
  LINESTRING(2 1,2 2)
@@ -64,6 +67,7 @@ SELECT st_astext(e) FROM (SELECT unnest(pgr_flipedges(ARRAY[
 --q3
 SELECT ST_AsText(g) FROM 
     (SELECT unnest(pgr_texttopoints('2,0;2,1;3,1;2,2', 0)) AS g) AS foo;
+NOTICE:  Deperecated function: pgr_textToPoints
  st_astext  
 ------------
  POINT(2 0)
@@ -77,6 +81,7 @@ SELECT * FROM pgr_pointstovids(
     pgr_texttopoints('2,0;2,1;3,1;2,2', 0),
     'edge_table'
 );
+NOTICE:  Deperecated function: pgr_textToPoints
  pgr_pointstovids 
 ------------------
  {1,2,3,5}
diff --git a/src/convinience/doc/doc-matrix.queries b/src/convenience/doc/doc-matrix.queries
similarity index 75%
rename from src/convinience/doc/doc-matrix.queries
rename to src/convenience/doc/doc-matrix.queries
index ab3e782..d96de48 100644
--- a/src/convinience/doc/doc-matrix.queries
+++ b/src/convenience/doc/doc-matrix.queries
@@ -1,7 +1,11 @@
 BEGIN;
 BEGIN
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_pointstodmatrix(pgr_texttopoints('2,0;2,1;3,1;2,2', 0));
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_pointsToDMatrix
                                               dmatrix                                              |    ids    
 ---------------------------------------------------------------------------------------------------+-----------
  {{0,1,1.4142135623731,2},{1,0,1,1},{1.4142135623731,1,0,1.4142135623731},{2,1,1.4142135623731,0}} | {1,2,3,4}
@@ -13,6 +17,8 @@ SELECT * from pgr_tsp(
     ),
     1
 );
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_pointsToDMatrix
  seq | id 
 -----+----
    0 |  1
@@ -27,6 +33,7 @@ SELECT * FROM pgr_vidstodmatrix(
     ARRAY(select the_geom FROM edge_table_vertices_pgr WHERE id in (1,2,3,5)),
     'edge_table'
 );
+NOTICE:  Deprecated function pgr_vidsToDMatrix
                   dmatrix                  |    ids    
 -------------------------------------------+-----------
  {{0,1,4,2},{1,0,3,1},{4,3,0,2},{2,1,2,0}} | {1,2,3,5}
@@ -37,6 +44,9 @@ SELECT * FROM pgr_vidstodmatrix(
     pgr_pointstovids(pgr_texttopoints('2,0;2,1;3,1;2,2', 0), 'edge_table'),
     pgr_texttopoints('2,0;2,1;3,1;2,2', 0),
     'edge_table');
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_vidsToDMatrix
                   dmatrix                  |    ids    
 -------------------------------------------+-----------
  {{0,1,4,2},{1,0,3,1},{4,3,0,2},{2,1,2,0}} | {1,2,3,5}
@@ -51,6 +61,9 @@ SELECT * FROM pgr_tsp(
     ),
     1
 );
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_vidsToDMatrix
  seq | id 
 -----+----
    0 |  1
@@ -64,18 +77,20 @@ SELECT * FROM pgr_vidsToDMatrix(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
     array[1,2,3,5],
     true, true, false);
+NOTICE:  Deprecated function pgr_vidsToDMatrix
              pgr_vidstodmatrix             
 -------------------------------------------
- {{0,1,6,2},{1,0,5,1},{2,1,0,2},{2,1,4,0}}
+ {{0,1,2,2},{1,0,1,1},{2,1,0,4},{2,1,4,0}}
 (1 row)
 
 SELECT * FROM pgr_vidsToDMatrix(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
     array[1,2,3,5],
     true, true, true);
+NOTICE:  Deprecated function pgr_vidsToDMatrix
              pgr_vidstodmatrix             
 -------------------------------------------
- {{0,1,4,2},{1,0,3,1},{4,3,0,3},{2,1,3,0}}
+ {{0,1,2,2},{1,0,1,1},{2,1,0,2},{2,1,2,0}}
 (1 row)
 
 --q4
@@ -87,6 +102,7 @@ SELECT * FROM pgr_tsp(
     ),
     1
 );
+NOTICE:  Deprecated function pgr_vidsToDMatrix
  seq | id 
 -----+----
    0 |  1
diff --git a/src/convinience/doc/pgr_flipEdges.rst b/src/convenience/doc/pgr_flipEdges.rst
similarity index 86%
rename from src/convinience/doc/pgr_flipEdges.rst
rename to src/convenience/doc/pgr_flipEdges.rst
index a4160e4..849ace7 100644
--- a/src/convinience/doc/pgr_flipEdges.rst
+++ b/src/convenience/doc/pgr_flipEdges.rst
@@ -9,25 +9,19 @@
 
 .. _pgr_flip_edges:
 
-pgr_flipEdges
+pgr_flipEdges - Deprecated Function
 ==============================================================================
 
-.. index::
-        single: flipEdges(ga geometry[]) --proposed
+.. warning:: This function is deprecated!!!
 
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 ------------------------------------------------------------------------------
 
-``pgr_flipEdges`` - 
-
-.. warning::  This is a proposed function
-
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
+``pgr_flipEdges`` - flip the edges in an array of geometries so the connect end to end. 
 
 Synopsis
 ------------------------------------------------------------------------------
@@ -58,6 +52,7 @@ Given an array of linestrings that are supposedly connected end to end like the
 
 .. rubric:: History
 
+* Deprecated in version 2.3.0
 * Proposed in version 2.1.0
 
 
diff --git a/src/convinience/doc/pgr_pointToEdgeNode.rst b/src/convenience/doc/pgr_pointToEdgeNode.rst
similarity index 89%
rename from src/convinience/doc/pgr_pointToEdgeNode.rst
rename to src/convenience/doc/pgr_pointToEdgeNode.rst
index e270455..64bc55b 100644
--- a/src/convinience/doc/pgr_pointToEdgeNode.rst
+++ b/src/convenience/doc/pgr_pointToEdgeNode.rst
@@ -9,25 +9,21 @@
 
 .. _pgr_point_to_edgenode:
 
-pgr_pointToEdgeNode
+pgr_pointToEdgeNode - Proposed
 ==============================================================================
 
 .. index::
-        single: pointToEdgeNode(edges text, pnt geometry, tol float8) --proposed
-
+        single: pointToEdgeNode(Complete Signature) --proposed
 
 Name
 ------------------------------------------------------------------------------
 
 ``pgr_pointToEdgeNode`` - Converts a point to a ``vertex_id`` based on closest edge.
 
-.. warning::  This is a proposed function
 
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
 
 
 Synopsis
diff --git a/src/convinience/doc/pgr_pointsToDMatrix.rst b/src/convenience/doc/pgr_pointsToDMatrix.rst
similarity index 71%
rename from src/convinience/doc/pgr_pointsToDMatrix.rst
rename to src/convenience/doc/pgr_pointsToDMatrix.rst
index a921e42..2a5f35d 100644
--- a/src/convinience/doc/pgr_pointsToDMatrix.rst
+++ b/src/convenience/doc/pgr_pointsToDMatrix.rst
@@ -9,31 +9,24 @@
 
 .. _pgr_points_to_dmatrix:
 
-pgr_pointsToDMatrix
+pgr_pointsToDMatrix - Deprecated Function
 ==============================================================================
 
-.. index::
-        single: pointsToDMatrix(pnts geometry[], OUT dmatrix double precision[], OUT ids integer[]) --proposed
+.. warning:: This function is deprecated!!!
 
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 ------------------------------------------------------------------------------
 
 ``pgr_pointsToDMatrix`` - Creates a distance matrix from an array of points.
 
-.. warning::  This is a proposed function
-
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
-
-
 Synopsis
 ------------------------------------------------------------------------------
 
-Create a distance symetric distance matrix suitable for TSP using Euclidean distances based on the st_distance(). You might want to create a variant of this the uses st_distance_sphere() or st_distance_spheriod() or some other function.
+Create a distance symmetric distance matrix suitable for TSP using Euclidean distances based on the st_distance(). You might want to create a variant of this the uses st_distance_sphere() or st_distance_spheriod() or some other function.
 
 The function returns:
 
@@ -49,7 +42,7 @@ The function returns:
 Description
 -----------------------------------------------------------------------------
 
-.. rubric:: Paramters
+.. rubric:: Parameters
 
 :pnts: ``geometry[]`` - An array of point geometries.
 
@@ -79,8 +72,9 @@ This example shows how this can be used in the context of feeding the results in
 See Also
 -----------------------------------------------------------------------------
 
-* :ref:`pgr_vids_to_dmatrix` - convert a point geometry to the closest vertex_id of an edge..
-* :ref:`pgr_tsp<pgr_tsp>` - Traveling Sales Person
+* :ref:`pgr_vids_to_dmatrix2`
+* :ref:`pgr_vids_to_dmatrix`
+* :ref:`pgr_tsp-V2.0`
 
 
 .. rubric:: Indices and tables
diff --git a/src/convinience/doc/pgr_pointsToVids.rst b/src/convenience/doc/pgr_pointsToVids.rst
similarity index 85%
rename from src/convinience/doc/pgr_pointsToVids.rst
rename to src/convenience/doc/pgr_pointsToVids.rst
index 2bbab03..f9fc384 100644
--- a/src/convinience/doc/pgr_pointsToVids.rst
+++ b/src/convenience/doc/pgr_pointsToVids.rst
@@ -9,11 +9,11 @@
 
 .. _pgr_points_to_vids:
 
-pgr_pointsToVids
+pgr_pointsToVids - Proposed
 ==============================================================================
 
 .. index::
-        single: pointsToVids(pnts geometry[], edges text, tol float8 DEFAULT(0.01)) --proposed
+        single: pointsToVids(Complete Signature) --proposed
 
 
 Name
@@ -21,13 +21,11 @@ Name
 
 ``pgr_pointsToVids`` - Converts an array of point geometries into vertex ids.
 
-.. warning::  This is a proposed function
 
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
 
 Synopsis
 ------------------------------------------------------------------------------
@@ -46,7 +44,7 @@ The function returns:
 Description
 -----------------------------------------------------------------------------
 
-.. rubric:: Paramters
+.. rubric:: Parameters
 
 :pnts: ``geometry[]`` - An array of point geometries.
 :edges: ``text`` - The edge table to be used for the conversion.
diff --git a/src/convinience/doc/pgr_textToPoints.rst b/src/convenience/doc/pgr_textToPoints.rst
similarity index 77%
rename from src/convinience/doc/pgr_textToPoints.rst
rename to src/convenience/doc/pgr_textToPoints.rst
index 96524cc..2467443 100644
--- a/src/convinience/doc/pgr_textToPoints.rst
+++ b/src/convenience/doc/pgr_textToPoints.rst
@@ -9,26 +9,20 @@
 
 .. _pgr_text_to_points:
 
-pgr_textToPoints
+pgr_textToPoints - Deprecated Function
 ==============================================================================
 
-.. index::
-        single: textToPoints(pnts text, srid integer DEFAULT(4326)) --proposed
+.. warning:: This function is deprecated!!!
 
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 ------------------------------------------------------------------------------
 
 ``pgr_textToPoints`` - Converts a text string of the format "x,y;x,y;x,y;..." into and array of point geometries.
 
-.. warning::  This is a proposed function
-
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
-
 Synopsis
 ------------------------------------------------------------------------------
 
@@ -46,7 +40,7 @@ The function returns:
 Description
 -----------------------------------------------------------------------------
 
-.. rubric:: Paramters
+.. rubric:: Parameters
 
 :pnts: ``text`` A text string of the format "x,y;x,y;x,y;..." where x is longitude and y is latitude if use values in lat-lon.
 :srid: ``integer`` The SRID to use when constructing the point geometry. If the paratmeter is absent it defaults to ``SRID:4326``.
@@ -67,8 +61,8 @@ Examples
 See Also
 -----------------------------------------------------------------------------
 
-* :ref:`pgr_point_to_edgenode` - convert a point geometry to a ``node_id`` based on closest edge.
-* :ref:`pgr_points_to_vids` - convert an array of point geometries into vertex ids.
+* :ref:`pgr_point_to_edgenode`
+* :ref:`pgr_points_to_vids`
 
 .. rubric:: Indices and tables
 
diff --git a/src/convinience/doc/pgr_vidsToDMatrix.rst b/src/convenience/doc/pgr_vidsToDMatrix.rst
similarity index 84%
rename from src/convinience/doc/pgr_vidsToDMatrix.rst
rename to src/convenience/doc/pgr_vidsToDMatrix.rst
index c6c2199..899165c 100644
--- a/src/convinience/doc/pgr_vidsToDMatrix.rst
+++ b/src/convenience/doc/pgr_vidsToDMatrix.rst
@@ -9,27 +9,20 @@
 
 .. _pgr_vids_to_dmatrix:
 
-pgr_vidsToDMatrix
+pgr_vidsToDMatrix - Deprecated Function
 ==============================================================================
 
-.. index::
-        single: vidsToDMatrix(IN vids integer[], IN pnts geometry[], IN edges text, tol float8 DEFAULT(0.1), OUT dmatrix double precision[], OUT ids integer[]) --proposed
+.. warning:: This function is deprecated!!!
 
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 ------------------------------------------------------------------------------
 
 ``pgr_vidsToDMatrix`` - Creates a distances matrix from an array of ``vertex_id``.
 
-.. warning::  This is a proposed function
-
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
-
-
 Synopsis
 ------------------------------------------------------------------------------
 
@@ -50,7 +43,7 @@ The function returns:
 Description
 -----------------------------------------------------------------------------
 
-.. rubric:: Paramters
+.. rubric:: Parameters
 
 :vids: ``integer[]`` - An array of ``vertex_id``.
 :pnts: ``geometry[]`` - An array of point geometries that approximates the extents of the ``vertex_id``.
@@ -60,7 +53,7 @@ Description
 .. warning::
 
     * we compute a symmetric matrix because TSP requires that so the distances are better the Euclidean but but are not perfect
-    * kdijkstra() can fail to find a path between some of the vertex ids. We to not detect this other than the cost might get set to -1.0, so the dmatrix shoule be checked for this as it makes it invalid for TSP
+    * kdijkstra() can fail to find a path between some of the vertex ids. We to not detect this other than the cost might get set to -1.0, so the dmatrix should be checked for this as it makes it invalid for TSP
 
 .. rubric:: History
 
@@ -98,8 +91,9 @@ This example uses the :ref:`sampledata` network.
 See Also
 -----------------------------------------------------------------------------
 
-* :ref:`pgr_text_to_points` - Create an array of points from a text string.
-* :ref:`pgr_tsp<pgr_tsp>` - Traveling Sales Person
+* :ref:`pgr_vids_to_dmatrix2`
+* :ref:`pgr_text_to_points`
+* :ref:`pgr_tsp-V2.0`
 
 .. rubric:: Indices and tables
 
diff --git a/src/convinience/doc/pgr_vidsToDMatrix2.rst b/src/convenience/doc/pgr_vidsToDMatrix2.rst
similarity index 80%
rename from src/convinience/doc/pgr_vidsToDMatrix2.rst
rename to src/convenience/doc/pgr_vidsToDMatrix2.rst
index 04e524a..880b52f 100644
--- a/src/convinience/doc/pgr_vidsToDMatrix2.rst
+++ b/src/convenience/doc/pgr_vidsToDMatrix2.rst
@@ -9,27 +9,20 @@
 
 .. _pgr_vids_to_dmatrix2:
 
-pgr_vidsToDMatrix
+pgr_vidsToDMatrix - Deprecated Function
 ==============================================================================
 
-.. index::
-        single: vidsToDMatrix(IN sql text, IN vids integer[], IN directed boolean, IN has_reverse_cost boolean, IN want_symmetric boolean, OUT dmatrix double precision[]) --proposed
+.. warning:: This function is deprecated!!!
 
+    * Is no longer supported.
+    * May be removed from future versions.
+    * There is no replacement.
 
 Name
 ------------------------------------------------------------------------------
 
 ``pgr_vidsToDMatrix`` - Creates a distances matrix from an array of ``vertex_id``.
 
-.. warning::  This is a proposed function
-
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
-
-
 Synopsis
 ------------------------------------------------------------------------------
 
@@ -48,7 +41,7 @@ The function returns:
 Description
 -----------------------------------------------------------------------------
 
-.. rubric:: Paramters
+.. rubric:: Parameters
 
 :sql: ``text`` - A SQL statement to select the edges needed for the solution.
 :vids: ``integer[]`` - An array of ``vertex_id``.
@@ -58,7 +51,7 @@ Description
 
 .. warning::
 
-    * kdijkstra() can fail to find a path between some of the vertex ids. We to not detect this other than the cost might get set to -1.0, so the dmatrix shoule be checked for this as it makes it invalid for TSP
+    * kdijkstra() can fail to find a path between some of the vertex ids. We to not detect this other than the cost might get set to -1.0, so the dmatrix should be checked for this as it makes it invalid for TSP
 
 
 
@@ -88,9 +81,10 @@ This example uses the :ref:`sampledata` network.
 See Also
 -----------------------------------------------------------------------------
 
-* :ref:`pgr_vids_to_dmatrix` -  - Creates a distances matrix from an array of ``vertex_id``.
-* :ref:`pgr_text_to_points` - Create an array of points from a text string.
-* :ref:`pgr_tsp<pgr_tsp>` - Traveling Sales Person
+* :ref:`pgr_vids_to_dmatrix`
+* :ref:`pgr_text_to_points`
+* :ref:`pgr_tsp-V2.0`
+
 
 .. rubric:: Indices and tables
 
diff --git a/src/convinience/sql/CMakeLists.txt b/src/convenience/sql/CMakeLists.txt
similarity index 70%
rename from src/convinience/sql/CMakeLists.txt
rename to src/convenience/sql/CMakeLists.txt
index 6620990..00ee38f 100644
--- a/src/convinience/sql/CMakeLists.txt
+++ b/src/convenience/sql/CMakeLists.txt
@@ -2,7 +2,8 @@
 LIST(APPEND PACKAGE_SQL_FILES
     ${CMAKE_CURRENT_SOURCE_DIR}/pgrouting_conversion_tools.sql
     ${CMAKE_CURRENT_SOURCE_DIR}/pgrouting_dmatrix_tools.sql
-    ${CMAKE_CURRENT_SOURCE_DIR}/pgr_vidsToDMatrix_dir.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/pgr_fakeContraction.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/pgr_vidsToDMatrix.sql
 )
 
 # set in parent scope
diff --git a/src/convenience/sql/pgr_fakeContraction.sql b/src/convenience/sql/pgr_fakeContraction.sql
new file mode 100644
index 0000000..365cffc
--- /dev/null
+++ b/src/convenience/sql/pgr_fakeContraction.sql
@@ -0,0 +1,56 @@
+create type contraction_vertex as (seq int, id int, type char, contracted text);
+create or replace function pgr_fakeContraction(edges text, ch_order integer[])
+    returns setof contraction_vertex  as
+$body$
+declare
+	cv contraction_vertex%ROWTYPE;
+	row record;
+begin
+	if ch_order = ARRAY[1] then
+		-- dealing with dead end contraction
+		for row in SELECT * FROM (
+			VALUES
+			(1, 2, 'v', '{1}'),
+			(2, 3, 'v', '{}'),
+			(3, 4, 'v', '{}'),
+			(4, 5, 'v', '{7, 8}'),
+			(5, 6, 'v', '{}'),
+			(6, 9, 'v', '{}'),
+			(7, 10, 'v', '{13}'),
+			(8, 11, 'v', '{}'),
+			(9, 13, 'v', '{}'),
+			(10, 15, 'v', '{14}'),
+			(11, 17, 'v', '{16}'))  
+		AS t (seq, id, type, contracted) loop
+		cv.seq := row.seq;
+		cv.id := row.id;
+		cv.type := row.type;
+		cv.contracted := row.contracted;
+		return next cv;
+		end loop;
+	end if;
+	if ch_order = ARRAY[1, 2] then
+		-- dealing with dead end and linear contraction
+		for row in SELECT * FROM (
+			VALUES
+			(1, -1, 'e', '{1, 2}'),
+			(2, -2, 'e', '{4}'),
+			(3, -3, 'e', '{10, 13}'),
+			(4, -4, 'e', '{12}'),
+			(5, 5, 'v', '{7, 8}'),
+			(6, 6, 'v', '{}'),
+			(7, 9, 'v', '{}'),
+			(8, 11, 'v', '{}'),
+			(9, 15, 'v', '{14}'),
+			(10, 17, 'v', '{16}'))  
+		AS t (seq, id, type, contracted) loop
+		cv.seq := row.seq;
+		cv.id := row.id;
+		cv.type := row.type;
+		cv.contracted := row.contracted;
+		return next cv;
+		end loop;
+	end if;
+end;
+$body$
+language 'plpgsql' ;
diff --git a/src/convenience/sql/pgr_vidsToDMatrix.sql b/src/convenience/sql/pgr_vidsToDMatrix.sql
new file mode 100644
index 0000000..706f16a
--- /dev/null
+++ b/src/convenience/sql/pgr_vidsToDMatrix.sql
@@ -0,0 +1,92 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; IF not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+CREATE OR REPLACE FUNCTION pgr_vidsToDMatrix(sql TEXT, vids  INTEGER[], dir BOOLEAN, has_rcost BOOLEAN, want_symmetric BOOLEAN)
+RETURNS float8[] AS
+$BODY$
+DECLARE
+directed BOOLEAN;
+has_reverse BOOLEAN;
+edges_sql TEXT;
+dmatrix_row float8[];
+dmatrix float8[];
+cell RECORD;
+unique_vids INTEGER[];
+total BIGINT;
+from_v BIGINT;
+to_v BIGINT;
+BEGIN
+    RAISE NOTICE 'Deprecated function pgr_vidsToDMatrix';
+    has_reverse =_pgr_parameter_check('dijkstra', sql, false);
+    edges_sql = sql;
+    IF (has_reverse != has_rcost) THEN
+        IF (has_reverse) THEN
+            sql = 'SELECT id, source, target, cost FROM (' || sql || ') a';
+        ELSE
+            raise EXCEPTION 'has_rcost set to true but reverse_cost not found';
+        END IF;
+    END IF;
+
+    unique_vids :=  ARRAY(SELECT DISTINCT UNNEST(vids) ORDER BY 1);
+
+    IF want_symmetric THEN
+        directed = false;
+    ELSE
+        directed = dir;
+    END IF;
+
+    total := array_length(unique_vids, 1);
+
+    -- initializing dmatrix
+    FOR i in 1 .. total LOOP
+        dmatrix_row := dmatrix_row || '+Infinity'::float8;
+    END LOOP;
+    FOR i in 1 .. total LOOP
+    dmatrix := dmatrix || ARRAY[dmatrix_row];
+    dmatrix[i][i] = 0;
+    END LOOP;
+
+    CREATE TEMP TABLE __x___y____temp AS
+        WITH result AS
+            (SELECT unnest(unique_vids) AS vid)
+        SELECT row_number() OVER() AS idx, vid FROM result;
+
+    FOR cell IN SELECT * FROM pgr_dijkstraCostMatrix(sql, unique_vids, directed) LOOP
+        SELECT idx INTO from_v FROM __x___y____temp WHERE vid =  cell.start_vid;
+        SELECT idx INTO to_v FROM __x___y____temp WHERE vid =  cell.end_vid;
+
+        dmatrix[from_v][to_v] = cell.agg_cost;
+        dmatrix[to_v][from_v] = cell.agg_cost;
+    END LOOP;
+
+    DROP TABLE IF EXISTS __x___y____temp;
+    RETURN dmatrix;
+
+    EXCEPTION WHEN others THEN 
+       DROP TABLE IF EXISTS __x___y____temp;
+       raise exception '% %', SQLERRM, SQLSTATE;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100;
+
diff --git a/src/convinience/sql/pgrouting_conversion_tools.sql b/src/convenience/sql/pgrouting_conversion_tools.sql
similarity index 98%
rename from src/convinience/sql/pgrouting_conversion_tools.sql
rename to src/convenience/sql/pgrouting_conversion_tools.sql
index 8c9acb5..57a0ba5 100644
--- a/src/convinience/sql/pgrouting_conversion_tools.sql
+++ b/src/convenience/sql/pgrouting_conversion_tools.sql
@@ -92,6 +92,7 @@ declare
     g geometry;
     
 begin
+    RAISE NOTICE 'Deperecated function: pgr_flipEdges';
     -- get the count of edges, and return if only one edge
     nn := array_length(ga, 1);
     if nn=1 then
@@ -140,6 +141,7 @@ declare
     g geometry[];
     
 begin
+    RAISE NOTICE 'Deperecated function: pgr_textToPoints';
     -- convert commas to space and split on ';'
     a := string_to_array(replace(pnts, ',', ' '), ';');
     -- convert each 'x y' into a point geometry and concattenate into a new array
diff --git a/src/convinience/sql/pgrouting_dmatrix_tools.sql b/src/convenience/sql/pgrouting_dmatrix_tools.sql
similarity index 93%
rename from src/convinience/sql/pgrouting_dmatrix_tools.sql
rename to src/convenience/sql/pgrouting_dmatrix_tools.sql
index 8f23f70..e497183 100644
--- a/src/convinience/sql/pgrouting_dmatrix_tools.sql
+++ b/src/convenience/sql/pgrouting_dmatrix_tools.sql
@@ -26,7 +26,7 @@ $body$
 /*
  *  pgr_pointstodmatrix(pnts geometry[], OUT dmatrix double precision[], OUT ids integer[])
  *
- *  Create a distance symetric distance matrix suitable for TSP using Euclidean distances
+ *  Create a distance symmetric distance matrix suitable for TSP using Euclidean distances
  *  based on the st_distance(). You might want to create a variant of this the uses st_distance_sphere()
  *  or st_distance_spheriod() or some other function.
  *
@@ -35,6 +35,7 @@ declare
     r record;
     
 begin
+    RAISE NOTICE 'Deprecated function pgr_pointsToDMatrix';
     dmatrix := array[]::double precision[];
     ids := array[]::integer[];
 
@@ -70,7 +71,7 @@ $body$
  *  pgr_vidstodmatrix(IN vids integer[], IN pnts geometry[], IN edges text, tol float8 DEFAULT(0.1),
  *                    OUT dmatrix double precision[], OUT ids integer[])
  *
- *  This function thats an array vertex ids, the original array of points, the edge table name and a tol.
+ *  This function that's an array vertex ids, the original array of points, the edge table name and a tol.
  *  It then computes kdijkstra() distances for each vertex to all the other vertices and creates a symmetric
  *  distances matrix suitable for TSP. The pnt array and the tol are used to establish a BBOX for limiteding
  *  selection of edges.the extents of the points is expanded by tol.
@@ -79,7 +80,7 @@ $body$
  *  1. we compute a symmetric matrix because TSP requires that so the distances are better the Euclidean but
  *     but are not perfect
  *  2. kdijkstra() can fail to find a path between some of the vertex ids. We to not detect this other than
- *     the cost might get set to -1.0, so the dmatrix shoule be checked for this as it makes it invalid for TSP
+ *     the cost might get set to -1.0, so the dmatrix should be checked for this as it makes it invalid for TSP
  *
 */
 declare
@@ -91,6 +92,7 @@ declare
     t float8[];
 
 begin
+    RAISE NOTICE 'Deprecated function pgr_vidsToDMatrix';
     -- check if the input arrays has any -1 values, maybe this whould be a raise exception
     if vids @> ARRAY[-1] then
     raise notice 'Some vids are undefined (-1)!';
diff --git a/src/convinience/test/doc-conversion.result b/src/convenience/test/doc-conversion.result
similarity index 66%
rename from src/convinience/test/doc-conversion.result
rename to src/convenience/test/doc-conversion.result
index 2bdf71c..574fcd2 100644
--- a/src/convinience/test/doc-conversion.result
+++ b/src/convenience/test/doc-conversion.result
@@ -2,6 +2,7 @@
 1
 6
 --q2
+NOTICE:  Deperecated function: pgr_flipEdges
 LINESTRING(2 1,2 2)
 LINESTRING(2 2,2 3)
 LINESTRING(2 3,2 2)
@@ -13,10 +14,12 @@ LINESTRING(3 1,2 1)
 LINESTRING(2 1,2 0)
 LINESTRING(2 0,2 1)
 --q3
+NOTICE:  Deperecated function: pgr_textToPoints
 POINT(2 0)
 POINT(2 1)
 POINT(3 1)
 POINT(2 2)
 --q4
+NOTICE:  Deperecated function: pgr_textToPoints
 {1,2,3,5}
 --q5
diff --git a/src/convinience/test/doc-conversion.test.sql b/src/convenience/test/doc-conversion.test.sql
similarity index 98%
rename from src/convinience/test/doc-conversion.test.sql
rename to src/convenience/test/doc-conversion.test.sql
index a1f80ec..4514499 100644
--- a/src/convinience/test/doc-conversion.test.sql
+++ b/src/convenience/test/doc-conversion.test.sql
@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 BEGIN;
+SET client_min_messages TO NOTICE;
 \echo --q1
 SELECT * FROM pgr_pointtoedgenode('edge_table', 'POINT(2 0)'::geometry, 0.02);
 SELECT * FROM pgr_pointtoedgenode('edge_table', 'POINT(3 2)'::geometry, 0.02);
diff --git a/src/convenience/test/doc-matrix.result b/src/convenience/test/doc-matrix.result
new file mode 100644
index 0000000..8493a2b
--- /dev/null
+++ b/src/convenience/test/doc-matrix.result
@@ -0,0 +1,39 @@
+--q1
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_pointsToDMatrix
+{{0,1,1.4142135623731,2},{1,0,1,1},{1.4142135623731,1,0,1.4142135623731},{2,1,1.4142135623731,0}}|{1,2,3,4}
+--q1.1
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_pointsToDMatrix
+0|1
+1|3
+2|2
+3|0
+--q2
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+{{0,1,4,2},{1,0,3,1},{4,3,0,2},{2,1,2,0}}|{1,2,3,5}
+--q2.1
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+{{0,1,4,2},{1,0,3,1},{4,3,0,2},{2,1,2,0}}|{1,2,3,5}
+--q2.2
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deperecated function: pgr_textToPoints
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+0|1
+1|2
+2|3
+3|0
+--q3
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+{{0,1,2,2},{1,0,1,1},{2,1,0,4},{2,1,4,0}}
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+{{0,1,2,2},{1,0,1,1},{2,1,0,2},{2,1,2,0}}
+--q4
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+0|1
+1|2
+2|3
+3|0
+--q5
diff --git a/src/convinience/test/doc-matrix.test.sql b/src/convenience/test/doc-matrix.test.sql
similarity index 97%
rename from src/convinience/test/doc-matrix.test.sql
rename to src/convenience/test/doc-matrix.test.sql
index 94a26ec..362dcae 100644
--- a/src/convinience/test/doc-matrix.test.sql
+++ b/src/convenience/test/doc-matrix.test.sql
@@ -1,5 +1,7 @@
 BEGIN;
 
+SET client_min_messages TO NOTICE;
+
 \echo --q1
 SELECT * FROM pgr_pointstodmatrix(pgr_texttopoints('2,0;2,1;3,1;2,2', 0));
 
diff --git a/src/convinience/test/pgtap/flipEdges-types-check.sql b/src/convenience/test/pgtap/flipEdges-types-check.sql
similarity index 100%
rename from src/convinience/test/pgtap/flipEdges-types-check.sql
rename to src/convenience/test/pgtap/flipEdges-types-check.sql
diff --git a/src/convinience/test/pgtap/pointToEdgeNode-types-check.sql b/src/convenience/test/pgtap/pointToEdgeNode-types-check.sql
similarity index 100%
rename from src/convinience/test/pgtap/pointToEdgeNode-types-check.sql
rename to src/convenience/test/pgtap/pointToEdgeNode-types-check.sql
diff --git a/src/convinience/test/pgtap/pointsToDMatrix-types-check.sql b/src/convenience/test/pgtap/pointsToDMatrix-types-check.sql
similarity index 100%
rename from src/convinience/test/pgtap/pointsToDMatrix-types-check.sql
rename to src/convenience/test/pgtap/pointsToDMatrix-types-check.sql
diff --git a/src/convinience/test/pgtap/pointsToVids-types-check.sql b/src/convenience/test/pgtap/pointsToVids-types-check.sql
similarity index 100%
rename from src/convinience/test/pgtap/pointsToVids-types-check.sql
rename to src/convenience/test/pgtap/pointsToVids-types-check.sql
diff --git a/src/convinience/test/pgtap/textToPoints-types-check.sql b/src/convenience/test/pgtap/textToPoints-types-check.sql
similarity index 100%
rename from src/convinience/test/pgtap/textToPoints-types-check.sql
rename to src/convenience/test/pgtap/textToPoints-types-check.sql
diff --git a/src/convinience/test/pgtap/vidsToDMatrix-types-check.sql b/src/convenience/test/pgtap/vidsToDMatrix-types-check.sql
similarity index 100%
rename from src/convinience/test/pgtap/vidsToDMatrix-types-check.sql
rename to src/convenience/test/pgtap/vidsToDMatrix-types-check.sql
diff --git a/src/convinience/test/test.conf b/src/convenience/test/test.conf
similarity index 99%
rename from src/convinience/test/test.conf
rename to src/convenience/test/test.conf
index 04fc77f..a4011ac 100644
--- a/src/convinience/test/test.conf
+++ b/src/convenience/test/test.conf
@@ -8,7 +8,6 @@
             vidstodmatrix-any-01
             doc-matrix
             doc-conversion
-
             )],
 
         'documentation' => [qw(
diff --git a/src/convenience/test/vidstodmatrix-any-01.result b/src/convenience/test/vidstodmatrix-any-01.result
new file mode 100644
index 0000000..b85fac0
--- /dev/null
+++ b/src/convenience/test/vidstodmatrix-any-01.result
@@ -0,0 +1,4 @@
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+{{0,3,2,6,5,4},{3,0,3,3,2,5},{2,3,0,4,3,2},{6,3,4,0,3,2},{5,2,3,3,0,3},{4,5,2,2,3,0}}
+NOTICE:  Deprecated function pgr_vidsToDMatrix
+{{0,3,2,4,5,4},{3,0,3,3,2,5},{2,3,0,2,3,2},{4,3,2,0,1,2},{5,2,3,1,0,3},{4,5,2,2,3,0}}
diff --git a/src/convinience/test/vidstodmatrix-any-01.test.sql b/src/convenience/test/vidstodmatrix-any-01.test.sql
similarity index 96%
rename from src/convinience/test/vidstodmatrix-any-01.test.sql
rename to src/convenience/test/vidstodmatrix-any-01.test.sql
index e6d217c..db1a2ed 100644
--- a/src/convinience/test/vidstodmatrix-any-01.test.sql
+++ b/src/convenience/test/vidstodmatrix-any-01.test.sql
@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 BEGIN;
+SET client_min_messages TO NOTICE;
     select * from pgr_vidsToDMatrix(
         'select id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost from edge_table',
         array[1,5,13,11,12,4],
@@ -31,4 +32,4 @@ BEGIN;
         'select id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost from edge_table',
         array[1,5,13,11,12,4],
         true, true, true);
-    ROLLBACK
+    ROLLBACK;
diff --git a/src/convinience/doc/convenience.rst b/src/convinience/doc/convenience.rst
deleted file mode 100644
index 0139dab..0000000
--- a/src/convinience/doc/convenience.rst
+++ /dev/null
@@ -1,61 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _convenience_functions:
-
-Convenience Functions
-===============================================================================
-
-.. warning::  This are proposed function
-
-     - Is not officially in the release.
-     - Name could change.
-     - Signature could change.
-     - Needs testing.
-     - Functionality could change.
-
-The following functions are general purpose convenience functions that might
-be useful when building a larger application or handling input from say an
-Ajax handler.
-
-  -  :ref:`pgr_point_to_edgenode` - convert a point geometry to a ``vertex_id`` based on closest edge.
-  -  :ref:`pgr_flip_edges` - flip the edges in an array of geometries so the connect end to end.
-  -  :ref:`pgr_text_to_points` - convert a string of ``x,y;x,y;...`` locations into point geometries.
-  -  :ref:`pgr_points_to_vids` - convert an array of point geometries into vertex ids.
-
-Distance Matrix Functions
-===============================================================================
-
-These function my be helpful when you need to create or manipulate distance matricies, like for TSP or VRP related problems.
-
- - :ref:`pgr_points_to_dmatrix` - Create a distance matrix from an array of points.
- - :ref:`pgr_vids_to_dmatrix` - Create a distance matrix from an array of ``vertix_id``.
- - :ref:`pgr_vids_to_dmatrix2` - Create a distance matrix from an array of ``vertix_id``.
-
-See also
---------
-
-.. rubric:: Indices and tables
-
-* :ref:`genindex`
-* :ref:`search`
-
-
-.. toctree::
-  :hidden:
-
-  pgr_pointToEdgeNode
-  pgr_flipEdges
-  pgr_textToPoints
-  pgr_pointsToVids
-
-  pgr_pointsToDMatrix
-  pgr_vidsToDMatrix
-  pgr_vidsToDMatrix2
-
diff --git a/src/convinience/sql/pgr_vidsToDMatrix_dir.sql b/src/convinience/sql/pgr_vidsToDMatrix_dir.sql
deleted file mode 100644
index 6f95723..0000000
--- a/src/convinience/sql/pgr_vidsToDMatrix_dir.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; IF not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-
-CREATE OR REPLACE FUNCTION pgr_vidsToDMatrix(sql text,
-    vids integer[], dir bool, has_rcost bool, want_symmetric bool)
-RETURNS float8[]
-AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'manytomany_dijkstra_dmatrix'
-LANGUAGE C STABLE STRICT;
diff --git a/src/convinience/test/doc-matrix.result b/src/convinience/test/doc-matrix.result
deleted file mode 100644
index abab630..0000000
--- a/src/convinience/test/doc-matrix.result
+++ /dev/null
@@ -1,25 +0,0 @@
---q1
-{{0,1,1.4142135623731,2},{1,0,1,1},{1.4142135623731,1,0,1.4142135623731},{2,1,1.4142135623731,0}}|{1,2,3,4}
---q1.1
-0|1
-1|3
-2|2
-3|0
---q2
-{{0,1,4,2},{1,0,3,1},{4,3,0,2},{2,1,2,0}}|{1,2,3,5}
---q2.1
-{{0,1,4,2},{1,0,3,1},{4,3,0,2},{2,1,2,0}}|{1,2,3,5}
---q2.2
-0|1
-1|2
-2|3
-3|0
---q3
-{{0,1,6,2},{1,0,5,1},{2,1,0,2},{2,1,4,0}}
-{{0,1,4,2},{1,0,3,1},{4,3,0,3},{2,1,3,0}}
---q4
-0|1
-1|2
-2|3
-3|0
---q5
diff --git a/src/convinience/test/vidstodmatrix-any-01.result b/src/convinience/test/vidstodmatrix-any-01.result
deleted file mode 100644
index 139be2f..0000000
--- a/src/convinience/test/vidstodmatrix-any-01.result
+++ /dev/null
@@ -1,2 +0,0 @@
-{{0,2,4,4,5,5},{2,0,2,2,3,3},{4,2,0,2,3,5},{6,4,6,0,1,3},{5,3,5,3,0,2},{3,3,5,3,2,0}}
-{{0,2,4,5,5,4},{2,0,2,3,3,3},{4,2,0,4,4,5},{5,3,4,0,2,3},{5,3,4,2,0,2},{4,3,5,3,2,0}}
diff --git a/src/costMatrix/doc/costMatrix.rst b/src/costMatrix/doc/costMatrix.rst
new file mode 100644
index 0000000..3b01c49
--- /dev/null
+++ b/src/costMatrix/doc/costMatrix.rst
@@ -0,0 +1,94 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _CostMatrix:
+
+Cost Matrix
+===============================================================================
+
+  - :ref:`pgr_dijkstraCostMatrix`
+  - :ref:`pgr_withPointsCostMatrix`
+
+
+.. include:: ../../proposedNext.rst
+    :start-after: begin-warning
+    :end-before: end-warning
+
+
+ 
+General Information
+-------------------------------------------------------------------------------
+
+Sinopsis
+...................
+
+:ref:`tsp` needs as input a symmetric cost matrix and no edge `(u, v)` must value :math:`\infty`.
+
+This collection of functions will return a cost matrix in form of a table.
+
+
+Characteristics
+................
+
+The main Characteristics are:
+
+* Can be used as input to :ref:`pgr_tsp`.
+
+  * :directly: when the resulting matrix is symmetric and there is no :math:`\infty` value.
+  * It will be the users responsibility to make the matrix symmetric.
+
+    * By using geometric or harmonic average of the non symmetric values.
+    * By using max or min the non symmetric values.
+    * By setting the upper triangle to be the mirror image of the lower triangle.
+    * By setting the lower triangle to be the mirror image of the upper triangle.
+
+  * It is also the users responsibility to fix an :math:`\infty` value.
+
+* Each function works as part of the family it belongs to.
+* It does not return a path.
+* Returns the sum of the costs of the shortest path for pair combination of nodes in the graph.
+* Process is done only on edges with positive costs.
+* Values are returned when there is a path.
+
+  * The returned values are in the form of a set of `(start_vid, end_vid, agg_cost)`.
+
+  * When the starting vertex and ending vertex are the same, there is no path.
+
+    * The `agg_cost` int the non included values `(v, v)` is `0`.
+
+  * When the starting vertex and ending vertex are the different and there is no path.
+
+    * The `agg_cost` in the non included values `(u, v)` is :math:`\infty`.
+
+* Let be the case the values returned are stored in a table, so the unique index would be the pair: `(start_vid, end_vid)`.
+
+* Depending on the function and its parameters, the results can be symmetric.
+
+  * The  `agg_cost` of `(u, v)` is the same as for `(v, u)`.
+
+* Any duplicated value in the `start_vids` are ignored.
+
+* The returned values are ordered:
+
+  * `start_vid` ascending
+  * `end_vid` ascending
+
+* Running time: approximately :math:`O(| start\_vids | * (V \log V + E))`
+
+
+
+See Also
+................
+
+* :ref:`pgr_tsp`
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
diff --git a/src/costMatrix/doc/dmatrix_return_values.txt b/src/costMatrix/doc/dmatrix_return_values.txt
new file mode 100644
index 0000000..45fad6f
--- /dev/null
+++ b/src/costMatrix/doc/dmatrix_return_values.txt
@@ -0,0 +1,23 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+
+Description of the return values
+...............................................................................
+
+Returns set of ``(start_vid, end_vid, agg_cost)``
+
+============= ============= =================================================
+Column        Type          Description
+============= ============= =================================================
+**start_vid** ``BIGINT``    Identifier of the starting vertex.
+**end_vid**   ``BIGINT``    Identifier of the ending vertex.
+**agg_cost**  ``FLOAT``     Aggregate cost of the shortest path from ``start_vid`` to ``end_vid``.
+============= ============= =================================================
+
diff --git a/src/costMatrix/doc/doc-pgr_fooDmatrix.queries b/src/costMatrix/doc/doc-pgr_fooDmatrix.queries
new file mode 100644
index 0000000..59da6ee
--- /dev/null
+++ b/src/costMatrix/doc/doc-pgr_fooDmatrix.queries
@@ -0,0 +1,132 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO WARNING;
+SET
+-- dijkstra q1
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5)
+);
+ start_vid | end_vid | agg_cost 
+-----------+---------+----------
+         1 |       2 |        1
+         1 |       3 |        6
+         1 |       4 |        5
+         2 |       1 |        1
+         2 |       3 |        5
+         2 |       4 |        4
+         3 |       1 |        2
+         3 |       2 |        1
+         3 |       4 |        3
+         4 |       1 |        3
+         4 |       2 |        2
+         4 |       3 |        1
+(12 rows)
+
+-- dijkstra q2
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+    false
+);
+ start_vid | end_vid | agg_cost 
+-----------+---------+----------
+         1 |       2 |        1
+         1 |       3 |        2
+         1 |       4 |        3
+         2 |       1 |        1
+         2 |       3 |        1
+         2 |       4 |        2
+         3 |       1 |        2
+         3 |       2 |        1
+         3 |       4 |        1
+         4 |       1 |        3
+         4 |       2 |        2
+         4 |       3 |        1
+(12 rows)
+
+-- dijkstra q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+        false
+    )
+    $$,
+    randomize := false
+);
+ seq | node | cost | agg_cost 
+-----+------+------+----------
+   1 |    1 |    1 |        0
+   2 |    2 |    1 |        1
+   3 |    3 |    1 |        2
+   4 |    4 |    3 |        3
+   5 |    1 |    0 |        6
+(5 rows)
+
+-- dijkstra q4
+-- withPoints q1
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6]);
+ start_vid | end_vid | agg_cost 
+-----------+---------+----------
+        -6 |      -1 |      1.3
+        -6 |       3 |      4.3
+        -6 |       6 |      1.3
+        -1 |      -6 |      1.3
+        -1 |       3 |      5.6
+        -1 |       6 |      2.6
+         3 |      -6 |      1.7
+         3 |      -1 |      1.6
+         3 |       6 |        1
+         6 |      -6 |      1.3
+         6 |      -1 |      2.6
+         6 |       3 |        3
+(12 rows)
+
+-- withPoints q2
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6], directed := false);
+ start_vid | end_vid | agg_cost 
+-----------+---------+----------
+        -6 |      -1 |      1.3
+        -6 |       3 |      1.7
+        -6 |       6 |      1.3
+        -1 |      -6 |      1.3
+        -1 |       3 |      1.6
+        -1 |       6 |      2.6
+         3 |      -6 |      1.7
+         3 |      -1 |      1.6
+         3 |       6 |        1
+         6 |      -6 |      1.3
+         6 |      -1 |      2.6
+         6 |       3 |        1
+(12 rows)
+
+-- withPoints q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 6, -6], directed := false);
+    $$,
+    randomize := false
+);
+ seq | node | cost | agg_cost 
+-----+------+------+----------
+   1 |   -6 |  1.3 |        0
+   2 |   -1 |  1.6 |      1.3
+   3 |    3 |    1 |      2.9
+   4 |    6 |  1.3 |      3.9
+   5 |   -6 |    0 |      5.2
+(5 rows)
+
+-- withPoints q4
+ROLLBACK;
+ROLLBACK
diff --git a/src/costMatrix/doc/pgr_dijkstraCostMatrix.rst b/src/costMatrix/doc/pgr_dijkstraCostMatrix.rst
new file mode 100644
index 0000000..30494ce
--- /dev/null
+++ b/src/costMatrix/doc/pgr_dijkstraCostMatrix.rst
@@ -0,0 +1,144 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _pgr_dijkstraCostMatrix:
+
+pgr_dijkstraCostMatrix - proposed
+===============================================================================
+
+Name
+-------------------------------------------------------------------------------
+
+``pgr_dijkstraCostMatrix`` - Calculates the a cost matrix using pgr_dijktras.
+
+
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph
+
+   Boost Graph Inside
+
+Synopsis
+-------------------------------------------------------------------------------
+
+Using Dijkstra algorithm, calculate and return a cost matrix.
+
+Signature Summary
+-----------------
+
+.. code-block:: none
+
+    pgr_dijkstraCostMatrix(edges_sql, start_vids)
+    pgr_dijkstraCostMatrix(edges_sql, start_vids, directed)
+    RETURNS SET OF (start_vid, end_vid, agg_cost)
+
+
+
+Signatures
+-------------------------------------------------------------------------------
+
+.. index::
+    single: dijkstraCostMatrix(Minimal Use) - Proposed
+
+Minimal Signature
+...............................................................................
+
+The minimal signature:
+    - Is for a **directed** graph.
+
+.. code-block:: none
+
+    pgr_dijkstraCostMatrix(edges_sql, start_vid)
+    RETURNS SET OF (start_vid, end_vid, agg_cost)
+
+
+:Example: Cost matrix for vertices 1, 2, 3, and 4.
+
+
+.. literalinclude:: doc-pgr_fooDmatrix.queries
+   :start-after: -- dijkstra q1
+   :end-before: -- dijkstra q2
+
+
+.. index::
+    single: dijkstraCostMatrix(Complete Signature) - Proposed
+
+Complete Signature
+...............................................................................
+
+.. code-block:: none
+
+    pgr_dijkstraCostMatrix(edges_sql, start_vids, directed:=true)
+    RETURNS SET OF (start_vid, end_vid, agg_cost)
+
+
+:Example: Cost matrix for an undirected graph for vertices 1, 2, 3, and 4.
+
+This example returns a symmetric cost matrix.
+
+.. literalinclude:: doc-pgr_fooDmatrix.queries
+   :start-after: -- dijkstra q2
+   :end-before: -- dijkstra q3
+
+
+Description of the Signatures
+-------------------------------------------------------------------------------
+
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
+
+
+
+Description of the parameters of the signatures
+...............................................................................
+
+================ ====================== =================================================
+Parameter        Type                   Description
+================ ====================== =================================================
+**edges_sql**    ``TEXT``               Edges SQL query as described above.
+**start_vids**   ``ARRAY[ANY-INTEGER]`` Array of identifiers of the vertices.
+**directed**     ``BOOLEAN``            (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
+================ ====================== =================================================
+
+
+
+.. Description of the return values
+
+.. include:: dmatrix_return_values.txt
+
+
+Examples
+-------------------------------------------------------------------------------
+
+:Example: Use with tsp
+
+.. literalinclude:: doc-pgr_fooDmatrix.queries
+   :start-after: -- dijkstra q3
+   :end-before: -- dijkstra q4
+
+
+See Also
+-------------------------------------------------------------------------------
+
+* :ref:`dijkstra`
+* :ref:`costMatrix`
+* :ref:`tsp`
+* The queries use the :ref:`sampledata` network.
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/costMatrix/doc/pgr_withPointsCostMatrix.rst b/src/costMatrix/doc/pgr_withPointsCostMatrix.rst
new file mode 100644
index 0000000..4217401
--- /dev/null
+++ b/src/costMatrix/doc/pgr_withPointsCostMatrix.rst
@@ -0,0 +1,161 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _pgr_withPointsCostMatrix:
+
+pgr_withPointsCostMatrix - proposed
+===============================================================================
+
+
+Name
+-------------------------------------------------------------------------------
+
+``pgr_withPointsCostMatrix`` - Calculates the shortest path and returns only the aggregate cost of the shortest path(s) found, for the combination of points given.
+
+
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph
+
+   Boost Graph Inside
+
+
+Signature Summary
+-------------------------------------------------------------------------------
+
+.. code-block:: none
+
+    pgr_withPointsCostMatrix(edges_sql, points_sql, start_vids)
+    pgr_withPointsCostMatrix(edges_sql, points_sql, start_vids, directed, driving_side)
+    RETURNS SET OF (start_vid, end_vid, agg_cost)
+
+.. note:: There is no **details** flag, unlike the other members of the withPoints family of functions.  
+
+
+Signatures
+-------------------------------------------------------------------------------
+
+.. index::
+    single: withPointsCostMatrix(Minimal use) - Proposed
+
+Minimal Signature
+...............................................................................
+
+The minimal signature:
+    - Is for a **directed** graph.
+    - The driving side is set as **b** both. So arriving/departing to/from the point(s) can be in any direction.
+
+.. code-block:: none
+
+    pgr_withPointsCostMatrix(edges_sql, points_sql, start_vid)
+    RETURNS SET OF (start_vid, end_vid, agg_cost)
+
+
+:Example:
+
+.. literalinclude:: doc-pgr_fooDmatrix.queries
+   :start-after: -- withPoints q1
+   :end-before: -- withPoints q2
+
+
+.. index::
+    single: withPointsCostMatrix(Complete Signature) - Proposed
+
+Complete Signature
+...............................................................................
+
+.. code-block:: none
+
+    pgr_withPointsCostMatrix(edges_sql, points_sql, start_vids,
+        directed:=true, driving_side:='b')
+    RETURNS SET OF (start_vid, end_vid, agg_cost)
+
+
+:Example: returning a symmetrical cost matrix
+
+* Using the default **side** value on the **points_sql** query
+* Using an undirected graph
+* Using the default **driving_side** value
+
+.. literalinclude:: doc-pgr_fooDmatrix.queries
+   :start-after: -- withPoints q2
+   :end-before: -- withPoints q3
+
+
+
+Description of the Signatures
+-------------------------------------------------------------------------------
+
+..
+    description of the sql queries
+
+
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
+
+.. include:: ../../common/src/points_input.h
+    :start-after: points_sql_start
+    :end-before: points_sql_end
+
+
+Description of the parameters of the signatures
+...............................................................................
+
+
+================ ====================== =================================================
+Parameter        Type                   Description
+================ ====================== =================================================
+**edges_sql**    ``TEXT``               Edges SQL query as described above.
+**points_sql**   ``TEXT``               Points SQL query as described above.
+**start_vids**   ``ARRAY[ANY-INTEGER]`` Array of identifiers of starting vertices. When negative: is a point's pid.
+**directed**     ``BOOLEAN``            (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
+**driving_side** ``CHAR``               (optional) Value in ['b', 'r', 'l', NULL] indicating if the driving side is:
+                                          - In the right or left or
+                                          - If it doesn't matter with 'b' or NULL.
+                                          - If column not present 'b' is considered.
+
+================ ====================== =================================================
+
+
+
+.. Description of the return values
+
+.. include:: dmatrix_return_values.txt
+
+
+Examples
+-------------------------------------------------------------------------------
+
+:Example: Use with tsp
+
+.. literalinclude:: doc-pgr_fooDmatrix.queries
+   :start-after: -- withPoints q3
+   :end-before: -- withPoints q4
+
+
+
+See Also
+-------------------------------------------------------------------------------
+
+* :ref:`withPoints`
+* :ref:`costMatrix`
+* :ref:`tsp`
+* `sampledata` network.
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/costMatrix/sql/CMakeLists.txt b/src/costMatrix/sql/CMakeLists.txt
new file mode 100644
index 0000000..11f8d6c
--- /dev/null
+++ b/src/costMatrix/sql/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Append in local scope
+LIST(APPEND PACKAGE_SQL_FILES
+    ${CMAKE_CURRENT_SOURCE_DIR}/withPointsCostMatrix.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/dijkstraCostMatrix.sql
+
+    #for version 3.0
+    #${CMAKE_CURRENT_SOURCE_DIR}/astarCostMatrix.sql
+
+    # coded but not used
+    #${CMAKE_CURRENT_SOURCE_DIR}/eucledianCostMatrix.sql
+    )
+
+# set in parent scope
+SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
diff --git a/src/dijkstra/sql/dijkstraVia.sql b/src/costMatrix/sql/astarCostMatrix.sql
similarity index 65%
copy from src/dijkstra/sql/dijkstraVia.sql
copy to src/costMatrix/sql/astarCostMatrix.sql
index f18a54b..c793afc 100644
--- a/src/dijkstra/sql/dijkstraVia.sql
+++ b/src/costMatrix/sql/astarCostMatrix.sql
@@ -1,11 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: dijkstraViaVertex.sql
+File: astar.sql
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
 
 ------
 
@@ -25,27 +27,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-CREATE OR REPLACE FUNCTION pgr_dijkstraVia(
-    edges_sql TEXT,
-    via_vertices ANYARRAY,
-    directed BOOLEAN DEFAULT TRUE,
-    strict BOOLEAN DEFAULT FALSE,
-    U_turn_on_edge BOOLEAN DEFAULT TRUE,
-
-
-    OUT seq INTEGER,
-    OUT path_id INTEGER,
-    OUT path_seq INTEGER,
+CREATE OR REPLACE FUNCTION pgr_astarCostMatrix(
+    edges_sql TEXT, -- XY edges sql
+    vids ANYARRAY,
+    directed BOOLEAN DEFAULT true,
+    heuristic INTEGER DEFAULT 5,
+    factor FLOAT DEFAULT 1.0,
+    epsilon FLOAT DEFAULT 1.0,
     OUT start_vid BIGINT,
     OUT end_vid BIGINT,
-    OUT node BIGINT,
-    OUT edge BIGINT,
-    OUT cost FLOAT,
-    OUT agg_cost FLOAT,
-    OUT route_agg_cost FLOAT)
-
-  RETURNS SETOF RECORD AS
- '$libdir/${PGROUTING_LIBRARY_NAME}', 'dijkstraVia'
-    LANGUAGE c IMMUTABLE STRICT;
-
+    OUT agg_cost FLOAT)
+
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT a.start_vid, a.end_vid, a.agg_cost
+    FROM _pgr_astar(_pgr_get_statement($1), $2, $2, $3, $4, $5, $6, true) a;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
 
diff --git a/src/allpairs/src/johnson_driver.h b/src/costMatrix/sql/dijkstraCostMatrix.sql
similarity index 63%
copy from src/allpairs/src/johnson_driver.h
copy to src/costMatrix/sql/dijkstraCostMatrix.sql
index 8a64bf6..705d972 100644
--- a/src/allpairs/src/johnson_driver.h
+++ b/src/costMatrix/sql/dijkstraCostMatrix.sql
@@ -1,13 +1,10 @@
 /*PGR-GNU*****************************************************************
-File: johnson_driver.h
 
-Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+mail: vicky_vergara at hotmail.com
 
 ------
 
@@ -27,25 +24,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#pragma once
 
-#include "./../../common/src/pgr_types.h"
+--  DIJKSTRA DMatrix
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+/***********************************
+        MANY TO MANY
+***********************************/
+
+CREATE OR REPLACE FUNCTION pgr_dijkstraCostMatrix(edges_sql TEXT, vids ANYARRAY, directed BOOLEAN DEFAULT true,
+    OUT start_vid BIGINT, OUT end_vid BIGINT, OUT agg_cost float)
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT a.start_vid, a.end_vid, a.agg_cost
+    FROM _pgr_dijkstra(_pgr_get_statement($1), $2, $2, $3, true) a;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
 
-//  CREATE OR REPLACE FUNCTION pgr_johnson(edges_sql TEXT, directed BOOLEAN,
-void
-do_pgr_johnson(
-        pgr_edge_t  *data_edges,
-        size_t total_tuples,
-        bool directed,
-        Matrix_cell_t **return_tuples,
-        size_t *return_count,
-        char ** err_msg);
 
 
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/costMatrix/sql/eucledianCostMatrix.sql b/src/costMatrix/sql/eucledianCostMatrix.sql
new file mode 100644
index 0000000..fbbe3db
--- /dev/null
+++ b/src/costMatrix/sql/eucledianCostMatrix.sql
@@ -0,0 +1,92 @@
+-- vertices_sql has the form
+-- SELECT id, the_geom FROM .....
+
+CREATE OR REPLACE FUNCTION pgr_eucledianCostMatrix(vertices_sql TEXT,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT agg_cost DOUBLE PRECISION)
+RETURNS SETOF RECORD AS
+$BODY$
+DECLARE
+    sql text;
+    rec record;
+    has_the_geom BOOLEAN DEFAULT false;
+    has_id BOOLEAN DEFAULT false;
+    has_x BOOLEAN DEFAULT false;
+    has_y BOOLEAN DEFAULT false;
+    
+BEGIN
+
+    sql := 'CREATE TABLE ___tmp  AS ' || vertices_sql ;
+    EXECUTE sql;
+
+    RETURN query SELECT * FROM pgr_eucledianDMatrix('___tmp'::regclass);
+
+    DROP TABLE ___tmp;
+    RETURN;
+
+END
+$BODY$
+language plpgsql volatile cost 10;
+
+CREATE OR REPLACE FUNCTION pgr_eucledianCostMatrix(
+    vertices_sql regclass,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT agg_cost DOUBLE PRECISION)
+RETURNS SETOF RECORD AS
+$BODY$
+DECLARE
+    sql text;
+    which INTEGER := 0;
+    rec record;
+    has_the_geom BOOLEAN DEFAULT false;
+    has_id BOOLEAN DEFAULT false;
+    has_x BOOLEAN DEFAULT false;
+    has_y BOOLEAN DEFAULT false;
+    
+BEGIN
+    sql = format('SELECT id, the_geom from %I ', vertices_sql);
+    BEGIN
+        EXECUTE sql || 'LIMIT 1';
+        which := 1;
+        EXCEPTION WHEN OTHERS THEN
+        which := 0;
+    END;
+
+    IF which = 0 THEN
+        sql = format('SELECT id, x, y from %I ', vertices_sql);
+        BEGIN
+            EXECUTE sql || 'LIMIT 1';
+            which := 2;
+            EXCEPTION WHEN OTHERS THEN
+                RAISE EXCEPTION 'An expected column was not found in the query (3)'
+                USING HINT = 'Please verify columns: (id, the_geom) or (id, x, y) columns';
+        END;
+    END IF;
+
+
+    IF which = 1 THEN
+        sql := 'WITH
+        vertices AS (' || sql || '),
+        distances AS (SELECT DISTINCT a.id::BIGINT AS start_id, b.id::BIGINT as end_id, ST_Distance(a.the_geom, b.the_geom) as distance
+            FROM  vertices AS a, vertices AS b
+            WHERE a.id != b.id
+            ORDER BY start_id, end_id)
+        SELECT * from distances';
+    ELSE 
+        sql := 'WITH
+        vertices AS (' || sql || '),
+        distances AS (SELECT DISTINCT a.id::BIGINT AS start_id, b.id::BIGINT as end_id, ST_Distance(ST_MakePoint(a.x,a.y), ST_MakePoint(b.x,b.y)) as distance
+            FROM  vertices AS a, vertices AS b
+            WHERE a.id != b.id
+            ORDER BY start_id, end_id)
+        SELECT * from distances';
+    END IF;
+
+    BEGIN
+        RETURN query EXECUTE sql;
+    END;
+END
+$BODY$
+language plpgsql volatile cost 10;
diff --git a/src/dijkstra/sql/dijkstraVia.sql b/src/costMatrix/sql/withPointsCostMatrix.sql
similarity index 67%
copy from src/dijkstra/sql/dijkstraVia.sql
copy to src/costMatrix/sql/withPointsCostMatrix.sql
index f18a54b..ca5d106 100644
--- a/src/dijkstra/sql/dijkstraVia.sql
+++ b/src/costMatrix/sql/withPointsCostMatrix.sql
@@ -1,11 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: dijkstraViaVertex.sql
+File: withPointsCost.sql
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
 
 ------
 
@@ -25,27 +27,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-CREATE OR REPLACE FUNCTION pgr_dijkstraVia(
-    edges_sql TEXT,
-    via_vertices ANYARRAY,
-    directed BOOLEAN DEFAULT TRUE,
-    strict BOOLEAN DEFAULT FALSE,
-    U_turn_on_edge BOOLEAN DEFAULT TRUE,
+/*
+MANY TO MANY
+*/
 
+CREATE OR REPLACE FUNCTION pgr_withPointsCostMatrix(
+    edges_sql TEXT,
+    points_sql TEXT,
+    pids ANYARRAY,
+    directed BOOLEAN DEFAULT true,
+    driving_side CHAR DEFAULT 'b', -- 'r'/'l'/'b'/NULL
 
-    OUT seq INTEGER,
-    OUT path_id INTEGER,
-    OUT path_seq INTEGER,
     OUT start_vid BIGINT,
     OUT end_vid BIGINT,
-    OUT node BIGINT,
-    OUT edge BIGINT,
-    OUT cost FLOAT,
-    OUT agg_cost FLOAT,
-    OUT route_agg_cost FLOAT)
-
-  RETURNS SETOF RECORD AS
- '$libdir/${PGROUTING_LIBRARY_NAME}', 'dijkstraVia'
-    LANGUAGE c IMMUTABLE STRICT;
-
-
+    OUT agg_cost float)
+RETURNS SETOF RECORD AS
+$BODY$
+BEGIN
+    RETURN query SELECT a.start_pid, a.end_pid, a.agg_cost
+        FROM _pgr_withPoints($1, $2, $3, $3, $4,  $5, TRUE, TRUE) AS a;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
diff --git a/src/costMatrix/test/doc-pgr_fooDmatrix-mac.result b/src/costMatrix/test/doc-pgr_fooDmatrix-mac.result
new file mode 100644
index 0000000..6eb4be0
--- /dev/null
+++ b/src/costMatrix/test/doc-pgr_fooDmatrix-mac.result
@@ -0,0 +1,66 @@
+-- dijkstra q1
+1|2|1
+1|3|6
+1|4|5
+2|1|1
+2|3|5
+2|4|4
+3|1|2
+3|2|1
+3|4|3
+4|1|3
+4|2|2
+4|3|1
+-- dijkstra q2
+1|2|1
+1|3|2
+1|4|3
+2|1|1
+2|3|1
+2|4|2
+3|1|2
+3|2|1
+3|4|1
+4|1|3
+4|2|2
+4|3|1
+-- dijkstra q3
+1|1|1|0
+2|2|1|1
+3|3|1|2
+4|4|3|3
+5|1|0|6
+-- dijkstra q4
+-- withPoints q1
+-6|-1|1.3
+-6|3|4.3
+-6|6|1.3
+-1|-6|1.3
+-1|3|5.6
+-1|6|2.6
+3|-6|1.7
+3|-1|1.6
+3|6|1
+6|-6|1.3
+6|-1|2.6
+6|3|3
+-- withPoints q2
+-6|-1|1.3
+-6|3|1.7
+-6|6|1.3
+-1|-6|1.3
+-1|3|1.6
+-1|6|2.6
+3|-6|1.7
+3|-1|1.6
+3|6|1
+6|-6|1.3
+6|-1|2.6
+6|3|1
+-- withPoints q3
+1|-6|1.3|0
+2|6|1|1.3
+3|3|1.6|2.3
+4|-1|1.3|3.9
+5|-6|0|5.2
+-- withPoints q4
diff --git a/src/costMatrix/test/doc-pgr_fooDmatrix-mac.test.sql b/src/costMatrix/test/doc-pgr_fooDmatrix-mac.test.sql
new file mode 100644
index 0000000..cacbf7f
--- /dev/null
+++ b/src/costMatrix/test/doc-pgr_fooDmatrix-mac.test.sql
@@ -0,0 +1,51 @@
+BEGIN;
+
+SET client_min_messages TO WARNING;
+\echo -- dijkstra q1
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5)
+);
+\echo -- dijkstra q2
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+    false
+);
+\echo -- dijkstra q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+        false
+    )
+    $$,
+    randomize := false
+);
+\echo -- dijkstra q4
+
+-- withPoints
+\echo -- withPoints q1
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6]);
+\echo -- withPoints q2
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6], directed := false);
+\echo -- withPoints q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 6, -6], directed := false);
+    $$,
+    randomize := false
+);
+\echo -- withPoints q4
+
+ROLLBACK;
diff --git a/src/costMatrix/test/doc-pgr_fooDmatrix-windows.result b/src/costMatrix/test/doc-pgr_fooDmatrix-windows.result
new file mode 100644
index 0000000..6eb4be0
--- /dev/null
+++ b/src/costMatrix/test/doc-pgr_fooDmatrix-windows.result
@@ -0,0 +1,66 @@
+-- dijkstra q1
+1|2|1
+1|3|6
+1|4|5
+2|1|1
+2|3|5
+2|4|4
+3|1|2
+3|2|1
+3|4|3
+4|1|3
+4|2|2
+4|3|1
+-- dijkstra q2
+1|2|1
+1|3|2
+1|4|3
+2|1|1
+2|3|1
+2|4|2
+3|1|2
+3|2|1
+3|4|1
+4|1|3
+4|2|2
+4|3|1
+-- dijkstra q3
+1|1|1|0
+2|2|1|1
+3|3|1|2
+4|4|3|3
+5|1|0|6
+-- dijkstra q4
+-- withPoints q1
+-6|-1|1.3
+-6|3|4.3
+-6|6|1.3
+-1|-6|1.3
+-1|3|5.6
+-1|6|2.6
+3|-6|1.7
+3|-1|1.6
+3|6|1
+6|-6|1.3
+6|-1|2.6
+6|3|3
+-- withPoints q2
+-6|-1|1.3
+-6|3|1.7
+-6|6|1.3
+-1|-6|1.3
+-1|3|1.6
+-1|6|2.6
+3|-6|1.7
+3|-1|1.6
+3|6|1
+6|-6|1.3
+6|-1|2.6
+6|3|1
+-- withPoints q3
+1|-6|1.3|0
+2|6|1|1.3
+3|3|1.6|2.3
+4|-1|1.3|3.9
+5|-6|0|5.2
+-- withPoints q4
diff --git a/src/costMatrix/test/doc-pgr_fooDmatrix-windows.test.sql b/src/costMatrix/test/doc-pgr_fooDmatrix-windows.test.sql
new file mode 100644
index 0000000..cacbf7f
--- /dev/null
+++ b/src/costMatrix/test/doc-pgr_fooDmatrix-windows.test.sql
@@ -0,0 +1,51 @@
+BEGIN;
+
+SET client_min_messages TO WARNING;
+\echo -- dijkstra q1
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5)
+);
+\echo -- dijkstra q2
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+    false
+);
+\echo -- dijkstra q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+        false
+    )
+    $$,
+    randomize := false
+);
+\echo -- dijkstra q4
+
+-- withPoints
+\echo -- withPoints q1
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6]);
+\echo -- withPoints q2
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6], directed := false);
+\echo -- withPoints q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 6, -6], directed := false);
+    $$,
+    randomize := false
+);
+\echo -- withPoints q4
+
+ROLLBACK;
diff --git a/src/costMatrix/test/doc-pgr_fooDmatrix.result b/src/costMatrix/test/doc-pgr_fooDmatrix.result
new file mode 100644
index 0000000..5a20003
--- /dev/null
+++ b/src/costMatrix/test/doc-pgr_fooDmatrix.result
@@ -0,0 +1,66 @@
+-- dijkstra q1
+1|2|1
+1|3|6
+1|4|5
+2|1|1
+2|3|5
+2|4|4
+3|1|2
+3|2|1
+3|4|3
+4|1|3
+4|2|2
+4|3|1
+-- dijkstra q2
+1|2|1
+1|3|2
+1|4|3
+2|1|1
+2|3|1
+2|4|2
+3|1|2
+3|2|1
+3|4|1
+4|1|3
+4|2|2
+4|3|1
+-- dijkstra q3
+1|1|1|0
+2|2|1|1
+3|3|1|2
+4|4|3|3
+5|1|0|6
+-- dijkstra q4
+-- withPoints q1
+-6|-1|1.3
+-6|3|4.3
+-6|6|1.3
+-1|-6|1.3
+-1|3|5.6
+-1|6|2.6
+3|-6|1.7
+3|-1|1.6
+3|6|1
+6|-6|1.3
+6|-1|2.6
+6|3|3
+-- withPoints q2
+-6|-1|1.3
+-6|3|1.7
+-6|6|1.3
+-1|-6|1.3
+-1|3|1.6
+-1|6|2.6
+3|-6|1.7
+3|-1|1.6
+3|6|1
+6|-6|1.3
+6|-1|2.6
+6|3|1
+-- withPoints q3
+1|-6|1.3|0
+2|-1|1.6|1.3
+3|3|1|2.9
+4|6|1.3|3.9
+5|-6|0|5.2
+-- withPoints q4
diff --git a/src/costMatrix/test/doc-pgr_fooDmatrix.test.sql b/src/costMatrix/test/doc-pgr_fooDmatrix.test.sql
new file mode 100644
index 0000000..cacbf7f
--- /dev/null
+++ b/src/costMatrix/test/doc-pgr_fooDmatrix.test.sql
@@ -0,0 +1,51 @@
+BEGIN;
+
+SET client_min_messages TO WARNING;
+\echo -- dijkstra q1
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5)
+);
+\echo -- dijkstra q2
+SELECT * FROM pgr_dijkstraCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+    false
+);
+\echo -- dijkstra q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 5),
+        false
+    )
+    $$,
+    randomize := false
+);
+\echo -- dijkstra q4
+
+-- withPoints
+\echo -- withPoints q1
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6]);
+\echo -- withPoints q2
+SELECT * FROM pgr_withPointsCostMatrix(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+    'SELECT pid, edge_id, fraction from pointsOfInterest',
+    array[-1, 3, 6, -6], directed := false);
+\echo -- withPoints q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 6, -6], directed := false);
+    $$,
+    randomize := false
+);
+\echo -- withPoints q4
+
+ROLLBACK;
diff --git a/src/costMatrix/test/test.conf b/src/costMatrix/test/test.conf
new file mode 100644
index 0000000..f3513c3
--- /dev/null
+++ b/src/costMatrix/test/test.conf
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+
+%main::tests = (
+    'any' => {
+        'comment' => 'newTSP',
+        'data' => [],
+        'tests' => [qw(
+            )],
+        'linux' => [qw(
+            doc-pgr_fooDmatrix
+            )],
+        'macos' => [qw(
+            doc-pgr_fooDmatrix-mac
+            )],
+        'windows' => [qw(
+            doc-pgr_fooDmatrix-windows
+            )],
+        'documentation' => [qw(
+            doc-pgr_fooDmatrix
+            )]
+    },
+    #wi29-tsp qa194-tsp
+#    'vpg-vpgis' => {}, # for version specific tests
+#    '8-1' => {},       # for pg 8.x and postgis 1.x
+#    '9.2-2.1' => {},   # for pg 9.2 and postgis 2.1
+);
+
+1;
diff --git a/src/dijkstra/demo/boost_demo.sql b/src/dijkstra/demo/boost_demo.sql
index 9b7eede..c3f2321 100644
--- a/src/dijkstra/demo/boost_demo.sql
+++ b/src/dijkstra/demo/boost_demo.sql
@@ -72,7 +72,7 @@ UPDATE table1 SET target = table1_vertices.vid
 FROM table1_vertices
 WHERE target_name = name;
 
--- Their output starts with 0 so we substract 1 to the vid
+-- Their output starts with 0 so we subtract 1 to the vid
 -- pgrouting: no paths or 0 length (aka I am there, so no path) are not included
 SELECT end_vid-1, agg_cost FROM pgr_dijkstra(
     'SELECT id, source, target, cost FROM table1',
diff --git a/src/dijkstra/demo/hanoslav_demo.sql b/src/dijkstra/demo/hanoslav_demo.sql
index 235d50c..34b332a 100644
--- a/src/dijkstra/demo/hanoslav_demo.sql
+++ b/src/dijkstra/demo/hanoslav_demo.sql
@@ -78,7 +78,7 @@ INSERT INTO table1 (source, target, cost) VALUES (11, 12, 2145);
 
 SET client_min_messages TO NOTICE;
 
--- Their output starts with 0 so we substract 1 to the vid
+-- Their output starts with 0 so we subtract 1 to the vid
 -- pgrouting: no paths or 0 length (aka I am there, so no path) are not included
 SELECT  name, cost, agg_cost  FROM pgr_dijkstra(
     'SELECT id, source, target, cost FROM table1',
diff --git a/src/dijkstra/doc/CMakeLists.txt b/src/dijkstra/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/dijkstra/doc/dijkstra.rst b/src/dijkstra/doc/dijkstra.rst
index 5fedbd2..ddeeb89 100644
--- a/src/dijkstra/doc/dijkstra.rst
+++ b/src/dijkstra/doc/dijkstra.rst
@@ -9,21 +9,27 @@
 
 .. _dijkstra:
 
-pgr_dijkstra - Shortest Path Dijkstra
+Dijkstra - Family of functions
 ===============================================================================
 
   - :ref:`pgr_dijkstra` - Dijkstra's algorithm for the shortest paths.
-  - :ref:`pgr_dijkstraCost` -Get the aggregate cost of the shortest paths.
+
+The following algorithms are based on pgr_dijkstra
+
+  - :ref:`pgr_dijkstraCost` - Get the aggregate cost of the shortest paths.
+  - :ref:`pgr_drivingDistance` - Get catchament information.
+  - :ref:`pgr_ksp` - Get the aggregate cost of the shortest paths.
 
 
 .. toctree::
-        :hidden:
+    :hidden:
+
+    ./pgr_dijkstra
+    ./pgr_dijkstraCost
 
-        ./pgr_dijkstra
-        ./pgr_dijkstraCost
 
-The problem definition
-======================
+The problem definition (Advanced documentation)
+-----------------------------------------------
 
 
 Given the following query:
diff --git a/src/dijkstra/doc/doc-pgr_dijkstra.queries b/src/dijkstra/doc/doc-pgr_dijkstra.queries
index ce09ec8..9bd3a04 100644
--- a/src/dijkstra/doc/doc-pgr_dijkstra.queries
+++ b/src/dijkstra/doc/doc-pgr_dijkstra.queries
@@ -1,3 +1,7 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO NOTICE;
+SET
 -- q1
 SELECT * FROM pgr_dijkstra(
     'SELECT id, source, target, cost, reverse_cost FROM edge_table',
@@ -535,6 +539,8 @@ SELECT * FROM pgr_dijkstra(
    6 |        6 |         2 |       3 |    3 |   -1 |    0 |        5
 (6 rows)
 
+SET client_min_messages TO NOTICE;
+SET
 SELECT * FROM pgr_dijkstra(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
     2, 3,
@@ -598,6 +604,8 @@ SELECT * FROM pgr_dijkstra(
    2 |        2 |         2 |       3 |    3 |   -1 |    0 |        1
 (2 rows)
 
+SET client_min_messages TO NOTICE;
+SET
 SELECT * FROM pgr_dijkstra(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
     2, 3,
@@ -612,3 +620,5 @@ NOTICE:  Deprecated function
 (2 rows)
 
 -- q18
+ROLLBACK;
+ROLLBACK
diff --git a/src/dijkstra/doc/doc-pgr_dijkstraVia.queries b/src/dijkstra/doc/doc-pgr_dijkstraVia.queries
index 205789d..3dcbdfd 100644
--- a/src/dijkstra/doc/doc-pgr_dijkstraVia.queries
+++ b/src/dijkstra/doc/doc-pgr_dijkstraVia.queries
@@ -27,8 +27,8 @@ SELECT * FROM pgr_dijkstraVia(
    1 |       1 |        1 |         1 |       3 |    1 |    1 |    1 |        0 |              0
    2 |       1 |        2 |         1 |       3 |    2 |    2 |    1 |        1 |              1
    3 |       1 |        3 |         1 |       3 |    3 |   -1 |    0 |        2 |              2
-   4 |       2 |        1 |         3 |       9 |    3 |    3 |    1 |        0 |              2
-   5 |       2 |        2 |         3 |       9 |    4 |   16 |    1 |        1 |              3
+   4 |       2 |        1 |         3 |       9 |    3 |    5 |    1 |        0 |              2
+   5 |       2 |        2 |         3 |       9 |    6 |    9 |    1 |        1 |              3
    6 |       2 |        3 |         3 |       9 |    9 |   -2 |    0 |        2 |              4
 (6 rows)
 
diff --git a/src/dijkstra/doc/pgr_dijkstra.rst b/src/dijkstra/doc/pgr_dijkstra.rst
index d285162..c690894 100644
--- a/src/dijkstra/doc/pgr_dijkstra.rst
+++ b/src/dijkstra/doc/pgr_dijkstra.rst
@@ -30,8 +30,8 @@ a graph with non-negative edge path costs, producing a shortest path from
 a starting vertex (``start_vid``) to an ending vertex (``end_vid``).
 This implementation can be used with a directed graph and an undirected graph.
 
-Characteristics:
-----------------
+Characteristics
+-------------------------------------------------------------------------------
 
 The main Characteristics are:
   - Process is done only on edges with positive costs.
@@ -52,7 +52,7 @@ The main Characteristics are:
     - `start_vid` ascending
     - `end_vid` ascending
 
-  - Runing time: :math:`O(| start\_vids | * (V \log V + E))`
+  - Running time: :math:`O(| start\_vids | * (V \log V + E))`
 
 
 Signature Summary
@@ -71,13 +71,13 @@ Signature Summary
 
 
 Signatures
-===============================================================================
+-------------------------------------------------------------------------------
 
 .. index::
-    single: dijkstra(edges_sql, start_vid, end_vid)
+    single: dijkstra(Minimal Use)
 
 Minimal signature
------------------
+.......................................
 
 .. code-block:: none
 
@@ -94,10 +94,10 @@ The minimal signature is for a **directed** graph from one ``start_vid`` to one
 
 
 .. index::
-    single: dijkstra(edges_sql, start_vid, end_vid, directed:=TRUE)
+    single: dijkstra(One to One)
 
-Dijkstra One to One
--------------------
+pgr_dijkstra One to One
+.......................................
 
 .. code-block:: none
 
@@ -117,10 +117,10 @@ This signature finds the shortest path from one ``start_vid`` to one ``end_vid``
 
 
 .. index::
-    single: dijkstra(edges_sql, start_vid, end_vids, directed:=TRUE)
+    single: dijkstra(One to Many)
 
-Dijkstra One to many
---------------------
+pgr_dijkstra One to many
+.......................................
 
 .. code-block:: none
 
@@ -148,10 +148,10 @@ where the starting vertex is fixed, and stop when all ``end_vids`` are reached.
 
 
 .. index::
-    single: dijkstra(edges_sql, start_vids, end_vid, directed)
+    single: dijkstra(Many to One)
 
-Dijkstra Many to One
---------------------
+pgr_dijkstra Many to One
+.......................................
 
 .. code-block:: none
 
@@ -178,10 +178,10 @@ where the ending vertex is fixed.
 
 
 .. index::
-    single: dijkstra(edges_sql, start_vids, end_vids, directed)
+    single: dijkstra(Many to Many)
 
-Dijkstra Many to Many
----------------------
+pgr_dijkstra Many to Many
+.......................................
 
 .. code-block:: none
 
@@ -208,47 +208,19 @@ The extra ``start_vid`` and ``end_vid`` in the result is used to distinguish to
    :end-before: -- q6
 
 Description of the Signatures
-=============================
-
-Description of the SQL query
 -------------------------------------------------------------------------------
 
-:edges_sql: an SQL query, which should return a set of rows with the following columns:
-
-================  ===================   =================================================
-Column            Type                  Description
-================  ===================   =================================================
-**id**            ``ANY-INTEGER``       Identifier of the edge.
-**source**        ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
-**target**        ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
-**cost**          ``ANY-NUMERICAL``     Weight of the edge `(source, target)`, If negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
-**reverse_cost**  ``ANY-NUMERICAL``     (optional) Weight of the edge `(target, source)`, If negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
-================  ===================   =================================================
-
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
 
-Where:
-
-:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
-:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
-
-
-Description of the parameters of the signatures
--------------------------------------------------------------------------------
-
-============== ====================== =================================================
-Column         Type                   Description
-============== ====================== =================================================
-**sql**        ``TEXT``               SQL query as decribed above.
-**start_vid**  ``BIGINT``             Identifier of the starting vertex of the path.
-**start_vids** ``ARRAY[ANY-INTEGER]`` Array of identifiers of starting vertices.
-**end_vid**    ``BIGINT``             Identifier of the ending vertex of the path.
-**end_vids**   ``ARRAY[ANY-INTEGER]`` Array of identifiers of ending vertices.
-**directed**   ``BOOLEAN``            (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
-============== ====================== =================================================
+.. include:: ../sql/dijkstra.sql
+    :start-after: pgr_dijkstra_parameters_start
+    :end-before: pgr_dijkstra_parameters_end
 
 
 Description of the return values
--------------------------------------------------------------------------------
+...............................................................................
 
 Returns set of ``(seq, path_seq [, start_vid] [, end_vid], node, edge, cost, agg_cost)``
 
@@ -256,7 +228,7 @@ Returns set of ``(seq, path_seq [, start_vid] [, end_vid], node, edge, cost, agg
 Column         Type       Description
 ============== ========== =================================================
 **seq**        ``INT``    Sequential value starting from **1**.
-**path_seq**   ``INT``    Relative position in the path. Has value **1** for the begining of a path.
+**path_seq**   ``INT``    Relative position in the path. Has value **1** for the beginning of a path.
 **start_vid**  ``BIGINT`` Identifier of the starting vertex. Used when multiple starting vetrices are in the query.
 **end_vid**    ``BIGINT`` Identifier of the ending vertex. Used when multiple ending vertices are in the query.
 **node**       ``BIGINT`` Identifier of the node in the path from ``start_vid`` to ``end_vid``.
@@ -266,8 +238,8 @@ Column         Type       Description
 ============== ========== =================================================
 
 
-Examples
-========
+Additional Examples
+--------------------------------------------------------------------------------------
 
 The examples of this section are based on the :ref:`sampledata` network.
 
@@ -275,7 +247,7 @@ The examples include combinations from starting vertices 2 and 11 to ending vert
 undirected graph with and with out reverse_cost.
 
 Examples for queries marked as ``directed`` with ``cost`` and ``reverse_cost`` columns
---------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig1`
 
@@ -286,7 +258,7 @@ The examples in this section use the following :ref:`fig1`
 
 
 Examples for queries marked as ``undirected`` with ``cost`` and ``reverse_cost`` columns
-----------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig2`
 
@@ -296,7 +268,7 @@ The examples in this section use the following :ref:`fig2`
 
 
 Examples for queries marked as ``directed`` with ``cost`` column
-----------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig3`
 
@@ -306,7 +278,7 @@ The examples in this section use the following :ref:`fig3`
 
 
 Examples for queries marked as ``undirected`` with ``cost`` column
-----------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig4`
 
@@ -316,39 +288,42 @@ The examples in this section use the following :ref:`fig4`
 
 
 Equvalences between signatures
-------------------------------
+.........................................................................................
 
-Examples for queries marked as ``directed`` with ``cost`` and ``reverse_cost`` columns
-The examples in this section use the following :ref:`fig1`
+:Examples: For queries marked as ``directed`` with ``cost`` and ``reverse_cost`` columns
+
+The examples in this section use the following:
+
+* :ref:`fig1`
 
 .. literalinclude:: doc-pgr_dijkstra.queries
    :start-after: -- q15
    :end-before: -- q16
 
 
-Equvalences between signatures
-------------------------------
 
-Examples for queries marked as ``undirected`` with ``cost`` and ``reverse_cost`` columns
-The examples in this section use the following :ref:`fig2`
+:Examples: For queries marked as ``undirected`` with ``cost`` and ``reverse_cost`` columns
+
+The examples in this section use the following:
+
+* :ref:`fig2`
 
 .. literalinclude:: doc-pgr_dijkstra.queries
    :start-after: -- q17
    :end-before: -- q18
 
 
-The queries use the :ref:`sampledata` network.
-
 .. rubric:: History
 
-* Renamed in version 2.0.0
 * Added functionality in version 2.1.0
+* Renamed in version 2.0.0
 
 
 See Also
 -------------------------------------------------------------------------------
 
 * http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
+* The queries use the :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
diff --git a/src/dijkstra/doc/pgr_dijkstraCost.rst b/src/dijkstra/doc/pgr_dijkstraCost.rst
index eb37eaa..0533e5d 100644
--- a/src/dijkstra/doc/pgr_dijkstraCost.rst
+++ b/src/dijkstra/doc/pgr_dijkstraCost.rst
@@ -31,8 +31,8 @@ of the shortest path for a subset of pairs of nodes of the graph.
 We make use of the Boost's implementation of dijkstra which runs in
 :math:`O(V \log V + E)` time.
 
-Characteristics:
-----------------
+Characteristics
+-------------------------------------------------------------------------------
 
 The main Characteristics are:
   - It does not return a path.
@@ -53,7 +53,7 @@ The main Characteristics are:
   - Let be the case the values returned are stored in a table, so the unique index would be the pair:
     `(start_vid, end_vid)`.
 
-  - For undirected graphs, the results are symetric.
+  - For undirected graphs, the results are symmetric.
 
     - The  `agg_cost` of `(u, v)` is the same as for `(v, u)`.
 
@@ -64,10 +64,10 @@ The main Characteristics are:
     - `start_vid` ascending
     - `end_vid` ascending
 
-  - Runing time: :math:`O(| start\_vids | * (V \log V + E))`
+  - Running time: :math:`O(| start\_vids | * (V \log V + E))`
 
 Signature Summary
------------------
+-------------------------------------------------------------------------------
 
 .. code-block:: none
 
@@ -82,13 +82,13 @@ Signature Summary
 
 
 Signatures
-===============================================================================
+-------------------------------------------------------------------------------
 
 .. index::
-	single: dijkstraCost(edges_sql, start_vid, end_vid)
+	single: dijkstraCost(Minimal Use)
 
 Minimal signature
------------------
+...............................................................................
 
 The minimal signature is for a **directed** graph from one ``start_vid`` to one ``end_vid``:
 
@@ -107,10 +107,10 @@ The minimal signature is for a **directed** graph from one ``start_vid`` to one
 
 
 .. index::
-	single: dijkstraCost(edges_sql, start_vid, end_vid, directed)
+	single: dijkstraCost(One to One)
 
 pgr_dijkstraCost One to One
---------------------------------
+...............................................................................
 
 
 This signature performs a Dijkstra from one ``start_vid`` to one ``end_vid``:
@@ -123,71 +123,69 @@ This signature performs a Dijkstra from one ``start_vid`` to one ``end_vid``:
 			 BOOLEAN directed:=true);
 	RETURNS SET OF (start_vid, end_vid, agg_cost) or EMPTY SET
 
-.. rubric:: Example
+:Example:
 
 .. literalinclude:: doc-pgr_dijkstraCost.queries
     :start-after: --q2
     :end-before: --q3
 
 
-
 .. index::
-	single: dijkstraCost(edges_sql, start_vids, end_vid, directed)
+    single: dijkstraCost(One to Many)
 
-pgr_dijkstraCost Many to One
---------------------------------
+pgr_dijkstraCost One to Many
+...............................................................................
 
 .. code-block:: none
 
-    pgr_dijkstraCost(TEXT edges_sql, array[ANY_INTEGER] start_vids, BIGINT end_vid,
-			 BOOLEAN directed:=true);
+    pgr_dijkstraCost(TEXT edges_sql, BIGINT start_vid, array[ANY_INTEGER] end_vids,
+	    BOOLEAN directed:=true);
 	RETURNS SET OF (start_vid, end_vid, agg_cost) or EMPTY SET
 
-This signature performs a Dijkstra from each ``start_vid`` in  ``start_vids`` to one ``end_vid``:
+This signature performs a Dijkstra from one ``start_vid`` to each ``end_vid`` in ``end_vids``:
   -  on a **directed** graph when ``directed`` flag is missing or is set to ``true``.
   -  on an **undirected** graph when ``directed`` flag is set to ``false``.
 
 
-.. rubric:: Example
+:Example:
 
 .. literalinclude:: doc-pgr_dijkstraCost.queries
-    :start-after: --q3
-    :end-before: --q4
+   :start-after: --q4
+   :end-before: --q5
 
 
 
 
 .. index::
-    single: dijkstraCost(edges_sql, start_vid, end_vids, directed)
+	single: dijkstraCost(Many to One)
 
-pgr_dijkstraCost One to Many
---------------------------------
+pgr_dijkstraCost Many to One
+...............................................................................
 
 .. code-block:: none
 
-    pgr_dijkstraCost(TEXT edges_sql, BIGINT start_vid, array[ANY_INTEGER] end_vids,
-	    BOOLEAN directed:=true);
+    pgr_dijkstraCost(TEXT edges_sql, array[ANY_INTEGER] start_vids, BIGINT end_vid,
+			 BOOLEAN directed:=true);
 	RETURNS SET OF (start_vid, end_vid, agg_cost) or EMPTY SET
 
-This signature performs a Dijkstra from one ``start_vid`` to each ``end_vid`` in ``end_vids``:
+This signature performs a Dijkstra from each ``start_vid`` in  ``start_vids`` to one ``end_vid``:
   -  on a **directed** graph when ``directed`` flag is missing or is set to ``true``.
   -  on an **undirected** graph when ``directed`` flag is set to ``false``.
 
 
-.. rubric:: Example
+:Example:
 
 .. literalinclude:: doc-pgr_dijkstraCost.queries
-   :start-after: --q4
-   :end-before: --q5
-
-
+    :start-after: --q3
+    :end-before: --q4
 
 
 
 .. index::
-	single: dijkstraCost(edges_sql, start_vids, end_vids, directed)
+	single: dijkstraCost(Many to Many)
 
-.. rubric:: pgr_dijkstraCost Many to Many
+pgr_dijkstraCost Many to Many
+...............................................................................
 
 .. code-block:: none
 
@@ -199,8 +197,7 @@ This signature performs a Dijkstra from each ``start_vid`` in  ``start_vids`` to
   -  on a **directed** graph when ``directed`` flag is missing or is set to ``true``.
   -  on an **undirected** graph when ``directed`` flag is set to ``false``.
 
-Example
--------
+:Example:
 
 .. literalinclude:: doc-pgr_dijkstraCost.queries
    :start-after: --q5
@@ -209,47 +206,20 @@ Example
 
 
 Description of the Signatures
-=============================
-
-Description of the edge's SQL query
------------------------------------
-
-:edges_sql: is a ``TEXT`` that containes an SQL query, which should return a set of rows with the following columns:
-
-================  ===================   =================================================
-Column            Type                      Description
-================  ===================   =================================================
-**id**            ``ANY-INTEGER``       Identifier of the edge.
-**source**        ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
-**target**        ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
-**cost**          ``ANY-NUMERICAL``     Weight of the edge `(source, target)`, if negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
-**reverse_cost**  ``ANY-NUMERICAL``     (optional) Weight of the edge `(target, source)`, if negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
-================  ===================   =================================================
-
-
-Where:
-
-:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
-:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, real, float
+-------------------------------------------------------------------------------
 
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
 
-Description of the parameters of the signatures
--------------------------------------------------------------------------------
+.. include:: ../sql/dijkstra.sql
+    :start-after: pgr_dijkstra_parameters_start
+    :end-before: pgr_dijkstra_parameters_end
 
-================  ====================== =================================================
-Column            Type                   Description
-================  ====================== =================================================
-**edges_sql**           ``TEXT``               SQL query as decribed above.
-**start_vid**     ``BIGINT``             Identifier of the starting vertex of the path.
-**end_vid**       ``BIGINT``             Identifier of the ending vertex of the path.
-**start_vids**    ``array[ANY-INTEGER]`` Array of identifiers of starting vertices.
-**end_vids**      ``array[ANY-INTEGER]`` Array of identifiers of ending vertices.
-**directed**      ``BOOLEAN``            (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
-================  ====================== =================================================
 
 
 Description of the return values
--------------------------------------------------------------------------------
+...............................................................................
 
 Returns set of ``(start_vid, end_vid, agg_cost)``
 
@@ -262,28 +232,22 @@ Column        Type          Description
 ============= ============= =================================================
 
 
-Examples
-========
-
-:Example 1:
+Additional Examples
+-------------------------------------------------------------------------------
 
-Repeated values are ignored, and arrays are sorted
+:Example 1: Demonstration of repeated values are ignored, and result is sorted.
 
 .. literalinclude:: doc-pgr_dijkstraCost.queries
     :start-after: --q6
     :end-before: --q7
 
-:Example 2:
-
-`start_vids` are the same as `end_vids`
+:Example 2: Making `start_vids` the same as `end_vids`
 
 .. literalinclude:: doc-pgr_dijkstraCost.queries
     :start-after: --q7
     :end-before: --q8
 
 
-The queries use the :ref:`sampledata` network.
-
 .. rubric:: History
 
 * New in version  2.2.0
@@ -293,6 +257,7 @@ See Also
 -------------------------------------------------------------------------------
 
 * http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
+* :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
diff --git a/src/dijkstra/doc/pgr_dijkstraVia.rst b/src/dijkstra/doc/pgr_dijkstraVia.rst
index 3bfa3ec..e8480fe 100644
--- a/src/dijkstra/doc/pgr_dijkstraVia.rst
+++ b/src/dijkstra/doc/pgr_dijkstraVia.rst
@@ -1,4 +1,4 @@
-.. 
+..
    ****************************************************************************
     pgRouting Manual
     Copyright(c) pgRouting Contributors
@@ -9,7 +9,7 @@
 
 .. _pgr_dijkstraVia:
 
-pgr_dijkstraVia
+pgr_dijkstraVia - Proposed
 ===============================================================================
 
 
@@ -24,36 +24,37 @@ a list of vertices.
    :target: http://www.boost.org/libs/graph
 
    Boost Graph Inside
-   
+
 
 Synopsis
 -------------------------------------------------------------------------------
 
 Given a list of vertices and a graph, this function is equivalent to finding the
 shortest path between :math:`vertex_i` and :math:`vertex_{i+1}` for all :math:`i < size\_of(vertex_via)`.
+
 The paths represents the sections of the route.
 
-.. note:: This is a proposed function for version 2.3
+.. note:: This is a proposed function
 
 Signatrue Summary
------------------
+-------------------------------------------------------------------------------
 
 .. code-block:: none
 
     pgr_dijkstraVia(edges_sql, via_vertices)
-    pgr_dijkstraVia(edges_sql, via_vertices, directed:=true, strict:=false, U_turn_on_edge:=true)
+    pgr_dijkstraVia(edges_sql, via_vertices, directed, strict, U_turn_on_edge)
 
     RETURNS SET OF (seq, path_pid, path_seq, start_vid, end_vid,
         node, edge, cost, agg_cost, route_agg_cost) or EMPTY SET
 
 Signatures
-===============================================================================
+-------------------------------------------------------------------------------
 
-.. index:: 
-    single: dijkstraVia(edges_sql, via_vertices) -proposed
+.. index::
+    single: dijkstraVia(Minimal Use) - proposed
 
 Minimal Signature
----------------------------------
+...............................................................................
 
 .. code-block:: none
 
@@ -67,15 +68,15 @@ Minimal Signature
     :start-after: --q00
     :end-before: -- q0
 
-.. index:: 
-    single: dijkstraVia(edges_sql, via_vertices, strict:=false, U_turn_on_edge:=true, directed:=true) -proposed
+.. index::
+    single: dijkstraVia(Full signature) - proposed
 
 Complete Signature
-------------------
+...............................................................................
 
 .. code-block:: none
 
-    pgr_dijkstraVia(edges_sql, via_vertices, directed:=true, strict:=false, U_turn_on_edge:=true)
+    pgr_dijkstraVia(edges_sql, via_vertices, directed, strict, U_turn_on_edge)
     RETURNS SET OF (seq, path_pid, path_seq, start_vid, end_vid,
         node, edge, cost, agg_cost, route_agg_cost) or EMPTY SET
 
@@ -88,37 +89,23 @@ Complete Signature
 
 
 Description of the Signature
-============================
-
-Description of the SQL query
 -------------------------------------------------------------------------------
 
-:edges_sql: is an SQL query, which should return a set of rows with the following columns:
-
-================  ===================   =================================================
-Column            Type                      Description
-================  ===================   =================================================
-**source**        ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
-**target**        ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
-**cost**          ``ANY-NUMERICAL``     Weight of the edge `(source, target)`, if negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
-**reverse_cost**  ``ANY-NUMERICAL``     (optional) Weight of the edge `(target, source)`, if negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
-================  ===================   =================================================
-
-Where:
-
-:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
-:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
 
+.. include:: ../sql/dijkstraVia.sql
+    :start-after: pgr_dijkstra_via_parameters_start
+    :end-before: pgr_dijkstra_via_parameters_end
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
-
-Recives  ``(edges_sql, via_vertices, directed:=true, strict:=false, U_turn_on_edge:=true)``
+...............................................................................
 
 =================== ====================== =================================================
 Parameter           Type                   Description
 =================== ====================== =================================================
-**edges_sql**       ``TEXT``               SQL query as decribed above.
+**edges_sql**       ``TEXT``               SQL query as described above.
 **via_vertices**    ``ARRAY[ANY-INTEGER]`` Array of vertices identifiers
 **directed**        ``BOOLEAN``            (optional) Default is true (is directed). When set to false the graph is considered as Undirected
 **strict**          ``BOOLEAN``            (optional) ignores if a subsection of the route is missing and returns everything it found Default is true (is directed). When set to false the graph is considered as Undirected
@@ -127,7 +114,7 @@ Parameter           Type                   Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+...............................................................................
 
 Returns set of ``(start_vid, end_vid, agg_cost)``
 
@@ -148,7 +135,7 @@ Column             Type          Description
 
 
 Examples
-========
+-------------------------------------------------------------------------------
 
 :Example 1: Find the route that visits the vertices 1 5 3 9 4 in that order
 
@@ -186,18 +173,11 @@ Examples
     :start-after: -- q6
 
 
-
-The queries use the :ref:`sampledata` network.
-
-.. rubric:: History
-
-* Proposed in version 2.2
-
-
 See Also
 -------------------------------------------------------------------------------
 
 * http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
+* :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
diff --git a/src/dijkstra/doc/pgr_dijkstra_v2.rst b/src/dijkstra/doc/pgr_dijkstra_v2.rst
index c8f0e1e..c136224 100644
--- a/src/dijkstra/doc/pgr_dijkstra_v2.rst
+++ b/src/dijkstra/doc/pgr_dijkstra_v2.rst
@@ -9,18 +9,21 @@
 
 .. _pgr_dijkstra_v2:
 
-pgr_dijkstra (V 2.0)- Shortest Path Dijkstra
+pgr_dijkstra - Deprecated Signature
 ===============================================================================
 
+.. warning:: This function signature is deprecated!!!
+
+    * That means it has been replaced by new signature(s)
+    * This signature is no longer supported, and may be removed from future versions.
+    * All code that use this function signature should be converted to use its replacement :ref:`pgr_dijkstra` (One to One).
+
 Name
 -------------------------------------------------------------------------------
 
 ``pgr_dijkstra`` — Returns the shortest path using Dijkstra algorithm.
 
 
-.. index::
-	single: dijkstra(sql, source, target, directed, has_rcost) -- deprecated
-
 Synopsis
 -------------------------------------------------------------------------------
 
@@ -31,13 +34,6 @@ Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1
 	pgr_costResult[] pgr_dijkstra(text sql, integer source, integer target,
 	                           boolean directed, boolean has_rcost);
 
-.. warning:: This signature is being deprecated in version 2.1, Please use it
-             without the ``has_rcost`` flag instead:
-
-             ``pgr_dijkstra(sql, source, target, directed)``
-
-             See :ref:`pgr_dijkstra`
-
 Description
 -------------------------------------------------------------------------------
 
@@ -112,5 +108,6 @@ The queries use the :ref:`sampledata` network.
 See Also
 -------------------------------------------------------------------------------
 
+* :ref:`dijkstra`, :ref:`pgr_dijkstra`
 * :ref:`type_cost_result`
 * http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
diff --git a/src/dijkstra/sql/dijkstra.sql b/src/dijkstra/sql/dijkstra.sql
index 33eb9ff..bfe4bc9 100644
--- a/src/dijkstra/sql/dijkstra.sql
+++ b/src/dijkstra/sql/dijkstra.sql
@@ -24,6 +24,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+/* ********** FOR USERS DOCUMENTATION
+
+The following applies to:
+    pgr_dijkstra
+    pgr_dijkstraCost
+    pgr_dijkstraCostMatrix
+
+pgr_dijkstra_parameters_start
+
+Description of the parameters of the signatures
+...............................................................................
+
+============== ================== ======== =================================================
+Column         Type               Default     Description
+============== ================== ======== =================================================
+**sql**        ``TEXT``                    SQL query as described above.
+**start_vid**  ``BIGINT``                  Identifier of the starting vertex of the path.
+**start_vids** ``ARRAY[BIGINT]``           Array of identifiers of starting vertices.
+**end_vid**    ``BIGINT``                  Identifier of the ending vertex of the path.
+**end_vids**   ``ARRAY[BIGINT]``           Array of identifiers of ending vertices.
+**directed**   ``BOOLEAN``        ``true`` - When ``true`` Graph is considered `Directed`
+                                           - When ``false`` the graph is considered as `Undirected`.
+============== ================== ======== =================================================
+
+pgr_dijkstra_parameters_end
+
+*/
 
 CREATE OR REPLACE FUNCTION _pgr_dijkstra(edges_sql TEXT, start_vid BIGINT, end_vid BIGINT, directed BOOLEAN,
     only_cost BOOLEAN DEFAULT false,
@@ -135,6 +162,7 @@ ROWS 1000;
 
 --     DIJKSTRA
 
+
 /***********************************
         ONE TO MANY
 ***********************************/
diff --git a/src/dijkstra/sql/dijkstraVia.sql b/src/dijkstra/sql/dijkstraVia.sql
index f18a54b..8ab1076 100644
--- a/src/dijkstra/sql/dijkstraVia.sql
+++ b/src/dijkstra/sql/dijkstraVia.sql
@@ -25,6 +25,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+/* ******** FOR USERS DOCUMENTATION
+
+pgr_dijkstra_via_parameters_start
+
+Description of the parameters of the signatures
+...............................................................................
+
+=================== ====================== ========= =========================================
+Parameter           Type                   Default   Description
+=================== ====================== ========= =========================================
+**edges_sql**       ``TEXT``                         SQL query as described above.
+**via_vertices**    ``ARRAY[ANY-INTEGER]``           Array of ordered vertices identifiers that are going to be visited.
+**directed**        ``BOOLEAN``            ``true``  - When ``true`` Graph is considered `Directed`
+                                                     - When ``false`` the graph is considered as Undirected.
+**strict**          ``BOOLEAN``            ``false`` - When ``false`` ignores missing paths returning all paths found
+                                                     - When ``true`` if a path is missing stops and returns `EMPTY SET`
+**U_turn_on_edge**  ``BOOLEAN``            ``true``  - When ``true`` departing from a visited vertex will not try to avoid using the edge used to reach it.  In other words, U turn using the edge with same `id` is allowed.
+                                                     - When ``false`` when a departing from a visited vertex tries to avoid using the edge used to reach it.  In other words, U turn using the edge with same `id` is used when no other path is found.
+=================== ====================== ========= =========================================
+
+pgr_dijkstra_via_parameters_end
+
+*/
+
+
 CREATE OR REPLACE FUNCTION pgr_dijkstraVia(
     edges_sql TEXT,
     via_vertices ANYARRAY,
diff --git a/src/dijkstra/src/dijkstraVia.c b/src/dijkstra/src/dijkstraVia.c
index 7cd375e..df048d9 100644
--- a/src/dijkstra/src/dijkstraVia.c
+++ b/src/dijkstra/src/dijkstraVia.c
@@ -48,13 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/arrays_input.h"
 #include "./dijkstraVia_driver.h"
 
-PG_FUNCTION_INFO_V1(dijkstraVia);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-dijkstraVia(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum dijkstraVia(PG_FUNCTION_ARGS);
 
 /*******************************************************************************/
 /*                          MODIFY AS NEEDED                                   */
@@ -75,7 +69,7 @@ process( char* edges_sql,
     edges = NULL;
     size_t total_tuples;
     total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -116,11 +110,8 @@ process( char* edges_sql,
 /*                                                                             */
 /*******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(dijkstraVia);
 PGDLLEXPORT Datum
-#endif
 dijkstraVia(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t               call_cntr;
diff --git a/src/dijkstra/src/dijkstraVia_driver.cpp b/src/dijkstra/src/dijkstraVia_driver.cpp
index 26b01aa..0af2721 100644
--- a/src/dijkstra/src/dijkstraVia_driver.cpp
+++ b/src/dijkstra/src/dijkstraVia_driver.cpp
@@ -26,24 +26,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
-
 #include <sstream>
 #include <deque>
 #include <vector>
 #include "./pgr_dijkstra.hpp"
 #include "./dijkstraVia_driver.h"
-#include "./../../common/src/memory_func.hpp"
+#include "./../../common/src/pgr_alloc.hpp"
 
-// #define DEBUG
 
-extern "C" {
 #include "./../../common/src/pgr_types.h"
-}
 
 
 template <class G>
@@ -53,9 +49,8 @@ pgr_dijkstraViaVertex(
         const std::vector< int64_t > via_vertices,
         std::deque< Path > &paths,
         bool strict,
-        bool U_turn_on_edge,  //! true = u turns are allowed between paths
-        std::ostringstream &log) {    
-
+        bool U_turn_on_edge,
+        std::ostringstream &log) {
     if (via_vertices.size() == 0) {
         return;
     }
@@ -63,8 +58,7 @@ pgr_dijkstraViaVertex(
     paths.clear();
     int64_t prev_vertex = via_vertices[0];
     Path path;
-    
-    //for (size_t i = 0; i < via_vertices.size() - 1; ++i) {
+
     int64_t i = 0;
     for (const auto &vertex : via_vertices) {
         if (i == 0) {
@@ -74,14 +68,12 @@ pgr_dijkstraViaVertex(
 
         // Delete uTurn edges only valid for paths that are not the first path
         if (!U_turn_on_edge && i > 1) {
-
             // we can only delete if there is was a path, that is at least one edge size
             if (path.size() > 1) {
                 // Delete from the graph the last edge if its outgoing also
                 // edge to be removed = second to last edge path[i].edge;
                 int64_t edge_to_be_removed = path[path.size() - 2].edge;
                 int64_t last_vertex_of_path = prev_vertex;
-               // path.path[path.path.size() - 1].vertex;
 
                 // and the current vertex is not a dead end
                 if (graph.out_degree(last_vertex_of_path) > 1) {
@@ -99,7 +91,7 @@ pgr_dijkstraViaVertex(
 
         if (!U_turn_on_edge && i > 1) {
             graph.restore_graph();
-            if (path.empty()) { 
+            if (path.empty()) {
                 /*
                  *  no path was found with the deleted edge
                  *  try with the edge back in the graph
@@ -132,7 +124,6 @@ get_path(
         double &route_cost,
         size_t &sequence) {
     int i = 0;
-    //for (size_t i = 0; i < path.size(); i++) {
     for (const auto e : path) {
         (*postgres_data)[sequence] = {
             route_id,
@@ -157,9 +148,9 @@ size_t
 get_route(
         Routes_t **ret_path,
         const std::deque< Path > &paths) {
-    size_t sequence = 0;    //arrys index
-    int path_id = 1;    // id's in posgresql start with 1
-    int route_id = 1;   
+    size_t sequence = 0;
+    int path_id = 1;
+    int route_id = 1;
     double route_cost = 0;  // routes_agg_cost
     for (const Path &path : paths) {
         if (path.size() > 0)
@@ -178,10 +169,9 @@ do_pgr_dijkstraViaVertex(
         bool strict,
         bool U_turn_on_edge,
         Routes_t **return_tuples,   size_t *return_count,
-        char ** err_msg){
+        char ** err_msg) {
     std::ostringstream log;
     try {
-
         if (total_tuples == 1) {
             log << "Required: more than one tuple\n";
             (*return_tuples) = NULL;
@@ -191,7 +181,6 @@ do_pgr_dijkstraViaVertex(
         }
 
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_tuples;
 
         std::deque< Path >paths;
         log << "Inserting vertices into a c++ vector structure\n";
@@ -199,12 +188,12 @@ do_pgr_dijkstraViaVertex(
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(data_edges, total_tuples);
             pgr_dijkstraViaVertex(digraph, via_vertices, paths, strict, U_turn_on_edge, log);
         } else {
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(data_edges, total_tuples);
             pgr_dijkstraViaVertex(undigraph, via_vertices, paths, strict, U_turn_on_edge, log);
         }
@@ -214,14 +203,14 @@ do_pgr_dijkstraViaVertex(
         if (count == 0) {
             (*return_tuples) = NULL;
             (*return_count) = 0;
-            log << 
-                "No paths found between Starting and any of the Ending vertices\n";
+            log <<
+                "No paths found\n";
             *err_msg = strdup(log.str().c_str());
             return;
         }
 
         // get the space required to store all the paths
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         log << "Converting a set of paths into the tuples\n";
         (*return_count) = (get_route(return_tuples, paths));
         (*return_tuples)[count - 1].edge = -2;
@@ -232,7 +221,7 @@ do_pgr_dijkstraViaVertex(
         *err_msg = strdup(log.str().c_str());
 #endif
     } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+        log << "Caught unknown exception!\n";
         *err_msg = strdup(log.str().c_str());
     }
 }
diff --git a/src/dijkstra/src/many_to_many_dijkstra.c b/src/dijkstra/src/many_to_many_dijkstra.c
index 09503d8..229434d 100644
--- a/src/dijkstra/src/many_to_many_dijkstra.c
+++ b/src/dijkstra/src/many_to_many_dijkstra.c
@@ -52,13 +52,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/arrays_input.h"
 #include "./many_to_many_dijkstra_driver.h"
 
-PG_FUNCTION_INFO_V1(many_to_many_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-many_to_many_dijkstra(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum many_to_many_dijkstra(PG_FUNCTION_ARGS);
 
 
 /******************************************************************************/
@@ -78,7 +72,7 @@ process(
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -116,11 +110,8 @@ process(
 /*                                                                           */
 /*****************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(many_to_many_dijkstra);
 PGDLLEXPORT Datum
-#endif
 many_to_many_dijkstra(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
@@ -154,13 +145,13 @@ many_to_many_dijkstra(PG_FUNCTION_ARGS) {
         size_t size_start_vidsArr;
         start_vidsArr = (int64_t*)
             pgr_get_bigIntArray(&size_start_vidsArr, PG_GETARG_ARRAYTYPE_P(1));
-        PGR_DBG("start_vidsArr size %d ", size_start_vidsArr);
+        PGR_DBG("start_vidsArr size %ld ", size_start_vidsArr);
 
         int64_t* end_vidsArr;
         size_t size_end_vidsArr;
         end_vidsArr = (int64_t*)
             pgr_get_bigIntArray(&size_end_vidsArr, PG_GETARG_ARRAYTYPE_P(2));
-        PGR_DBG("end_vidsArr size %d ", size_end_vidsArr);
+        PGR_DBG("end_vidsArr size %ld ", size_end_vidsArr);
 
         PGR_DBG("Calling process");
         process(
diff --git a/src/dijkstra/src/many_to_many_dijkstra_driver.cpp b/src/dijkstra/src/many_to_many_dijkstra_driver.cpp
index 750af3d..0db5d04 100644
--- a/src/dijkstra/src/many_to_many_dijkstra_driver.cpp
+++ b/src/dijkstra/src/many_to_many_dijkstra_driver.cpp
@@ -27,12 +27,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
-
 #include <sstream>
 #include <deque>
 #include <vector>
@@ -40,13 +39,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./pgr_dijkstra.hpp"
 #include "./many_to_many_dijkstra_driver.h"
 
-// #define DEBUG
-
-#include "../../common/src/memory_func.hpp"
-
-extern "C" {
+#include "../../common/src/pgr_alloc.hpp"
 #include "./../../common/src/pgr_types.h"
-}
 
 // CREATE OR REPLACE FUNCTION pgr_dijkstra(
 // sql text,
@@ -69,7 +63,6 @@ do_pgr_many_to_many_dijkstra(
     std::ostringstream log;
     try {
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_tuples;
 
         std::deque< Path >paths;
         log << "Inserting vertices into a c++ vector structure\n";
@@ -82,12 +75,12 @@ do_pgr_many_to_many_dijkstra(
         std::vector< int64_t > end_vertices(s_end_vertices.begin(), s_end_vertices.end());
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(data_edges, total_tuples);
             pgr_dijkstra(digraph, paths, start_vertices, end_vertices, only_cost);
         } else {
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(data_edges, total_tuples);
             pgr_dijkstra(undigraph, paths, start_vertices, end_vertices, only_cost);
         }
@@ -106,7 +99,7 @@ do_pgr_many_to_many_dijkstra(
             return;
         }
 
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         log << "Converting a set of paths into the tuples\n";
         (*return_count) = (collapse_paths(return_tuples, paths));
 
@@ -119,7 +112,7 @@ do_pgr_many_to_many_dijkstra(
 
         return;
     } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+        log << "Caught unknown exception!\n";
         *err_msg = strdup(log.str().c_str());
         return;
     }
diff --git a/src/dijkstra/src/many_to_one_dijkstra.c b/src/dijkstra/src/many_to_one_dijkstra.c
index 161b292..7ee3dd7 100644
--- a/src/dijkstra/src/many_to_one_dijkstra.c
+++ b/src/dijkstra/src/many_to_one_dijkstra.c
@@ -44,6 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 // #define DEBUG
 
 #include "fmgr.h"
+
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
@@ -52,13 +53,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/arrays_input.h"
 #include "./many_to_one_dijkstra_driver.h"
 
-PG_FUNCTION_INFO_V1(many_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-many_to_one_dijkstra(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum many_to_one_dijkstra(PG_FUNCTION_ARGS);
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
@@ -77,7 +72,7 @@ process(
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -115,11 +110,8 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(many_to_one_dijkstra);
 PGDLLEXPORT Datum
-#endif
 many_to_one_dijkstra(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
diff --git a/src/dijkstra/src/many_to_one_dijkstra_driver.cpp b/src/dijkstra/src/many_to_one_dijkstra_driver.cpp
index 76ec49c..7bd5243 100644
--- a/src/dijkstra/src/many_to_one_dijkstra_driver.cpp
+++ b/src/dijkstra/src/many_to_one_dijkstra_driver.cpp
@@ -29,24 +29,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
-
 #include <sstream>
 #include <deque>
 #include <vector>
+#include <set>
 #include "./pgr_dijkstra.hpp"
 #include "./many_to_one_dijkstra_driver.h"
 
-// #define DEBUG
-
-#include "../../common/src/memory_func.hpp"
-extern "C" {
+#include "../../common/src/pgr_alloc.hpp"
 #include "./../../common/src/pgr_types.h"
-}
 
 // CREATE OR REPLACE FUNCTION pgr_dijkstra(
 // sql text,
@@ -68,7 +64,6 @@ do_pgr_many_to_one_dijkstra(
     std::ostringstream log;
     try {
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_tuples;
 
         std::deque< Path >paths;
         log << "Inserting vertices into a c++ vector structure\n";
@@ -77,12 +72,12 @@ do_pgr_many_to_one_dijkstra(
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(data_edges, total_tuples);
             pgr_dijkstra(digraph, paths, start_vertices, end_vid, only_cost);
         } else {
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(data_edges, total_tuples);
             pgr_dijkstra(undigraph, paths, start_vertices, end_vid, only_cost);
         }
@@ -101,7 +96,7 @@ do_pgr_many_to_one_dijkstra(
             return;
         }
 
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         log << "Converting a set of paths into the tuples\n";
         (*return_count) = (collapse_paths(return_tuples, paths));
 
@@ -114,7 +109,7 @@ do_pgr_many_to_one_dijkstra(
 
         return;
     } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+        log << "Caught unknown exception!\n";
         *err_msg = strdup(log.str().c_str());
         return;
     }
diff --git a/src/dijkstra/src/one_to_many_dijkstra.c b/src/dijkstra/src/one_to_many_dijkstra.c
index 496f333..083c856 100644
--- a/src/dijkstra/src/one_to_many_dijkstra.c
+++ b/src/dijkstra/src/one_to_many_dijkstra.c
@@ -51,13 +51,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/arrays_input.h"
 #include "./one_to_many_dijkstra_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_many_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-one_to_many_dijkstra(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum one_to_many_dijkstra(PG_FUNCTION_ARGS);
 
 
 /******************************************************************************/
@@ -78,7 +72,7 @@ process(
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -115,11 +109,8 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(one_to_many_dijkstra);
 PGDLLEXPORT Datum
-#endif
 one_to_many_dijkstra(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
diff --git a/src/dijkstra/src/one_to_many_dijkstra_driver.cpp b/src/dijkstra/src/one_to_many_dijkstra_driver.cpp
index 153247d..f654aef 100644
--- a/src/dijkstra/src/one_to_many_dijkstra_driver.cpp
+++ b/src/dijkstra/src/one_to_many_dijkstra_driver.cpp
@@ -27,23 +27,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
-
 #include <sstream>
 #include <deque>
 #include <vector>
+#include <set>
 #include "./pgr_dijkstra.hpp"
 #include "./one_to_many_dijkstra_driver.h"
 
-// #define DEBUG
-#include "../../common/src/memory_func.hpp"
-extern "C" {
+#include "../../common/src/pgr_alloc.hpp"
 #include "./../../common/src/pgr_types.h"
-}
 
 // CREATE OR REPLACE FUNCTION pgr_dijkstra(sql text, start_vid bigint, end_vids anyarray, directed boolean default true,
 void
@@ -61,7 +58,6 @@ do_pgr_one_to_many_dijkstra(
   std::ostringstream log;
   try {
     graphType gType = directed? DIRECTED: UNDIRECTED;
-    const auto initial_size = total_tuples;
 
     std::deque< Path >paths;
     log << "Inserting vertices into a c++ vector structure\n";
@@ -71,12 +67,12 @@ do_pgr_one_to_many_dijkstra(
 
     if (directed) {
         log << "Working with directed Graph\n";
-        Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+        pgrouting::DirectedGraph digraph(gType);
         digraph.graph_insert_data(data_edges, total_tuples);
         pgr_dijkstra(digraph, paths, start_vid, end_vertices, only_cost);
     } else {
         log << "Working with Undirected Graph\n";
-        Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+        pgrouting::UndirectedGraph undigraph(gType);
         undigraph.graph_insert_data(data_edges, total_tuples);
         pgr_dijkstra(undigraph, paths, start_vid, end_vertices, only_cost);
     }
@@ -94,7 +90,7 @@ do_pgr_one_to_many_dijkstra(
         return;
     }
 
-    (*return_tuples) = get_memory(count, (*return_tuples));
+    (*return_tuples) = pgr_alloc(count, (*return_tuples));
     log << "Converting a set of paths into the tuples\n";
     (*return_count) = (collapse_paths(return_tuples, paths));
 
@@ -106,8 +102,8 @@ do_pgr_one_to_many_dijkstra(
 
     return;
   } catch ( ... ) {
-      log << "Caught unknown expection!\n";
-      *err_msg = strdup("Caught unknown expection!\n");
+      log << "Caught unknown exception!\n";
+      *err_msg = strdup("Caught unknown exception!\n");
       return;
   }
 }
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/dijkstra/src/one_to_one_dijkstra.c
index d099701..6667571 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/dijkstra/src/one_to_one_dijkstra.c
@@ -36,10 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "access/htup_details.h"
 #endif
 
-/*
-  Uncomment when needed
-*/
-// #define DEBUG
 
 #include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
@@ -51,13 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 PG_MODULE_MAGIC;
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum one_to_one_dijkstra(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
@@ -84,7 +74,7 @@ process(
     }
 
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -120,11 +110,8 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
 PGDLLEXPORT Datum
-#endif
 one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
diff --git a/src/dijkstra/src/one_to_one_dijkstra_driver.cpp b/src/dijkstra/src/one_to_one_dijkstra_driver.cpp
index df1ae8d..2fb8e48 100644
--- a/src/dijkstra/src/one_to_one_dijkstra_driver.cpp
+++ b/src/dijkstra/src/one_to_one_dijkstra_driver.cpp
@@ -27,24 +27,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
-
 #include <sstream>
 #include <deque>
 #include <vector>
 #include "./pgr_dijkstra.hpp"
 #include "./one_to_one_dijkstra_driver.h"
 
-//#define DEBUG
 
-#include "../../common/src/memory_func.hpp"
-extern "C" {
+#include "../../common/src/pgr_alloc.hpp"
 #include "./../../common/src/pgr_types.h"
-}
 
 // CREATE OR REPLACE FUNCTION pgr_dijkstra(
 // sql text,
@@ -66,18 +62,17 @@ do_pgr_one_to_one_dijkstra(
   std::ostringstream log;
   try {
       graphType gType = directed? DIRECTED: UNDIRECTED;
-      const auto initial_size = total_tuples;
 
       Path path;
 
       if (directed) {
           log << "Working with directed Graph\n";
-          Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+          pgrouting::DirectedGraph digraph(gType);
           digraph.graph_insert_data(data_edges, total_tuples);
           pgr_dijkstra(digraph, path, start_vid, end_vid, only_cost);
       } else {
           log << "Working with Undirected Graph\n";
-          Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+          pgrouting::UndirectedGraph undigraph(gType);
           undigraph.graph_insert_data(data_edges, total_tuples);
           pgr_dijkstra(undigraph, path, start_vid, end_vid, only_cost);
       }
@@ -95,7 +90,7 @@ do_pgr_one_to_one_dijkstra(
           return;
       }
 
-      (*return_tuples) = get_memory(count, (*return_tuples));
+      (*return_tuples) = pgr_alloc(count, (*return_tuples));
       size_t sequence = 0;
       path.generate_postgres_data(return_tuples, sequence);
       (*return_count) = sequence;
@@ -108,7 +103,7 @@ do_pgr_one_to_one_dijkstra(
 
       return;
   } catch ( ... ) {
-      log << "Caught unknown expection!\n";
+      log << "Caught unknown exception!\n";
       *err_msg = strdup(log.str().c_str());
       return;
   }
diff --git a/src/dijkstra/src/pgr_dijkstra.hpp b/src/dijkstra/src/pgr_dijkstra.hpp
index 61dcbef..b07f2bd 100644
--- a/src/dijkstra/src/pgr_dijkstra.hpp
+++ b/src/dijkstra/src/pgr_dijkstra.hpp
@@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #pragma once
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #ifdef unlink
@@ -45,7 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <boost/graph/dijkstra_shortest_paths.hpp>
 
 #include "./../../common/src/basePath_SSEC.hpp"
-#include "./../../common/src/baseGraph.hpp"
+#include "./../../common/src/pgr_base_graph.hpp"
 #if 0
 #include "./../../common/src/signalhandler.h"
 #endif
@@ -245,7 +245,7 @@ class Pgr_dijkstra {
              std::vector< V > &targets) const;
 
 
-     //! @name Variables
+     //! @name members;
      //@{
      struct found_goals{};  //!< exception for termination
      std::vector< V > predecessors;
@@ -389,7 +389,7 @@ Pgr_dijkstra< G >::get_path(
         return;
     }
 
-    // findout how large is the path
+    // find out how large is the path
     int64_t result_size = 1;
     while (target != source) {
         if (target == predecessors[target]) break;
@@ -509,8 +509,7 @@ Pgr_dijkstra< G >::drivingDistance(
     distances.resize(graph.num_vertices());
 
     // get source;
-    V v_source;
-    if (!graph.get_gVertex(start_vertex, v_source)) {
+    if (!graph.has_vertex(start_vertex)) {
         /* The node has to be in the path*/
         Path p(start_vertex, start_vertex);
         p.push_back({start_vertex, -1, 0, 0});
@@ -518,6 +517,7 @@ Pgr_dijkstra< G >::drivingDistance(
         return;
     }
 
+    auto v_source(graph.get_V(start_vertex));;
     dijkstra_1_to_distance(graph, v_source, distance); 
     get_nodesInDistance(graph, path, v_source, distance);
     std::sort(path.begin(), path.end(),
@@ -544,16 +544,17 @@ Pgr_dijkstra< G >::dijkstra(
     predecessors.resize(graph.num_vertices());
     distances.resize(graph.num_vertices());
 
-    // get the graphs source and target
-    V v_source;
-    V v_target;
 
-    if (!graph.get_gVertex(start_vertex, v_source)
-            || !graph.get_gVertex(end_vertex, v_target)) {
+    if (!graph.has_vertex(start_vertex)
+            || !graph.has_vertex(end_vertex)) {
         path.clear();
         return;
     }
 
+    // get the graphs source and target
+    auto v_source(graph.get_V(start_vertex));
+    auto v_target(graph.get_V(end_vertex));
+
     // perform the algorithm
     dijkstra_1_to_1(graph, v_source, v_target);
 
@@ -582,17 +583,13 @@ Pgr_dijkstra< G >::dijkstra(
     distances.resize(graph.num_vertices());
 
     // get the graphs source and target
-    V v_source;
-    if (!graph.get_gVertex(start_vertex, v_source)) {
-        // paths.clear();
-        return;
-    }
+    if (!graph.has_vertex(start_vertex)) return;
+    auto v_source(graph.get_V(start_vertex));
 
     std::set< V > s_v_targets;
     for (const auto &vertex : end_vertex) {    
-        V v_target;
-        if (graph.get_gVertex(vertex, v_target)) {
-            s_v_targets.insert(v_target);
+        if (graph.has_vertex(vertex)) {
+            s_v_targets.insert(graph.get_V(vertex));
         }
     }
 
@@ -675,11 +672,11 @@ Pgr_dijkstra< G >::dijkstra_1_to_1(
     try {
         boost::dijkstra_shortest_paths(graph.graph, source,
                 boost::predecessor_map(&predecessors[0])
-                .weight_map(get(&boost_edge_t::cost, graph.graph))
+                .weight_map(get(&pgrouting::Basic_edge::cost, graph.graph))
                 .distance_map(&distances[0])
                 .visitor(dijkstra_one_goal_visitor(target)));
     }
-    catch(found_goals &fg) {
+    catch(found_goals &) {
         found = true;  // Target vertex found
     }
     return found;
@@ -694,14 +691,14 @@ Pgr_dijkstra< G >::dijkstra_1_to_distance(G &graph, V source, double distance) {
     try {
         boost::dijkstra_shortest_paths(graph.graph, source,
                 boost::predecessor_map(&predecessors[0])
-                .weight_map(get(&boost_edge_t::cost, graph.graph))
+                .weight_map(get(&pgrouting::Basic_edge::cost, graph.graph))
                 .distance_map(&distances[0])
                 .visitor(dijkstra_distance_visitor(
                         distance,
                         nodesInDistance,
                         distances)));
     }
-    catch(found_goals &fg) {
+    catch(found_goals &) {
         found = true;
     }
     return found;
@@ -718,11 +715,11 @@ Pgr_dijkstra< G >::dijkstra_1_to_many(
     try {
         boost::dijkstra_shortest_paths(graph.graph, source,
                 boost::predecessor_map(&predecessors[0])
-                .weight_map(get(&boost_edge_t::cost, graph.graph))
+                .weight_map(get(&pgrouting::Basic_edge::cost, graph.graph))
                 .distance_map(&distances[0])
                 .visitor(dijkstra_many_goal_visitor(targets)));
     }
-    catch(found_goals &fg) {
+    catch(found_goals &) {
         found = true;  // Target vertex found
     }
     return found;
diff --git a/src/dijkstra/test/dijkstra-v2.test.sql b/src/dijkstra/test/dijkstra-v2.test.sql
index 9615059..5f537f9 100644
--- a/src/dijkstra/test/dijkstra-v2.test.sql
+++ b/src/dijkstra/test/dijkstra-v2.test.sql
@@ -4,6 +4,8 @@
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
 
+SET client_min_messages TO NOTICE;
+
 \echo --q1
 SELECT * FROM pgr_dijkstra(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
diff --git a/src/dijkstra/test/doc-pgr_dijkstra.test.sql b/src/dijkstra/test/doc-pgr_dijkstra.test.sql
index 4bf410d..55640ac 100644
--- a/src/dijkstra/test/doc-pgr_dijkstra.test.sql
+++ b/src/dijkstra/test/doc-pgr_dijkstra.test.sql
@@ -1,3 +1,5 @@
+BEGIN;
+SET client_min_messages TO NOTICE;
 
 \echo -- q1
 SELECT * FROM pgr_dijkstra(
@@ -220,6 +222,7 @@ SELECT * FROM pgr_dijkstra(
     ARRAY[2], ARRAY[3]
 );
 -- Version 2.0
+SET client_min_messages TO NOTICE;
 SELECT * FROM pgr_dijkstra(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
     2, 3,
@@ -256,6 +259,7 @@ SELECT * FROM pgr_dijkstra(
     FALSE
 );
 -- Version 2.0
+SET client_min_messages TO NOTICE;
 SELECT * FROM pgr_dijkstra(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
     2, 3,
@@ -265,3 +269,4 @@ SELECT * FROM pgr_dijkstra(
 \echo -- q18
 
 
+ROLLBACK;
diff --git a/src/dijkstra/test/doc-pgr_dijkstraVia.result b/src/dijkstra/test/doc-pgr_dijkstraVia.result
index 941eb37..a63254d 100644
--- a/src/dijkstra/test/doc-pgr_dijkstraVia.result
+++ b/src/dijkstra/test/doc-pgr_dijkstraVia.result
@@ -13,8 +13,8 @@
 1|1|1|1|3|1|1|1|0|0
 2|1|2|1|3|2|2|1|1|1
 3|1|3|1|3|3|-1|0|2|2
-4|2|1|3|9|3|3|1|0|2
-5|2|2|3|9|4|16|1|1|3
+4|2|1|3|9|3|5|1|0|2
+5|2|2|3|9|6|9|1|1|3
 6|2|3|3|9|9|-2|0|2|4
 -- q1
 1|1|1|1|5|1|1|1|0|0
diff --git a/src/driving_distance/CMakeLists.txt b/src/driving_distance/CMakeLists.txt
deleted file mode 100644
index c51535e..0000000
--- a/src/driving_distance/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-SUBDIRS(doc src test)
diff --git a/src/driving_distance/doc/doc-pgr_drivingDistance.queries b/src/driving_distance/doc/doc-pgr_drivingDistance.queries
index a429c0d..4d0180f 100644
--- a/src/driving_distance/doc/doc-pgr_drivingDistance.queries
+++ b/src/driving_distance/doc/doc-pgr_drivingDistance.queries
@@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 BEGIN;
 BEGIN
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_drivingDistance(
         'SELECT id, source, target, cost, reverse_cost FROM edge_table',
diff --git a/src/driving_distance/doc/doc-pgr_drivingdistance-v2.queries b/src/driving_distance/doc/doc-pgr_drivingdistance-v2.queries
index 668d59a..5fa1b9e 100644
--- a/src/driving_distance/doc/doc-pgr_drivingdistance-v2.queries
+++ b/src/driving_distance/doc/doc-pgr_drivingdistance-v2.queries
@@ -1,5 +1,7 @@
 BEGIN;
 BEGIN
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_drivingDistance(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
diff --git a/src/driving_distance/doc/drivingDistance.rst b/src/driving_distance/doc/drivingDistance.rst
index 9aa783a..c56a2eb 100644
--- a/src/driving_distance/doc/drivingDistance.rst
+++ b/src/driving_distance/doc/drivingDistance.rst
@@ -14,23 +14,24 @@ Driving Distance
 ===============================================================================
 
 
+  - :ref:`pgr_drivingDistance` - Driving Distance based on pgr_dijkstra
 
-  - :ref:`pgr_drivingDistance<pgr_drivingDistance>` - Driving Distance
+.. toctree::
+    :hidden:
 
+    ./pgr_drivingDistance.rst
 
 .. _pgr_driving_distance_post:
 
 Driving Distance post-processing
 ===============================================================================
 
-  -  :ref:`pgr_alphaShape` - Alpha shape computation
-  -  :ref:`pgr_points_as_polygon` - Polygon around set of points
-
+  - :ref:`pgr_alphaShape` - Alpha shape computation
+  - :ref:`pgr_points_as_polygon` - Polygon around set of points
 
 .. toctree::
-   :hidden:
+    :hidden:
 
-   ./pgr_drivingDistance.rst
-   ./../../alpha_shape/doc/pgr_alphaShape.rst
-   ./../../alpha_shape/doc/pgr_pointsAsPolygon.rst
+    ./../../alpha_shape/doc/pgr_alphaShape.rst
+    ./../../alpha_shape/doc/pgr_pointsAsPolygon.rst
 
diff --git a/src/driving_distance/doc/pgr_drivingDistance.rst b/src/driving_distance/doc/pgr_drivingDistance.rst
index 8d4439e..fac8f7c 100644
--- a/src/driving_distance/doc/pgr_drivingDistance.rst
+++ b/src/driving_distance/doc/pgr_drivingDistance.rst
@@ -30,88 +30,104 @@ Synopsis
 Using Dijkstra algorithm, extracts all the nodes that have costs less than or equal to the value ``distance``.
 The edges extracted will conform the corresponding spanning tree.
 
-.. index::
-	single: drivingDistance(edges_sql, start_vid, distance)
-
-.. rubric:: The minimal signature:
+Signature Summary
+-------------------------------------------------------------------------------
 
 .. code-block:: sql
 
-   pgr_drivingDistance(sql text, start_v bigint, distance float8)
-     RETURNS SET OF (seq, node, edge, cost, agg_cost)
+    pgr_drivingDistance(edges_sql, start_vid, distance)
+    pgr_drivingDistance(edges_sql, start_vid, distance, directed)
+    pgr_drivingDistance(edges_sql, start_vids, distance, directed, equicost)
+
+    RETURNS SET OF (seq, [start_vid,] node, edge, cost, agg_cost)
+
 
+Signatures
+-------------------------------------------------------------------------------
 
 .. index::
-	single: drivingDistance(edges_sql, start_vid, distance, directed)
+	single: drivingDistance(Minimal Use)
 
-.. rubric:: Driving Distance from a single starting point:
+Minimal Use
+...................
 
 .. code-block:: sql
 
-   pgr_drivingDistance(sql text, start_vid bigint, distance float8, directed boolean)
-     RETURNS SET OF (seq, node, edge, cost, agg_cost)
+    pgr_drivingDistance(edges_sql, start_vid, distance)
+    RETURNS SET OF (seq, node, edge, cost, agg_cost)
+
 
 
 .. index::
-	single: drivingDistance(edges_sql, start_vids, distance, directed, equiCost)
+	single: drivingDistance(Single Start Vertex)
 
-.. rubric:: Driving Distance from a multiple starting points:
+Driving Distance From A Single Starting Vertex
+..............................................
 
 .. code-block:: sql
 
-   pgr_drivingDistance(sql text, start_vids anyarray, distance float8,
-         directed boolean default true,
-         equicost boolean default false)
-     RETURNS SET OF (seq, start_vid, node, edge, cost, agg_cost)
+    pgr_drivingDistance(edges_sql, start_vid, distance, directed)
+    RETURNS SET OF (seq, node, edge, cost, agg_cost)
 
-Description of the SQL query
--------------------------------------------------------------------------------
 
-:sql: a SQL query, which should return a set of rows with the following columns:
+.. index::
+	single: drivingDistance(Multiple Starting Vertices)
 
-        .. code-block:: sql
+Driving Distance From Multiple Starting Vertices
+.................................................
 
-                SELECT id, source, target, cost [,reverse_cost] FROM edge_table
+.. code-block:: sql
 
+    pgr_drivingDistance(edges_sql, start_vids, distance, directed, equicost)
+    RETURNS SET OF (seq, start_vid, node, edge, cost, agg_cost)
 
-        :id: ``ANY-INTEGER`` identifier of the edge.
-        :source: ``ANY-INTEGER`` identifier of the source vertex of the edge.
-        :target: ``ANY-INTEGER`` identifier of the target vertex of the edge.
-        :cost: ``ANY-NUMERICAL`` value of the edge traversal cost. A negative cost will prevent the edge (``source``, ``target``) from being inserted in the graph.
-        :reverse_cost: ``ANY-NUMERICAL`` (optional) the value for the reverse traversal of the edge. A negative cost will prevent the edge (``target``, ``source``) from being inserted in the graph.
+Description of the Signatures
+-------------------------------------------------------------------------------
 
-Where:
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
 
-:ANY-INTEGER: smallint, int, bigint
-:ANY-NUMERICAL: smallint, int, bigint, real, float
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+.................................................
+
+============== ====================== =================================================
+Column          Type                  Description
+============== ====================== =================================================
+**edges_sql**  ``TEXT``               SQL query as described above.
+**start_vid**  ``BIGINT``             Identifier of the starting vertex.
+**start_vids** ``ARRAY[ANY-INTEGER]`` Array of identifiers of starting vertices.
+**distance**   ``FLOAT``              Upper limit for the inclusion of the node in the result.
+**directed**   ``BOOLEAN``            (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
+**equicost**   ``BOOLEAN``            (optional). When ``true`` the node will only appear in the closest ``start_vid`` list.  Default is ``false`` which resembles several calls using the single starting point signatures. Tie brakes are arbitrarely.
+============== ====================== =================================================
 
-:sql: SQL query as decribed above.
-:start_v: ``BIGINT`` id of the starting vertex.
-:start_v: ``array[ANY-INTEGER]`` array of id of starting vertices.
-:distance: ``FLOAT`` Upper limit for the inclusion of the node in the result.
-:directed: ``boolean`` (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
-:equicost: ``boolean`` (optional). When ``true`` the node will only appear in the closest ``start_v`` list.  Default is ``false`` which resembles several calls using the single starting point signatures. Tie brakes are arbitrarely.
 
 
 Description of the return values
--------------------------------------------------------------------------------
+.................................................
 
 Returns set of ``(seq [, start_v], node, edge, cost, agg_cost)``
 
-:seq: ``INT`` row sequence.
-:start_v: ``BIGINT`` id of the starting vertex. Used when multiple starting vetrices are in the query.
-:node: ``BIGINT`` id of the node within the limits from ``start_v``.
-:edge: ``BIGINT`` id of the edge used to arrive to ``node``. ``0`` when the ``node`` is the ``start_v``.
-:cost: ``FLOAT`` cost to traverse ``edge``.
-:agg_cost:  ``FLOAT`` total cost from ``start_v`` to ``node``.
+============== =========== =================================================
+Column         Type        Description
+============== =========== =================================================
+**seq**        ``INTEGER`` Sequential value starting from **1**.
+**start_vid**  ``INTEGER`` Identifier of the starting vertex.
+**node**       ``BIGINT``  Identifier of the node in the path within the limits from ``start_vid``.
+**edge**       ``BIGINT``  Identifier of the edge used to arrive to ``node``. ``0`` when the ``node`` is the ``start_vid``.
+**cost**       ``FLOAT``   Cost to traverse ``edge``.
+**agg_cost**   ``FLOAT``   Aggregate cost from ``start_vid`` to ``node``.
+============== =========== =================================================
 
 
 
+Additional Examples
+-------------------------------------------------------------------------------
+
 Examples for queries marked as ``directed`` with ``cost`` and ``reverse_cost`` columns
---------------------------------------------------------------------------------------
+................................................................................................
 
 The examples in this section use the following :ref:`fig1`
 
@@ -120,7 +136,7 @@ The examples in this section use the following :ref:`fig1`
    :end-before: --q2
 
 Examples for queries marked as ``undirected`` with ``cost`` and ``reverse_cost`` columns
-----------------------------------------------------------------------------------------
+................................................................................................
 
 The examples in this section use the following :ref:`fig2`
 
@@ -130,7 +146,7 @@ The examples in this section use the following :ref:`fig2`
    :end-before: --q3
 
 Examples for queries marked as ``directed`` with ``cost`` column
-----------------------------------------------------------------------------------------
+......................................................................................
 
 The examples in this section use the following :ref:`fig3`
 
@@ -141,7 +157,7 @@ The examples in this section use the following :ref:`fig3`
 
 
 Examples for queries marked as ``undirected`` with ``cost`` column
-----------------------------------------------------------------------------------------
+......................................................................................
 
 The examples in this section use the following :ref:`fig4`
 
@@ -149,19 +165,13 @@ The examples in this section use the following :ref:`fig4`
    :start-after: --q4
    :end-before: --q5
 
-The queries use the :ref:`sampledata` network.
-
-.. rubric:: History
-
-* Renamed in version 2.0.0
-* Added functionality in version 2.1
-
 
 See Also
 -------------------------------------------------------------------------------
 
 * :ref:`pgr_alphashape` - Alpha shape computation
 * :ref:`pgr_points_as_polygon` - Polygon around set of points
+* :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
diff --git a/src/driving_distance/doc/pgr_drivingDistance_v2.rst b/src/driving_distance/doc/pgr_drivingDistance_v2.rst
index df50505..095e8f8 100644
--- a/src/driving_distance/doc/pgr_drivingDistance_v2.rst
+++ b/src/driving_distance/doc/pgr_drivingDistance_v2.rst
@@ -9,11 +9,16 @@
 
 .. _pgr_driving_distance_v2:
 
-pgr_drivingDistance (V2.0)
+pgr_drivingDistance - Deprecated Signature
 ===============================================================================
 
-.. index:: 
-	single: drivingDistance(text,integer,double precision,boolean,boolean) -- deprecated
+.. warning:: This function signature is deprecated!!!
+
+    * That means it has been replaced by new signature(s)
+    * This signature is no longer supported, and may be removed from future versions.
+    * All code that use this function signature should be converted to use its replacement :ref:`pgr_drivingDistance`.
+
+
 
 Name
 -------------------------------------------------------------------------------
@@ -31,14 +36,6 @@ This function computes a Dijkstra shortest path solution them extracts the cost
 	pgr_costResult[] pgr_drivingDistance(text sql, integer source, double precision distance,
                                       boolean directed, boolean has_rcost);
 
-.. warning:: This signature is being deprecated on version 2.1, Please use it
-             without the ``has_rcost`` flag instead:
-
-             ``pgr_drivingDistance(sql, start_v, distance, directed)``
-
-             See :ref:`pgr_drivingDistance`
-
-
 
 Description
 -------------------------------------------------------------------------------
@@ -95,5 +92,6 @@ The queries use the :ref:`sampledata` network.
 See Also
 -------------------------------------------------------------------------------
 
+* :ref:`pgr_drivingDistance`
 * :ref:`pgr_alphashape` - Alpha shape computation
 * :ref:`pgr_points_as_polygon` - Polygon around set of points
diff --git a/src/driving_distance/sql/routing_dd.sql b/src/driving_distance/sql/routing_dd.sql
index bae8e47..b7b8198 100644
--- a/src/driving_distance/sql/routing_dd.sql
+++ b/src/driving_distance/sql/routing_dd.sql
@@ -56,7 +56,7 @@ CREATE OR REPLACE FUNCTION pgr_drivingDistance(edges_sql text, source bigint, di
              sql = 'SELECT id, source, target, cost, -1 as reverse_cost FROM (' || edges_sql || ') __q ';
          ELSE
              -- the user says it has reverse cost but its false
-             -- cant do anything
+             -- can't do anything
              RAISE EXCEPTION 'has_rcost set to true but reverse_cost not found';
          END IF;
       END IF;
diff --git a/src/driving_distance/src/CMakeLists.txt b/src/driving_distance/src/CMakeLists.txt
index f22ac9d..a74d2fa 100644
--- a/src/driving_distance/src/CMakeLists.txt
+++ b/src/driving_distance/src/CMakeLists.txt
@@ -7,4 +7,3 @@ ADD_LIBRARY(driving_distance OBJECT
     many_to_dist_withPointsDD.c
     withPoints_dd_driver.cpp
  )
-
diff --git a/src/driving_distance/src/boost_interface_drivedist.cpp b/src/driving_distance/src/boost_interface_drivedist.cpp
index 58b1d76..1fdca34 100644
--- a/src/driving_distance/src/boost_interface_drivedist.cpp
+++ b/src/driving_distance/src/boost_interface_drivedist.cpp
@@ -22,23 +22,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
  ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#ifdef open
+#undef open
+#endif
 #endif
 
-#include "unistd.h"
+#include "./boost_interface_drivedist.h"
 #include <sstream>
 #include <deque>
 #include <vector>
+#include <set>
 
-#include "../../common/src/memory_func.hpp"
+#include "./../../common/src/pgr_types.h"
+#include "../../common/src/pgr_alloc.hpp"
 #include "./../../dijkstra/src/pgr_dijkstra.hpp"
-#include "./boost_interface_drivedist.h"
 
-extern "C" {
-#include "./../../common/src/pgr_types.h"
-}
 
 
 
@@ -46,25 +47,27 @@ void
 do_pgr_driving_many_to_dist(
         pgr_edge_t  *data_edges, size_t total_tuples,
         int64_t  *start_vertex, size_t s_len,
-        float8 distance,
+        double distance,
         bool directedFlag,
         bool equiCostFlag,
         General_path_element_t **ret_path, size_t *path_count,
         char ** err_msg) {
     try {
+        *ret_path = NULL;
+        *path_count = 0;
+
         graphType gType = directedFlag? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_tuples;
 
         std::deque< Path >paths;
         std::set< int64_t > s_start_vertices(start_vertex, start_vertex + s_len);
         std::vector< int64_t > start_vertices(s_start_vertices.begin(), s_start_vertices.end());
 
         if (directedFlag) {
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(data_edges, total_tuples);
             pgr_drivingDistance(digraph, paths, start_vertices, distance, equiCostFlag);
         } else {
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(data_edges, total_tuples);
             pgr_drivingDistance(undigraph, paths, start_vertices, distance, equiCostFlag);
         }
@@ -74,10 +77,9 @@ do_pgr_driving_many_to_dist(
 
         if (count == 0) {
             *err_msg = strdup("NOTICE: No return values was found");
-            *ret_path = noResult(path_count, (*ret_path));
             return;
         }
-        *ret_path = get_memory(count, (*ret_path));
+        *ret_path = pgr_alloc(count, (*ret_path));
         auto trueCount(collapse_paths(ret_path, paths));
         *path_count = trueCount;
 
@@ -88,10 +90,10 @@ do_pgr_driving_many_to_dist(
         *err_msg = strdup(log.str().c_str());
 #endif
         return;
-
     } catch ( ... ) {
-        *err_msg = strdup("Caught unknown expection!");
-        *ret_path = noResult(path_count, (*ret_path));
+        *err_msg = strdup("Caught unknown exception!");
+        if (ret_path) free(ret_path);
+        *path_count = 0;
         return;
     }
 }
@@ -99,14 +101,11 @@ do_pgr_driving_many_to_dist(
 
 
 
-
-
-
 void
 do_pgr_driving_distance(
         pgr_edge_t  *data_edges, size_t total_edges,
         int64_t     start_vertex,
-        float8      distance,
+        double      distance,
         bool        directedFlag,
         General_path_element_t **ret_path, size_t *path_count,
         char                   **err_msg) {
@@ -115,25 +114,25 @@ do_pgr_driving_distance(
         // if it already has values there will be a leak
         // call with pointing to NULL
         *ret_path = NULL;
+        *path_count = 0;
 
         log << "NOTICE: Started processing pgr_drivingDistance for 1 start_vid\n";
         // in c code this should have been checked:
         //  1) start_vertex is in the data_edges  DONE
 
         graphType gType = directedFlag? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_edges;
 
         Path path;
 
 
         if (directedFlag) {
             log << "NOTICE: Processing Directed graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(data_edges, total_edges);
             pgr_drivingDistance(digraph, path, start_vertex, distance);
         } else {
             log << "NOTICE: Processing Undirected graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(data_edges, total_edges);
             pgr_drivingDistance(undigraph, path, start_vertex, distance);
         }
@@ -142,7 +141,6 @@ do_pgr_driving_distance(
         if (path.empty()) {
             log << "NOTICE: it should have at least the one for it self";
             *err_msg = strdup(log.str().c_str());
-            *ret_path = noResult(path_count, (*ret_path));
             return;
         }
 
@@ -151,7 +149,7 @@ do_pgr_driving_distance(
 
         log << "NOTICE Count: " << count << " tuples\n";
 
-        *ret_path = get_memory(count, (*ret_path));
+        *ret_path = pgr_alloc(count, (*ret_path));
 
         size_t sequence = 0;
         path.get_pg_dd_path(ret_path, sequence);
@@ -167,7 +165,8 @@ do_pgr_driving_distance(
     } catch ( ... ) {
         log << "NOTICE: unknown exception cought";
         *err_msg = strdup(log.str().c_str());
-        *ret_path = noResult(path_count, (*ret_path));
+        if (ret_path) free(ret_path);
+        *path_count = 0;
         return;
     }
 }
diff --git a/src/driving_distance/src/boost_interface_drivedist.h b/src/driving_distance/src/boost_interface_drivedist.h
index 8bf563e..5260e33 100644
--- a/src/driving_distance/src/boost_interface_drivedist.h
+++ b/src/driving_distance/src/boost_interface_drivedist.h
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #ifndef SRC_DRIVING_DISTANCE_SRC_BOOST_INTERFACE_DRIVEDIST_H_
 #define SRC_DRIVING_DISTANCE_SRC_BOOST_INTERFACE_DRIVEDIST_H_
 
+#include "stdlib.h"
 #include "./../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
@@ -34,7 +35,7 @@ extern "C" {
     void do_pgr_driving_many_to_dist(
             pgr_edge_t  * edges, size_t total_tuples,
             int64_t  *start_vertex, size_t s_len,
-            float8 distance,
+            double distance,
             bool directed,
             bool equicost,
             General_path_element_t **ret_path, size_t *path_count,
diff --git a/src/driving_distance/src/drivedist.c b/src/driving_distance/src/drivedist.c
index 11171c2..239924f 100644
--- a/src/driving_distance/src/drivedist.c
+++ b/src/driving_distance/src/drivedist.c
@@ -40,13 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/edges_input.h"
 #include "./boost_interface_drivedist.h"
 
-PG_FUNCTION_INFO_V1(driving_distance);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-driving_distance(PG_FUNCTION_ARGS); 
+PGDLLEXPORT Datum driving_distance(PG_FUNCTION_ARGS);
 
 static
 void compute_driving_distance(
@@ -65,7 +59,7 @@ void compute_driving_distance(
 
   PGR_DBG("Load data");
 
-  pgr_get_data_5_columns(sql, &edges, &total_edges);
+  pgr_get_edges(sql, &edges, &total_edges);
 
   if (total_edges == 0) {
     PGR_DBG("No edges found");
@@ -92,11 +86,8 @@ void compute_driving_distance(
 }
 
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(driving_distance);
 PGDLLEXPORT Datum
-#endif
 driving_distance(PG_FUNCTION_ARGS) {
   FuncCallContext     *funcctx;
   uint32_t             call_cntr;
diff --git a/src/driving_distance/src/many_to_dist_driving_distance.c b/src/driving_distance/src/many_to_dist_driving_distance.c
index 181e2ee..07f63ad 100644
--- a/src/driving_distance/src/many_to_dist_driving_distance.c
+++ b/src/driving_distance/src/many_to_dist_driving_distance.c
@@ -59,7 +59,7 @@ void driving_many_to_dist_driver(
     char *err_msg = (char *)"";
 
 
-    pgr_get_data_5_columns(sql, &edges, &total_tuples);
+    pgr_get_edges(sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -118,7 +118,7 @@ driving_many_to_dist(PG_FUNCTION_ARGS) {
         size_t num;
 
         sourcesArr = (int64_t*) pgr_get_bigIntArray(&num, PG_GETARG_ARRAYTYPE_P(1));
-        PGR_DBG("sourcesArr size %d ", num);
+        PGR_DBG("sourcesArr size %ld ", num);
 
         PGR_DBG("Calling driving_many_to_dist_driver");
         driving_many_to_dist_driver(
diff --git a/src/driving_distance/src/many_to_dist_withPointsDD.c b/src/driving_distance/src/many_to_dist_withPointsDD.c
index f162839..e45a947 100644
--- a/src/driving_distance/src/many_to_dist_withPointsDD.c
+++ b/src/driving_distance/src/many_to_dist_withPointsDD.c
@@ -44,13 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./withPoints_dd_driver.h"
 
 
-PG_FUNCTION_INFO_V1(many_withPointsDD);
-#ifndef _MSC_VER
-Datum 
-#else  
-PGDLLEXPORT Datum 
-#endif
-many_withPointsDD(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum many_withPointsDD(PG_FUNCTION_ARGS);
 
 static 
 void process(
@@ -67,7 +61,7 @@ void process(
         General_path_element_t **result_tuples,
         size_t *result_count  ){
 
-    driving_side[0] = tolower(driving_side[0]);
+    driving_side[0] = (char) tolower(driving_side[0]);
     PGR_DBG("driving side:%c",driving_side[0]);
     if (! ((driving_side[0] == 'r')
                 || (driving_side[0] == 'l'))) {
@@ -90,11 +84,11 @@ void process(
 
     pgr_edge_t *edges_of_points = NULL;
     size_t total_edges_of_points = 0;
-    pgr_get_data_5_columns(edges_of_points_query, &edges_of_points, &total_edges_of_points);
+    pgr_get_edges(edges_of_points_query, &edges_of_points, &total_edges_of_points);
 
     pgr_edge_t *edges = NULL;
     size_t total_edges = 0;
-    pgr_get_data_5_columns(edges_no_points_query, &edges, &total_edges);
+    pgr_get_edges(edges_no_points_query, &edges, &total_edges);
 
     PGR_DBG("freeing allocated memory not used anymore");
     free(edges_of_points_query);
@@ -146,11 +140,8 @@ void process(
 
 
 
-#ifndef _MSC_VER
-Datum
-#else  
+PG_FUNCTION_INFO_V1(many_withPointsDD);
 PGDLLEXPORT Datum
-#endif
 many_withPointsDD(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t                  call_cntr;
@@ -189,7 +180,7 @@ many_withPointsDD(PG_FUNCTION_ARGS) {
         size_t num;
 
         sourcesArr = (int64_t*) pgr_get_bigIntArray(&num, PG_GETARG_ARRAYTYPE_P(2));
-        PGR_DBG("sourcesArr size %d ", num);
+        PGR_DBG("sourcesArr size %ld ", num);
 
         PGR_DBG("Calling driving_many_to_dist_driver");
         process(
diff --git a/src/driving_distance/src/withPoints_dd.c b/src/driving_distance/src/withPoints_dd.c
index bea7556..828f0d9 100644
--- a/src/driving_distance/src/withPoints_dd.c
+++ b/src/driving_distance/src/withPoints_dd.c
@@ -48,13 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 // #define DEBUG
 #include "./../../common/src/debug_macro.h"
 
-PG_FUNCTION_INFO_V1(withPoints_dd);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-withPoints_dd(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum withPoints_dd(PG_FUNCTION_ARGS);
 
 
 /*******************************************************************************/
@@ -74,7 +68,7 @@ process(
         General_path_element_t **result_tuples,
         size_t *result_count) {
 
-    driving_side[0] = tolower(driving_side[0]);
+    driving_side[0] = (char) tolower(driving_side[0]);
     PGR_DBG("driving side:%c",driving_side[0]);
     if (! ((driving_side[0] == 'r')
                 || (driving_side[0] == 'l'))) {
@@ -97,11 +91,11 @@ process(
 
     pgr_edge_t *edges_of_points = NULL;
     size_t total_edges_of_points = 0;
-    pgr_get_data_5_columns(edges_of_points_query, &edges_of_points, &total_edges_of_points);
+    pgr_get_edges(edges_of_points_query, &edges_of_points, &total_edges_of_points);
 
     pgr_edge_t *edges = NULL;
     size_t total_edges = 0;
-    pgr_get_data_5_columns(edges_no_points_query, &edges, &total_edges);
+    pgr_get_edges(edges_no_points_query, &edges, &total_edges);
 
     PGR_DBG("freeing allocated memory not used anymore");
     free(edges_of_points_query);
@@ -155,11 +149,8 @@ process(
 
 
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(withPoints_dd);
 PGDLLEXPORT Datum
-#endif
 withPoints_dd(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
diff --git a/src/driving_distance/src/withPoints_dd_driver.cpp b/src/driving_distance/src/withPoints_dd_driver.cpp
index 50060c6..69eb709 100644
--- a/src/driving_distance/src/withPoints_dd_driver.cpp
+++ b/src/driving_distance/src/withPoints_dd_driver.cpp
@@ -28,27 +28,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#ifdef open
+#undef open
+#endif
 #endif
-
 
 #include <sstream>
 #include <deque>
 #include <vector>
-#include <cassert>
+#include <algorithm>
+#include <set>
+
 #include "./../../dijkstra/src/pgr_dijkstra.hpp"
 #include "./../../withPoints/src/pgr_withPoints.hpp"
 #include "./withPoints_dd_driver.h"
 
-// #define DEBUG
 
-extern "C" {
 #include "./../../common/src/pgr_types.h"
-}
-
-#include "./../../common/src/memory_func.hpp"
+#include "./../../common/src/pgr_alloc.hpp"
 
 
 /*******************************************************************************/
@@ -71,7 +71,7 @@ do_pgr_many_withPointsDD(
         pgr_edge_t      *edges_of_points,   size_t total_edges_of_points,
 
         int64_t  *start_pids_arr,    size_t s_len,
-        float8 distance,
+        double distance,
 
         bool directed,
         char driving_side,
@@ -128,17 +128,16 @@ do_pgr_many_withPointsDD(
 
 
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const size_t initial_size = total_edges;
 
         std::deque< Path >paths;
 
         if (directed) {
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(edges, total_edges);
             digraph.graph_insert_data(new_edges);
             pgr_drivingDistance(digraph, paths, start_vids, distance, equiCost);
         } else {
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(edges, total_edges);
             undigraph.graph_insert_data(new_edges);
             pgr_drivingDistance(undigraph, paths, start_vids, distance, equiCost);
@@ -167,7 +166,7 @@ do_pgr_many_withPointsDD(
             *err_msg = strdup("NOTICE: No return values was found");
             return 0;
         }
-        *return_tuples = get_memory(count, (*return_tuples));
+        *return_tuples = pgr_alloc(count, (*return_tuples));
         *return_count = collapse_paths(return_tuples, paths);
 
 #ifndef DEBUG
@@ -176,12 +175,10 @@ do_pgr_many_withPointsDD(
         *err_msg = strdup(log.str().c_str());
 #endif
         return 0;
-
     } catch ( ... ) {
-        *err_msg = strdup("Caught unknown expection!");
+        *err_msg = strdup("Caught unknown exception!");
         return 1000;
     }
-
 }
 
 
@@ -203,7 +200,7 @@ do_pgr_withPointsDD(
         pgr_edge_t  *edges_of_points, size_t total_edges_of_points,
 
         int64_t start_vid,
-        float8      distance,
+        double      distance,
 
         char driving_side,
         bool details,
@@ -211,7 +208,7 @@ do_pgr_withPointsDD(
 
         General_path_element_t **return_tuples,
         size_t *return_count,
-        char ** err_msg){
+        char ** err_msg) {
     std::ostringstream log;
     try {
         /*
@@ -254,19 +251,18 @@ do_pgr_withPointsDD(
 #endif
 
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const size_t initial_size = total_edges;
 
         Path path;
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(edges, total_edges);
             digraph.graph_insert_data(new_edges);
             pgr_drivingDistance(digraph, path, start_vid, distance);
         } else {
             log << "Working with undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(edges, total_edges);
             undigraph.graph_insert_data(new_edges);
             pgr_drivingDistance(undigraph, path, start_vid, distance);
@@ -298,7 +294,7 @@ do_pgr_withPointsDD(
 
 
         *return_tuples = NULL;
-        *return_tuples = get_memory(count, (*return_tuples));
+        *return_tuples = pgr_alloc(count, (*return_tuples));
 
         size_t sequence = 0;
         path.get_pg_dd_path(return_tuples, sequence);
@@ -316,7 +312,7 @@ do_pgr_withPointsDD(
 #endif
         return 0;
     } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+        log << "Caught unknown exception!\n";
         *err_msg = strdup(log.str().c_str());
     }
     return 1000;
diff --git a/src/driving_distance/src/withPoints_dd_driver.h b/src/driving_distance/src/withPoints_dd_driver.h
index 00a9060..322a838 100644
--- a/src/driving_distance/src/withPoints_dd_driver.h
+++ b/src/driving_distance/src/withPoints_dd_driver.h
@@ -41,7 +41,7 @@ extern "C" {
             pgr_edge_t      *edges_of_points,   size_t total_edges_of_points,
 
             int64_t  *start_pids_arr,    size_t s_len,
-            float8 distance,
+            double distance,
 
             bool directed,
             char driving_side,
diff --git a/src/driving_distance/test/doc-pgr_drivingDistance.test.sql b/src/driving_distance/test/doc-pgr_drivingDistance.test.sql
index 8587e97..fd9f488 100644
--- a/src/driving_distance/test/doc-pgr_drivingDistance.test.sql
+++ b/src/driving_distance/test/doc-pgr_drivingDistance.test.sql
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
 BEGIN;
+    SET client_min_messages TO NOTICE;
 
 \echo --q1
 SELECT * FROM pgr_drivingDistance(
diff --git a/src/driving_distance/test/doc-pgr_drivingdistance-v2.test.sql b/src/driving_distance/test/doc-pgr_drivingdistance-v2.test.sql
index 6bddfe3..9294643 100644
--- a/src/driving_distance/test/doc-pgr_drivingdistance-v2.test.sql
+++ b/src/driving_distance/test/doc-pgr_drivingdistance-v2.test.sql
@@ -4,6 +4,7 @@
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
 BEGIN;
+    SET client_min_messages TO NOTICE;
 \echo --q1
 SELECT * FROM pgr_drivingDistance(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
diff --git a/src/driving_distance/test/drivingdistance-any-00.test.sql b/src/driving_distance/test/drivingdistance-any-00.test.sql
index f1e3387..cb6db0a 100644
--- a/src/driving_distance/test/drivingdistance-any-00.test.sql
+++ b/src/driving_distance/test/drivingdistance-any-00.test.sql
@@ -1,7 +1,8 @@
--- each ring will increas by 4 because it is on a square grid
+-- each ring will increase by 4 because it is on a square grid
 -- to find the start node number
 -- select *, st_distance(st_makepoint(25,25), the_geom) from vertices_tmp where st_dwithin(st_makepoint(25,25), the_geom, 1.0) order by st_distance(st_makepoint(25,25), the_geom) limit 1;
 BEGIN;
+    SET client_min_messages TO NOTICE;
 
     -- create 50x50 grid of overlapping lines horizontal and vertical
 
diff --git a/src/internalQueryTests/sql/CMakeLists.txt b/src/internalQueryTests/sql/CMakeLists.txt
new file mode 100644
index 0000000..555bde1
--- /dev/null
+++ b/src/internalQueryTests/sql/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Append in local scope
+LIST(APPEND PACKAGE_SQL_FILES
+    ${CMAKE_CURRENT_SOURCE_DIR}/test_ch_edges.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/testXYedges.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/test_matrixRows.sql
+)
+
+# set in parent scope
+SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
diff --git a/src/astar/test/spas-any-00.test.sql b/src/internalQueryTests/sql/testXYedges.sql
similarity index 74%
rename from src/astar/test/spas-any-00.test.sql
rename to src/internalQueryTests/sql/testXYedges.sql
index 558b21e..00c7ff0 100644
--- a/src/astar/test/spas-any-00.test.sql
+++ b/src/internalQueryTests/sql/testXYedges.sql
@@ -1,8 +1,14 @@
 /*PGR-GNU*****************************************************************
+File: testXYedges.sql
 
+Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
 ------
 
 This program is free software; you can redistribute it and/or modify
@@ -20,8 +26,11 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-select * from pgr_astar('select id::INTEGER, source::INTEGER, target::INTEGER,
-    case when cost<=0 then 999 else cost end as cost,
-    case when reverse_cost<=0 then 999 else reverse_cost end as reverse_cost,
-     x1, y1, x2, y2 from edge_table', 11, 5, false, true);
+
+CREATE OR REPLACE FUNCTION _pgr_testXYedges(
+    edges_sql TEXT) 
+
+  RETURNS BOOLEAN AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'testXYedges'
+    LANGUAGE c IMMUTABLE STRICT;
 
diff --git a/src/shooting_star/test/spss-any-00.test.sql b/src/internalQueryTests/sql/test_ch_edges.sql
similarity index 75%
rename from src/shooting_star/test/spss-any-00.test.sql
rename to src/internalQueryTests/sql/test_ch_edges.sql
index 9a36c94..7e094be 100644
--- a/src/shooting_star/test/spss-any-00.test.sql
+++ b/src/internalQueryTests/sql/test_ch_edges.sql
@@ -1,8 +1,14 @@
 /*PGR-GNU*****************************************************************
+File: testXYedges.sql
 
+Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
+Function's developer: 
+Copyright (c) 2015 Rohith Reddy
+Mail: 
+
 ------
 
 This program is free software; you can redistribute it and/or modify
@@ -20,5 +26,11 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-select * from pgr_shootingstar('select eid as id, source::int4, target::int4, case when cost<=0 then 999 else cost end as cost, case when reverse_cost<=0 then 999 else reverse_cost end as reverse_cost, x1, y1, x2, y2, to_cost, rule from edges1', 11, 6, true, true);
+
+CREATE OR REPLACE FUNCTION _pgr_test_c_edges(
+    edges_sql TEXT) 
+
+  RETURNS BOOLEAN AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'test_c_edges'
+    LANGUAGE c IMMUTABLE STRICT;
 
diff --git a/src/shooting_star/test/spss-any-01.test.sql b/src/internalQueryTests/sql/test_matrixRows.sql
similarity index 74%
rename from src/shooting_star/test/spss-any-01.test.sql
rename to src/internalQueryTests/sql/test_matrixRows.sql
index 6135652..f8419db 100644
--- a/src/shooting_star/test/spss-any-01.test.sql
+++ b/src/internalQueryTests/sql/test_matrixRows.sql
@@ -1,8 +1,14 @@
 /*PGR-GNU*****************************************************************
+File: testXYedges.sql
 
+Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
 ------
 
 This program is free software; you can redistribute it and/or modify
@@ -20,5 +26,11 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-select * from pgr_shootingstar('select eid as id, source::int4, target::int4, case when cost<=0 then 999 else cost end as cost, case when reverse_cost<=0 then 999 else reverse_cost end as reverse_cost, x1, y1, x2, y2, to_cost, rule from edges1', 11, 6, false, true);
+
+CREATE OR REPLACE FUNCTION _pgr_test_matrixRows(
+    matrix_rows_sql TEXT) 
+
+  RETURNS BOOLEAN AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'test_matrixRows'
+    LANGUAGE c IMMUTABLE STRICT;
 
diff --git a/src/internalQueryTests/src/CMakeLists.txt b/src/internalQueryTests/src/CMakeLists.txt
new file mode 100644
index 0000000..2a459a1
--- /dev/null
+++ b/src/internalQueryTests/src/CMakeLists.txt
@@ -0,0 +1,11 @@
+ADD_LIBRARY(internalQueryTests OBJECT 
+    testXYedges.c 
+    testXYedges_driver.cpp
+    
+    test_matrixRows.c
+    test_matrixRows_driver.cpp
+
+
+    test_c_edges.c 
+    test_c_edges_driver.cpp
+    )
diff --git a/src/internalQueryTests/src/testXYedges.c b/src/internalQueryTests/src/testXYedges.c
new file mode 100644
index 0000000..9ba9154
--- /dev/null
+++ b/src/internalQueryTests/src/testXYedges.c
@@ -0,0 +1,118 @@
+/*PGR-GNU*****************************************************************
+File: testXYedges.c
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#include "postgres.h"
+#include "executor/spi.h"
+#include "funcapi.h"
+#include "utils/array.h"
+#include "catalog/pg_type.h"
+#if PGSQL_VERSION > 92
+#include "access/htup_details.h"
+#endif
+
+/*
+  Uncomment when needed
+*/
+// #define DEBUG
+
+#include "fmgr.h"
+#include "./../../common/src/debug_macro.h"
+#include "./../../common/src/pgr_types.h"
+#include "./../../common/src/postgres_connection.h"
+#include "./../../common/src/edges_input.h"
+
+#include "./testXYedges_driver.h"
+
+PGDLLEXPORT Datum testXYedges(PG_FUNCTION_ARGS);
+
+
+static
+void
+process(char* edges_sql,
+        bool *result_bool) {
+    pgr_SPI_connect();
+
+    PGR_DBG("Load data");
+    Pgr_edge_xy_t *edges = NULL;
+    size_t total_edges = 0;
+    pgr_get_edges_xy(edges_sql, &edges, &total_edges);
+
+    if (total_edges == 0) {
+        PGR_DBG("No edges found");
+        (*result_bool) = true;
+        pfree(edges);
+        pgr_SPI_finish();
+        return;
+    }
+    PGR_DBG("Total %ld tuples in query:", total_edges);
+    size_t i;
+    for (i = 0; i < total_edges; ++i) {
+        PGR_DBG("id = %li \t source = %li \t target = %ld  cost = %lf reverse_cost = %lf",
+               edges[i].id, edges[i].source, edges[i].target, edges[i].cost, edges[i].reverse_cost);
+        PGR_DBG("    (x1,y1) = (%.32lf ,%.32lf) (x2,y2) = (%.32lf,.%.32lf)",
+               edges[i].x1, edges[i].y1, edges[i].x2, edges[i].y2);
+    }
+
+
+    PGR_DBG("Starting processing");
+    char *err_msg = NULL;
+    char *log_msg = NULL;
+    (*result_bool) = do_pgr_testXYedges(
+            edges,
+            total_edges,
+            &log_msg,
+            &err_msg);
+
+    pfree(edges);
+    PGR_DBG("Returned log message = %s\n", log_msg);
+    if (log_msg) {
+        elog(DEBUG1, "%s", log_msg);
+        free(log_msg);
+    }
+    PGR_DBG("Returned error message = %s\n", err_msg);
+
+    if (err_msg) {
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
+
+    pgr_SPI_finish();
+}
+
+PG_FUNCTION_INFO_V1(testXYedges);
+PGDLLEXPORT Datum
+testXYedges(PG_FUNCTION_ARGS) {
+    bool  result_bool = false;
+    process(
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            &result_bool);
+
+    PG_RETURN_BOOL(result_bool);
+}
+
diff --git a/src/internalQueryTests/src/testXYedges_driver.cpp b/src/internalQueryTests/src/testXYedges_driver.cpp
new file mode 100644
index 0000000..21527c4
--- /dev/null
+++ b/src/internalQueryTests/src/testXYedges_driver.cpp
@@ -0,0 +1,208 @@
+/*PGR-GNU*****************************************************************
+File: testXYedges_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include "./testXYedges_driver.h"
+
+
+#include "./../../common/src/pgr_types.h"
+#include "./../../dijkstra/src/pgr_dijkstra.hpp"
+#include "./../../common/src/pgr_base_graph.hpp"
+#include "./../../common/src/pgr_assert.h"
+
+/************************************************************
+  edges_sql TEXT
+ ***********************************************************/
+bool
+do_pgr_testXYedges(
+        Pgr_edge_xy_t *data_edges,
+        size_t total_edges,
+        char ** log_msg,
+        char ** err_msg) {
+    std::ostringstream log;
+    std::ostringstream err;
+    try {
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+
+        std::vector< Pgr_edge_xy_t > edges(data_edges, data_edges + total_edges);
+        auto vertices(pgrouting::extract_vertices(edges));
+
+
+        log << "Original: \n" <<
+            std::setprecision(32);
+        for (const auto edge : edges) {
+            log << "id = " << edge.id
+                << "\tsource = " << edge.source
+                << "\ttarget = " << edge.target
+                << "\tcost = " << edge.cost
+                << "\treverse_cost = " << edge.reverse_cost
+                << "\n\t(x1,y1) = (" << edge.x1 << "," << edge.y1 << ")"
+                << "\t(x2,y2) = (" << edge.x2 << "," << edge.y2 << ")\n";
+        }
+
+        {
+            log << "Testing Directed ,  insertion using vector\n";
+            pgrouting::xyDirectedGraph graph(DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+        {
+            log << "Testing Directed ,  insertion using C array\n";
+            pgrouting::xyDirectedGraph graph(DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+        {
+            log << "Testing Directed ,  creating with vertices, insertion using vector\n";
+            pgrouting::xyDirectedGraph graph(vertices, DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+        {
+            log << "Testing Directed ,  creating with vertices, insertion using C array\n";
+            pgrouting::xyDirectedGraph graph(vertices, DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+
+        {
+            log << "Testing Undirected ,  insertion using vector\n";
+            pgrouting::xyUndirectedGraph graph(UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+        {
+            log << "Testing Directed ,  insertion using C array\n";
+            pgrouting::xyUndirectedGraph graph(UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+        {
+            log << "Testing Undirected ,  insertion using C array\n";
+            pgrouting::xyUndirectedGraph graph(UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+        {
+            log << "Testing Undirected ,  creating with vertices, insertion using vector\n";
+            pgrouting::xyUndirectedGraph graph(vertices, UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+        }
+
+        *err_msg = NULL;
+        *log_msg = strdup(log.str().c_str());
+        return true;
+    } catch (AssertFailedException &except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    } catch (std::exception& except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    } catch(...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    }
+}
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/internalQueryTests/src/testXYedges_driver.h
similarity index 68%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/internalQueryTests/src/testXYedges_driver.h
index 801bb6c..1ff4672 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/internalQueryTests/src/testXYedges_driver.h
@@ -1,13 +1,12 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: testXYedges_driver.h
 
-Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Mail: 
 
 ------
 
@@ -27,8 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_INTERNALQUERYTESTS_SRC_TESTXYEDGES_DRIVER_H_
+#define SRC_INTERNALQUERYTESTS_SRC_TESTXYEDGES_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
 
@@ -36,19 +35,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
+    /*********************************************************
+      edges_sql TEXT
+     ********************************************************/
+    bool do_pgr_testXYedges(
+            Pgr_edge_xy_t *edges,
+            size_t total_edges,
+            char ** log_msg,
+            char ** err_msg);
 
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_INTERNALQUERYTESTS_SRC_TESTXYEDGES_DRIVER_H_
diff --git a/src/internalQueryTests/src/test_c_edges.c b/src/internalQueryTests/src/test_c_edges.c
new file mode 100644
index 0000000..26f0f52
--- /dev/null
+++ b/src/internalQueryTests/src/test_c_edges.c
@@ -0,0 +1,113 @@
+/*PGR-GNU*****************************************************************
+File: testXYedges.c
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#include "postgres.h"
+#include "executor/spi.h"
+#include "funcapi.h"
+#include "utils/array.h"
+#include "catalog/pg_type.h"
+#if PGSQL_VERSION > 92
+#include "access/htup_details.h"
+#endif
+#include "fmgr.h"
+
+#include "./../../common/src/debug_macro.h"
+#include "./../../common/src/pgr_types.h"
+#include "./../../common/src/postgres_connection.h"
+#include "./../../common/src/edges_input.h"
+
+#include "./test_c_edges_driver.h"
+
+PGDLLEXPORT Datum test_c_edges(PG_FUNCTION_ARGS);
+
+
+static
+void
+process(char *edges_sql,
+        bool *result_bool) {
+    pgr_SPI_connect();
+
+    PGR_DBG("Load data");
+    pgr_edge_t *edges = NULL;
+    size_t total_edges = 0;
+    pgr_get_edges(edges_sql, &edges, &total_edges);
+
+    if (total_edges == 0) {
+        PGR_DBG("No edges found");
+        (*result_bool) = true;
+        pfree(edges);
+        pgr_SPI_finish();
+        return;
+    }
+    PGR_DBG("Total %ld tuples in query:", total_edges);
+    size_t i;
+    for (i = 0; i < total_edges; ++i) {
+        PGR_DBG("id = %li \t source = %li \t target = %ld  cost = %lf reverse_cost = %lf",
+               edges[i].id, edges[i].source, edges[i].target, edges[i].cost, edges[i].reverse_cost);
+        /*PGR_DBG("    (x1,y1) = (%.32lf ,%.32lf) (x2,y2) = (%.32lf,.%.32lf)",
+               edges[i].x1, edges[i].y1, edges[i].x2, edges[i].y2);*/
+    }
+
+
+    PGR_DBG("Starting processing");
+    char *err_msg = NULL;
+    char *log_msg = NULL;
+    (*result_bool) = do_pgr_test_c_edges(
+            edges,
+            total_edges,
+            &log_msg,
+            &err_msg);
+
+    pfree(edges);
+    elog(NOTICE, "Returned log message = %s\n", log_msg);
+    if (log_msg) {
+        elog(DEBUG1, "%s", log_msg);
+        free(log_msg);
+    }
+    PGR_DBG("Returned error message = %s\n", err_msg);
+
+    if (err_msg) {
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
+
+    pgr_SPI_finish();
+}
+
+PG_FUNCTION_INFO_V1(test_c_edges);
+PGDLLEXPORT Datum
+test_c_edges(PG_FUNCTION_ARGS) {
+    bool  result_bool = false;
+    process(
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            &result_bool);
+
+    PG_RETURN_BOOL(result_bool);
+}
+
diff --git a/src/internalQueryTests/src/test_c_edges_driver.cpp b/src/internalQueryTests/src/test_c_edges_driver.cpp
new file mode 100644
index 0000000..14566c1
--- /dev/null
+++ b/src/internalQueryTests/src/test_c_edges_driver.cpp
@@ -0,0 +1,381 @@
+/*PGR-GNU*****************************************************************
+File: testXYedges_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Rohith Reddy
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include "./test_c_edges_driver.h"
+
+#include "./../../common/src/pgr_types.h"
+
+#include "./../../dijkstra/src/pgr_dijkstra.hpp"
+#if 0
+#include "./../../common/src/pgr_base_graph.hpp"
+#endif
+#include "./../../contraction/src/pgr_contractionGraph.hpp"
+#include "./../../common/src/pgr_assert.h"
+
+
+/************************************************************
+  edges_sql TEXT
+ ***********************************************************/
+bool
+do_pgr_test_c_edges(
+        pgr_edge_t *data_edges,
+        size_t total_edges,
+        char ** log_msg,
+        char ** err_msg){
+    std::ostringstream log;
+    std::ostringstream err;
+    try {
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+
+        std::vector< pgr_edge_t > edges(data_edges, data_edges + total_edges);
+        std::vector < pgrouting::contraction::Vertex > vertices(pgrouting::contraction::extract_vertices(edges));
+
+
+        log << "Original: \n" <<
+            std::setprecision(9);
+        for (const auto edge: edges) {
+            log << "id = " << edge.id
+                << "\tsource = " << edge.source
+                << "\ttarget = " << edge.target
+                << "\tcost = " << edge.cost
+                << "\treverse_cost = " << edge.reverse_cost
+                << ")\n";
+        }
+        // TODO(Rohith) make the graph work with pgr_dijkstra
+        #if 0
+        {
+            log << "Testing Directed ,  insertion using vector\n";
+            pgrouting::CHDirectedGraph graph(DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+        
+        {
+            log << "Testing Directed ,  insertion using C array\n";
+            pgrouting::CHDirectedGraph graph(DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+        {
+            log << "Testing Directed ,  creating with vertices, insertion using vector\n";
+            pgrouting::CHDirectedGraph graph(vertices, DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+        {
+            log << "Testing Directed ,  creating with vertices, insertion using C array\n";
+            pgrouting::CHDirectedGraph graph(vertices, DIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+
+        {
+            log << "Testing Undirected ,  insertion using vector\n";
+            pgrouting::CHUndirectedGraph graph(UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+        {
+            log << "Testing Undirected ,  insertion using C array\n";
+            pgrouting::CHUndirectedGraph graph(UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+        {
+            log << "Testing Undirected ,  insertion using C array\n";
+            pgrouting::CHUndirectedGraph graph(UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(data_edges, total_edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+        {
+            log << "Testing Undirected ,  creating with vertices, insertion using vector\n";
+            pgrouting::CHUndirectedGraph graph(vertices, UNDIRECTED);
+            log << "  - Created graph:\n";
+            log << graph;
+
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << graph;
+
+            log << "  - Can do a dijKstra:\n";
+            Path path;
+            pgr_dijkstra(graph, path, 2, 3, true);
+
+        }
+
+        {
+            log << "Testing Identifiers, creating with vertices, insertion using vector\n";
+            log << "  - Created graph:\n";
+            pgrouting::CHUndirectedGraph graph(vertices, UNDIRECTED);
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            log << "  - All vertices:\n";
+            Identifiers<int64_t> all_vertices, contracted_vertices, remaining_vertices;
+            for (const auto vertex: vertices) {
+                all_vertices.insert(graph.get_V(vertex.id));
+                //log << vertex;
+            }
+            log << "    " << all_vertices;
+            log << "\n";
+            log << "  - Contracted vertices:\n";
+            /*
+             1, 7, 8, 13, 14, 16
+            */
+            contracted_vertices.insert(graph.get_V(1));
+            contracted_vertices.insert(graph.get_V(7));
+            contracted_vertices.insert(graph.get_V(8));
+            contracted_vertices.insert(graph.get_V(13));
+            contracted_vertices.insert(graph.get_V(14));
+            contracted_vertices.insert(graph.get_V(16));
+            log << "    " << contracted_vertices;
+            log << "\n";
+            log << "  - Remaining vertices:\n";
+            remaining_vertices = all_vertices - contracted_vertices;
+            log << "    " << remaining_vertices;
+            log << "\n";
+        }
+
+        {
+            log << "Testing Vertex class, creating graph with vertices, insertion using vector\n";
+            log << "  - Created graph:\n";
+            pgrouting::CHDirectedGraph graph(vertices, UNDIRECTED);
+            log << "  - Inserting Edges:\n";
+            graph.graph_insert_data(edges);
+            int64_t vid1 = graph.get_V(1);
+            int64_t vid2 = graph.get_V(2);
+            int64_t vid5 = graph.get_V(5);
+            int64_t vid4 = graph.get_V(4);
+            int64_t vid7 = graph.get_V(7);
+            int64_t vid8 = graph.get_V(8);
+            int64_t vid10 = graph.get_V(10);
+            int64_t vid12 = graph.get_V(12);
+            int64_t vid13 = graph.get_V(13);
+            int64_t vid14 = graph.get_V(14);
+            int64_t vid15 = graph.get_V(15);
+            int64_t vid16 = graph.get_V(16);
+            int64_t vid17 = graph.get_V(17);
+
+            log << "  - id ----- V:\n";
+            log << "  " << 1 << " ----- " << vid1 << "\n";
+            log << "  " << 2 << " ----- " << vid2 << "\n";
+            log << "  " << 4 << " ----- " << vid4 << "\n";
+            log << "  " << 5 << " ----- " << vid5 << "\n";
+            log << "  " << 7 << " ----- " << vid7 << "\n";
+            log << "  " << 8 << " ----- " << vid8 << "\n";
+            log << "  " << 10 << " ----- " << vid10 << "\n";
+            log << "  " << 12 << " ----- " << vid12 << "\n";
+            log << "  " << 13 << " ----- " << vid13 << "\n";
+            log << "  " << 14 << " ----- " << vid14 << "\n";
+            log << "  " << 15 << " ----- " << vid15 << "\n";
+            log << "  " << 16 << " ----- " << vid16 << "\n";
+            log << "  " << 17 << " ----- " << vid17 << "\n";
+            pgrouting::contraction::Vertex v1 = graph[vid1];
+            pgrouting::contraction::Vertex v2 = graph[vid2];
+            pgrouting::contraction::Vertex v4 = graph[vid4];
+            pgrouting::contraction::Vertex v5 = graph[vid5];
+            pgrouting::contraction::Vertex v7 = graph[vid7];
+            pgrouting::contraction::Vertex v8 = graph[vid8];
+            pgrouting::contraction::Vertex v10 = graph[vid10];
+            pgrouting::contraction::Vertex v12 = graph[vid12];
+            pgrouting::contraction::Vertex v13 = graph[vid13];
+            pgrouting::contraction::Vertex v14 = graph[vid14];
+            pgrouting::contraction::Vertex v15 = graph[vid15];
+            pgrouting::contraction::Vertex v16 = graph[vid16];
+            pgrouting::contraction::Vertex v17 = graph[vid17];
+
+            log << "  - Dead end contraction:\n";
+            // vertex 1 is contracted to vertex 2
+            v2.add_contracted_vertex(v1, vid1);
+            log << "Vertex 1 is contracted to Vertex 2:\n";
+            log << v1;
+            log << v2;
+            // vertex 7 is contracted to vertex 8
+            v8.add_contracted_vertex(v7, vid7);
+            log << "Vertex 7 is contracted to Vertex 8:\n";
+            log << v7;
+            log << v8;
+            // vertex 8 is contracted to vertex 5
+            v5.add_contracted_vertex(v8, vid8);
+            log << "Vertex 8 is contracted to Vertex 5:\n";
+            log << v8;
+            log << v5;
+            // vertex 13 is contracted to vertex 10
+            v10.add_contracted_vertex(v13, vid13);
+            log << "Vertex 13 is contracted to Vertex 10:\n";
+            log << v13;
+            log << v10;
+            // vertex 14 is contracted to vertex 15
+            v15.add_contracted_vertex(v14, vid14);
+            log << "Vertex 14 is contracted to Vertex 15:\n";
+            log << v14;
+            log << v15;
+            // vertex 16 is contracted to vertex 17
+            v17.add_contracted_vertex(v16, vid16);
+            log << "Vertex 16 is contracted to Vertex 17:\n";
+            log << v16;
+            log << v17;
+
+
+            log << "  - Linear contraction:\n";
+            pgrouting::contraction::Edge e1;
+            pgrouting::contraction::Edge e2;
+            pgrouting::contraction::Edge e3;
+            pgrouting::contraction::Edge e4;
+            // vertex 2 is contracted to edge -1
+            e1.id = -1;
+            e1.source = 3;
+            e1.target = 5;
+            log << "Vertex 1 is contracted to edge -1:\n";
+            e1.add_contracted_vertex(v2, vid2);
+            log << e1;
+            // vertex 4 is contracted to edge -2
+            e2.id = -2;
+            e2.source = 3;
+            e2.target = 9;
+            log << "Vertex 4 is contracted to edge -2:\n";
+            e2.add_contracted_vertex(v4, vid4);
+            log << e2;
+            // vertex 10 is contracted to edge -3
+            e3.id = -3;
+            e3.source = 5;
+            e3.target = 11;
+            log << "Vertex 10 is contracted to edge -3:\n";
+            e3.add_contracted_vertex(v10, vid10);
+            log << e3;
+            // vertex 12 is contracted to edge -4
+            e4.id = -4;
+            e4.source = 9;
+            e4.target = 11;
+            log << "Vertex 12 is contracted to edge -4:\n";
+            e4.add_contracted_vertex(v12, vid12);
+            log << e4;
+            #if 0
+            
+            Pgr_contract<pgrouting::CDirectedGraph>  contractor;
+            contractor.getDeadEndSet(graph);
+            log << "  - Dead end vertices:\n";
+            contractor.print_dead_end_vertices(log);
+
+            #endif
+        }
+        #endif
+
+
+        *err_msg = NULL;
+        *log_msg = strdup(log.str().c_str());
+        return true;
+
+    } catch (AssertFailedException &except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    } catch (std::exception& except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    } catch(...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    }
+}
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/internalQueryTests/src/test_c_edges_driver.h
similarity index 66%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/internalQueryTests/src/test_c_edges_driver.h
index 801bb6c..ec01d36 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/internalQueryTests/src/test_c_edges_driver.h
@@ -1,13 +1,12 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: test_c_edges_driver.h
 
-Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2015 Rohith Reddy
+Mail: 
 
 ------
 
@@ -27,8 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_TESTCEDGES_SRC_TEST_C_EDGES_DRIVER_H_
+#define SRC_TESTCEDGES_SRC_TEST_C_EDGES_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
 
@@ -36,19 +35,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
+    /*********************************************************
+      edges_sql TEXT
+     ********************************************************/
+    bool do_pgr_test_c_edges(
+            pgr_edge_t *edges,
+            size_t total_edges,
+            char ** log_msg,
+            char ** err_msg);
 
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_TESTCEDGES_SRC_TEST_C_EDGES_DRIVER_H_
diff --git a/src/internalQueryTests/src/test_matrixRows.c b/src/internalQueryTests/src/test_matrixRows.c
new file mode 100644
index 0000000..b0efbb8
--- /dev/null
+++ b/src/internalQueryTests/src/test_matrixRows.c
@@ -0,0 +1,120 @@
+/*PGR-GNU*****************************************************************
+File: testXYedges.c
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#include "postgres.h"
+#include "executor/spi.h"
+#include "funcapi.h"
+#include "utils/array.h"
+#include "catalog/pg_type.h"
+#if PGSQL_VERSION > 92
+#include "access/htup_details.h"
+#endif
+
+/*
+  Uncomment when needed
+*/
+// #define DEBUG
+
+#include "fmgr.h"
+#include "./../../common/src/debug_macro.h"
+#include "./../../common/src/pgr_types.h"
+#include "./../../common/src/postgres_connection.h"
+#include "./../../common/src/matrixRows_input.h"
+
+#include "./test_matrixRows_driver.h"
+
+PGDLLEXPORT Datum test_matrixRows(PG_FUNCTION_ARGS);
+
+
+/*******************************************************************************/
+/*                          MODIFY AS NEEDED                                   */
+static
+void
+process(char* matrix_rows_sql,
+        bool *result_bool) {
+    pgr_SPI_connect();
+
+    PGR_DBG("Load data");
+    Matrix_cell_t *matrix_rows = NULL;
+    size_t total_rows = 0;
+    pgr_get_matrixRows(matrix_rows_sql, &matrix_rows, &total_rows);
+
+    if (total_rows == 0) {
+        PGR_DBG("No rows found");
+        (*result_bool) = true;
+        pfree(matrix_rows);
+        pgr_SPI_finish();
+        return;
+    }
+
+    PGR_DBG("Total %ld rows in query:", total_rows);
+    size_t i;
+    for (i = 0; i < total_rows; ++i) {
+        PGR_DBG("start_vid = %li \t end_vid = %li agg_cost = %lf",
+               matrix_rows[i].from_vid, matrix_rows[i].to_vid, matrix_rows[i].cost);
+    }
+
+
+    PGR_DBG("Starting processing");
+    char *err_msg = NULL;
+    char *log_msg = NULL;
+    (*result_bool) = do_pgr_test_matrixRows(
+            matrix_rows,
+            total_rows,
+            &log_msg,
+            &err_msg);
+
+    pfree(matrix_rows);
+    PGR_DBG("Returned log message = %s\n", log_msg);
+    if (log_msg) {
+        elog(DEBUG1, "%s", log_msg);
+        free(log_msg);
+    }
+    PGR_DBG("Returned error message = %s\n", err_msg);
+
+    if (err_msg) {
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
+
+    pgr_SPI_finish();
+}
+
+
+PG_FUNCTION_INFO_V1(test_matrixRows);
+PGDLLEXPORT Datum
+test_matrixRows(PG_FUNCTION_ARGS) {
+    bool  result_bool = false;
+
+    process(
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            &result_bool);
+
+    PG_RETURN_BOOL(result_bool);
+}
diff --git a/src/internalQueryTests/src/test_matrixRows_driver.cpp b/src/internalQueryTests/src/test_matrixRows_driver.cpp
new file mode 100644
index 0000000..4177913
--- /dev/null
+++ b/src/internalQueryTests/src/test_matrixRows_driver.cpp
@@ -0,0 +1,80 @@
+/*PGR-GNU*****************************************************************
+File: testXYedges_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer: 
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include <cstring>
+#include "./test_matrixRows_driver.h"
+#include "./../../common/src/pgr_assert.h"
+
+bool do_pgr_test_matrixRows(
+        Matrix_cell_t *matrix_rows,
+        size_t total_rows,
+        char ** log_msg,
+        char ** err_msg) {
+    std::ostringstream log;
+    std::ostringstream err;
+    try {
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+
+        std::vector< Matrix_cell_t > matrix(matrix_rows, matrix_rows + total_rows);
+
+        log << "Original: \n" <<
+            std::setprecision(32);
+        for (const auto row : matrix) {
+            log << "start_vid = " << row.from_vid
+                << "\tend_vid = " << row.to_vid
+                << "\tagg_cost = " << row.cost;
+        }
+
+        *err_msg = NULL;
+        *log_msg = strdup(log.str().c_str());
+        return true;
+    } catch (AssertFailedException &except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    } catch (std::exception& except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    } catch(...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return false;
+    }
+}
diff --git a/src/allpairs/src/johnson_driver.h b/src/internalQueryTests/src/test_matrixRows_driver.h
similarity index 74%
copy from src/allpairs/src/johnson_driver.h
copy to src/internalQueryTests/src/test_matrixRows_driver.h
index 8a64bf6..a26cd0a 100644
--- a/src/allpairs/src/johnson_driver.h
+++ b/src/internalQueryTests/src/test_matrixRows_driver.h
@@ -1,13 +1,12 @@
 /*PGR-GNU*****************************************************************
-File: johnson_driver.h
+File: testXYedges_driver.h
 
-Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Mail: 
 
 ------
 
@@ -27,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_INTERNALQUERYTESTS_SRC_TEST_MATRIXROWS_DRIVER_H_
+#define SRC_INTERNALQUERYTESTS_SRC_TEST_MATRIXROWS_DRIVER_H_
 #pragma once
 
 #include "./../../common/src/pgr_types.h"
@@ -35,17 +36,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-//  CREATE OR REPLACE FUNCTION pgr_johnson(edges_sql TEXT, directed BOOLEAN,
-void
-do_pgr_johnson(
-        pgr_edge_t  *data_edges,
-        size_t total_tuples,
-        bool directed,
-        Matrix_cell_t **return_tuples,
-        size_t *return_count,
-        char ** err_msg);
+    bool do_pgr_test_matrixRows(
+            Matrix_cell_t *matrix_rows,
+            size_t total_rows,
+            char ** log_msg,
+            char ** err_msg);
 
 
 #ifdef __cplusplus
 }
 #endif
+
+#endif  // SRC_INTERNALQUERYTESTS_SRC_TEST_MATRIXROWS_DRIVER_H_
diff --git a/src/internalQueryTests/test/XYedge.result b/src/internalQueryTests/test/XYedge.result
new file mode 100644
index 0000000..718f4d2
--- /dev/null
+++ b/src/internalQueryTests/test/XYedge.result
@@ -0,0 +1 @@
+t
diff --git a/src/internalQueryTests/test/XYedge.test.sql b/src/internalQueryTests/test/XYedge.test.sql
new file mode 100644
index 0000000..6a4cf17
--- /dev/null
+++ b/src/internalQueryTests/test/XYedge.test.sql
@@ -0,0 +1,4 @@
+SELECT * FROM _pgr_testXYedges(
+    'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edge_table'
+);
+
diff --git a/src/internalQueryTests/test/pgtap/matrixRows_types_check.sql b/src/internalQueryTests/test/pgtap/matrixRows_types_check.sql
new file mode 100644
index 0000000..2053413
--- /dev/null
+++ b/src/internalQueryTests/test/pgtap/matrixRows_types_check.sql
@@ -0,0 +1,94 @@
+
+\i setup.sql
+
+SELECT plan(17);
+
+SELECT has_function('_pgr_test_matrixrows', ARRAY['text']);
+SELECT function_returns('_pgr_test_matrixrows', ARRAY['text'],'boolean');
+
+CREATE TEMP TABLE matrix AS
+SELECT * FROM pgr_dijkstracostMatrix('
+    SELECT id, source, target, cost, reverse_cost
+    FROM edge_table',
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr));
+
+CREATE OR REPLACE FUNCTION test_anyInteger(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM matrix $$ )';
+    
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION test_anyNumerical(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM matrix $$ )';
+    
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+SELECT test_anyInteger('_pgr_test_matrixrows',
+    ARRAY['start_vid', 'end_vid', 'agg_cost'],
+    'start_vid');
+SELECT test_anyInteger('_pgr_test_matrixrows',
+    ARRAY['start_vid', 'end_vid', 'agg_cost'],
+    'end_vid');
+SELECT test_anyNumerical('_pgr_test_matrixrows',
+    ARRAY['start_vid', 'end_vid', 'agg_cost'],
+    'agg_cost');
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/internalQueryTests/test/pgtap/testXYedges_types_check.sql b/src/internalQueryTests/test/pgtap/testXYedges_types_check.sql
new file mode 100644
index 0000000..c93b5f8
--- /dev/null
+++ b/src/internalQueryTests/test/pgtap/testXYedges_types_check.sql
@@ -0,0 +1,133 @@
+
+\i setup.sql
+
+SELECT plan(87);
+
+SELECT has_function('_pgr_testxyedges', ARRAY['text']);
+SELECT function_returns('_pgr_testxyedges', ARRAY['text'],'boolean');
+
+CREATE OR REPLACE FUNCTION test_anyInteger(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM edge_table $$ )';
+    
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION test_anyNumerical(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+    FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+        END IF;
+        start_sql = start_sql || p || ', ';
+    END LOOP;
+    end_sql = ' FROM edge_table $$ )';
+    
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+    
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+SELECT test_anyInteger('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'id');
+SELECT test_anyInteger('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'source');
+SELECT test_anyInteger('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'target');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'cost');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'reverse_cost');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'x1');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'y1');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'x2');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'reverse_cost', 'x1', 'y1', 'x2', 'y2'],
+    'y2');
+
+
+SELECT test_anyInteger('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'id');
+SELECT test_anyInteger('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'source');
+SELECT test_anyInteger('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'target');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'cost');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'x1');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'y1');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'x2');
+SELECT test_anyNumerical('_pgr_testxyedges',
+    ARRAY['id', 'source', 'target', 'cost', 'x1', 'y1', 'x2', 'y2'],
+    'y2');
+
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/allpairs/test/test.conf b/src/internalQueryTests/test/test.conf
similarity index 56%
copy from src/allpairs/test/test.conf
copy to src/internalQueryTests/test/test.conf
index 528a981..34e9094 100644
--- a/src/allpairs/test/test.conf
+++ b/src/internalQueryTests/test/test.conf
@@ -2,24 +2,23 @@
 
 %main::tests = (
     'any' => {
-        'comment' => 'All pairs tests.',
-        'data' => [''],
+        'comment' => 'XY edges test',
+        'data' => [ ],
+        'debugtests' => [qw(
+            XYedge
+            )],
         'tests' => [qw(
-            doc-johnson
-            doc-floydWarshall
             )],
-
         'documentation' => [qw(
-            doc-johnson
-            doc-floydWarshall
+            )],
+        'nottested' => [qw(
+            testCHedges
             )]
     },
-# I dont know what this are for or how to use them.
-#  TODO ask Steve 
+
 #    'vpg-vpgis' => {}, # for version specific tests
 #    '8-1' => {},       # for pg 8.x and postgis 1.x
 #    '9.2-2.1' => {},   # for pg 9.2 and postgis 2.1
-
 );
 
 1;
diff --git a/src/internalQueryTests/test/testCHedges.result b/src/internalQueryTests/test/testCHedges.result
new file mode 100644
index 0000000..0e11ecd
--- /dev/null
+++ b/src/internalQueryTests/test/testCHedges.result
@@ -0,0 +1,682 @@
+NOTICE:  Returned log message = Original: 
+id = 1	source = 1	target = 2	cost = 1	reverse_cost = 1)
+id = 2	source = 2	target = 3	cost = -1	reverse_cost = 1)
+id = 3	source = 3	target = 4	cost = -1	reverse_cost = 1)
+id = 4	source = 2	target = 5	cost = 1	reverse_cost = 1)
+id = 5	source = 3	target = 6	cost = 1	reverse_cost = -1)
+id = 6	source = 7	target = 8	cost = 1	reverse_cost = 1)
+id = 7	source = 8	target = 5	cost = 1	reverse_cost = 1)
+id = 8	source = 5	target = 6	cost = 1	reverse_cost = 1)
+id = 9	source = 6	target = 9	cost = 1	reverse_cost = 1)
+id = 10	source = 5	target = 10	cost = 1	reverse_cost = 1)
+id = 11	source = 6	target = 11	cost = 1	reverse_cost = -1)
+id = 12	source = 10	target = 11	cost = 1	reverse_cost = -1)
+id = 13	source = 11	target = 12	cost = 1	reverse_cost = -1)
+id = 14	source = 10	target = 13	cost = 1	reverse_cost = 1)
+id = 15	source = 9	target = 12	cost = 1	reverse_cost = 1)
+id = 16	source = 4	target = 9	cost = 1	reverse_cost = 1)
+id = 17	source = 14	target = 15	cost = 1	reverse_cost = 1)
+id = 18	source = 16	target = 17	cost = 1	reverse_cost = 1)
+Testing Directed ,  insertion using vector
+  - Created graph:
+  - Inserting Edges:
+  - Can do a dijKstra:
+Testing Directed ,  insertion using C array
+  - Created graph:
+  - Inserting Edges:
+  - Can do a dijKstra:
+Testing Directed ,  creating with vertices, insertion using vector
+  - Created graph:
+0:  out_edges_of({
+    id: 1,
+    contracted vertices: {}
+}
+):
+1:  out_edges_of({
+    id: 2,
+    contracted vertices: {}
+}
+):
+2:  out_edges_of({
+    id: 3,
+    contracted vertices: {}
+}
+):
+3:  out_edges_of({
+    id: 4,
+    contracted vertices: {}
+}
+):
+4:  out_edges_of({
+    id: 5,
+    contracted vertices: {}
+}
+):
+5:  out_edges_of({
+    id: 6,
+    contracted vertices: {}
+}
+):
+6:  out_edges_of({
+    id: 7,
+    contracted vertices: {}
+}
+):
+7:  out_edges_of({
+    id: 8,
+    contracted vertices: {}
+}
+):
+8:  out_edges_of({
+    id: 9,
+    contracted vertices: {}
+}
+):
+9:  out_edges_of({
+    id: 10,
+    contracted vertices: {}
+}
+):
+10:  out_edges_of({
+    id: 11,
+    contracted vertices: {}
+}
+):
+11:  out_edges_of({
+    id: 12,
+    contracted vertices: {}
+}
+):
+12:  out_edges_of({
+    id: 13,
+    contracted vertices: {}
+}
+):
+13:  out_edges_of({
+    id: 14,
+    contracted vertices: {}
+}
+):
+14:  out_edges_of({
+    id: 15,
+    contracted vertices: {}
+}
+):
+15:  out_edges_of({
+    id: 16,
+    contracted vertices: {}
+}
+):
+16:  out_edges_of({
+    id: 17,
+    contracted vertices: {}
+}
+):
+  - Inserting Edges:
+0:  out_edges_of({
+    id: 1,
+    contracted vertices: {}
+}
+): 1=(1, 2) = 1 at t
+1:  out_edges_of({
+    id: 2,
+    contracted vertices: {}
+}
+): 1=(2, 1) = 1 at t 4=(2, 5) = 1 at t
+2:  out_edges_of({
+    id: 3,
+    contracted vertices: {}
+}
+): 2=(3, 2) = 1 at t 5=(3, 6) = 1 at t
+3:  out_edges_of({
+    id: 4,
+    contracted vertices: {}
+}
+): 3=(4, 3) = 1 at t 16=(4, 9) = 1 at t
+4:  out_edges_of({
+    id: 5,
+    contracted vertices: {}
+}
+): 4=(5, 2) = 1 at t 7=(5, 8) = 1 at t 8=(5, 6) = 1 at t 10=(5, 10) = 1 at t
+5:  out_edges_of({
+    id: 6,
+    contracted vertices: {}
+}
+): 8=(6, 5) = 1 at t 9=(6, 9) = 1 at t 11=(6, 11) = 1 at t
+6:  out_edges_of({
+    id: 7,
+    contracted vertices: {}
+}
+): 6=(7, 8) = 1 at t
+7:  out_edges_of({
+    id: 8,
+    contracted vertices: {}
+}
+): 6=(8, 7) = 1 at t 7=(8, 5) = 1 at t
+8:  out_edges_of({
+    id: 9,
+    contracted vertices: {}
+}
+): 9=(9, 6) = 1 at t 15=(9, 12) = 1 at t 16=(9, 4) = 1 at t
+9:  out_edges_of({
+    id: 10,
+    contracted vertices: {}
+}
+): 10=(10, 5) = 1 at t 12=(10, 11) = 1 at t 14=(10, 13) = 1 at t
+10:  out_edges_of({
+    id: 11,
+    contracted vertices: {}
+}
+): 13=(11, 12) = 1 at t
+11:  out_edges_of({
+    id: 12,
+    contracted vertices: {}
+}
+): 15=(12, 9) = 1 at t
+12:  out_edges_of({
+    id: 13,
+    contracted vertices: {}
+}
+): 14=(13, 10) = 1 at t
+13:  out_edges_of({
+    id: 14,
+    contracted vertices: {}
+}
+): 17=(14, 15) = 1 at t
+14:  out_edges_of({
+    id: 15,
+    contracted vertices: {}
+}
+): 17=(15, 14) = 1 at t
+15:  out_edges_of({
+    id: 16,
+    contracted vertices: {}
+}
+): 18=(16, 17) = 1 at t
+16:  out_edges_of({
+    id: 17,
+    contracted vertices: {}
+}
+): 18=(17, 16) = 1 at t
+  - Can do a dijKstra:
+Testing Directed ,  creating with vertices, insertion using C array
+  - Created graph:
+0:  out_edges_of({
+    id: 1,
+    contracted vertices: {}
+}
+):
+1:  out_edges_of({
+    id: 2,
+    contracted vertices: {}
+}
+):
+2:  out_edges_of({
+    id: 3,
+    contracted vertices: {}
+}
+):
+3:  out_edges_of({
+    id: 4,
+    contracted vertices: {}
+}
+):
+4:  out_edges_of({
+    id: 5,
+    contracted vertices: {}
+}
+):
+5:  out_edges_of({
+    id: 6,
+    contracted vertices: {}
+}
+):
+6:  out_edges_of({
+    id: 7,
+    contracted vertices: {}
+}
+):
+7:  out_edges_of({
+    id: 8,
+    contracted vertices: {}
+}
+):
+8:  out_edges_of({
+    id: 9,
+    contracted vertices: {}
+}
+):
+9:  out_edges_of({
+    id: 10,
+    contracted vertices: {}
+}
+):
+10:  out_edges_of({
+    id: 11,
+    contracted vertices: {}
+}
+):
+11:  out_edges_of({
+    id: 12,
+    contracted vertices: {}
+}
+):
+12:  out_edges_of({
+    id: 13,
+    contracted vertices: {}
+}
+):
+13:  out_edges_of({
+    id: 14,
+    contracted vertices: {}
+}
+):
+14:  out_edges_of({
+    id: 15,
+    contracted vertices: {}
+}
+):
+15:  out_edges_of({
+    id: 16,
+    contracted vertices: {}
+}
+):
+16:  out_edges_of({
+    id: 17,
+    contracted vertices: {}
+}
+):
+  - Inserting Edges:
+0:  out_edges_of({
+    id: 1,
+    contracted vertices: {}
+}
+): 1=(1, 2) = 1 at t
+1:  out_edges_of({
+    id: 2,
+    contracted vertices: {}
+}
+): 1=(2, 1) = 1 at t 4=(2, 5) = 1 at t
+2:  out_edges_of({
+    id: 3,
+    contracted vertices: {}
+}
+): 2=(3, 2) = 1 at t 5=(3, 6) = 1 at t
+3:  out_edges_of({
+    id: 4,
+    contracted vertices: {}
+}
+): 3=(4, 3) = 1 at t 16=(4, 9) = 1 at t
+4:  out_edges_of({
+    id: 5,
+    contracted vertices: {}
+}
+): 4=(5, 2) = 1 at t 7=(5, 8) = 1 at t 8=(5, 6) = 1 at t 10=(5, 10) = 1 at t
+5:  out_edges_of({
+    id: 6,
+    contracted vertices: {}
+}
+): 8=(6, 5) = 1 at t 9=(6, 9) = 1 at t 11=(6, 11) = 1 at t
+6:  out_edges_of({
+    id: 7,
+    contracted vertices: {}
+}
+): 6=(7, 8) = 1 at t
+7:  out_edges_of({
+    id: 8,
+    contracted vertices: {}
+}
+): 6=(8, 7) = 1 at t 7=(8, 5) = 1 at t
+8:  out_edges_of({
+    id: 9,
+    contracted vertices: {}
+}
+): 9=(9, 6) = 1 at t 15=(9, 12) = 1 at t 16=(9, 4) = 1 at t
+9:  out_edges_of({
+    id: 10,
+    contracted vertices: {}
+}
+): 10=(10, 5) = 1 at t 12=(10, 11) = 1 at t 14=(10, 13) = 1 at t
+10:  out_edges_of({
+    id: 11,
+    contracted vertices: {}
+}
+): 13=(11, 12) = 1 at t
+11:  out_edges_of({
+    id: 12,
+    contracted vertices: {}
+}
+): 15=(12, 9) = 1 at t
+12:  out_edges_of({
+    id: 13,
+    contracted vertices: {}
+}
+): 14=(13, 10) = 1 at t
+13:  out_edges_of({
+    id: 14,
+    contracted vertices: {}
+}
+): 17=(14, 15) = 1 at t
+14:  out_edges_of({
+    id: 15,
+    contracted vertices: {}
+}
+): 17=(15, 14) = 1 at t
+15:  out_edges_of({
+    id: 16,
+    contracted vertices: {}
+}
+): 18=(16, 17) = 1 at t
+16:  out_edges_of({
+    id: 17,
+    contracted vertices: {}
+}
+): 18=(17, 16) = 1 at t
+  - Can do a dijKstra:
+Testing Undirected ,  insertion using vector
+  - Created graph:
+  - Inserting Edges:
+  - Can do a dijKstra:
+Testing Directed ,  insertion using C array
+  - Created graph:
+  - Inserting Edges:
+  - Can do a dijKstra:
+Testing Undirected ,  insertion using C array
+  - Created graph:
+  - Inserting Edges:
+  - Can do a dijKstra:
+Testing Undirected ,  creating with vertices, insertion using vector
+  - Created graph:
+0:  out_edges_of({
+    id: 1,
+    contracted vertices: {}
+}
+):
+1:  out_edges_of({
+    id: 2,
+    contracted vertices: {}
+}
+):
+2:  out_edges_of({
+    id: 3,
+    contracted vertices: {}
+}
+):
+3:  out_edges_of({
+    id: 4,
+    contracted vertices: {}
+}
+):
+4:  out_edges_of({
+    id: 5,
+    contracted vertices: {}
+}
+):
+5:  out_edges_of({
+    id: 6,
+    contracted vertices: {}
+}
+):
+6:  out_edges_of({
+    id: 7,
+    contracted vertices: {}
+}
+):
+7:  out_edges_of({
+    id: 8,
+    contracted vertices: {}
+}
+):
+8:  out_edges_of({
+    id: 9,
+    contracted vertices: {}
+}
+):
+9:  out_edges_of({
+    id: 10,
+    contracted vertices: {}
+}
+):
+10:  out_edges_of({
+    id: 11,
+    contracted vertices: {}
+}
+):
+11:  out_edges_of({
+    id: 12,
+    contracted vertices: {}
+}
+):
+12:  out_edges_of({
+    id: 13,
+    contracted vertices: {}
+}
+):
+13:  out_edges_of({
+    id: 14,
+    contracted vertices: {}
+}
+):
+14:  out_edges_of({
+    id: 15,
+    contracted vertices: {}
+}
+):
+15:  out_edges_of({
+    id: 16,
+    contracted vertices: {}
+}
+):
+16:  out_edges_of({
+    id: 17,
+    contracted vertices: {}
+}
+):
+  - Inserting Edges:
+0:  out_edges_of({
+    id: 1,
+    contracted vertices: {}
+}
+): 1=(1, 2) = 1 at t
+1:  out_edges_of({
+    id: 2,
+    contracted vertices: {}
+}
+): 1=(2, 1) = 1 at t 4=(2, 5) = 1 at t
+2:  out_edges_of({
+    id: 3,
+    contracted vertices: {}
+}
+): 2=(3, 2) = 1 at t 5=(3, 6) = 1 at t
+3:  out_edges_of({
+    id: 4,
+    contracted vertices: {}
+}
+): 3=(4, 3) = 1 at t 16=(4, 9) = 1 at t
+4:  out_edges_of({
+    id: 5,
+    contracted vertices: {}
+}
+): 4=(5, 2) = 1 at t 7=(5, 8) = 1 at t 8=(5, 6) = 1 at t 10=(5, 10) = 1 at t
+5:  out_edges_of({
+    id: 6,
+    contracted vertices: {}
+}
+): 8=(6, 5) = 1 at t 9=(6, 9) = 1 at t 11=(6, 11) = 1 at t
+6:  out_edges_of({
+    id: 7,
+    contracted vertices: {}
+}
+): 6=(7, 8) = 1 at t
+7:  out_edges_of({
+    id: 8,
+    contracted vertices: {}
+}
+): 6=(8, 7) = 1 at t 7=(8, 5) = 1 at t
+8:  out_edges_of({
+    id: 9,
+    contracted vertices: {}
+}
+): 9=(9, 6) = 1 at t 15=(9, 12) = 1 at t 16=(9, 4) = 1 at t
+9:  out_edges_of({
+    id: 10,
+    contracted vertices: {}
+}
+): 10=(10, 5) = 1 at t 12=(10, 11) = 1 at t 14=(10, 13) = 1 at t
+10:  out_edges_of({
+    id: 11,
+    contracted vertices: {}
+}
+): 13=(11, 12) = 1 at t
+11:  out_edges_of({
+    id: 12,
+    contracted vertices: {}
+}
+): 15=(12, 9) = 1 at t
+12:  out_edges_of({
+    id: 13,
+    contracted vertices: {}
+}
+): 14=(13, 10) = 1 at t
+13:  out_edges_of({
+    id: 14,
+    contracted vertices: {}
+}
+): 17=(14, 15) = 1 at t
+14:  out_edges_of({
+    id: 15,
+    contracted vertices: {}
+}
+): 17=(15, 14) = 1 at t
+15:  out_edges_of({
+    id: 16,
+    contracted vertices: {}
+}
+): 18=(16, 17) = 1 at t
+16:  out_edges_of({
+    id: 17,
+    contracted vertices: {}
+}
+): 18=(17, 16) = 1 at t
+  - Can do a dijKstra:
+Testing Identifiers, creating with vertices, insertion using vector
+  - Created graph:
+  - Inserting Edges:
+  - All vertices:
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, }
+  - Contracted vertices:
+    {0, 6, 7, 12, 13, 15, }
+  - Remaining vertices:
+    {1, 2, 3, 4, 5, 8, 9, 10, 11, 14, 16, }
+Testing Vertex class, creating graph with vertices, insertion using vector
+  - Created graph:
+  - Inserting Edges:
+  - id ----- V:
+  1 ----- 0
+  2 ----- 1
+  4 ----- 3
+  5 ----- 4
+  7 ----- 6
+  8 ----- 7
+  10 ----- 9
+  12 ----- 11
+  13 ----- 12
+  14 ----- 13
+  15 ----- 14
+  16 ----- 15
+  17 ----- 16
+  - Dead end contraction:
+Vertex 1 is contracted to Vertex 2:
+{
+    id: 1,
+    contracted vertices: {}
+}
+{
+    id: 2,
+    contracted vertices: {0, }
+}
+Vertex 7 is contracted to Vertex 8:
+{
+    id: 7,
+    contracted vertices: {}
+}
+{
+    id: 8,
+    contracted vertices: {6, }
+}
+Vertex 8 is contracted to Vertex 5:
+{
+    id: 8,
+    contracted vertices: {}
+}
+{
+    id: 5,
+    contracted vertices: {6, 7, }
+}
+Vertex 13 is contracted to Vertex 10:
+{
+    id: 13,
+    contracted vertices: {}
+}
+{
+    id: 10,
+    contracted vertices: {12, }
+}
+Vertex 14 is contracted to Vertex 15:
+{
+    id: 14,
+    contracted vertices: {}
+}
+{
+    id: 15,
+    contracted vertices: {13, }
+}
+Vertex 16 is contracted to Vertex 17:
+{
+    id: 16,
+    contracted vertices: {}
+}
+{
+    id: 17,
+    contracted vertices: {15, }
+}
+  - Linear contraction:
+Vertex 1 is contracted to edge -1:
+{
+    id: -1,
+    source: 3,
+    target: 5,
+    cost: 6.90898356e-310,
+    first: 64,
+    contracted vertices: {0, 1, }
+}
+Vertex 4 is contracted to edge -2:
+{
+    id: -2,
+    source: 3,
+    target: 9,
+    cost: 6.90898356e-310,
+    first: 96,
+    contracted vertices: {3, }
+}
+Vertex 10 is contracted to edge -3:
+{
+    id: -3,
+    source: 5,
+    target: 11,
+    cost: 6.90898356e-310,
+    first: 144,
+    contracted vertices: {9, 12, }
+}
+Vertex 12 is contracted to edge -4:
+{
+    id: -4,
+    source: 9,
+    target: 11,
+    cost: 6.95276435e-310,
+    first: 200,
+    contracted vertices: {11, }
+}
+
+
+t
diff --git a/src/internalQueryTests/test/testCHedges.test.sql b/src/internalQueryTests/test/testCHedges.test.sql
new file mode 100644
index 0000000..73a0584
--- /dev/null
+++ b/src/internalQueryTests/test/testCHedges.test.sql
@@ -0,0 +1,5 @@
+-- SET client_min_messages TO DEBUG;
+
+SELECT * FROM _pgr_test_c_edges(
+    'SELECT id, source, target, cost, reverse_cost FROM edge_table'
+);
diff --git a/src/kdijkstra/CMakeLists.txt b/src/kdijkstra/CMakeLists.txt
deleted file mode 100644
index c51535e..0000000
--- a/src/kdijkstra/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-SUBDIRS(doc src test)
diff --git a/src/kdijkstra/doc/CMakeLists.txt b/src/kdijkstra/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/kdijkstra/doc/doc-kdijkstra.queries b/src/kdijkstra/doc/doc-kdijkstra.queries
index 7f20492..5a31979 100644
--- a/src/kdijkstra/doc/doc-kdijkstra.queries
+++ b/src/kdijkstra/doc/doc-kdijkstra.queries
@@ -1,5 +1,7 @@
 BEGIN;
 BEGIN
+SET client_min_messages TO NOTICE;
+SET
 -- q1
 SELECT * FROM pgr_kdijkstraCost(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
diff --git a/src/kdijkstra/doc/pgr_kDijkstra.rst b/src/kdijkstra/doc/pgr_kDijkstra.rst
index 66163fb..fbec1f5 100644
--- a/src/kdijkstra/doc/pgr_kDijkstra.rst
+++ b/src/kdijkstra/doc/pgr_kDijkstra.rst
@@ -10,25 +10,25 @@
 
 .. _pgr_kdijkstra:
 
-pgr_kDijkstra - Mutliple destination Shortest Path Dijkstra
+pgr_kDijkstra - Deprecated Functions
 ===============================================================================
 
-.. index::
-    single: pgr_kDijkstraCost(text,integer,integer[],boolean,boolean) -- deprecated 
-    single: pgr_kDijkstraPath(text,integer,integer[],boolean,boolean) -- deprecated
+.. warning:: These functions are deprecated!!!
+
+    * It has been replaced by a new functions, are no longer supported, and may be removed from future versions.
+    * All code that uses the functions should be converted to use its replacement.
+
 
 Name
 -------------------------------------------------------------------------------
 
 * ``pgr_kdijkstraCost`` - Returns the costs for K shortest paths using Dijkstra algorithm.
 
-.. warning:: This functions is deprecated in 2.2.
-    Use :ref:`pgr_dijkstraCost` instead.
+.. warning:: Use :ref:`pgr_dijkstraCost` (One To Many) instead.
 
 * ``pgr_kdijkstraPath`` - Returns the paths for K shortest paths using Dijkstra algorithm.
 
-.. warning:: This function is deprecated in 2.2.
-    Use :ref:`pgr_dijkstra` instead.
+.. warning:: Use :ref:`pgr_dijkstra` (One To Many) instead.
 
 
 Synopsis
@@ -123,5 +123,6 @@ This behavior is a function of PostGIS functions ``st_linemerge()`` and
 See Also
 -------------------------------------------------------------------------------
 
+* :ref:`pgr_dijkstraCost`, :ref:`pgr_dijkstra`
 * :ref:`type_cost_result`
 * http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
diff --git a/src/kdijkstra/src/CMakeLists.txt b/src/kdijkstra/src/CMakeLists.txt
deleted file mode 100644
index c3f928d..0000000
--- a/src/kdijkstra/src/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-ADD_LIBRARY(kdijkstra OBJECT 
-    k_targets_boost_wrapper.cpp  
-    k_targets_sp.c)
diff --git a/src/kdijkstra/src/k_targets_boost_wrapper.cpp b/src/kdijkstra/src/k_targets_boost_wrapper.cpp
deleted file mode 100644
index 33f7ebc..0000000
--- a/src/kdijkstra/src/k_targets_boost_wrapper.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/*PGR-GNU*****************************************************************
-
- * Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2005 Sylvain Pasche
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#ifdef __MINGW32__
-#include <winsock2.h>
-#include <windows.h>
-#endif
-
-#include <exception>
-#include <vector>
-#include <sstream>
-#include <boost/config.hpp>
-
-#include <boost/graph/graph_traits.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/dijkstra_shortest_paths.hpp>
-
-#include "k_targets_boost_wrapper.h"
-
-using namespace std;
-using namespace boost;
-
-
-// Maximal number of nodes in the path (to avoid infinite loops)
-#define MAX_NODES 100000000
-
-struct Vertex
-{
-    int id;
-    float8 cost;
-};
-
-// Adds an edge to the graph.
-// Edge id, cost, source and target ids and coordinates are copied also
-template <class G, class E>
-static void
-graph_add_edge(G &graph, E &e, int id, int source, int target, float8 cost)
-{
-  bool inserted;
-
-  if (cost < 0) // edges are not inserted in the graph if cost is negative
-    return;
-
-  tie(e, inserted) = add_edge(source, target, graph);
-
-  graph[e].cost = cost;
-  graph[e].id = id;
-
-  // typedef typename graph_traits<G>::vertex_descriptor Vertex;
-  // Vertex s = vertex(source, graph);
-  // Vertex t = vertex(target, graph);
-}
-
-
-int onetomany_dijkstra_boostdist(edge_t *edges, unsigned int count,
-        int start_vertex, int *end_vertices, int nb_targets,
-        bool directed, bool has_reverse_cost,
-        pgr_cost_t **dists,
-        char **err_msg)
-{
-  try {    
-    // FIXME: use a template for the directedS parameters
-    typedef adjacency_list < listS, vecS, directedS, no_property, Vertex> graph_t;
-    typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
-    typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
-    // typedef std::pair<int, int> Edge;
-
-    // FIXME: compute this value
-    const unsigned int num_nodes = ((directed && has_reverse_cost ? 2 : 1) * count) + 100;
-
-    graph_t graph(num_nodes);
-
-    //property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, graph);
-
-    for (std::size_t j = 0; j < count; ++j)
-    {
-        edge_descriptor e;
-        graph_add_edge<graph_t, edge_descriptor>(graph, e,
-                   edges[j].id, edges[j].source,
-                   edges[j].target, edges[j].cost);
-
-        if (!directed || (directed && has_reverse_cost))
-        {
-          float8 cost;
-
-          if (has_reverse_cost)
-          {
-              cost = edges[j].reverse_cost;
-          }
-          else
-          {
-              cost = edges[j].cost;
-          }
-
-          graph_add_edge<graph_t, edge_descriptor>(graph, e,
-                 edges[j].id,
-                 edges[j].target,
-                 edges[j].source,
-                 cost);
-          }
-    }
-
-    std::vector<vertex_descriptor> predecessors(num_vertices(graph));
-
-    vertex_descriptor _source = vertex(start_vertex, graph);
-
-    if ((long)_source < 0) 
-    {
-        *err_msg = (char *) "Starting vertex not found";
-        return -1;
-    }
-
-    std::vector < vertex_descriptor > _target(nb_targets);
-    for (int i = 0; i < nb_targets; i++)
-    {
-        _target[i] = vertex(end_vertices[i], graph);
-
-
-        if ((long)_target[i] < 0 )
-        {
-            *err_msg = (char *) "Ending vertex not found";
-            return -1;
-        }
-    }        
-
-    std::vector<float8> distances(num_vertices(graph));
-
-    dijkstra_shortest_paths(graph, _source,
-                predecessor_map(&predecessors[0]).
-                weight_map(get(&Vertex::cost, graph))
-                .distance_map(&distances[0]));
-
-    std::vector< std::vector<uint64_t> > path_vect(nb_targets);
-
-    int max;
-
-    int index_of_last_path_vertex = 0;
-    size_t sum_path_sizes = 0;
-    int i = 0, j = 0;
-    std::vector < bool > no_path(nb_targets);
-    for (i = 0; i < nb_targets; i++)
-    {
-        no_path[i] = false;
-        max = MAX_NODES;
-        path_vect[i].push_back(_target[i]);
-
-        while (_target[i] != _source && !no_path[i]) 
-        {
-            if (_target[i] == predecessors[_target[i]]) 
-            {
-                //"No path found"
-                path_vect[i].clear();
-                path_vect[i].push_back(end_vertices[i]);
-                path_vect[i].push_back(start_vertex);
-                no_path[i] = true;
-                break;
-            }
-
-            _target[i] = predecessors[_target[i]];
-            path_vect[i].push_back(_target[i]);
-
-            if (!max--) 
-            {
-                *err_msg = (char *) "Overflow";
-                return -1;
-            }
-        }
-        sum_path_sizes += path_vect[i].size();
-    }
-
-    *dists = (pgr_cost_t *) malloc(sizeof(pgr_cost_t) * nb_targets + 1);
-    if (! *dists) {
-        *err_msg = (char *) "Error: out of memory";
-        return -1;
-    }
-
-    for (int numTarget = 0; numTarget < nb_targets; numTarget++)
-    {
-
-        (*dists)[numTarget].seq = numTarget;
-        (*dists)[numTarget].id1 = static_cast<int>(path_vect[numTarget].at(path_vect[numTarget].size() -1));
-        (*dists)[numTarget].id2 = static_cast<int>(path_vect[numTarget].at(0));
-        (*dists)[numTarget].cost = 0.0;
-        if (no_path[numTarget]){
-            (*dists)[numTarget].cost = -1.0;
-        }
-        else {
-            for(i = static_cast<int>(path_vect[numTarget].size()) - 1, j = index_of_last_path_vertex; i >= 0; i--, j++)
-            {
-                graph_traits < graph_t >::vertex_descriptor v_src;
-                graph_traits < graph_t >::vertex_descriptor v_targ;
-                graph_traits < graph_t >::edge_descriptor e;
-                graph_traits < graph_t >::out_edge_iterator out_i, out_end;
-
-                if (i == 0) continue;
-
-                v_src = path_vect[numTarget].at(i);
-                v_targ = path_vect[numTarget].at(i - 1);
-
-                for (tie(out_i, out_end) = out_edges(v_src, graph); out_i != out_end; ++out_i)
-                {
-                    graph_traits < graph_t >::vertex_descriptor targ; // v set but not used
-                    e = *out_i;
-                    // v = source(e, graph);
-                    targ = target(e, graph);
-
-                    if (targ == v_targ) {
-                        (*dists)[numTarget].cost += graph[*out_i].cost;
-                        break;
-                    }
-                }
-
-            }
-            index_of_last_path_vertex = j;
-        }
-    }
-
-    return EXIT_SUCCESS;
-  }
-  catch(std::exception& e) {
-      *err_msg = (char *) e.what();
-      return -1;
-  }
-  catch (...) {
-      *err_msg = (char *) "Unknown exception caught!";
-      return -1;
-  }
-}
diff --git a/src/kdijkstra/src/k_targets_boost_wrapper.h b/src/kdijkstra/src/k_targets_boost_wrapper.h
deleted file mode 100644
index 8fdcdc6..0000000
--- a/src/kdijkstra/src/k_targets_boost_wrapper.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*PGR-GNU*****************************************************************
-
- * Bi Directional Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2005 Sylvain Pasche
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#ifndef _TOMANYSP_H
-#define _TOMANYSP_H
-
-//#include "MyWrapper.h"
-
-#include "postgres.h"
-// #include "../../common/src/pgr_types.h"
-
-typedef struct {
-    int id;
-    int source;
-    int target;
-    double cost;
-    double reverse_cost;
-} edge_t;
-
-
-typedef struct
-{
-    int seq;
-    int id1;
-    int id2;
-    float8 cost;
-} pgr_cost_t;
-
-typedef struct
-{
-    int seq;
-    int id1;
-    int id2;
-    int id3;
-    float8 cost;
-} pgr_cost3_t;
-
-
-typedef struct 
-{
-    int vertex_id_source;
-    int edge_id_source;
-    int vertex_id_target;
-    int edge_id_target;
-    float8 cost;
-} dist_fromto_t;
-
-
-typedef struct 
-{
-    int vertex_id_source;
-    int edge_id_source;
-    int vertex_id_target;
-    int edge_id_target;
-    float8 cost;
-    char* the_way;
-} path_fromto_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-    int onetomany_dijkstra_boostdist(
-            edge_t *edges, unsigned int count, int start_vertex,
-            int *end_vertices, int nb_targets,
-            bool directed, bool has_reverse_cost,
-            pgr_cost_t **dists,
-            char **err_msg );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _TOMANYSP_H
diff --git a/src/kdijkstra/src/k_targets_sp.c b/src/kdijkstra/src/k_targets_sp.c
deleted file mode 100644
index c7916ff..0000000
--- a/src/kdijkstra/src/k_targets_sp.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*PGR-GNU*****************************************************************
-
- * Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2005 Sylvain Pasche
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#include "../../common/src/pgr_types.h"
-#include "postgres.h"
-#include "executor/spi.h"
-#include "funcapi.h"
-#include "utils/array.h"
-#include "utils/lsyscache.h"
-#include "catalog/pg_type.h"
-#if PGSQL_VERSION > 92
-#include "access/htup_details.h"
-#endif
-
-#include "fmgr.h"
-
-#include "k_targets_boost_wrapper.h"
-
-Datum manytomany_dijkstra_dmatrix(PG_FUNCTION_ARGS);
-
-#undef DEBUG
-//#define DEBUG 1
-#include "../../common/src/debug_macro.h"
-#include "../../common/src/postgres_connection.h"
-
-
-// The number of tuples to fetch from the SPI cursor at each iteration
-#define TUPLIMIT 1000
-
-/*
-// this is already defined dijkstra.c
-#ifdef PG_MODULE_MAGIC
-PG_MODULE_MAGIC;
-#endif
-*/
-
-typedef struct edge_columns
-{
-  int id;
-  int source;
-  int target;
-  int cost;
-  int reverse_cost;
-} edge_columns_t;
-
-
-
-
-#define DTYPE int
-
-static DTYPE *get_pgarray(int *num, ArrayType *input)
-{
-    int         ndims, *dims; // , *lbs;
-    bool       *nulls;
-    Oid         i_eltype;
-    int16       i_typlen;
-    bool        i_typbyval;
-    char        i_typalign;
-    Datum      *i_data;
-    int         i, n;
-    DTYPE      *data;
-
-    /* get input array element type */
-    i_eltype = ARR_ELEMTYPE(input);
-    get_typlenbyvalalign(i_eltype, &i_typlen, &i_typbyval, &i_typalign);
-
-
-    /* validate input data type */
-    switch(i_eltype){
-    case INT2OID:
-    case INT4OID:
-    case FLOAT4OID:
-    case FLOAT8OID:
-            break;
-    default:
-            elog(ERROR, "target must be integer[]");
-            break;
-    }
-
-    /* get various pieces of data from the input array */
-    ndims = ARR_NDIM(input);
-    dims = ARR_DIMS(input);
-    // lbs = ARR_LBOUND(input);
-
-    if (ndims != 1) {
-        elog(ERROR, "target must be integer[]");
-    }
-
-    /* get src data */
-    deconstruct_array(input, i_eltype, i_typlen, i_typbyval, i_typalign,
-&i_data, &nulls, &n);
-
-    PGR_DBG("get_pgarray: ndims=%d, n=%d", ndims, n);
-
-#ifdef DEBUG
-    for (i=0; i<ndims; i++) {
-        PGR_DBG("   dims[%d]=%d, lbs[%d]=%d", i, dims[i], i, lbs[i]);
-    }
-#endif
-
-    /* construct a C array */
-    data = (DTYPE *) palloc(n * sizeof(DTYPE));
-    if (!data) {
-        elog(ERROR, "Error: Out of memory!");
-    }
-
-    for (i=0; i<n; i++) {
-        if (nulls[i]) {
-            data[i] = -1;
-        }
-        else {
-            switch(i_eltype){
-                case INT2OID:
-                    data[i] = (DTYPE) DatumGetInt16(i_data[i]);
-                    break;
-                case INT4OID:
-                    data[i] = (DTYPE) DatumGetInt32(i_data[i]);
-                    break;
-                case FLOAT4OID:
-                    data[i] = (DTYPE) DatumGetFloat4(i_data[i]);
-                    break;
-                case FLOAT8OID:
-                    data[i] = (DTYPE) DatumGetFloat8(i_data[i]);
-                    break;
-            }
-        }
-        PGR_DBG("    data[%d]=%.4f", i, data[i]);
-    }
-
-    pfree(nulls);
-    pfree(i_data);
-
-    *num = dims[0];
-
-    return data;
-}
-
-
-/*
- * This function fetches the edge columns from the SPITupleTable.
- * 
-*/ 
-static int fetch_edge_columns(SPITupleTable *tuptable, edge_columns_t *edge_columns, bool has_reverse_cost)
-{
-    edge_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
-    edge_columns->source = SPI_fnumber(SPI_tuptable->tupdesc, "source");
-    edge_columns->target = SPI_fnumber(SPI_tuptable->tupdesc, "target");
-    edge_columns->cost = SPI_fnumber(SPI_tuptable->tupdesc, "cost");
-    if (edge_columns->id == SPI_ERROR_NOATTRIBUTE ||
-        edge_columns->source == SPI_ERROR_NOATTRIBUTE ||
-        edge_columns->target == SPI_ERROR_NOATTRIBUTE ||
-        edge_columns->cost == SPI_ERROR_NOATTRIBUTE) 
-    {
-        elog(ERROR, "Error, query must return columns "
-            "'id', 'source', 'target' and 'cost'");
-        return -1;
-    }
-
-    if (SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->source) != INT4OID ||
-        SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->target) != INT4OID ||
-        SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->cost) != FLOAT8OID) 
-    {
-        elog(ERROR, "Error, columns 'source', 'target' must be of type int4, 'cost' must be of type float8");
-        return -1;
-    }
-
-    PGR_DBG("columns: id %i source %i target %i cost %i", 
-        edge_columns->id, edge_columns->source, 
-        edge_columns->target, edge_columns->cost);
-
-    if (has_reverse_cost)
-    {
-        edge_columns->reverse_cost = SPI_fnumber(SPI_tuptable->tupdesc, 
-                                               "reverse_cost");
-
-        if (edge_columns->reverse_cost == SPI_ERROR_NOATTRIBUTE) 
-        {
-            elog(ERROR, "Error, reverse_cost is used, but query did't return "
-                "'reverse_cost' column");
-            return -1;
-        }
-
-        if (SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->reverse_cost) 
-          != FLOAT8OID) 
-        {
-            elog(ERROR, "Error, columns 'reverse_cost' must be of type float8");
-            return -1;
-        }
-
-        PGR_DBG("columns: reverse_cost cost %i", edge_columns->reverse_cost);
-    }
-
-    return 0;
-}
-
-static void fetch_edge(HeapTuple *tuple, TupleDesc *tupdesc, edge_columns_t *edge_columns, edge_t *target_edge)
-{
-    Datum binval;
-    bool isnull;
-
-    binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->id, &isnull);
-    if (isnull)
-        elog(ERROR, "id contains a null value");
-    target_edge->id = DatumGetInt32(binval);
-
-    binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->source, &isnull);
-    if (isnull)
-        elog(ERROR, "source contains a null value");
-    target_edge->source = DatumGetInt32(binval);
-
-    binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->target, &isnull);
-    if (isnull)
-        elog(ERROR, "target contains a null value");
-    target_edge->target = DatumGetInt32(binval);
-
-    binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->cost, &isnull);
-    if (isnull)
-        elog(ERROR, "cost contains a null value");
-    target_edge->cost = DatumGetFloat8(binval);
-
-    if (edge_columns->reverse_cost != -1) 
-    {
-        binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->reverse_cost, 
-                             &isnull);
-        if (isnull)
-            elog(ERROR, "reverse_cost contains a null value");
-        target_edge->reverse_cost =  DatumGetFloat8(binval);
-    }
-}
-
-
-
-static int many2many_dijkstra_dm(char *sql, int *vids, int num, bool directed,
-        bool has_reverse_cost, bool symmetric, float8 *dm)
-{
-    // int SPIcode;
-    void *SPIplan;
-    Portal SPIportal;
-    bool moredata = TRUE;
-    int ntuples;
-    edge_t *edges = NULL;
-    int total_tuples = 0;
-    edge_columns_t edge_columns = {.id= -1, .source= -1, .target= -1,
-                                   .cost= -1, .reverse_cost= -1};
-    int v_max_id = 0;
-    int v_min_id = INT_MAX;
-
-    // int sumFoundVids = 0;
-
-    int i, j;
-    int zcnt = 0;
-
-    int vvids[num];
-    int v_count[num];
-    for (i=0; i<num; i++)
-        v_count[i] = 0;
-
-    char *err_msg;
-    int ret = -1;
-
-    pgr_cost_t *dists;
-
-    PGR_DBG("start many2many_dijkstra_dm");
-
-    pgr_SPI_connect();
-    SPIplan = pgr_SPI_prepare(sql);
-    SPIportal = pgr_SPI_cursor_open(SPIplan);
-
-    PGR_DBG("Starting while loop to collect edges ...");
-
-    while (moredata == TRUE) {
-        PGR_DBG("Calling SPI_cursor_fetch");
-        SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
-
-        if (fetch_edge_columns(SPI_tuptable, &edge_columns,
-                has_reverse_cost) == -1) {
-            pgr_SPI_finish();
-            return -1;
-        }
-
-        ntuples = SPI_processed;
-        PGR_DBG("ntuples=%d", ntuples);
-        if (ntuples > 0) {
-            SPITupleTable *tuptable = SPI_tuptable;
-            TupleDesc tupdesc = SPI_tuptable->tupdesc;
-            int t;
-
-            total_tuples += ntuples;
-
-            if (!edges)
-                edges = palloc(total_tuples * sizeof(edge_t));
-            else
-                edges = repalloc(edges, total_tuples * sizeof(edge_t));
-
-            if (edges == NULL) {
-                elog(ERROR, "Out of memory!");
-                pgr_SPI_finish();
-                return -1;
-            }
-
-            for (t=0; t < ntuples; t++) {
-                HeapTuple tuple = tuptable->vals[t];
-                fetch_edge(&tuple, &tupdesc, &edge_columns,
-                    &edges[total_tuples - ntuples + t]);
-            }
-            SPI_freetuptable(tuptable);
-        }
-        else {
-            moredata = FALSE;
-        }
-    }
-    PGR_DBG("Total %d edges!", total_tuples);
-
-    // find min and max vertex ids
-
-    for (i=0; i<total_tuples; i++) {
-        if (edges[i].source < v_min_id) v_min_id = edges[i].source;
-        if (edges[i].source > v_max_id) v_max_id = edges[i].source;
-        if (edges[i].target < v_min_id) v_min_id = edges[i].target;
-        if (edges[i].target > v_max_id) v_max_id = edges[i].target;
-    }
-    PGR_DBG("v_min_id: %d, v_max_id: %d", v_min_id, v_max_id);
-
-    // renumber vertices
-
-    for (i=0; i<total_tuples; i++) {
-        // check if edge contains vids[]
-        for (j=0; j<num; j++) {
-            if (edges[i].source == vids[j] || edges[i].target == vids[j])
-                v_count[j]++;
-        }
-        edges[i].source -= v_min_id;
-        edges[i].target -= v_min_id;
-    }
-
-    for (j=0; j< num; j++) {
-        if (v_count[j] == 0) zcnt++;
-        PGR_DBG("vids[%d]: %d, cnt: %d", j, vids[j], v_count[j]);
-        vvids[j] = vids[j] - v_min_id;
-    }
-
-    if (zcnt > 0) {
-        elog(ERROR, "%d vid(s) were not found in the edges!", zcnt);
-        return -1;
-    }
-
-    PGR_DBG("Starting loop to build dmatrix!");
-
-    for (j=0; j<num; j++) {
-        PGR_DBG("Calling onetomany_dijkstra_boostdist j=%d", j);
-
-        ret = onetomany_dijkstra_boostdist(edges, total_tuples, vvids[j],
-                vvids, num, directed, has_reverse_cost, &dists, &err_msg);
-
-        if (ret < 0) {
-            elog(ERROR, "onetomany_dijkstra_boostdist failed on j=%d", j);
-        }
-
-        // ASSUMING: results are in order of vvids array
-        for (i=0; i<num; i++) {
-            dm[j*num + i] = dists[i].cost;
-        }
-
-        free(dists);
-        dists = NULL;
-    }
-    
-    PGR_DBG("Making the matrix symmertic if requested!");
-
-    // if symmetric requsted, then average cells to make it symmetric
-
-    if (symmetric) {
-        for (i=0; i<num; i++) {
-            dm[i * num + i] = 0.0;
-            for (j=i+1; j<num; j++) {
-                if (dm[j*num + i] < 0.0 && dm[i*num + j] > 0.0)
-                    dm[j*num + i] = dm[i*num + j];
-                else if (dm[i*num + j] < 0.0 && dm[j*num + i] > 0.0)
-                    dm[i*num + j] = dm[j*num + i];
-                else if (dm[j*num + i] < 0.0 && dm[i*num + j] < 0.0)
-                    dm[i*num + j] = dm[j*num + i] = -1.0;
-                else
-                    dm[j*num + i] = dm[i*num + j] = (dm[j*num + i] + dm[i*num + j]) / 2.0;
-            }
-        }
-    }
-
-    PGR_DBG("Leaving many2many_dijkstra_dm");
-
-    pgr_SPI_finish();
-    return 0;
-}
-
-/*
-    create or replace function pgr_vidsToDMatrix(sql text,
-        vids integer[], dir bool, has_rcost bool, symmetric bool)
-    return real8[]
-    as '', 'manytomany_dijkstra_dmatrix' language C stable strict;
-
-*/
-
-PG_FUNCTION_INFO_V1(manytomany_dijkstra_dmatrix);
-
-Datum manytomany_dijkstra_dmatrix(PG_FUNCTION_ARGS)
-{
-    ArrayType   *result;
-    Datum  *result_data;
-    // Datum  *values;
-    bool   *nulls;
-    int     i;
-    int     num;
-    int     ret;
-    float8 *dm;
-
-    Oid     o_eltype   = FLOAT8OID;
-    int16   o_typlen;
-    bool    o_typbyval;
-    char    o_typalign;
-
-    int     ndims = 2;
-    int     dims[2];
-    int     lbs[2] = {1, 1};;
-
-    char   *sql = pgr_text2char(PG_GETARG_TEXT_P(0));
-    int    *vids = get_pgarray(&num, PG_GETARG_ARRAYTYPE_P(1));
-
-    dm = (float8 *)palloc(num * num * sizeof(float8));
-
-    ret = many2many_dijkstra_dm(sql, vids, num,
-        PG_GETARG_BOOL(2), PG_GETARG_BOOL(3), PG_GETARG_BOOL(4),
-        dm);
-    
-    if (ret) {
-        elog(ERROR, "Error computing distance matrix!");
-    }
-
-    result_data = (Datum *)palloc(num * num * sizeof(Datum));
-    nulls       = (bool *)palloc(num * num * sizeof(bool));
-
-    for (i=0; i<num*num; i++) {
-        if (dm[i] < 0.0) {
-            nulls[i] = true;
-            result_data[i] = PointerGetDatum(NULL);
-        }
-        else {
-            nulls[i] = false;
-            result_data[i] = Float8GetDatum((float8)dm[i]);
-        }
-    }
-
-    pfree(dm);
-
-    dims[0] = dims[1] = num;
-    get_typlenbyvalalign(o_eltype, &o_typlen, &o_typbyval, &o_typalign);
-
-    result = construct_md_array((void *)result_data, nulls, ndims, dims,
-        lbs, o_eltype, o_typlen, o_typbyval, o_typalign);
-
-    pfree(result_data);
-    pfree(nulls);
-
-    PG_RETURN_ARRAYTYPE_P(result);
-}
-
diff --git a/src/kdijkstra/test/doc-kdijkstra.test.sql b/src/kdijkstra/test/doc-kdijkstra.test.sql
index a76aad0..86241cc 100644
--- a/src/kdijkstra/test/doc-kdijkstra.test.sql
+++ b/src/kdijkstra/test/doc-kdijkstra.test.sql
@@ -4,6 +4,7 @@ BEGIN;
 --              PGR_kdijkstraPath
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
+SET client_min_messages TO NOTICE;
 \echo -- q1
 SELECT * FROM pgr_kdijkstraCost(
     'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table',
diff --git a/src/ksp/CMakeLists.txt b/src/ksp/CMakeLists.txt
deleted file mode 100644
index fe4fdcf..0000000
--- a/src/ksp/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-set(PACKAGE_SQL_FILES "")
-add_subdirectory(sql)
-set(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-subdirs(doc src test)
diff --git a/src/ksp/doc/CMakeLists.txt b/src/ksp/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/ksp/doc/doc-ksp-v2.queries b/src/ksp/doc/doc-ksp-v2.queries
index 4622a62..f09ee8e 100644
--- a/src/ksp/doc/doc-ksp-v2.queries
+++ b/src/ksp/doc/doc-ksp-v2.queries
@@ -1,3 +1,5 @@
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_ksp(
    'SELECT id, source, target, cost FROM edge_table order by id',
diff --git a/src/ksp/doc/doc-ksp.queries b/src/ksp/doc/doc-ksp.queries
index 89f7e8c..1667b58 100644
--- a/src/ksp/doc/doc-ksp.queries
+++ b/src/ksp/doc/doc-ksp.queries
@@ -1,3 +1,5 @@
+SET client_min_messages TO NOTICE;
+SET
 --q1
 SELECT * FROM pgr_ksp(
      'SELECT id, source, target, cost, reverse_cost FROM edge_table',
diff --git a/src/ksp/doc/pgr_ksp.rst b/src/ksp/doc/pgr_ksp.rst
index 6cbdc92..57498f1 100644
--- a/src/ksp/doc/pgr_ksp.rst
+++ b/src/ksp/doc/pgr_ksp.rst
@@ -29,86 +29,92 @@ Synopsis
 
 The K shortest path routing algorithm based on Yen's algorithm. "K" is the number of shortest paths desired.
 
-.. index:: 
-  single: ksp(edges_sql, start_vid, end_vid, k)
-
-.. rubric:: The minimal signature:
+Signature Summary
+-------------------------------------------------------------------------------
 
 .. code-block:: sql
 
-  pgr_ksp(TEXT sql_q, BIGINT start_vid, BIGINT end_vid, INTEGER k);
+    pgr_ksp(edges_sql, start_vid, end_vid, K);
+    pgr_ksp(edges_sql, start_vid, end_vid, k, directed, heap_paths)
     RETURNS SET OF (seq, path_id, path_seq, node, edge, cost, agg_cost) or EMPTY SET
 
+Signatures
+-------------------------------------------------------------------------------
 
 .. index:: 
-  single: ksp(edges_sql, start_vid, end_vid, k, directed, heap_paths)
+  single: ksp(Minimal Signature)
 
-.. rubric:: The full signature:
+Minimal Signature
+..................
 
 .. code-block:: sql
 
-  pgr_ksp(TEXT edges_sql, BIGINT start_vid, BIGINT end_vid, INTEGER k,
-        BOOLEAN directed:=true, BOOLEAN heap_paths:=false);
+    pgr_ksp(edges_sql, start_vid, end_vid, K);
     RETURNS SET OF (seq, path_id, path_seq, node, edge, cost, agg_cost) or EMPTY SET
 
 
-Description of the SQL query
--------------------------------------------------------------------------------
+.. index:: 
+  single: ksp(Complete Signature)
 
-General description of the ``edges_sql``
+Complete Signature
+...................
 
 .. code-block:: sql
 
-    SELECT id, source, target, cost [,reverse_cost] FROM ...
-
-:sql_q: a SQL query, which returns a set of rows with the following columns:
-
-        :id: ``ANY-INTEGER`` identifier of the edge.
-        :source: ``ANY-INTEGER`` identifier of the source vertex of the edge.
-        :target: ``ANY-INTEGER`` identifier of the target vertex of the edge.
-        :cost: ``ANY-NUMERICAL`` value of the edge traversal cost. A negative cost will prevent the edge (``source``, ``target``) from being inserted in the graph.
-        :reverse_cost: ``ANY-NUMERICAL`` (optional) the value for the reverse traversal of the edge. A negative cost will prevent the edge (``target``, ``source``) from being inserted in the graph.
+    pgr_ksp(edges_sql, start_vid, end_vid, k, directed, heap_paths)
+    RETURNS SET OF (seq, path_id, path_seq, node, edge, cost, agg_cost) or EMPTY SET
 
-Where:
 
-:ANY-INTEGER: smallint, int, bigint
-:ANY-NUMERICAL: smallint, int, bigint, real, float
+Description of the Signatures
+-------------------------------------------------------------------------------
 
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
 
-Description of the parameters of the signatures
--------------------------------------------------------------------------------
 
-:sql_q: ``TEXT`` SQL query as decribed above.
-:start_vid: ``BIGINT`` id of the starting vertex.
-:end_vid: ``BIGINT`` id of the ending vertex.
-:k: ``INTEGER`` The desiered number of paths.
-:directed: ``BOOLEAN`` (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
-:heap_paths: ``BOOLEAN`` (optional). When ``true`` returns all the paths stored in the process heap. Default is ``false`` which only returns ``k`` pahts. 
+============== ============ =================================================                                                                                                                                          
+Column         Type           Description                                                                                                                                                                                
+============== ============ =================================================
+**edges_sql**   ``TEXT``    SQL query as described above.
+**start_vid**   ``BIGINT``  Identifier of the starting vertex.
+**end_vid**     ``BIGINT``  Identifier of the ending vertex.
+**k**           ``INTEGER`` The desiered number of paths.
+**directed**    ``BOOLEAN`` (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
+**heap_paths**  ``BOOLEAN`` (optional). When ``true`` returns all the paths stored in the process heap. Default is ``false`` which only returns ``k`` pahts. 
+============== ============ =================================================
 
 Roughly, if the shortest path has ``N`` edges, the heap will contain about than ``N * k`` paths for small value of ``k`` and ``k > 1``.
 
 
 
 Description of the return values
--------------------------------------------------------------------------------
+...................................
 
 Returns set of ``(seq, path_seq, path_id, node, edge, cost, agg_cost)``
 
-:seq: ``INT`` sequential number starting from **1**.
-:path_seq: ``INT`` relative position in the pathi of ``node`` and ``edge``. Has value **1** for the begining of a path.
-:path_id: ``BIGINT`` path identifier. The ordering of the paths For two paths i, j if i < j then agg_cost(i) <= agg_cost(j).
-:node: ``BIGINT`` id of the node in the path.
-:edge: ``BIGINT`` id of the edge used to go from ``node`` to the next node in the path sequence. ``-1`` for the last node of the route.
-:cost: ``FLOAT`` cost to traverse from ``node`` using ``edge`` to the next node in the path sequence.
-:agg_cost:  ``FLOAT`` total cost from ``start_vid`` to ``node``.
+============== =========== =================================================
+Column         Type        Description
+============== =========== =================================================
+**seq**        ``INTEGER`` Sequential value starting from **1**.
+**path_seq**   ``INTEGER`` Relative position in the path of ``node`` and ``edge``. Has value **1** for the beginning of a path.
+**path_id**    ``BIGINT``  Path identifier. The ordering of the paths For two paths i, j if i < j then agg_cost(i) <= agg_cost(j).
+**node**       ``BIGINT``  Identifier of the node in the path.
+**edge**       ``BIGINT``  Identifier of the edge used to go from ``node`` to the next node in the path sequence. ``-1`` for the last node of the route.
+**cost**       ``FLOAT``   Cost to traverse from ``node`` using ``edge`` to the next node in the path sequence.
+**agg_cost**   ``FLOAT``   Aggregate cost from ``start_vid`` to ``node``.
+============== =========== =================================================
 
 
-.. warning:: During the transition to 3.0, because pgr_ksp version 2.0 doesn't have defined a directed flag nor a heap_path flag, when pgr_ksp is used with only one flag version 2.0 will be used.
+.. warning:: During the transition to 3.0, because pgr_ksp version 2.0 doesn't have defined a directed flag nor a heap_path flag, when pgr_ksp is used with only one flag version 2.0 signature will be used.
 
 
-Examples to handle the one flag to choose signatures
+Additional Examples
 ------------------------------------------------------------------------------------------
 
+Examples to handle the one flag to choose signatures
+.........................................................................................
+
 The examples in this section use the following :ref:`fig1`
 
 .. literalinclude:: doc-ksp.queries
@@ -117,7 +123,7 @@ The examples in this section use the following :ref:`fig1`
 
 
 Examples for queries marked as ``directed`` with ``cost`` and ``reverse_cost`` columns
---------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig1`
 
@@ -128,7 +134,7 @@ The examples in this section use the following :ref:`fig1`
 
 
 Examples for queries marked as ``undirected`` with ``cost`` and ``reverse_cost`` columns
-----------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig2`
 
@@ -138,7 +144,7 @@ The examples in this section use the following :ref:`fig2`
 
 
 Examples for queries marked as ``directed`` with ``cost`` column
-----------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig3`
 
@@ -149,7 +155,7 @@ The examples in this section use the following :ref:`fig3`
 
 
 Examples for queries marked as ``undirected`` with ``cost`` column
-----------------------------------------------------------------------------------------
+.........................................................................................
 
 The examples in this section use the following :ref:`fig4`
 
@@ -157,22 +163,13 @@ The examples in this section use the following :ref:`fig4`
     :start-after: --q5
     :end-before: --q6
 
-
-The queries use the :ref:`sampledata` network.
-
-
-.. rubric:: History
-
-* New in version 2.0.0
-* Added functionality version 2.1
-
 See Also
 -------------------------------------------------------------------------------
 
 * http://en.wikipedia.org/wiki/K_shortest_path_routing
+* :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
 * :ref:`genindex`
 * :ref:`search`
-
diff --git a/src/ksp/doc/pgr_ksp_v2.rst b/src/ksp/doc/pgr_ksp_v2.rst
index 950e712..d5f96d7 100644
--- a/src/ksp/doc/pgr_ksp_v2.rst
+++ b/src/ksp/doc/pgr_ksp_v2.rst
@@ -9,11 +9,16 @@
 
 .. _pgr_ksp_v2:
 
-pgr_ksp (V 2.0) 
+pgr_ksp - Deprecated Signature
 ===============================================================================
 
-.. index:: 
-  single: ksp(text,integer,integer,integer,boolean) -- deprecated
+.. warning:: This function signature is deprecated!!!
+
+    * That means it has been replaced by new signature(s)
+    * This signature is no longer supported, and may be removed from future versions.
+    * All code that use this function signature should be converted to use its replacement :ref:`pgr_ksp`.
+
+
 
 Name
 -------------------------------------------------------------------------------
@@ -31,17 +36,6 @@ The K shortest path routing algorithm based on Yen's algorithm. "K" is the numbe
   pgr_costResult3[] pgr_ksp(sql text, source integer, target integer,
                            paths integer, has_rcost boolean);
 
-.. warning:: This signature is being deprecated in version 2.1, Please use it
-             without the ``has_rcost`` flag instead.
-             
-               - for undirected graph.
-                 ``pgr_ksp(sql, source, target, distance, directed:=false)``
-               - for directed graph.
-                 ``pgr_ksp(sql, source, target, distance, directed:=true)``
-
-             See :ref:`pgr_ksp`
-
-
 
 Description
 -------------------------------------------------------------------------------
@@ -103,5 +97,6 @@ The queries use the :ref:`sampledata` network.
 See Also
 -------------------------------------------------------------------------------
 
+* :ref:`pgr_ksp`
 * :ref:`type_cost_result3`
 * http://en.wikipedia.org/wiki/K_shortest_path_routing
diff --git a/src/ksp/src/CMakeLists.txt b/src/ksp/src/CMakeLists.txt
index cc9ac2d..2221b38 100644
--- a/src/ksp/src/CMakeLists.txt
+++ b/src/ksp/src/CMakeLists.txt
@@ -5,4 +5,3 @@ ADD_LIBRARY(ksp OBJECT
     withPoints_ksp_driver.cpp
     ksp_driver.cpp
     )
-
diff --git a/src/ksp/src/ksp.c b/src/ksp/src/ksp.c
index 91b3f2e..e3e5710 100644
--- a/src/ksp/src/ksp.c
+++ b/src/ksp/src/ksp.c
@@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "./../../common/src/pgr_types.h"
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
@@ -32,20 +31,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "access/htup_details.h"
 #endif
 
+#include "./../../common/src/pgr_types.h"
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/time_msg.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
 #include "./ksp_driver.h"
 
-
-PG_FUNCTION_INFO_V1(kshortest_path);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif  // _MSC_VER
-kshortest_path(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum kshortest_path(PG_FUNCTION_ARGS);
 
 
 static
@@ -68,7 +61,7 @@ void compute(char* sql, int64_t start_vertex,
   }
 
   PGR_DBG("Load data");
-  pgr_get_data_5_columns(sql, &edges, &total_tuples);
+  pgr_get_edges(sql, &edges, &total_tuples);
 
   PGR_DBG("Total %ld tuples in query:", total_tuples);
   PGR_DBG("Calling do_pgr_ksp\n");
@@ -82,7 +75,7 @@ void compute(char* sql, int64_t start_vertex,
   time_msg(" processing KSP", start_t, clock());
 
   PGR_DBG("total tuples found %ld\n", *path_count);
-  PGR_DBG("Exist Status = %i\n", ret);
+  PGR_DBG("Exit Status = %i\n", errcode);
   PGR_DBG("Returned message = %s\n", err_msg);
 
 
@@ -97,11 +90,8 @@ void compute(char* sql, int64_t start_vertex,
 }
 
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(kshortest_path);
 PGDLLEXPORT Datum
-#endif  // _MSC_VER
 kshortest_path(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t               call_cntr;
@@ -163,7 +153,7 @@ kshortest_path(PG_FUNCTION_ARGS) {
     path = (General_path_element_t*) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {   /* do when there is more left to send */
-        PGR_DBG("returning %ld \n", call_cntr);
+        PGR_DBG("returning %u \n", call_cntr);
         HeapTuple    tuple;
         Datum        result;
         /* //Datum values[4];
diff --git a/src/ksp/src/ksp.h b/src/ksp/src/ksp.h
deleted file mode 100644
index 600650b..0000000
--- a/src/ksp/src/ksp.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*PGR-GNU*****************************************************************
-File: ksp.h
-
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include "./../../common/src/pgr_types.h"
-
-    int compute(char* sql, int64_t start_vertex,
-            int64_t end_vertex, int no_paths,
-            bool has_reverse_cost, bool directedFlag,
-            General_path_element_t **path, size_t *ksp_path_count);
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/src/ksp/src/ksp_driver.cpp b/src/ksp/src/ksp_driver.cpp
index 62acd1e..9cc911e 100644
--- a/src/ksp/src/ksp_driver.cpp
+++ b/src/ksp/src/ksp_driver.cpp
@@ -22,21 +22,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#ifdef open
+#undef open
+#endif
 #ifdef unlink
 #undef unlink
 #endif
 #endif
 
-
 #include <deque>
 #include <sstream>
 
 
 #include "./ksp_driver.h"
-#include "../../common/src/memory_func.hpp"
+#include "../../common/src/pgr_alloc.hpp"
 #include "./pgr_ksp.hpp"
 
 
@@ -48,22 +50,23 @@ int  do_pgr_ksp(
         General_path_element_t **ksp_path, size_t *path_count,
         char ** err_msg) {
     try {
+        *ksp_path = NULL;
+        *path_count = 0;
         std::ostringstream log;
 
         graphType gType = directedFlag? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_tuples;
 
         std::deque< Path > paths;
 
         if (directedFlag) {
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
-            Pgr_ksp< Pgr_base_graph< DirectedGraph > > fn_yen;
-            digraph.graph_insert_data(data_edges, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
+            Pgr_ksp< pgrouting::DirectedGraph > fn_yen;
+            digraph.graph_insert_data(data_edges, total_tuples);
             paths = fn_yen.Yen(digraph, start_vertex, end_vertex, k, heap_paths);
         } else {
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
-            Pgr_ksp< Pgr_base_graph< UndirectedGraph > > fn_yen;
-            undigraph.graph_insert_data(data_edges, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
+            Pgr_ksp< pgrouting::UndirectedGraph > fn_yen;
+            undigraph.graph_insert_data(data_edges, total_tuples);
             paths = fn_yen.Yen(undigraph, start_vertex, end_vertex, k, heap_paths);
         }
 
@@ -73,13 +76,12 @@ int  do_pgr_ksp(
         if (count == 0) {
             *err_msg = strdup(
                     "NOTICE: No paths found between Starting and Ending vertices");
-            *ksp_path = noResult(path_count, (*ksp_path));
             return 0;
         }
 
         // get the space required to store all the paths
         *ksp_path = NULL;
-        *ksp_path = get_memory(count, (*ksp_path));
+        *ksp_path = pgr_alloc(count, (*ksp_path));
 
         size_t sequence = 0;
         int route_id = 0;
@@ -89,10 +91,10 @@ int  do_pgr_ksp(
             ++route_id;
         }
 
-        if (count != sequence) {                                
+        if (count != sequence) {
             *err_msg = NULL;
             return 2;
-        }                                                                                                       
+        }
         *path_count = count;
 
 #if 1
@@ -102,7 +104,9 @@ int  do_pgr_ksp(
 #endif
         return EXIT_SUCCESS;
     } catch ( ... ) {
-        *err_msg = strdup("Caught unknown expection!");
+        *err_msg = strdup("Caught unknown exception!");
+        if (ksp_path) free(ksp_path);
+        *path_count = 0;
         return -1;
     }
 }
diff --git a/src/ksp/src/ksp_driver.h b/src/ksp/src/ksp_driver.h
index ef0cae6..62dac5e 100644
--- a/src/ksp/src/ksp_driver.h
+++ b/src/ksp/src/ksp_driver.h
@@ -24,12 +24,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #pragma once
 
+#include "./../../common/src/pgr_types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "./../../common/src/pgr_types.h"
-
     int  do_pgr_ksp(pgr_edge_t  * edges, size_t total_tuples,
             int64_t  start_vertex, int64_t end_vertex,
             int no_paths, bool directed, bool heap_paths,
diff --git a/src/ksp/src/pgr_ksp.cpp b/src/ksp/src/pgr_ksp.cpp
index 98004d0..ddae481 100644
--- a/src/ksp/src/pgr_ksp.cpp
+++ b/src/ksp/src/pgr_ksp.cpp
@@ -21,7 +21,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #ifdef unlink
@@ -53,16 +53,19 @@ void Pgr_ksp< G >::getFirstSolution(G &graph) {
 
 template < class G>
 std::deque<Path>
-Pgr_ksp< G >::Yen(G &graph, 
+Pgr_ksp< G >::Yen(G &graph,
   int64_t  start_vertex, int64_t end_vertex, int K, bool heap_paths) {
     m_ResultSet.clear();
     m_Heap.clear();
+
     if ((start_vertex != end_vertex) && (K > 0)) {
-        if   (!graph.get_gVertex(start_vertex, v_source)
-           || !graph.get_gVertex(end_vertex, v_target)) {
-             std::deque<Path> l_ResultList;
-             return l_ResultList;
+        if (!graph.has_vertex(start_vertex)
+                || !graph.has_vertex(end_vertex)) {
+            std::deque<Path> l_ResultList;
+            return l_ResultList;
         }
+        v_source = graph.get_V(start_vertex);
+        v_target = graph.get_V(end_vertex);
         m_start = start_vertex;
         m_end = end_vertex;
         executeYen(graph, K);
@@ -101,8 +104,10 @@ void Pgr_ksp< G >::doNextCycle(G &graph) {
 
         for (const auto &path : m_ResultSet) {
             if (path.isEqual(rootPath)) {
-                graph.disconnect_edge(path[i].node,     // from
-                        path[i + 1].node);  // to
+                if (path.size() > i + 1) {
+                    graph.disconnect_edge(path[i].node,     // from
+                            path[i + 1].node);  // to
+                }
             }
         }
         removeVertices(graph, rootPath);
@@ -111,7 +116,7 @@ void Pgr_ksp< G >::doNextCycle(G &graph) {
         // THROW_ON_SIGINT
         Pgr_dijkstra< G > fn_dijkstra;
         fn_dijkstra.dijkstra(graph, spurPath, spurNodeId, m_end);
-        //this->dijkstra(spurPath, spurNodeId , m_end);
+        // this->dijkstra(spurPath, spurNodeId , m_end);
         // THROW_ON_SIGINT
 
         if (spurPath.size() > 0) {
diff --git a/src/ksp/src/pgr_ksp.hpp b/src/ksp/src/pgr_ksp.hpp
index b7d9583..2b9effe 100644
--- a/src/ksp/src/pgr_ksp.hpp
+++ b/src/ksp/src/pgr_ksp.hpp
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #pragma once
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #ifdef unlink
@@ -32,11 +32,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 #endif
 
-
+#include <sstream>
 #include <deque>
+#include <vector>
 #include <set>
-#include "./../../common/src/basePath_SSEC.hpp"
 #include "./../../dijkstra/src/pgr_dijkstra.hpp"
+#include "./../../common/src/basePath_SSEC.hpp"
 
 template < class G >
 class Pgr_ksp {
@@ -92,7 +93,7 @@ class Pgr_ksp {
 
      Path curr_result_path;  //!< storage for the current result
 
-     typedef typename  std::set<Path, compPaths> pSet;
+     typedef std::set<Path, compPaths> pSet;
      pSet m_ResultSet;  //!< ordered set of shortest paths
      pSet m_Heap;  //!< the heap
 };
diff --git a/src/ksp/src/withPoints_ksp.c b/src/ksp/src/withPoints_ksp.c
index f39eab9..7ad2ea6 100644
--- a/src/ksp/src/withPoints_ksp.c
+++ b/src/ksp/src/withPoints_ksp.c
@@ -47,13 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./withPoints_ksp_driver.h"
 #include "./../../common/src/debug_macro.h"
 
-PG_FUNCTION_INFO_V1(withPoints_ksp);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-withPoints_ksp(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum withPoints_ksp(PG_FUNCTION_ARGS);
 
 
 /*******************************************************************************/
@@ -75,7 +69,7 @@ process(
         General_path_element_t **result_tuples,
         size_t *result_count) {
 
-    driving_side[0] = tolower(driving_side[0]);
+    driving_side[0] = (char) tolower(driving_side[0]);
     PGR_DBG("driving side:%c",driving_side[0]);
     if (! ((driving_side[0] == 'r')
                 || (driving_side[0] == 'l'))) {
@@ -98,11 +92,11 @@ process(
 
     pgr_edge_t *edges_of_points = NULL;
     size_t total_edges_of_points = 0;
-    pgr_get_data_5_columns(edges_of_points_query, &edges_of_points, &total_edges_of_points);
+    pgr_get_edges(edges_of_points_query, &edges_of_points, &total_edges_of_points);
 
     pgr_edge_t *edges = NULL;
     size_t total_edges = 0;
-    pgr_get_data_5_columns(edges_no_points_query, &edges, &total_edges);
+    pgr_get_edges(edges_no_points_query, &edges, &total_edges);
 
     PGR_DBG("freeing allocated memory not used anymore");
     free(edges_of_points_query);
@@ -161,11 +155,8 @@ process(
 
 
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(withPoints_ksp);
 PGDLLEXPORT Datum
-#endif
 withPoints_ksp(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t             call_cntr;
diff --git a/src/ksp/src/withPoints_ksp_driver.cpp b/src/ksp/src/withPoints_ksp_driver.cpp
index a01a0d2..c2e478a 100644
--- a/src/ksp/src/withPoints_ksp_driver.cpp
+++ b/src/ksp/src/withPoints_ksp_driver.cpp
@@ -28,23 +28,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
-//#ifdef unlink
-//#undef unlink
-//#endif
 #endif
 
-
 #include <sstream>
 #include <deque>
 #include <vector>
+#include "./pgr_ksp.hpp"
 #include "./withPoints_ksp_driver.h"
 #include "./../../withPoints/src/pgr_withPoints.hpp"
-#include "./../../common/src/memory_func.hpp"
-#include "./pgr_ksp.hpp"
-
+#include "./../../common/src/pgr_alloc.hpp"
 
 
 // CREATE OR REPLACE FUNCTION pgr_withPointsKSP(
@@ -69,7 +64,7 @@ do_pgr_withPointsKsp(
         bool details,
         General_path_element_t **return_tuples,
         size_t *return_count,
-        char ** err_msg){
+        char ** err_msg) {
     std::ostringstream log;
     try {
         /*
@@ -101,23 +96,22 @@ do_pgr_withPointsKsp(
 
 
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_edges;
 
         std::deque< Path > paths;
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(edges, total_edges);
             digraph.graph_insert_data(new_edges);
-            Pgr_ksp< Pgr_base_graph< DirectedGraph > > fn_yen;
+            Pgr_ksp< pgrouting::DirectedGraph  > fn_yen;
             paths = fn_yen.Yen(digraph, start_vid, end_vid, k, heap_paths);
         } else {
             log << "Working with undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(edges, total_edges);
             undigraph.graph_insert_data(new_edges);
-            Pgr_ksp< Pgr_base_graph< UndirectedGraph > > fn_yen;
+            Pgr_ksp< pgrouting::UndirectedGraph > fn_yen;
             paths = fn_yen.Yen(undigraph, start_vid, end_vid, k, heap_paths);
         }
 
@@ -143,7 +137,7 @@ do_pgr_withPointsKsp(
 
 
         *return_tuples = NULL;
-        *return_tuples = get_memory(count, (*return_tuples));
+        *return_tuples = pgr_alloc(count, (*return_tuples));
 
         size_t sequence = 0;
         int route_id = 0;
@@ -166,7 +160,7 @@ do_pgr_withPointsKsp(
 #endif
         return 0;
     } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+        log << "Caught unknown exception!\n";
         *err_msg = strdup(log.str().c_str());
     }
     return 1000;
diff --git a/src/ksp/src/withPoints_ksp_driver.h b/src/ksp/src/withPoints_ksp_driver.h
index e304dae..fb09eec 100644
--- a/src/ksp/src/withPoints_ksp_driver.h
+++ b/src/ksp/src/withPoints_ksp_driver.h
@@ -28,12 +28,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #pragma once
 
+#include "./../../common/src/pgr_types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "./../../common/src/pgr_types.h"
-
     //  CREATE OR REPLACE FUNCTION pgr_withPointKsp(
     //  edges_sql TEXT,
     //  points_sql TEXT,
diff --git a/src/ksp/test/doc-ksp-v2.test.sql b/src/ksp/test/doc-ksp-v2.test.sql
index de709b2..15beb93 100644
--- a/src/ksp/test/doc-ksp-v2.test.sql
+++ b/src/ksp/test/doc-ksp-v2.test.sql
@@ -1,3 +1,5 @@
+SET client_min_messages TO NOTICE;
+
 \echo --q1
 
 SELECT * FROM pgr_ksp(
diff --git a/src/ksp/test/doc-ksp.test.sql b/src/ksp/test/doc-ksp.test.sql
index 3d467ce..81d6b79 100644
--- a/src/ksp/test/doc-ksp.test.sql
+++ b/src/ksp/test/doc-ksp.test.sql
@@ -1,6 +1,7 @@
 --------------------------------------------------------------------------------
 --              PGR_ksp V3
 --------------------------------------------------------------------------------
+SET client_min_messages TO NOTICE;
 
 \echo --q1
 
diff --git a/src/ksp/test/ksp-network.test.sql b/src/ksp/test/ksp-network.test.sql
index eadf435..c102968 100644
--- a/src/ksp/test/ksp-network.test.sql
+++ b/src/ksp/test/ksp-network.test.sql
@@ -1,4 +1,5 @@
 BEGIN;
+SET client_min_messages TO NOTICE;
 --
 -- Generate 15 shortest paths between nodes 4 and 5
 -- with auto detection
diff --git a/src/label_graph/CMakeLists.txt b/src/label_graph/CMakeLists.txt
deleted file mode 100644
index c51535e..0000000
--- a/src/label_graph/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-SUBDIRS(doc src test)
diff --git a/src/label_graph/doc/CMakeLists.txt b/src/label_graph/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/label_graph/doc/pgr_labelGraph.rst b/src/label_graph/doc/pgr_labelGraph.rst
index 84a9225..721bdc3 100644
--- a/src/label_graph/doc/pgr_labelGraph.rst
+++ b/src/label_graph/doc/pgr_labelGraph.rst
@@ -11,31 +11,33 @@
 .. _pgr_labelGraph:
 
 
-pgr_labelGraph
+pgr_labelGraph - Proposed
 ===============================================================================
 
-.. index:: 
-	single: pgr_labelGraph(text, text, text, text, text, text)
-	module: common
-
-
-
 Name
 -------------------------------------------------------------------------------
 
-``pgr_labelGraph`` — Locates and labels sub-networks within a network which are not topologically connected. Must be run after ``pgr_createTopology()``. No use of ``geometry`` column. Only ``id``, ``source`` and  ``target`` columns are required.
+``pgr_labelGraph`` — Locates and labels sub-networks within a network which are not topologically connected.
 
+.. include:: ../../proposed.rst
+    :start-after: begin-warning
+    :end-before: end-warning
 
 
 Synopsis
 -------------------------------------------------------------------------------
 
+Must be run after ``pgr_createTopology()``. No use of ``geometry`` column. Only ``id``, ``source`` and  ``target`` columns are required.
+
 The function returns:
 
   - ``OK`` when a column with provided name has been generated and populated successfully. All connected edges will have unique similar integer values. In case of ``rows_where`` condition, non participating rows will have -1 integer values.
   - ``FAIL`` when the processing cannot be finished due to some error. Notice will be thrown accordingly.
   - ``rows_where condition generated 0 rows`` when passed SQL condition has not been fulfilled by any row. 
 
+.. index:: 
+	single: labelGraph(Complete Signature) - Proposed
+
 .. code-block:: sql
 
 	varchar pgr_labelGraph(text, text, text, text, text, text)
diff --git a/src/label_graph/src/CMakeLists.txt b/src/label_graph/src/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/linecommand/src/dijkstra.hpp b/src/linecommand/src/dijkstra.hpp
index 9d338f6..40d2837 100644
--- a/src/linecommand/src/dijkstra.hpp
+++ b/src/linecommand/src/dijkstra.hpp
@@ -21,53 +21,55 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-      
-template <typename G> 
-void process_dijkstra(G &graph, const std::vector<std::string> &tokens) {
+#include <deque>
+#include <string>
+#include <vector>
 
-      std::string::size_type sz;
-      if (tokens[1].compare("from") != 0) {
+template <typename G>
+void process_dijkstra(G &graph, const std::vector<std::string> &tokens) {
+    std::string::size_type sz;
+    if (tokens[1].compare("from") != 0) {
         std::cout << "missing 'from' kewyword\n";
         return;
-      }
+    }
 
-      std::vector< int64_t > sources; 
-      unsigned int i_ptr = 2;
+    std::vector< int64_t > sources;
+    unsigned int i_ptr = 2;
 
-      for ( ; i_ptr < tokens.size(); ++i_ptr) {
-          if (tokens[i_ptr].compare("to") == 0) break;
-          try {
+    for ( ; i_ptr < tokens.size(); ++i_ptr) {
+        if (tokens[i_ptr].compare("to") == 0) break;
+        try {
             uint64_t start_vertex(stol(tokens[i_ptr], &sz));
             sources.push_back(start_vertex);
-          } catch(...) {
+        } catch(...) {
             break;
-          }
-      }
+        }
+    }
 
-      if (i_ptr == tokens.size() || tokens[i_ptr].compare("to") != 0) {
+    if (i_ptr == tokens.size() || tokens[i_ptr].compare("to") != 0) {
         std::cout << "dijkstra: 'dist' kewyword not found\n";
         return;
-      }
+    }
 
-      if (sources.size() == 0) {
+    if (sources.size() == 0) {
         std::cout << "dijkstra: No start value found\n";
         return;
-      }
+    }
 
-      ++i_ptr;
-      if (i_ptr == tokens.size()) {
+    ++i_ptr;
+    if (i_ptr == tokens.size()) {
         std::cout << "dijkstra: No 'to' values found\n";
         return;
-      }
+    }
 
-      std::vector< int64_t > targets; 
-      for ( ; i_ptr < tokens.size(); ++i_ptr) {
+    std::vector< int64_t > targets;
+    for ( ; i_ptr < tokens.size(); ++i_ptr) {
         auto end_vertex(stol(tokens[i_ptr], &sz));
         targets.push_back(end_vertex);
-      }
+    }
 
-      
-      if (sources.size() == 1 && targets.size() == 1) {
+
+    if (sources.size() == 1 && targets.size() == 1) {
         // one to one
         Path path;
         pgr_dijkstra(graph, path, sources[0], targets[0]);
@@ -76,38 +78,38 @@ void process_dijkstra(G &graph, const std::vector<std::string> &tokens) {
         path.clear();
 
 
-      } else if (sources.size() == 1 && targets.size() > 1){
+    } else if (sources.size() == 1 && targets.size() > 1) {
         // one to many
         pgr_dijkstra(graph, paths, sources[0], targets);
 
         std::cout << "THE OPUTPUTS ---->  total outputs: " << paths.size() << "\n";
         for (unsigned int i = 0; i < paths.size(); ++i) {
-           if (sizeof(paths[i]) == 0) continue; //no solution found
-           std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
-           paths[i].print_path();
+            if (sizeof(paths[i]) == 0) continue;  // no solution found
+            std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
+            paths[i].print_path();
         }
-      } else if (sources.size() > 1 && targets.size() == 1){
+    } else if (sources.size() > 1 && targets.size() == 1) {
         // many to 1
         std::deque<Path> paths;
         pgr_dijkstra(graph, paths, sources, targets[0]);
-        
+
 
         std::cout << "THE OPUTPUTS ---->  total outputs: " << paths.size() << "\n";
         for (unsigned int i = 0; i < paths.size(); ++i) {
-           if (sizeof(paths[i]) == 0) continue; //no solution found
-           std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
-           paths[i].print_path();
+            if (sizeof(paths[i]) == 0) continue;  // no solution found
+            std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
+            paths[i].print_path();
         }
-      } else {
-        //many to many
+    } else {
+        // many to many
         std::deque<Path> paths;
         pgr_dijkstra(graph, paths, sources, targets);
 
         std::cout << "THE OPUTPUTS ---->  total outputs: " << paths.size() << "\n";
         for (unsigned int i = 0; i < paths.size(); ++i) {
-          if (sizeof(paths[i]) == 0) continue; //no solution found
-          std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
-          paths[i].print_path();
+            if (sizeof(paths[i]) == 0) continue;  // no solution found
+            std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
+            paths[i].print_path();
         }
-      }
+    }
 }
diff --git a/src/linecommand/src/driving.cpp b/src/linecommand/src/driving.cpp
index 5d911f4..8294ff6 100644
--- a/src/linecommand/src/driving.cpp
+++ b/src/linecommand/src/driving.cpp
@@ -20,15 +20,19 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-void process_drivingDistance(G &graph, const std::vector<std::string> &tokens) {
 
+#include <deque>
+#include <string>
+#include <vector>
+
+void process_drivingDistance(G &graph, const std::vector<std::string> &tokens) {
       std::string::size_type sz;
       if (tokens[1].compare("from") != 0) {
         std::cout << "missing 'from' kewyword\n";
         return;
       }
 
-      std::vector< int64_t > sources; 
+      std::vector< int64_t > sources;
       unsigned int i_ptr = 2;
 
       for ( ; i_ptr < tokens.size(); ++i_ptr) {
@@ -88,12 +92,12 @@ void process_drivingDistance(G &graph, const std::vector<std::string> &tokens) {
           std::cout << "\t\t\tTHE OPUTPUT\n";
           std::cout << "seq\tfrom\tnode\tedge\tcost\n";
           for (const auto &path :  paths) {
-            if (sizeof(path) == 0) return; //no solution found
+            if (sizeof(path) == 0) return;  // no solution found
             path.print_path();
           }
         } else {
           std::cout << "Performing pgr_DrivingDistance for multiple sources with equi-cost\n";
-          Path path = equi_cost(paths); 
+          Path path = equi_cost(paths);
           std::cout << "\t\t\tTHE EquiCost OPUTPUT\n";
           std::cout << "seq\tfrom\tnode\tedge\tcost\n";
           path.print_path();
diff --git a/src/linecommand/src/ksp.cpp b/src/linecommand/src/ksp.cpp
index c020fd0..f4fc385 100644
--- a/src/linecommand/src/ksp.cpp
+++ b/src/linecommand/src/ksp.cpp
@@ -1,15 +1,40 @@
+/*PGR-GNU*****************************************************************
 
-      
-template <typename G> 
-void process_ksp(G &graph, const std::vector<std::string> &tokens) {
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
 
+
+#include <deque>
+#include <string>
+#include <vector>
+
+template <typename G>
+void process_ksp(G &graph, const std::vector<std::string> &tokens) {
       std::string::size_type sz;
       if (tokens[1].compare("from") != 0) {
         std::cout << "ksp: missing 'from' kewyword\n";
         return;
       }
 
-      std::vector< int64_t > sources; 
+      std::vector< int64_t > sources;
       unsigned int i_ptr = 2;
 
       for ( ; i_ptr < tokens.size(); ++i_ptr) {
@@ -38,62 +63,62 @@ void process_ksp(G &graph, const std::vector<std::string> &tokens) {
         return;
       }
 
-      std::vector< int64_t > targets; 
+      std::vector< int64_t > targets;
       for ( ; i_ptr < tokens.size(); ++i_ptr) {
         auto end_vertex(stol(tokens[i_ptr], &sz));
         targets.push_back(end_vertex);
       }
 
       Pgr_ksp< G > ksp;
-      
+
       if (sources.size() == 1 && targets.size() == 1) {
         // one to one
         std::deque< Path > paths;
-        paths = ksp.Yen(graph, sources[0], targets[0], 3); //TODO make variable
+        paths = ksp.Yen(graph, sources[0], targets[0], 3);  // TODO(someone) make variable
         std::cout << "THE OPUTPUT ----" << "\n";
         for (unsigned int i = 0; i < paths.size(); ++i) {
-           if (sizeof(paths[i]) == 0) continue; //no solution found
+           if (sizeof(paths[i]) == 0) continue;  // no solution found
            std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
            paths[i].print_path();
         }
       } else {
-	std::cout << "ksp: unknown number of arguments\n";
+    std::cout << "ksp: unknown number of arguments\n";
       }
-#if 0 // ksp is only one to 1
-	else if (sources.size() == 1 && targets.size() > 1){
+#if 0
+    // ksp is only one to 1
+    } else if (sources.size() == 1 && targets.size() > 1) {
         // one to many
         std::deque<Path> paths;
         dijkstra.dijkstra(graph, paths, sources[0], targets);
 
         std::cout << "THE OPUTPUTS ---->  total outputs: " << paths.size() << "\n";
         for (unsigned int i = 0; i < paths.size(); ++i) {
-           if (sizeof(paths[i]) == 0) continue; //no solution found
+           if (sizeof(paths[i]) == 0) continue;  // no solution found
            std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
            paths[i].print_path();
         }
-      } else if (sources.size() > 1 && targets.size() == 1){
+      } else if (sources.size() > 1 && targets.size() == 1) {
         // many to 1
         std::deque<Path> paths;
         dijkstra.dijkstra(graph, paths, sources, targets[0]);
-        
+
 
         std::cout << "THE OPUTPUTS ---->  total outputs: " << paths.size() << "\n";
         for (unsigned int i = 0; i < paths.size(); ++i) {
-           if (sizeof(paths[i]) == 0) continue; //no solution found
+           if (sizeof(paths[i]) == 0) continue;  // no solution found
            std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
            paths[i].print_path();
         }
       } else {
-        //many to many
+        // many to many
         std::deque<Path> paths;
         dijkstra.dijkstra(graph, paths, sources, targets);
         std::cout << "THE OPUTPUTS ---->  total outputs: " << paths.size() << "\n";
         for (unsigned int i = 0; i < paths.size(); ++i) {
-          if (sizeof(paths[i]) == 0) continue; //no solution found
+          if (sizeof(paths[i]) == 0) continue;  // no solution found
           std::cout << "Path #" << i << " cost: " << paths[i].cost << "\n";
           paths[i].print_path();
         }
       }
 #endif
-
 }
diff --git a/src/linecommand/src/pgRouting.cpp b/src/linecommand/src/pgRouting.cpp
index 771af5b..e768141 100644
--- a/src/linecommand/src/pgRouting.cpp
+++ b/src/linecommand/src/pgRouting.cpp
@@ -20,16 +20,11 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-
-/************************************************************************/
-/* $Id: MainP.cpp 65 2010-09-08 06:48:36Z yan.qi.asu $                                                                 */
-/************************************************************************/
 #include <boost/config.hpp>
 #include <string>
-#include <boost/program_options.hpp>
+#include <vector>
 namespace po = boost::program_options;
 
-#include <boost/graph/adjacency_list.hpp>
 
 #include <iostream>
 #include <sstream>
@@ -38,6 +33,8 @@ namespace po = boost::program_options;
 #include <unistd.h>
 #include <libpq-fe.h>
 
+#include <boost/program_options.hpp>
+#include <boost/graph/adjacency_list.hpp>
 
 #include "postgres.h"
 #include "./../../common/src/pgr_types.h"
@@ -53,102 +50,100 @@ namespace po = boost::program_options;
 
 
 /****************************************
-SIMULATES  THE C CODE THAT LOADS THE DATA
-****************************************/
+  SIMULATES  THE C CODE THAT LOADS THE DATA
+ ****************************************/
 void import_from_file(const std::string &input_file_name, pgr_edge_t *edges, unsigned int *count, int64_t start_vertex, int64_t end_vertex, bool &found) {
     const char* file_name = input_file_name.c_str();
 
     std::ifstream ifs(file_name);
     if (!ifs) {
-            std::cerr << "The file " << file_name << " can not be opened!" << std::endl;
-            exit(1);
+        std::cerr << "The file " << file_name << " can not be opened!" << std::endl;
+        exit(1);
     }
 
-        ifs >> (*count);
-
-        long edge_id; // , start_id, end_id;
-        //double edge_weight, reverse_weight;
-        bool s_found = false;
-        bool t_found = false;
-
-        unsigned int i = 0;
-        while (i < (*count) && ifs >> edge_id) {
-                if (edge_id == -1)  break;
-                edges[i].id = edge_id;
-                ifs >> edges[i].source;
-                ifs >> edges[i].target;
-                ifs >> edges[i].cost;
-                ifs >> edges[i].reverse_cost;
-                // when loading checking if start and end are found
-                if (!s_found)
-                   s_found = ((edges[i].source == start_vertex) || (edges[i].target == end_vertex));
-                if (!t_found)
-                   t_found = ((edges[i].source == end_vertex) || (edges[i].target == end_vertex));
-                i++;
-        }
-  ifs.close();
-  found = s_found && t_found;
+    ifs >> (*count);
+
+    int64_t edge_id;  // , start_id, end_id;
+    // double edge_weight, reverse_weight;
+    bool s_found = false;
+    bool t_found = false;
+
+    unsigned int i = 0;
+    while (i < (*count) && ifs >> edge_id) {
+        if (edge_id  ==  -1)  break;
+        edges[i].id = edge_id;
+        ifs >> edges[i].source;
+        ifs >> edges[i].target;
+        ifs >> edges[i].cost;
+        ifs >> edges[i].reverse_cost;
+        // when loading checking if start and end are found
+        if (!s_found)
+            s_found = ((edges[i].source  ==  start_vertex) || (edges[i].target  ==  end_vertex));
+        if (!t_found)
+            t_found = ((edges[i].source  ==  end_vertex) || (edges[i].target  ==  end_vertex));
+        i++;
+    }
+    ifs.close();
+    found = s_found && t_found;
 }
 
 void get_options_description(po::options_description &od_desc) {
     od_desc.add_options()
         ("help", "Produce this help message.")
         ("test,t",  po::value<bool>()->default_value(true),
-            "For testing purposes.")
-        ("dbname,d", po::value<std::string>()->required(), 
-            "Specifies the name of the database to connect to.")
+         "For testing purposes.")
+        ("dbname,d", po::value<std::string>()->required(),
+         "Specifies the name of the database to connect to.")
         ("host,h",  po::value<std::string>()->default_value("localhost"),
-            "Specifies the host name of the machine on which the server is running.")
+         "Specifies the host name of the machine on which the server is running.")
         ("port,p",  po::value<std::string>()->default_value("5432"),
-            "Port number to connect to at the server host.")
+         "Port number to connect to at the server host.")
         ("username,U",  po::value<std::string>()->default_value(getlogin()),
-            "Connect to the database as the user username instead of the default.\n (You must have permission to do so, of course.)")
+         "Connect to the database as the user username instead of the default.\n (You must have permission to do so, of course.)")
         ("password,W",  po::value<std::string>()->default_value(""),
-            "User's the password.\n")
+         "User's the password.\n");
 #if 0
-        ("no-password,w",  po::value<bool>()->implicit_value(false),
-            "Never issue a password prompt.\n" 
-            "If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail.\n"
-            "This option can be useful in batch jobs and scripts where no user is present to enter a password.")
+    ("no-password,w",  po::value<bool>()->implicit_value(false),
+     "Never issue a password prompt.\n"
+     "If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail.\n"
+     "This option can be useful in batch jobs and scripts where no user is present to enter a password.")
 #endif
-    ;
 }
 
 
 int process_command_line(
-  po::variables_map &vm, 
-  po::options_description &od_desc) {
-
+        po::variables_map &vm,
+        po::options_description &od_desc) {
     if (vm.count("help")) {
         std::cout << od_desc << "\n";
         return 0;
     }
 
-    if (vm.count("dbname")) 
-      std::cout << "dbname = " << vm["dbname"].as<std::string>() << "\n";
+    if (vm.count("dbname"))
+        std::cout << "dbname = " << vm["dbname"].as<std::string>() << "\n";
     else
-      std::cout << "Parameter: dbname missing\n";
+        std::cout << "Parameter: dbname missing\n";
 
-    if (vm.count("host")) 
-      std::cout << "host = " << vm["host"].as<std::string>() << "\n";
+    if (vm.count("host"))
+        std::cout << "host = " << vm["host"].as<std::string>() << "\n";
     else
-      std::cout << "Parameter: host missing\n";
+        std::cout << "Parameter: host missing\n";
 
-    if (vm.count("port")) 
-      std::cout << "port = " << vm["port"].as<std::string>() << "\n";
+    if (vm.count("port"))
+        std::cout << "port = " << vm["port"].as<std::string>() << "\n";
     else
-      std::cout << "Parameter: port missing\n";
+        std::cout << "Parameter: port missing\n";
 
-    if (vm.count("username")) 
-      std::cout << "username = " << vm["username"].as<std::string>() << "\n";
+    if (vm.count("username"))
+        std::cout << "username = " << vm["username"].as<std::string>() << "\n";
     else
-      std::cout << "Parameter: username missing\n";
+        std::cout << "Parameter: username missing\n";
 
     if (vm.count("dbname") & vm.count("username") & vm.count("host")) {
         std::cout << "Parameters: \n"
-             << vm["dbname"].as<std::string>() << "\n"
-             << vm["username"].as<std::string>() << "\n"
-             << vm["host"].as<std::string>() << ".\n";
+            << vm["dbname"].as<std::string>() << "\n"
+            << vm["username"].as<std::string>() << "\n"
+            << vm["host"].as<std::string>() << ".\n";
         return 2;
     } else {
         std::cout << "Missing parameter.\n";
@@ -159,81 +154,80 @@ int process_command_line(
 
 
 static void
-exit_nicely(PGconn *conn)
-{
+exit_nicely(PGconn *conn) {
     PQfinish(conn);
     exit(1);
 }
 
 
 
-template <typename G> 
+template <typename G>
 void process(G graph, pgr_edge_t *data_edges, int row_count) {
-  graph.graph_insert_data(data_edges, row_count);
-  std::vector<int64_t> targets;
-  std::string::size_type sz;
-
-  
-  // read the command and break into tokens
-  std::string cmd;
-  std::string buf;
-  std::vector<std::string> tokens;
-  while (true) {
-    std::cout << "\n\n\n\n\t\t COMMANDS\n\n "
-     << "\tWARSHALL\n"
-     << "\twarshall\n"
-
-     << "\n\tKSP\n"
-     << "(Input the command separating with spaces)\n"
-     << "\tksp from  to \n"
-
-     << "\n\tDIJKSTRA\n"
-     << "(Input the command separating with spaces)\n"
-     << "\tdijkstra from  to \n"
-     << "\tdijkstra from  to1 to2 to3\n\n"
-
-     << "\n\tDRIVING DISTANCE\n"
-     << "(Use kewywords)\n"
-     << "\tdrivDist from <id> [<id> ...] dist <distance> [equi]\n"
-
-     << "\n\tFINISH\n"
-     << "\tend\n\n"
-     << ">>>";
-    tokens.clear();
-    targets.clear();
-    cmd = "";
-    std::getline(std::cin, cmd);
-    std::stringstream ss(cmd);
-    while (ss >> buf) {
-        tokens.push_back(buf);
-    }
+    graph.graph_insert_data(data_edges, row_count);
+    std::vector<int64_t> targets;
+    std::string::size_type sz;
+
+
+    // read the command and break into tokens
+    std::string cmd;
+    std::string buf;
+    std::vector<std::string> tokens;
+    while (true) {
+        std::cout << "\n\n\n\n\t\t COMMANDS\n\n "
+            << "\tWARSHALL\n"
+            << "\twarshall\n"
+
+            << "\n\tKSP\n"
+            << "(Input the command separating with spaces)\n"
+            << "\tksp from  to \n"
+
+            << "\n\tDIJKSTRA\n"
+            << "(Input the command separating with spaces)\n"
+            << "\tdijkstra from  to \n"
+            << "\tdijkstra from  to1 to2 to3\n\n"
+
+            << "\n\tDRIVING DISTANCE\n"
+            << "(Use kewywords)\n"
+            << "\tdrivDist from <id> [<id> ...] dist <distance> [equi]\n"
+
+            << "\n\tFINISH\n"
+            << "\tend\n\n"
+            << ">>>";
+        tokens.clear();
+        targets.clear();
+        cmd = "";
+        std::getline(std::cin, cmd);
+        std::stringstream ss(cmd);
+        while (ss >> buf) {
+            tokens.push_back(buf);
+        }
 
-    if (tokens.size() == 0) {
-      std::cout << "No command received\n";
-      continue;
-    }
+        if (tokens.size()  ==  0) {
+            std::cout << "No command received\n";
+            continue;
+        }
 
-    if (tokens[0].compare("end")==0) return;
+        if (tokens[0].compare("end") == 0) return;
 
-    if (tokens[0].compare("dijkstra") != 0 
-       && tokens[0].compare("warshall") != 0 
-       && tokens[0].compare("ksp") != 0 
-       && tokens[0].compare("drivDist") != 0 ) {
-      std::cout << "Command: " << cmd << " not found\n";
-      continue;
-    }
-    
-    
-    if (tokens[0].compare("dijkstra") == 0) {
-       process_dijkstra(graph, tokens);
-    } else if (tokens[0].compare("ksp") == 0) {
-       process_ksp(graph, tokens);
-    } else if (tokens[0].compare("warshall") == 0) {
-       process_warshall(graph, tokens);
-    } else {
-      process_drivingDistance(graph, tokens);
+        if (tokens[0].compare("dijkstra") != 0
+                && tokens[0].compare("warshall") != 0
+                && tokens[0].compare("ksp") != 0
+                && tokens[0].compare("drivDist") != 0 ) {
+            std::cout << "Command: " << cmd << " not found\n";
+            continue;
+        }
+
+
+        if (tokens[0].compare("dijkstra")  ==  0) {
+            process_dijkstra(graph, tokens);
+        } else if (tokens[0].compare("ksp")  ==  0) {
+            process_ksp(graph, tokens);
+        } else if (tokens[0].compare("warshall")  ==  0) {
+            process_warshall(graph, tokens);
+        } else {
+            process_drivingDistance(graph, tokens);
+        }
     }
-  }
 }
 
 
@@ -241,21 +235,20 @@ void process(G graph, pgr_edge_t *data_edges, int row_count) {
 int main(int ac, char* av[]) {
     po::options_description od_desc("Allowed options");
     get_options_description(od_desc);
-    
+
     po::variables_map vm;
     po::store(po::parse_command_line(ac, av, od_desc), vm);
     if (vm.count("help")) {
-       std::cout << od_desc << "\n"; 
-       return 0;
+        std::cout << od_desc << "\n";
+        return 0;
     }
 
-    try{
-      po::notify(vm);
+    try {
+        po::notify(vm);
+    } catch(...) {
+        std::cout << od_desc << "\n";
+        return 0;
     }
-    catch(...){
-	std::cout << od_desc << "\n"; 
-	return 0;	
-    } 
 
     auto ret_val = process_command_line(vm, od_desc);
     if (ret_val != 2) return ret_val;
@@ -268,7 +261,7 @@ int main(int ac, char* av[]) {
     auto db_username(vm["username"].as<std::string>());
     auto db_pwd(vm["password"].as<std::string>());
     auto test(vm["test"].as<bool>());
-    //auto db_no_pwd(vm["no-password"].as<std::string>());
+    // auto db_no_pwd(vm["no-password"].as<std::string>());
 
     const char *conninfo = db_dbase.c_str();
     PGconn     *conn;
@@ -277,63 +270,62 @@ int main(int ac, char* av[]) {
 
 
     conn = PQconnectdb(conninfo);
- /* Check to see that the backend connection was successfully made */
-    if (PQstatus(conn) != CONNECTION_OK)
-    {
+    /* Check to see that the backend connection was successfully made */
+    if (PQstatus(conn) != CONNECTION_OK) {
         fprintf(stderr, "Connection to database failed: %s",
                 PQerrorMessage(conn));
         exit_nicely(conn);
         exit(0);
     }
 
-   std::string data_sql;
-   if (test) {
-     data_sql = "select id, source, target, cost, -1 as reverse_cost  from table1 order by id";
-     // data_sql = "select id, source, target, cost, reverse_cost from edge_table order by id";
-   } else {
-     std::cout << "Input data query: ";
-     std::getline (std::cin,data_sql);
-   }
-   std::cout << "\nThe data is from:" << data_sql <<"\n";
+    std::string data_sql;
+    if (test) {
+        data_sql = "select id, source, target, cost, -1 as reverse_cost  from table1 order by id";
+        // data_sql = "select id, source, target, cost, reverse_cost from edge_table order by id";
+    } else {
+        std::cout << "Input data query: ";
+        std::getline(std::cin, data_sql);
+    }
+    std::cout << "\nThe data is from:" << data_sql <<"\n";
 
-   res = PQexec(conn, data_sql.c_str());
+    res = PQexec(conn, data_sql.c_str());
 
-      if (PQresultStatus(res) != PGRES_TUPLES_OK) {
+    if (PQresultStatus(res) != PGRES_TUPLES_OK) {
         std::cout << "We did not get any data!\n";
         exit_nicely(conn);
         exit(1);
-      }
+    }
 
-      rec_count = PQntuples(res);
-      col_count = PQnfields(res);
-      if (col_count > 5 || col_count < 4) {
+    rec_count = PQntuples(res);
+    col_count = PQnfields(res);
+    if (col_count > 5 || col_count < 4) {
         std::cout << "Max number of columns 5\n";
         std::cout << "Min number of columns 4\n";
         exit_nicely(conn);
         exit(1);
-      }
+    }
+
+    auto id_fnum = PQfnumber(res, "id");
+    auto source_fnum = PQfnumber(res, "source");
+    auto target_fnum = PQfnumber(res, "target");
+    auto cost_fnum = PQfnumber(res, "cost");
+    auto reverse_fnum = PQfnumber(res, "reverse_cost");
+
 
-      auto id_fnum = PQfnumber(res, "id");
-      auto source_fnum = PQfnumber(res, "source");
-      auto target_fnum = PQfnumber(res, "target");
-      auto cost_fnum = PQfnumber(res, "cost");
-      auto reverse_fnum = PQfnumber(res, "reverse_cost");
 
+    pgr_edge_t *data_edges;
+    data_edges = (pgr_edge_t *) malloc(rec_count * sizeof(pgr_edge_t));
 
 
-      pgr_edge_t *data_edges;
-      data_edges = (pgr_edge_t *) malloc(rec_count * sizeof(pgr_edge_t));
-	
+    printf("We received %d records.\n", rec_count);
+    puts(" ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  == ");
 
-      printf("We received %d records.\n", rec_count);
-      puts("==========================");
 
-      
 
-      std::string::size_type sz;
-      std::string str;
+    std::string::size_type sz;
+    std::string str;
 
-      for (int row = 0; row < rec_count; ++row) {
+    for (int row = 0; row < rec_count; ++row) {
         str = std::string(PQgetvalue(res, row, id_fnum));
         data_edges[row].id = stol(str, &sz);
 
@@ -347,50 +339,49 @@ int main(int ac, char* av[]) {
         data_edges[row].cost = stod(str, &sz);
 
         if (reverse_fnum != -1) {
-          str = std::string(PQgetvalue(res, row, reverse_fnum));
-          data_edges[row].reverse_cost = stod(str, &sz);
-        } 
+            str = std::string(PQgetvalue(res, row, reverse_fnum));
+            data_edges[row].reverse_cost = stod(str, &sz);
+        }
 #if 0
         std::cout << "\tid: " << data_edges[row].id << "\t";
         std::cout << "\tsource: " << data_edges[row].source << "\t";
         std::cout << "\ttarget: " << data_edges[row].target << "\t";
         std::cout << "\tcost: " << data_edges[row].cost << "\t";
         if (reverse_fnum != -1) {
-          std::cout << "\treverse: " << data_edges[row].reverse_cost << "\t";
+            std::cout << "\treverse: " << data_edges[row].reverse_cost << "\t";
         }
         std::cout << "\n";
 #endif
-      }
+    }
 
 
-      puts("==========================");
+    puts(" ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  == ");
 
-      PQclear(res);
+    PQclear(res);
 
-      PQfinish(conn);
+    PQfinish(conn);
 
 
-//////////////////////  END READING DATA FROM DATABASE ///////////////////
+    //////////////////////  END READING DATA FROM DATABASE ///////////////////
 
     std::string directed;
     std::cout << "Is the graph directed [N,n]? default[Y]";
-    std::getline(std::cin,directed);
-    graphType gType =  (directed.compare("N")==0 || directed.compare("n")==0)? UNDIRECTED: DIRECTED;
-    bool directedFlag =  (directed.compare("N")==0 || directed.compare("n")==0)? false: true;
+    std::getline(std::cin, directed);
+    graphType gType =  (directed.compare("N") == 0 || directed.compare("n") == 0)? UNDIRECTED: DIRECTED;
+    bool directedFlag =  (directed.compare("N") == 0 || directed.compare("n") == 0)? false: true;
 
 
     const int initial_size = rec_count;
 
-    
+
     Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
     Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
-    
+
     if (directedFlag) {
-      process(digraph, data_edges, rec_count);
+        process(digraph, data_edges, rec_count);
     } else {
-      process(undigraph, data_edges, rec_count);
+        process(undigraph, data_edges, rec_count);
     }
-
 }
 
 
diff --git a/src/linecommand/src/warshall.hpp b/src/linecommand/src/warshall.hpp
index 8378986..cbf0115 100644
--- a/src/linecommand/src/warshall.hpp
+++ b/src/linecommand/src/warshall.hpp
@@ -18,9 +18,12 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 */
+
+#include <string>
+#include <vector>
 #include "./../../warshall/src/pgr_warshall.hpp"
 
-template <typename G> 
+template <typename G>
 void process_warshall(G &graph, const std::vector<std::string> &tokens) {
       std::string::size_type sz;
 
@@ -48,7 +51,6 @@ void process_warshall(G &graph, const std::vector<std::string> &tokens) {
             std::cout << seq++ << "\t" << postgres_rows[i].from_vid << "\t" <<  postgres_rows[i].to_vid << "\t" << postgres_rows[i].cost << "\n";
         }
 #endif  // TEST_POSTGRES
-        
       } else {
         std::cout << "unknown number of parameters\n";
       }
diff --git a/src/mainpage.dox b/src/mainpage.dox
index 931f4d2..da1324e 100644
--- a/src/mainpage.dox
+++ b/src/mainpage.dox
@@ -1,8 +1,8 @@
-/*! \mainpage pgRouting Developer's Documentation
+/*! \mainpage Developer's Documentation
  
-\section intro_sec Introduction
+ at section intro_sec Introduction
  
-This documentation is focused on the developer of pgRouting.
+This documentation is focused on the developer of [pgRouting](http://pgrouting.org).
 
 A developer might want to:
 
@@ -18,15 +18,15 @@ The following steps are based on:
 wirtten by Mohamed Zia
   - [Git Branch Model](http://nvie.com/posts/a-successful-git-branching-model)
 
-\section install_sec Installation for developing
+ at section install_sec Installation for developing
 
 
 Step by Step processing
 
-1. Create a fork of the original pgRouting repository.
+1. Create a fork of the original [pgRouting](https://github.com/pgRouting/pgrouting) repository.
    - If you don't have an account in Github, please [create one](https://github.com/)
      - for purposes of this document the account name is: `acountName`
-   - Navigate to [pgRouting repository](https://github.com/pgRouting/pgrouting)
+   - Navigate to [pgRouting](https://github.com/pgRouting/pgrouting) repository.
    - In the top-right corner of the page, click Fork.
    - Additional information can be found in [fork-a-repo](https://help.github.com/articles/fork-a-repo)
 
@@ -42,13 +42,13 @@ Step by Step processing
      cd pgrouting
 ~~~~
 
-4. Seting the remote fetching connections
-   - More on remotes](https://help.github.com/categories/managing-remotes/) . 
+4. Setting the remote fetching connections
+   - [More on remotes](https://help.github.com/categories/managing-remotes/) . 
    - check the remote connection
 ~~~~{.c}
     git remote -v
 ~~~~
-   -  Add upstream remote (ussually the main repository) 
+   -  Add upstream remote (usually the main repository) 
 ~~~~{.c}
     git remote add upstream https://github.com/pgRouting/pgrouting
 ~~~~
@@ -64,7 +64,7 @@ upstream        https://github.com/acountName/pgrouting (fetch)
 upstream        https://github.com/acountName/pgrouting (push)
 ~~~~
 
-\section branch_model Git Branching Model
+ at section branch_model Git Branching Model
 
 We are making big efforts to start using the Git Branching Model
 So here are some basic rules about Master and develop:
@@ -72,8 +72,8 @@ So here are some basic rules about Master and develop:
      - For micro changes
      - let us branch Master to a quick-fix branch
      - Merge into the quick-fix
-     - We need to do some changes for the release numers etc...
-     - Finnaly we merge into Master
+     - We need to do some changes for the release numbers etc...
+     - Finally we merge into Master
    - To accept a pull request into develop:
      - Its the same quick fix as for Master
      - It has to pass the tests on travis and Jenkins (linux & Windows)
@@ -142,7 +142,7 @@ For the rest of the document the following branch has being created in the main
 ~~~~{.c}
     git add <file>
     git remove <file>
-    git mv <oldNmae> <newName>
+    git mv <oldName> <newName>
     git commit -a -m '<commit message>'
 ~~~~
 
@@ -150,11 +150,11 @@ For the rest of the document the following branch has being created in the main
 ~~~~{.c}
     git checkout dev-myFeature
     git merge dev-myFeature-idea1
-    <fix conflics if any>
+    <fix conflicts if any>
 ~~~~
 
   
-\section up_to_date Keep Fork Up to Date
+ at section up_to_date Keep Fork Up to Date
 
 1. To keep your local repository up-to-date
 ~~~~{.c}
@@ -172,32 +172,34 @@ For the rest of the document the following branch has being created in the main
 ~~~~{.c}
     git checkout dev-myFeature
     git merge develop
-    <fix conflics if any>
+    <fix conflicts if any>
 ~~~~
 
 
-\section perform_tests Beware of Side Effects
+ at section perform_tests Beware of Side Effects
 
 Modifications that you make should not affect other parts of the library.
-pgRouting has a testing tool, so that developers make sure of
+pgRouting has a testing tool, for developers.
+
+Make sure that
   - Code changes don't generate unexpected results
   - Bug fixes actually fix the bug
   - Expected output is generated
 
+To do this:
 1. Move to the root directory.
-
 2. get the help of testing tool:
 ~~~~{.c}
-     tools/test-runner.pl -help
+     tools/testers/algorithm-tester.pl -help
 ~~~~
 3. run all the tests
 ~~~~{.c}
-     tools/test-runner.pl 
+     tools/testers/algorithm-tester.pl
 ~~~~
 
-\section automate_process Make a run.sh
+ at section automate_process Make a run.sh
 
-A shell to automate the compilation and execution is usefull when developing.
+A shell to automate the compilation and execution is useful when developing.
 
 1. Move to the root directory.
 
@@ -212,34 +214,39 @@ cd build/
 #make clean
 #rm -rf *
 #cmake -DBOOST_ROOT:PATH=/usr/local/boost_1_58_0 ..
-#cmake -DWITH_DOC=ON ..
+#cmake -DWITH_DOC=ON -DBUILD_DOXY ..
 cmake ..
 
 make
 
 sudo make install
 #make doc
+#make doxy
 
 cd ..
-tools/test-runner.pl -alg common -v -clean -ignorenotice
-#tools/test-runner.pl -alg dijkstra -v -clean 
-#tools/test-runner.pl -alg dijkstra_via_vertices -v -clean 
-#tools/test-runner.pl -alg doc -v -clean -ignorenotice
+
+# before testing everything
+tools/test-runner.pl -alg common 
+tools/test-runner.pl -alg dijkstra 
+tools/test-runner.pl -alg myfeature
+
+# test everything
+tools/test-runner.pl -alg
 ~~~~
 
-4. Comment and uncommet the file depending on your particular needs and execute it.
+4. Comment and uncomment the file depending on your particular needs and execute it.
 ~~~~{.c}
    sh run.sh
 ~~~~
 
-5. Don't add that file to the repository, its for your development only.
+ at warning Don't add run.sh to the repository, its for your development only.
 
 
-\section setup_travis Setup Travis
+ at section setup_travis Setup Travis
 
 The main difference between your run.sh test and Travis test is:
   - With run.sh you are testing locally.
-  - Travis test a matrix combination of  postgreSQL and postGIS versions
+  - Travis tests a matrix combination of postgreSQL and postGIS versions
 
 To make use of travis test make sure that:
 
@@ -256,7 +263,7 @@ branches:
 
 
 
-\section file_convetions File conventions
+ at section file_convetions File conventions
 
 Some conventions for directories and files
 ~~~~{.c}
diff --git a/src/max_flow/demo/slide_demo.sql b/src/max_flow/demo/slide_demo.sql
new file mode 100644
index 0000000..9b2f0df
--- /dev/null
+++ b/src/max_flow/demo/slide_demo.sql
@@ -0,0 +1,45 @@
+/*PGR-GNU*****************************************************************
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+DROP TABLE IF EXISTS flow_example;
+CREATE TABLE flow_example (
+	id SERIAL,
+	source INTEGER,
+	target INTEGER,
+	capacity INTEGER
+	);
+
+INSERT INTO flow_example (source, target, capacity) VALUES (1,2,10);
+INSERT INTO flow_example (source, target, capacity) VALUES (1,3,10);
+INSERT INTO flow_example (source, target, capacity) VALUES (2,3,2);
+INSERT INTO flow_example (source, target, capacity) VALUES (2,4,4);
+INSERT INTO flow_example (source, target, capacity) VALUES (2,5,8);
+INSERT INTO flow_example (source, target, capacity) VALUES (3,5,9);
+INSERT INTO flow_example (source, target, capacity) VALUES (4,6,10);
+INSERT INTO flow_example (source, target, capacity) VALUES (5,4,6);
+INSERT INTO flow_example (source, target, capacity) VALUES (5,6,10);
+
+
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id, source, target, capacity FROM flow_example',
+     source_vertex := 1,
+     sink_vertex := 6
+);
\ No newline at end of file
diff --git a/src/allpairs/doc/CMakeLists.txt b/src/max_flow/doc/CMakeLists.txt
similarity index 100%
rename from src/allpairs/doc/CMakeLists.txt
rename to src/max_flow/doc/CMakeLists.txt
diff --git a/src/max_flow/doc/doc-pgr_edgeDisjointPaths.queries b/src/max_flow/doc/doc-pgr_edgeDisjointPaths.queries
new file mode 100644
index 0000000..71216b2
--- /dev/null
+++ b/src/max_flow/doc/doc-pgr_edgeDisjointPaths.queries
@@ -0,0 +1,91 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO NOTICE;
+SET
+-- q1
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, 5
+);
+ seq | path_seq | node | edge 
+-----+----------+------+------
+   1 |        1 |    3 |    2
+   2 |        2 |    2 |    4
+   3 |        3 |    5 |   -1
+   4 |        1 |    3 |    5
+   5 |        2 |    6 |    8
+   6 |        3 |    5 |   -1
+(6 rows)
+
+-- q2
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, 5,
+    directed := false
+);
+ seq | path_seq | node | edge 
+-----+----------+------+------
+   1 |        1 |    3 |    2
+   2 |        2 |    2 |    4
+   3 |        3 |    5 |   -1
+   4 |        1 |    3 |    3
+   5 |        2 |    4 |   16
+   6 |        3 |    9 |    9
+   7 |        4 |    6 |    8
+   8 |        5 |    5 |   -1
+   9 |        1 |    3 |    5
+  10 |        2 |    6 |   11
+  11 |        3 |   11 |   12
+  12 |        4 |   10 |   10
+  13 |        5 |    5 |   -1
+(13 rows)
+
+-- q3
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, ARRAY[4, 5, 10]
+);
+ seq | path_seq | end_vid | node | edge 
+-----+----------+---------+------+------
+   1 |        1 |       5 |    3 |    2
+   2 |        2 |       5 |    2 |    4
+   3 |        3 |       5 |    5 |   -1
+   4 |        1 |       5 |    3 |    5
+   5 |        2 |       5 |    6 |    8
+   6 |        3 |       5 |    5 |   -1
+(6 rows)
+
+-- q4
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    ARRAY[3, 6], 5
+);
+ seq | path_seq | start_vid | node | edge 
+-----+----------+-----------+------+------
+   1 |        1 |         3 |    3 |    2
+   2 |        2 |         3 |    2 |    4
+   3 |        3 |         3 |    5 |   -1
+   4 |        1 |         6 |    6 |    8
+   5 |        2 |         6 |    5 |   -1
+(5 rows)
+
+-- q5
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    ARRAY[3, 6], ARRAY[4, 5, 10]
+);
+ seq | path_seq | start_vid | end_vid | node | edge 
+-----+----------+-----------+---------+------+------
+   1 |        1 |         3 |       5 |    3 |    2
+   2 |        2 |         3 |       5 |    2 |    4
+   3 |        3 |         3 |       5 |    5 |   -1
+   4 |        1 |         6 |       5 |    6 |    8
+   5 |        2 |         6 |       5 |    5 |   -1
+   6 |        1 |         6 |       4 |    6 |    9
+   7 |        2 |         6 |       4 |    9 |   16
+   8 |        3 |         6 |       4 |    4 |   -1
+(8 rows)
+
+-- q6
+ROLLBACK;
+ROLLBACK
diff --git a/src/max_flow/doc/doc-pgr_maxFlowBoykovKolmogorov.queries b/src/max_flow/doc/doc-pgr_maxFlowBoykovKolmogorov.queries
new file mode 100644
index 0000000..5943a77
--- /dev/null
+++ b/src/max_flow/doc/doc-pgr_maxFlowBoykovKolmogorov.queries
@@ -0,0 +1,107 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO NOTICE;
+SET
+-- q1
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, 11
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |      10 |      5 |     10 |  100 |                30
+   2 |       8 |      6 |      5 |  100 |                30
+   3 |       9 |      6 |      9 |   50 |                80
+   4 |      11 |      6 |     11 |  130 |                 0
+   5 |      15 |      9 |     12 |   50 |                30
+   6 |      12 |     10 |     11 |  100 |                 0
+   7 |      13 |     12 |     11 |   50 |                 0
+(7 rows)
+
+-- q2
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, ARRAY[1, 3, 11]
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |       1 |      2 |      1 |   50 |                80
+   2 |       3 |      4 |      3 |   80 |                50
+   3 |       4 |      5 |      2 |   50 |                 0
+   4 |      10 |      5 |     10 |   80 |                50
+   5 |       5 |      6 |      3 |   50 |                 0
+   6 |       8 |      6 |      5 |  130 |                 0
+   7 |       9 |      6 |      9 |  130 |                 0
+   8 |      11 |      6 |     11 |  130 |                 0
+   9 |      15 |      9 |     12 |   50 |                30
+  10 |      16 |      9 |      4 |   80 |                 0
+  11 |      12 |     10 |     11 |   80 |                20
+  12 |      13 |     12 |     11 |   50 |                 0
+(12 rows)
+
+-- q3
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], 11
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |      10 |      5 |     10 |  100 |                30
+   2 |       8 |      6 |      5 |  100 |                30
+   3 |      11 |      6 |     11 |  130 |                 0
+   4 |      12 |     10 |     11 |  100 |                 0
+   5 |      13 |     12 |     11 |   50 |                 0
+(5 rows)
+
+-- q4
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], ARRAY[1, 3, 11]
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |       1 |      2 |      1 |   50 |                80
+   2 |       3 |      4 |      3 |   80 |                50
+   3 |       4 |      5 |      2 |   50 |                 0
+   4 |      10 |      5 |     10 |  100 |                30
+   5 |       5 |      6 |      3 |   50 |                 0
+   6 |       8 |      6 |      5 |  130 |                 0
+   7 |       9 |      6 |      9 |   80 |                50
+   8 |      11 |      6 |     11 |  130 |                 0
+   9 |       7 |      8 |      5 |   20 |                30
+  10 |      16 |      9 |      4 |   80 |                 0
+  11 |      12 |     10 |     11 |  100 |                 0
+  12 |      13 |     12 |     11 |   50 |                 0
+(12 rows)
+
+-- q5
+ROLLBACK;
+ROLLBACK
diff --git a/src/max_flow/doc/doc-pgr_maxFlowEdmondsKarp.queries b/src/max_flow/doc/doc-pgr_maxFlowEdmondsKarp.queries
new file mode 100644
index 0000000..922e3bd
--- /dev/null
+++ b/src/max_flow/doc/doc-pgr_maxFlowEdmondsKarp.queries
@@ -0,0 +1,107 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO NOTICE;
+SET
+-- q1
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, 11
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |      10 |      5 |     10 |  100 |                30
+   2 |       8 |      6 |      5 |  100 |                30
+   3 |       9 |      6 |      9 |   50 |                80
+   4 |      11 |      6 |     11 |  130 |                 0
+   5 |      15 |      9 |     12 |   50 |                30
+   6 |      12 |     10 |     11 |  100 |                 0
+   7 |      13 |     12 |     11 |   50 |                 0
+(7 rows)
+
+-- q2
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+   , 6, ARRAY[1, 3, 11]
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |       1 |      2 |      1 |   50 |                80
+   2 |       3 |      4 |      3 |   80 |                50
+   3 |       4 |      5 |      2 |   50 |                 0
+   4 |      10 |      5 |     10 |   80 |                50
+   5 |       5 |      6 |      3 |   50 |                 0
+   6 |       8 |      6 |      5 |  130 |                 0
+   7 |       9 |      6 |      9 |  130 |                 0
+   8 |      11 |      6 |     11 |  130 |                 0
+   9 |      15 |      9 |     12 |   50 |                30
+  10 |      16 |      9 |      4 |   80 |                 0
+  11 |      12 |     10 |     11 |   80 |                20
+  12 |      13 |     12 |     11 |   50 |                 0
+(12 rows)
+
+-- q3
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+   , ARRAY[6, 8, 12], 11
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |      10 |      5 |     10 |  100 |                30
+   2 |       8 |      6 |      5 |  100 |                30
+   3 |      11 |      6 |     11 |  130 |                 0
+   4 |      12 |     10 |     11 |  100 |                 0
+   5 |      13 |     12 |     11 |   50 |                 0
+(5 rows)
+
+-- q4
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+   , ARRAY[6, 8, 12], ARRAY[1, 3, 11]
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |       1 |      2 |      1 |   50 |                80
+   2 |       3 |      4 |      3 |   80 |                50
+   3 |       4 |      5 |      2 |   50 |                 0
+   4 |      10 |      5 |     10 |  100 |                30
+   5 |       5 |      6 |      3 |   50 |                 0
+   6 |       8 |      6 |      5 |  130 |                 0
+   7 |       9 |      6 |      9 |   80 |                50
+   8 |      11 |      6 |     11 |  130 |                 0
+   9 |       7 |      8 |      5 |   20 |                30
+  10 |      16 |      9 |      4 |   80 |                 0
+  11 |      12 |     10 |     11 |  100 |                 0
+  12 |      13 |     12 |     11 |   50 |                 0
+(12 rows)
+
+-- q5
+ROLLBACK;
+ROLLBACK
diff --git a/src/max_flow/doc/doc-pgr_maxFlowPushRelabel.queries b/src/max_flow/doc/doc-pgr_maxFlowPushRelabel.queries
new file mode 100644
index 0000000..350cdbc
--- /dev/null
+++ b/src/max_flow/doc/doc-pgr_maxFlowPushRelabel.queries
@@ -0,0 +1,114 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO NOTICE;
+SET
+-- q1
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, 11
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |      10 |      5 |     10 |  100 |                30
+   2 |       8 |      6 |      5 |  100 |                30
+   3 |       9 |      6 |      9 |   50 |                80
+   4 |      11 |      6 |     11 |  130 |                 0
+   5 |      15 |      9 |     12 |   50 |                30
+   6 |      12 |     10 |     11 |  100 |                 0
+   7 |      13 |     12 |     11 |   50 |                 0
+(7 rows)
+
+-- q2
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, ARRAY[11, 1, 13]
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |       1 |      2 |      1 |  130 |                 0
+   2 |       4 |      2 |      5 |   20 |                80
+   3 |       2 |      3 |      2 |  100 |                 0
+   4 |       3 |      4 |      3 |   50 |                80
+   5 |       4 |      5 |      2 |   50 |                 0
+   6 |       7 |      5 |      8 |   50 |                80
+   7 |      10 |      5 |     10 |  100 |                30
+   8 |       5 |      6 |      3 |   50 |                 0
+   9 |       8 |      6 |      5 |  130 |                 0
+  10 |       9 |      6 |      9 |  100 |                30
+  11 |      11 |      6 |     11 |  130 |                 0
+  12 |       6 |      7 |      8 |   50 |                 0
+  13 |       6 |      8 |      7 |   50 |                50
+  14 |       7 |      8 |      5 |   50 |                 0
+  15 |      15 |      9 |     12 |   50 |                30
+  16 |      16 |      9 |      4 |   50 |                30
+  17 |      12 |     10 |     11 |  100 |                 0
+  18 |      13 |     12 |     11 |   50 |                 0
+(18 rows)
+
+-- q3
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], 11
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |      10 |      5 |     10 |  100 |                30
+   2 |       8 |      6 |      5 |  100 |                30
+   3 |      11 |      6 |     11 |  130 |                 0
+   4 |      12 |     10 |     11 |  100 |                 0
+   5 |      13 |     12 |     11 |   50 |                 0
+(5 rows)
+
+-- q4
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], ARRAY[1, 3, 11]
+);
+ seq | edge_id | source | target | flow | residual_capacity 
+-----+---------+--------+--------+------+-------------------
+   1 |       1 |      2 |      1 |   50 |                80
+   2 |       3 |      4 |      3 |   80 |                50
+   3 |       4 |      5 |      2 |   50 |                 0
+   4 |      10 |      5 |     10 |  100 |                30
+   5 |       5 |      6 |      3 |   50 |                 0
+   6 |       8 |      6 |      5 |  130 |                 0
+   7 |       9 |      6 |      9 |   30 |               100
+   8 |      11 |      6 |     11 |  130 |                 0
+   9 |       7 |      8 |      5 |   20 |                30
+  10 |      16 |      9 |      4 |   80 |                 0
+  11 |      12 |     10 |     11 |  100 |                 0
+  12 |      13 |     12 |     11 |   50 |                 0
+  13 |      15 |     12 |      9 |   50 |                 0
+(13 rows)
+
+-- q5
+ROLLBACK;
+ROLLBACK
diff --git a/src/max_flow/doc/doc-pgr_maximumCardinalityMatching.queries b/src/max_flow/doc/doc-pgr_maximumCardinalityMatching.queries
new file mode 100644
index 0000000..760e519
--- /dev/null
+++ b/src/max_flow/doc/doc-pgr_maximumCardinalityMatching.queries
@@ -0,0 +1,40 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO NOTICE;
+SET
+-- q1
+SELECT * FROM pgr_maximumCardinalityMatching(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table'
+);
+ seq | edge_id | source | target 
+-----+---------+--------+--------
+   1 |       1 |      1 |      2
+   2 |       3 |      4 |      3
+   3 |       9 |      6 |      9
+   4 |       6 |      7 |      8
+   5 |      14 |     10 |     13
+   6 |      13 |     11 |     12
+   7 |      17 |     14 |     15
+   8 |      18 |     16 |     17
+(8 rows)
+
+-- q2
+SELECT * FROM pgr_maximumCardinalityMatching(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    directed := false
+);
+ seq | edge_id | source | target 
+-----+---------+--------+--------
+   1 |       1 |      1 |      2
+   2 |       3 |      3 |      4
+   3 |       9 |      6 |      9
+   4 |       6 |      7 |      8
+   5 |      14 |     10 |     13
+   6 |      13 |     11 |     12
+   7 |      17 |     14 |     15
+   8 |      18 |     16 |     17
+(8 rows)
+
+-- q3
+ROLLBACK;
+ROLLBACK
diff --git a/src/max_flow/doc/maxFlow.rst b/src/max_flow/doc/maxFlow.rst
new file mode 100644
index 0000000..2e03328
--- /dev/null
+++ b/src/max_flow/doc/maxFlow.rst
@@ -0,0 +1,90 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _maxFlow:
+
+Maximum Flow
+===================================
+
+  - :ref:`pgr_maxFlowPushRelabel` - Push and relabel algorithm implementation for maximum flow.
+  - :ref:`pgr_maxFlowEdmondsKarp` - Edmonds and Karp algorithm implementation for maximum flow.
+  - :ref:`pgr_maxFlowBoykovKolmogorov` - Boykov and Kolmogorov algorithm implementation for maximum flow.
+
+The maximum flow through the graph is guaranteed to be the same with all implementations,
+but the actual flow through each edge may vary.
+
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+.. toctree::
+        :hidden:
+
+        ./pgr_maxFlowPushRelabel
+        ./pgr_maxFlowEdmondsKarp
+        ./pgr_maxFlowBoykovKolmogorov
+
+
+Problem definition
+==================
+
+A flow network is a directed graph where each edge has a capacity and a flow.
+The flow through an edge must not exceed the capacity of the edge.
+Additionally, the incoming and outgoing flow of a node must be equal except the for source which only has outgoing flow, and the destination(sink) which only has incoming flow.
+
+Maximum flow algorithms calculate the maximum flow through the graph and the flow of each edge.
+
+Given the following query:
+
+pgr_maxFlow :math:`(edges\_sql, source\_vertex, sink\_vertex)`
+
+where :math:`edges\_sql = \{(id_i, source_i, target_i, capacity_i, reverse\_capacity_i)\}`
+
+.. rubric:: Graph definition
+
+The weighted directed graph, :math:`G(V,E)`, is defined as:
+
+* the set of vertices  :math:`V`
+
+  - :math:`source\_vertex  \cup  sink\_vertex  \bigcup  source_i  \bigcup  target_i`
+
+* the set of edges :math:`E`
+
+  - :math:`E = \begin{cases} &\{(source_i, target_i, capacity_i) \text{ when } capacity > 0 \} &\quad  \text{ if } reverse\_capacity = \varnothing \\ \\ &\{(source_i, target_i, capacity_i) \text{ when } capacity > 0 \} \\ \cup &\{(target_i, source_i, reverse\_capacity_i) \text{ when } reverse\_capacity_i > 0)\} &\quad \text{ if } reverse\_capacity \neq \varnothing \\ \end{cases}`
+
+
+.. rubric:: Maximum flow problem
+
+Given:
+
+
+  - :math:`G(V,E)`
+  - :math:`source\_vertex \in V` the source vertex
+  - :math:`sink\_vertex \in V` the sink vertex
+
+Then:
+
+     :math:`pgr\_maxFlow(edges\_sql, source, sink) = \boldsymbol{\Phi}`
+
+     :math:`\boldsymbol{\Phi} = {(id_i, edge\_id_i, source_i, target_i, flow_i, residual\_capacity_i)}`
+
+where:
+
+  :math:`\boldsymbol{\Phi}` is a subset of the original edges with their residual capacity and flow. The maximum flow through the graph can be obtained by aggregating on the source or sink and summing the flow from/to it. In particular:
+
+  - :math:`id_i = i`
+  - :math:`edge\_id = id_i   \text{ in edges_sql}`
+  - :math:`residual\_capacity_i = capacity_i - flow_i`
+
+
+See Also
+--------
+
+* https://en.wikipedia.org/wiki/Maximum_flow_problem
diff --git a/src/max_flow/doc/maxFlowApplications.rst b/src/max_flow/doc/maxFlowApplications.rst
new file mode 100644
index 0000000..2af0a2f
--- /dev/null
+++ b/src/max_flow/doc/maxFlowApplications.rst
@@ -0,0 +1,60 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _maxFlowApplications:
+
+Applications of Maximum Flow
+============================
+
+  - :ref:`pgr_maximumCardinalityMatching` - Calculates a maximum cardinality matching in a graph.
+  - :ref:`pgr_edgeDisjointPaths` - Calculates edge disjoint paths between two groups of vertices.
+
+Maximum flow algorithms provide solutions to other graph problems.
+
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+.. toctree::
+        :hidden:
+
+        ./pgr_maximumCardinalityMatching
+        ./pgr_edgeDisjointPaths
+
+
+Applications
+---------------------------------------------
+
+Maximum cardinality matching
+...............................
+
+- A matching or independent edge set in a graph is a set of edges without common vertices.
+- A maximum matching is a matching that contains the largest possible number of edges.
+- There may be many maximum matchings.
+- The graph can be directed or undirected.
+
+The :ref:`pgr_maximumCardinalityMatching` function can be used to calculate one such maximum matching.
+
+Edge disjoint paths
+...............................
+
+In a undirected/directed graph, two paths are edge-disjoint(or edge-independant) if they do not have any internal edge in common.
+
+While the number of maximum edge disjoint paths is fixed, there may be several different routes.
+
+The :ref:`pgr_edgeDisjointPaths` function returns the maximum number of paths and possible routes.
+
+
+
+See Also
+--------
+
+* https://en.wikipedia.org/wiki/Maximum_flow_problem#Application
diff --git a/src/max_flow/doc/pgr_edgeDisjointPaths.rst b/src/max_flow/doc/pgr_edgeDisjointPaths.rst
new file mode 100644
index 0000000..c914dd4
--- /dev/null
+++ b/src/max_flow/doc/pgr_edgeDisjointPaths.rst
@@ -0,0 +1,225 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+
+.. _pgr_edgeDisjointPaths:
+
+pgr_edgeDisjointPaths - Proposed
+==========================================
+
+Name
+-------------------------------------------------------------------------------
+
+``pgr_edgeDisjointPaths`` — Calculates edge disjoint paths between two groups of vertices.
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph/doc/boykov_kolmogorov_max_flow.html
+
+   Boost Graph Inside
+
+
+
+Synopsis
+-------------------------------------------------------------------------------
+
+Calculates the edge disjoint paths between two groups of vertices.
+Utilizes underlying maximum flow algorithms to calculate the paths.
+
+Characteristics:
+----------------
+
+The main characterics are:
+  - Calculates the edge disjoint paths between any two groups of vertices.
+  - Returns EMPTY SET when source and destination are the same, or cannot be reached.
+  - The graph can be directed or undirected.
+  - One to many, many to one, many to many versions are also supported.
+  - Uses :ref:`pgr_maxFlowBoykovKolmogorov` to calculate the paths.
+  - No `cost` or `aggregate cost` of the paths are returned. (Under discussion)
+
+Signature Summary
+-----------------
+
+.. code-block:: none
+
+    pgr_edgeDisjointPaths(edges_sql, source_vertex, destination_vertex)
+    pgr_edgeDisjointPaths(edges_sql, source_vertex, destination_vertex, directed)
+    pgr_edgeDisjointPaths(edges_sql, source_vertices, destination_vertex, directed)
+    pgr_edgeDisjointPaths(edges_sql, source_vertex, destination_vertices, directed)
+    pgr_edgeDisjointPaths(edges_sql, source_vertices, destination_vertices, directed)
+
+    RETURNS SET OF (seq, path_seq, [start_vid,] [end_vid,] node, edge) OR EMPTY SET
+
+
+Signatures
+----------
+
+.. index::
+    single: edgeDisjointPaths(Minimal Use) - Proposed
+
+Minimal signature
+.................
+
+.. code-block:: none
+
+    pgr_edgeDisjointPaths(edges_sql, source_vertex, destination_vertex)
+    RETURNS SET OF (seq, path_seq, node, edge) OR EMPTY SET
+
+The minimal signature is between `source_vertex` and `destination_vertex` for a `directed` graph.
+
+:Example:
+
+.. literalinclude:: doc-pgr_edgeDisjointPaths.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+.. index::
+    single: edgeDisjointPaths(One to One) - Proposed
+
+One to One
+.......................................
+
+The available signature calculates edge disjoint paths from one source vertex to one destination vertex.
+The graph can be directed or undirected.
+
+.. code-block:: none
+
+    pgr_edgeDisjointPaths(edges_sql, source_vertex, destination_vertex, directed)
+    RETURNS SET OF (seq, path_seq, node, edge) OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_edgeDisjointPaths.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+
+.. index::
+    single: edgeDisjointPaths(One to Many) - Proposed
+
+One to Many
+.......................................
+
+The available signature calculates the maximum flow from one source vertex to many sink vertices.
+
+.. code-block:: none
+
+    pgr_edgeDisjointPaths(edges_sql, source_vertex, destination_vertices, directed)
+    RETURNS SET OF (seq, path_seq, end_vid, node, edge) OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_edgeDisjointPaths.queries
+   :start-after: -- q3
+   :end-before: -- q4
+
+
+
+.. index::
+    single: edgeDisjointPaths(Many to One) - Proposed
+
+Many to One
+.......................................
+
+The available signature calculates the maximum flow from many source vertices to one sink vertex.
+
+.. code-block:: none
+
+    pgr_edgeDisjointPaths(edges_sql, source_vertices, destination_vertex)
+    RETURNS SET OF (seq, path_seq, start_vid, node, edge)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_edgeDisjointPaths.queries
+   :start-after: -- q4
+   :end-before: -- q5
+
+
+
+.. index::
+    single: edgeDisjointPaths(Many to Many) - Proposed
+
+Many to Many
+.......................................
+
+The available signature calculates the maximum flow from many sources to many sinks.
+
+.. code-block:: none
+
+    pgr_edgeDisjointPaths(edges_sql, source_vertices, destination_vertices, directed)
+    RETURNS SET OF (seq, path_seq, start_vid, end_vid, node, edge) OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_edgeDisjointPaths.queries
+   :start-after: -- q5
+   :end-before: -- q6
+
+
+
+Description of the Signatures
+----------------------------------------------
+
+Description of the SQL query
+.......................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+====================  ===================   =================================================
+Column                Type                  Description
+====================  ===================   =================================================
+**id**                ``ANY-INTEGER``       Identifier of the edge.
+**source**            ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
+**target**            ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
+**going**             ``ANY-NUMERIC``       A positive value represents the existence of the edge (source, target).
+**coming**            ``ANY-NUMERIC``       A positive value represents the existence of the edge (target, source).
+====================  ===================   =================================================
+
+Where:
+  - :ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+  - :ANY-NUMERIC: SMALLINT, INTEGER, BIGINT, REAL, DOUBLE PRECISION
+
+Description of the parameters of the signatures
+........................................................
+
+================= ====================== =================================================
+Column            Type                   Description
+================= ====================== =================================================
+**edges_sql**     ``TEXT``               SQL query as described above.
+**source_vertex** ``BIGINT``             Identifier(s) of the source vertex(vertices).
+**sink_vertex**   ``BIGINT``             Identifier(s) of the destination vertex(vertices).
+**directed**      ``BOOLEAN``            (optional) Determines the type of the graph. Default TRUE.
+================= ====================== =================================================
+
+Description of the return values
+........................................................
+
+============== ========== =================================================
+Column         Type       Description
+============== ========== =================================================
+**seq**        ``INT``    Sequential value starting from **1**.
+**path_seq**   ``INT``    Relative position in the path. Has value **1** for the beginning of a path.
+**start_vid**  ``BIGINT`` Identifier of the starting vertex. Used when multiple starting vertices are in the query.
+**end_vid**    ``BIGINT`` Identifier of the ending vertex. Used when multiple ending vertices are in the query.
+**node**       ``BIGINT`` Identifier of the node in the path from ``start_vid`` to ``end_vid``.
+**edge**       ``BIGINT`` Identifier of the edge used to go from ``node`` to the next node in the path sequence. ``-1`` for the last node of the path.
+============== ========== =================================================
+
+
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/max_flow/doc/pgr_maxFlowBoykovKolmogorov.rst b/src/max_flow/doc/pgr_maxFlowBoykovKolmogorov.rst
new file mode 100644
index 0000000..435d12e
--- /dev/null
+++ b/src/max_flow/doc/pgr_maxFlowBoykovKolmogorov.rst
@@ -0,0 +1,219 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+   INSTRUCTIONS
+   - if section consists of only one value then use this file as index.rst
+   - change [...] (including the square braquets) to appropriate values
+   - one file / function,  may signatures of the same function go in the same file
+
+.. _pgr_maxFlowBoykovKolmogorov:
+
+pgr_maxFlowBoykovKolmogorov - Proposed
+======================================================
+
+
+Name
+----
+
+``pgr_maxFlowBoykovKolmogorov`` — Calculates the maximum flow in a directed graph given a source and a destination. Implemented by Boost Graph Library.
+
+
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph/doc/boykov_kolmogorov_max_flow.html
+
+   Boost Graph Inside
+
+
+Synopsis
+-------------------------------------------------------------------------------
+
+Calculates the maximum flow in a directed graph from a source node to a sink node.
+Edges must be weighted with non-negative capacities.
+Developed by Boykov and Kolmogorov.
+
+
+Characteristics:
+----------------
+
+The main characterics are:
+  - The graph must be directed.
+  - Calculates the flow/residual capacity for each edge. In the output, edges with zero flow are omitted.
+  - The maximum flow through the graph can be calculated by aggregation on source/sink.
+  - Returns nothing if source and sink are the same.
+  - Allows multiple sources and sinks (See signatures below).
+  - Running time: in general polynomial complexity, performs well on graphs that represent 2D grids (eg.: roads).
+
+Signature Summary
+-----------------
+
+.. code-block:: none
+
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertex,  sink_vertex)
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertices,  sink_vertex)
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertex,  sink_vertices)
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertices,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+
+Signatures
+----------------------------
+
+.. index::
+    single: maxFlowBoykovKolmogorov(One to One) - Proposed
+
+One to One
+..............................................
+
+The available signature calculates the maximum flow from one source vertex to one sink vertex.
+
+.. code-block:: none
+
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertex,  sink_vertex)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowBoykovKolmogorov.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+
+.. index::
+    single: maxFlowBoykovKolmogorov(One to Many) - Proposed
+
+One to Many
+..............................................
+
+The available signature calculates the maximum flow from one source vertex to many sink vertices.
+
+.. code-block:: none
+
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertex,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowBoykovKolmogorov.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+
+.. index::
+    single: maxFlowBoykovKolmogorov(Many to One) - Proposed
+
+Many to One
+..............................................
+
+The available signature calculates the maximum flow from many source vertices to one sink vertex.
+
+.. code-block:: none
+
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertices,  sink_vertex)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowBoykovKolmogorov.queries
+   :start-after: -- q3
+   :end-before: -- q4
+
+
+.. index::
+    single: maxFlowBoykovKolmogorov(Many to Many) - Proposed
+
+Many to Many
+..............................................
+
+The available signature calculates the maximum flow from many sources to many sinks.
+
+.. code-block:: none
+
+    pgr_maxFlowBoykovKolmogorov(edges_sql, source_vertices,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowBoykovKolmogorov.queries
+   :start-after: -- q4
+   :end-before: -- q5
+
+
+
+
+Description of the Signatures
+--------------------------------------------------------
+
+Description of the SQL query
+..............................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+====================  ===================   =================================================
+Column                Type                  Description
+====================  ===================   =================================================
+**id**                ``ANY-INTEGER``       Identifier of the edge.
+**source**            ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
+**target**            ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
+**capacity**          ``ANY-INTEGER``       Capacity of the edge `(source, target)`. Must be positive.
+**reverse_capacity**  ``ANY-INTEGER``       (optional) Weight of the edge `(target, source)`. Must be positive or null.
+====================  ===================   =================================================
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+
+
+Description of the parameters of the signatures
+.......................................................
+
+================= ====================== =================================================
+Column            Type                   Description
+================= ====================== =================================================
+**edges_sql**     ``TEXT``               SQL query as described above.
+**source_vertex** ``BIGINT``             Identifier of the source vertex(or vertices).
+**sink_vertex**   ``BIGINT``             Identifier of the sink vertex(or vertices).
+================= ====================== =================================================
+
+Description of the Return Values
+.......................................................
+
+=====================  ====================  =================================================
+Column                 Type                  Description
+=====================  ====================  =================================================
+**seq**                ``INT``               Sequential value starting from **1**.
+**edge_id**            ``BIGINT``            Identifier of the edge in the original query(edges_sql).
+**source**             ``BIGINT``            Identifier of the first end point vertex of the edge.
+**target**             ``BIGINT``            Identifier of the second end point vertex of the edge.
+**flow**               ``BIGINT``            Flow through the edge in the direction (source, target).
+**residual_capacity**  ``BIGINT``            Residual capacity of the edge in the direction (source, target).
+=====================  ====================  =================================================
+
+See Also
+--------
+
+* http://www.boost.org/libs/graph/doc/boykov_kolmogorov_max_flow.html
+* http://www.csd.uwo.ca/~yuri/Papers/pami04.pdf
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/max_flow/doc/pgr_maxFlowEdmondsKarp.rst b/src/max_flow/doc/pgr_maxFlowEdmondsKarp.rst
new file mode 100644
index 0000000..b7a46aa
--- /dev/null
+++ b/src/max_flow/doc/pgr_maxFlowEdmondsKarp.rst
@@ -0,0 +1,209 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+
+.. _pgr_maxFlowEdmondsKarp:
+
+pgr_maxFlowEdmondsKarp - Proposed
+============================================
+
+
+Name
+----
+
+``pgr_maxFlowEdmondsKarp`` — Calculates the maximum flow in a directed graph given a source and a destination. Implemented by Boost Graph Library.
+
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph/doc/edmonds_karp_max_flow.html
+
+   Boost Graph Inside
+
+
+Synopsis
+-------------------------------------------------------------------------------
+
+Calculates the maximum flow in a directed graph from a source node to a sink node.
+Edges must be weighted with non-negative capacities.
+Developed by Edmonds and Karp.
+
+
+Characteristics:
+----------------
+
+The main characterics are:
+  - The graph must be directed.
+  - Calculates the flow/residual capacity for each edge. In the output, edges with zero flow are omitted.
+  - The maximum flow through the graph can be calculated by aggregation on source/sink.
+  - Returns nothing if source and sink are the same.
+  - Allows multiple sources and sinks (See signatures below).
+  - Running time: :math:`O(V * E^2)`.
+
+Signature Summary
+-----------------
+
+.. code-block:: none
+
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertex,  sink_vertex)
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertices,  sink_vertex)
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertex,  sink_vertices)
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertices,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+Signatures
+-----------------------
+
+.. index::
+    single: maxFlowEdmondsKarp(One to One) - Proposed
+
+One to One
+.................................................
+
+Calculates the maximum flow from one source vertex to one sink vertex on a `directed` graph.
+
+.. code-block:: none
+
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertex,  sink_vertex)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowEdmondsKarp.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+.. index::
+    single: maxFlowEdmondsKarp(One to Many) - Proposed
+
+One to Many
+.................................................
+
+Calculates the maximum flow from one source vertex to many sink vertices on a `directed` graph.
+
+.. code-block:: none
+
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertex,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowEdmondsKarp.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+.. index::
+    single: maxFlowEdmondsKarp(Many to One) - Proposed
+
+Many to One
+.................................................
+
+Calculates the maximum flow from many source vertices to one sink vertex on a `directed` graph.
+
+.. code-block:: none
+
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertices,  sink_vertex)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowEdmondsKarp.queries
+   :start-after: -- q3
+   :end-before: -- q4
+
+.. index::
+    single: maxFlowEdmondsKarp(Many to Many) - Proposed
+
+Many to Many
+.................................................
+
+Calculates the maximum flow from many sources to many sinks on a `directed` graph.
+
+.. code-block:: none
+
+    pgr_maxFlowEdmondsKarp(edges_sql, source_vertices,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowEdmondsKarp.queries
+   :start-after: -- q4
+   :end-before: -- q5
+
+
+
+Description of the Signatures
+-----------------------------------------------
+
+Description of the SQL query
+.................................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+====================  ===================   =================================================
+Column                Type                  Description
+====================  ===================   =================================================
+**id**                ``ANY-INTEGER``       Identifier of the edge.
+**source**            ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
+**target**            ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
+**capacity**          ``ANY-INTEGER``       Capacity of the edge `(source, target)`. Must be positive.
+**reverse_capacity**  ``ANY-INTEGER``       (optional) Weight of the edge `(target, source)`. Must be positive or null.
+====================  ===================   =================================================
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+
+
+Description of the parameters of the signatures
+.................................................
+
+================= ====================== =================================================
+Column            Type                   Description
+================= ====================== =================================================
+**edges_sql**     ``TEXT``               SQL query as described above.
+**source_vertex** ``BIGINT``             Identifier of the source vertex(or vertices).
+**sink_vertex**   ``BIGINT``             Identifier of the sink vertex(or vertices).
+================= ====================== =================================================
+
+Description of the return values
+.................................................
+
+=====================  ====================  =================================================
+Column                 Type                  Description
+=====================  ====================  =================================================
+**seq**                ``INT``               Sequential value starting from **1**.
+**edge_id**            ``BIGINT``            Identifier of the edge in the original query(edges_sql).
+**source**             ``BIGINT``            Identifier of the first end point vertex of the edge.
+**target**             ``BIGINT``            Identifier of the second end point vertex of the edge.
+**flow**               ``BIGINT``            Flow through the edge in the direction (source, target).
+**residual_capacity**  ``BIGINT``            Residual capacity of the edge in the direction (source, target).
+=====================  ====================  =================================================
+
+See Also
+--------
+
+* :ref:`maxFlow`
+* http://www.boost.org/libs/graph/doc/edmonds_karp_max_flow.html
+* https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/max_flow/doc/pgr_maxFlowPushRelabel.rst b/src/max_flow/doc/pgr_maxFlowPushRelabel.rst
new file mode 100644
index 0000000..b56ff46
--- /dev/null
+++ b/src/max_flow/doc/pgr_maxFlowPushRelabel.rst
@@ -0,0 +1,213 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+   INSTRUCTIONS
+   - if section consists of only one value then use this file as index.rst
+   - change [...] (including the square braquets) to appropriate values
+   - one file / function,  may signatures of the same function go in the same file
+
+.. _pgr_maxFlowPushRelabel:
+
+pgr_maxFlowPushRelabel Proposed
+============================================
+
+
+Name
+----
+
+``pgr_maxFlowPushRelabel`` — Calculates the maximum flow in a directed graph given a source and a destination.
+
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph/doc/push_relabel_max_flow.html 
+
+   Boost Graph Inside
+
+
+Synopsis
+-------------------------------------------------------------------------------
+
+Calculates the maximum flow in a directed graph from a source node to a sink node.
+Edges must be weighted with non-negative capacities.
+
+Characteristics:
+----------------
+
+The main characterics are:
+  - Calculates the flow/residual capacity for each edge. In the output, edges with zero flow are omitted.
+  - The maximum flow through the graph can be calculated by aggregation on source/sink.
+  - Returns nothing if source and sink are the same.
+  - Allows multiple sources and sinks.
+  - Running time: :math:`O( V ^ 3)`
+
+Signature Summary
+-----------------
+
+.. code-block:: none
+
+    pgr_maxFlowPushRelabel(edges_sql, source_vertex,  sink_vertex)
+    pgr_maxFlowPushRelabel(edges_sql, source_vertices,  sink_vertex)
+    pgr_maxFlowPushRelabel(edges_sql, source_vertex,  sink_vertices)
+    pgr_maxFlowPushRelabel(edges_sql, source_vertices,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+
+Signatures
+-----------------------
+
+.. index::
+    single: maxFlowPushRelabel(One to One) - Proposed
+
+One to One
+.....................................................................
+
+Calculates the maximum flow from one source vertex to one sink vertex in a directed graph.
+
+.. code-block:: none
+
+    pgr_maxFlowPushRelabel(edges_sql, source_vertex,  sink_vertex)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowPushRelabel.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+
+.. index::
+    single: maxFlowPushRelabel(One to Many) - Proposed
+
+One to Many
+.....................................................................
+
+Ccalculates the maximum flow from one source vertex to many sink vertices in a directed graph.
+
+.. code-block:: none
+
+    pgr_maxFlowPushRelabel(edges_sql, source_vertex,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowPushRelabel.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+
+.. index::
+    single: maxFlowPushRelabel(Many to One) - Proposed
+
+Many to One
+.....................................................................
+
+Calculates the maximum flow from many source vertices to one sink vertex in a directed graph.
+
+.. code-block:: none
+
+    pgr_maxFlowPushRelabel(edges_sql, source_vertices,  sink_vertex)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowPushRelabel.queries
+   :start-after: -- q3
+   :end-before: -- q4
+
+
+.. index::
+    single: maxFlowPushRelabel(Many to Many) - Proposed
+
+Many to Many
+.....................................................................
+
+Calculates the maximum flow from many sources to many sinks in a directed graph.
+
+.. code-block:: none
+
+    pgr_maxFlowPushRelabel(edges_sql, source_vertices,  sink_vertices)
+    RETURNS SET OF (id, edge_id, source, target, flow, residual_capacity)
+      OR EMPTY SET
+
+:Example:
+
+.. literalinclude:: doc-pgr_maxFlowPushRelabel.queries
+   :start-after: -- q4
+   :end-before: -- q5
+
+Description of the Signatures
+--------------------------------------------------------
+
+
+Description of the SQL query
+.....................................................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+====================  ===================   =================================================
+Column                Type                  Description
+====================  ===================   =================================================
+**id**                ``ANY-INTEGER``       Identifier of the edge.
+**source**            ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
+**target**            ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
+**capacity**          ``ANY-INTEGER``       Capacity of the edge `(source, target)`. Must be positive.
+**reverse_capacity**  ``ANY-INTEGER``       (optional) Weight of the edge `(target, source)`. Must be positive or null.
+====================  ===================   =================================================
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+
+
+Description of the parameters of the signatures
+.....................................................................
+
+================= ====================== =================================================
+Column            Type                   Description
+================= ====================== =================================================
+**edges_sql**     ``TEXT``               SQL query as described above.
+**source_vertex** ``BIGINT``             Identifier of the source vertex(or vertices).
+**sink_vertex**   ``BIGINT``             Identifier of the sink vertex(or vertices).
+================= ====================== =================================================
+
+Description of the Return Values
+.....................................................................
+
+=====================  ====================  =================================================
+Column                 Type                  Description
+=====================  ====================  =================================================
+**seq**                ``INT``               Sequential value starting from **1**.
+**edge_id**            ``BIGINT``            Identifier of the edge in the original query(edges_sql).
+**source**             ``BIGINT``            Identifier of the first end point vertex of the edge.
+**target**             ``BIGINT``            Identifier of the second end point vertex of the edge.
+**flow**               ``BIGINT``            Flow through the edge in the direction (source, target).
+**residual_capacity**  ``BIGINT``            Residual capacity of the edge in the direction (source, target).
+=====================  ====================  =================================================
+
+See Also
+--------
+
+* :ref:`maxFlow`
+* http://www.boost.org/libs/graph/doc/push_relabel_max_flow.html 
+* https://en.wikipedia.org/wiki/Push%E2%80%93relabel_maximum_flow_algorithm
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/max_flow/doc/pgr_maximumCardinalityMatching.rst b/src/max_flow/doc/pgr_maximumCardinalityMatching.rst
new file mode 100644
index 0000000..4c86c5d
--- /dev/null
+++ b/src/max_flow/doc/pgr_maximumCardinalityMatching.rst
@@ -0,0 +1,171 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _pgr_maximumCardinalityMatching:
+
+pgr_maximumCardinalityMatching - Proposed
+============================================================
+
+
+Name
+----
+
+``pgr_maximumCardinalityMatching`` — Calculates a maximum cardinality matching in a graph.
+
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+.. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
+   :target: http://www.boost.org/libs/graph/doc/maximum_matching.html
+
+   Boost Graph Inside
+
+
+Synopsis
+-------------------------------------------------------------------------------
+
+Calculates a maximum cardinality matching in a directed/undirected graph.
+
+- A matching or independent edge set in a graph is a set of edges without common vertices.
+- A maximum matching is a matching that contains the largest possible number of edges.
+- There may be many maximum matchings.
+
+
+Characteristics:
+----------------
+
+The main characterics are:
+  - Calculates **one** possible maximum cardinality matching in a graph.
+  - The graph can be directed or undirected.
+  - Running time: :math:`O( E*V * \alpha(E,V))`
+  - :math:`\alpha(E,V)` is the inverse of the `Ackermann function`_.
+
+  .. _Ackermann function: https://en.wikipedia.org/wiki/Ackermann_function
+
+Signature Summary
+-----------------
+
+
+.. code-block:: none
+
+    pgr_MaximumCardinalityMatching(edges_sql)
+    pgr_MaximumCardinalityMatching(edges_sql, directed)
+
+    RETURNS SET OF (id, edge_id, source, target)
+        OR EMPTY SET
+
+
+Signatures
+----------
+
+.. index::
+    single: MaximumCardinalityMatching(Minimal Use) - Proposed
+
+
+
+Minimal signature
+....................
+
+.. code-block:: none
+
+    pgr_MaximumCardinalityMatching(edges_sql)
+    RETURNS SET OF (id, edge_id, source, target) OR EMPTY SET
+
+The minimal signature calculates one possible maximum cardinality matching on a `directed` graph.
+
+:Example:
+
+.. literalinclude:: doc-pgr_maximumCardinalityMatching.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+.. index::
+    single: MaximumCardinalityMatching(Complete Signature) - Proposed
+
+Complete signature
+....................
+
+.. code-block:: none
+
+    pgr_MaximumCardinalityMatching(edges_sql, directed)
+    RETURNS SET OF (id, edge_id, source, target) OR EMPTY SET
+
+
+The complete signature calculates one possible maximum cardinality matching.
+
+:Example:
+
+.. literalinclude:: doc-pgr_maximumCardinalityMatching.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+
+
+Description of the Signatures
+--------------------------------------------------------
+
+
+Description of the SQL query
+...........................................................
+
+:edges_sql: an SQL query, which should return a set of rows with the following columns:
+
+====================  ===================   =================================================
+Column                Type                  Description
+====================  ===================   =================================================
+**id**                ``ANY-INTEGER``       Identifier of the edge.
+**source**            ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
+**target**            ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
+**going**             ``ANY-NUMERIC``       A positive value represents the existence of the edge (source, target).
+**coming**            ``ANY-NUMERIC``       A positive value represents the existence of the edge (target, source).
+====================  ===================   =================================================
+
+Where:
+
+  - :ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+  - :ANY-NUMERIC: SMALLINT, INTEGER, BIGINT, REAL, DOUBLE PRECISION
+
+Description of the parameters of the signatures
+...........................................................
+
+================= ====================== =================================================
+Column            Type                   Description
+================= ====================== =================================================
+**edges_sql**     ``TEXT``               SQL query as described above.
+**directed**      ``BOOLEAN``            (optional) Determines the type of the graph. Default TRUE.
+================= ====================== =================================================
+
+Description of the Result
+...........................................................
+
+=====================  ====================  =================================================
+Column                 Type                  Description
+=====================  ====================  =================================================
+**seq**                ``INT``               Sequential value starting from **1**.
+**edge_id**            ``BIGINT``            Identifier of the edge in the original query(edges_sql).
+**source**             ``BIGINT``            Identifier of the first end point vertex of the edge.
+**target**             ``BIGINT``            Identifier of the second end point vertex of the edge.
+=====================  ====================  =================================================
+
+See Also
+--------
+
+* :ref:`maxFlowApplications`
+* http://www.boost.org/libs/graph/doc/maximum_matching.html
+* https://en.wikipedia.org/wiki/Matching_%28graph_theory%29
+* https://en.wikipedia.org/wiki/Ackermann_function
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/max_flow/sql/CMakeLists.txt b/src/max_flow/sql/CMakeLists.txt
new file mode 100644
index 0000000..f134c84
--- /dev/null
+++ b/src/max_flow/sql/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Append in local scope
+LIST(APPEND PACKAGE_SQL_FILES
+        ${CMAKE_CURRENT_SOURCE_DIR}/max_flow.sql
+        ${CMAKE_CURRENT_SOURCE_DIR}/maximum_cardinality_matching.sql
+        ${CMAKE_CURRENT_SOURCE_DIR}/edge_disjoint_paths.sql
+)
+
+# set in parent scope
+SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
diff --git a/src/max_flow/sql/edge_disjoint_paths.sql b/src/max_flow/sql/edge_disjoint_paths.sql
new file mode 100644
index 0000000..83a347e
--- /dev/null
+++ b/src/max_flow/sql/edge_disjoint_paths.sql
@@ -0,0 +1,102 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Copyright (c) 2016 Andrea Nardelli
+mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+
+/***********************************
+        ONE TO ONE
+***********************************/
+
+CREATE OR REPLACE FUNCTION pgr_edgeDisjointPaths(
+    IN edges_sql TEXT,
+    IN source_vertex bigint,
+    IN destination_vertex bigint,
+    IN directed BOOLEAN DEFAULT TRUE,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT node BIGINT,
+    OUT edge BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'edge_disjoint_paths_one_to_one'
+    LANGUAGE c IMMUTABLE STRICT;
+
+/***********************************
+        ONE TO MANY
+***********************************/
+
+CREATE OR REPLACE FUNCTION pgr_edgeDisjointPaths(
+    IN edges_sql TEXT,
+    IN source_vertex bigint,
+    IN destination_vertices ANYARRAY,
+    IN directed BOOLEAN DEFAULT TRUE,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT end_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'edge_disjoint_paths_one_to_many'
+    LANGUAGE c IMMUTABLE STRICT;
+
+/***********************************
+        MANY TO ONE
+***********************************/
+
+CREATE OR REPLACE FUNCTION pgr_edgeDisjointPaths(
+    IN edges_sql TEXT,
+    IN source_vertices ANYARRAY,
+    IN destination_vertex BIGINT,
+    IN directed BOOLEAN DEFAULT TRUE,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT start_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'edge_disjoint_paths_many_to_one'
+    LANGUAGE c IMMUTABLE STRICT;
+
+/***********************************
+        MANY TO MANY
+***********************************/
+
+CREATE OR REPLACE FUNCTION pgr_edgeDisjointPaths(
+    IN edges_sql TEXT,
+    IN source_vertices ANYARRAY,
+    IN destination_vertices ANYARRAY,
+    IN directed BOOLEAN DEFAULT TRUE,
+    OUT seq INTEGER,
+    OUT path_seq INTEGER,
+    OUT start_vid BIGINT,
+    OUT end_vid BIGINT,
+    OUT node BIGINT,
+    OUT edge BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'edge_disjoint_paths_many_to_many'
+    LANGUAGE c IMMUTABLE STRICT;
\ No newline at end of file
diff --git a/src/max_flow/sql/max_flow.sql b/src/max_flow/sql/max_flow.sql
new file mode 100644
index 0000000..b9f9423
--- /dev/null
+++ b/src/max_flow/sql/max_flow.sql
@@ -0,0 +1,361 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Copyright (c) 2016 Andrea Nardelli
+mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+/***********************************
+        ONE TO ONE
+***********************************/
+
+--INTERNAL FUNCTIONS
+
+CREATE OR REPLACE FUNCTION _pgr_maxflow(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertex BIGINT,
+    algorithm TEXT DEFAULT 'push_relabel',
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'max_flow_one_to_one'
+    LANGUAGE c IMMUTABLE STRICT;
+
+--FUNCTIONS
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertex BIGINT,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'push_relabel');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertex BIGINT,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'boykov_kolmogorov');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertex BIGINT,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'edmonds_karp');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+/***********************************
+        ONE TO MANY
+***********************************/
+
+--INTERNAL FUNCTIONS
+
+CREATE OR REPLACE FUNCTION _pgr_maxflow(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertices ANYARRAY,
+    algorithm TEXT DEFAULT 'push_relabel',
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'max_flow_one_to_many'
+    LANGUAGE c IMMUTABLE STRICT;
+
+--FUNCTIONS
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertices ANYARRAY,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'push_relabel');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertices ANYARRAY,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'boykov_kolmogorov');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp(
+    edges_sql TEXT,
+    source_vertex BIGINT,
+    sink_vertices ANYARRAY,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'edmonds_karp');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+/***********************************
+        MANY TO ONE
+***********************************/
+
+--INTERNAL FUNCTIONS
+
+CREATE OR REPLACE FUNCTION _pgr_maxflow(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertex BIGINT,
+    algorithm TEXT DEFAULT 'push_relabel',
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'max_flow_many_to_one'
+    LANGUAGE c IMMUTABLE STRICT;
+
+--FUNCTIONS
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertex BIGINT,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'push_relabel');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertex BIGINT,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'boykov_kolmogorov');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertex BIGINT,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'edmonds_karp');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+/***********************************
+        MANY TO MANY
+***********************************/
+
+--INTERNAL FUNCTIONS
+
+CREATE OR REPLACE FUNCTION _pgr_maxflow(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertices ANYARRAY,
+    algorithm TEXT DEFAULT 'push_relabel',
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'max_flow_many_to_many'
+    LANGUAGE c IMMUTABLE STRICT;
+
+--FUNCTIONS
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowPushRelabel(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertices ANYARRAY,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'push_relabel');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowBoykovKolmogorov(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertices ANYARRAY,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'boykov_kolmogorov');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+CREATE OR REPLACE FUNCTION pgr_maxFlowEdmondsKarp(
+    edges_sql TEXT,
+    source_vertices ANYARRAY,
+    sink_vertices ANYARRAY,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT,
+    OUT flow BIGINT,
+    OUT residual_capacity BIGINT
+    )
+  RETURNS SETOF RECORD AS
+  $BODY$
+  BEGIN
+        RETURN QUERY SELECT *
+        FROM _pgr_maxflow(_pgr_get_statement($1), $2, $3, 'edmonds_karp');
+  END
+  $BODY$
+  LANGUAGE plpgsql VOLATILE;
diff --git a/src/withPoints/src/get_new_queries.h b/src/max_flow/sql/maximum_cardinality_matching.sql
similarity index 68%
copy from src/withPoints/src/get_new_queries.h
copy to src/max_flow/sql/maximum_cardinality_matching.sql
index 147c05e..abfbcef 100644
--- a/src/withPoints/src/get_new_queries.h
+++ b/src/max_flow/sql/maximum_cardinality_matching.sql
@@ -1,12 +1,10 @@
 /*PGR-GNU*****************************************************************
-File: get_new_queries.h
 
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Copyright (c) 2016 Andrea Nardelli
+mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -26,20 +24,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-    void get_new_queries(
-            char *edges_sql,
-            char *points_sql, 
-            char **edges_of_points_query,
-            char **edges_no_points_query);
-
-
-#ifdef __cplusplus
-}
-#endif
-
+--FUNCTIONS
+
+CREATE OR REPLACE FUNCTION pgr_maximumcardinalitymatching(
+    edges_sql TEXT,
+    directed BOOLEAN DEFAULT TRUE,
+    OUT seq INTEGER,
+    OUT edge_id BIGINT,
+    OUT source BIGINT,
+    OUT target BIGINT
+    )
+  RETURNS SETOF RECORD AS
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'maximum_cardinality_matching'
+    LANGUAGE c IMMUTABLE STRICT;
\ No newline at end of file
diff --git a/src/max_flow/src/CMakeLists.txt b/src/max_flow/src/CMakeLists.txt
new file mode 100644
index 0000000..aa26d81
--- /dev/null
+++ b/src/max_flow/src/CMakeLists.txt
@@ -0,0 +1,25 @@
+ADD_LIBRARY(max_flow OBJECT
+        max_flow_one_to_one.c
+        max_flow_many_to_many.c
+        max_flow_one_to_many.c
+        max_flow_many_to_one.c
+
+        maximum_cardinality_matching.c
+
+        edge_disjoint_paths_one_to_one.c
+        edge_disjoint_paths_one_to_many.c
+        edge_disjoint_paths_many_to_many.c
+        edge_disjoint_paths_many_to_one.c
+
+        max_flow_one_to_one_driver.cpp
+        max_flow_many_to_many_driver.cpp
+        max_flow_one_to_many_driver.cpp
+        max_flow_many_to_one_driver.cpp
+
+        maximum_cardinality_matching_driver.cpp
+
+        edge_disjoint_paths_one_to_one_driver.cpp
+        edge_disjoint_paths_one_to_many_driver.cpp
+        edge_disjoint_paths_many_to_many_driver.cpp
+        edge_disjoint_paths_many_to_one_driver.cpp
+)
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/max_flow/src/edge_disjoint_paths_many_to_many.c
similarity index 62%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/max_flow/src/edge_disjoint_paths_many_to_many.c
index d099701..075c1b3 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_many.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: edge_disjoint_paths_many_to_many.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -37,8 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 /*
-  Uncomment when needed
-*/
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
@@ -47,44 +48,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
-
-PG_MODULE_MAGIC;
+#include "./../../common/src/arrays_input.h"
+#include "./edge_disjoint_paths_many_to_many_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+edge_disjoint_paths_many_to_many(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t *source_vertices, size_t size_source_verticesArr,
+    int64_t *sink_vertices, size_t size_sink_verticesArr,
+    bool directed,
+    General_path_element_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
     PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
-
-    if (start_vid == end_vid) {
-        (*result_count) = 0;
-        (*result_tuples) = NULL;
-        pgr_SPI_finish();
-        return;
-    }
+    pgr_basic_edge_t *edges = NULL;
 
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+
+    pgr_get_basic_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,18 +86,19 @@ process(
     PGR_DBG("Starting processing");
     clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
-            result_tuples,
-            result_count,
-            &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
+    do_pgr_edge_disjoint_paths_many_to_many(
+        edges,
+        total_tuples,
+        source_vertices,
+        size_source_verticesArr,
+        sink_vertices,
+        size_sink_verticesArr,
+        directed,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing edge disjoint paths", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
@@ -120,59 +109,65 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(edge_disjoint_paths_many_to_many);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+edge_disjoint_paths_many_to_many(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+
+        int64_t *sink_vertices;
+        size_t size_sink_verticesArr;
+        sink_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_sink_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(2));
+        PGR_DBG("sink_verticesArr size %ld ", size_sink_verticesArr);
+
+        int64_t *source_vertices;
+        size_t size_source_verticesArr;
+        source_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_source_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(1));
+        PGR_DBG("source_verticesArr size %ld ", size_source_verticesArr);
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            source_vertices, size_source_verticesArr,
+            sink_vertices, size_sink_verticesArr,
+            PG_GETARG_BOOL(3),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -183,27 +178,20 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
 
         values = palloc(6 * sizeof(Datum));
         nulls = palloc(6 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 6; ++i) {
             nulls[i] = false;
@@ -212,10 +200,10 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
         values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].start_id);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].end_id);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].node);
+        values[5] = Int64GetDatum(result_tuples[call_cntr].edge);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/edge_disjoint_paths_many_to_many_driver.cpp b/src/max_flow/src/edge_disjoint_paths_many_to_many_driver.cpp
new file mode 100644
index 0000000..172ead6
--- /dev/null
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_many_driver.cpp
@@ -0,0 +1,106 @@
+/*PGR-GNU*****************************************************************
+File: edge_disjoint_paths_many_to_many_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_edgedisjointpaths.hpp"
+#include "./edge_disjoint_paths_many_to_many_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_edge_disjoint_paths_many_to_many(
+    pgr_basic_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t *source_vertices,
+    size_t size_source_verticesArr,
+    int64_t *sink_vertices,
+    size_t size_sink_verticesArr,
+    bool directed,
+    General_path_element_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        std::vector<General_path_element_t> path_elements;
+        std::set<int64_t> set_source_vertices;
+        std::set<int64_t> set_sink_vertices;
+        for (size_t i = 0; i < size_source_verticesArr; ++i) {
+            set_source_vertices.insert(source_vertices[i]);
+        }
+        for (size_t i = 0; i < size_sink_verticesArr; ++i) {
+            set_sink_vertices.insert(sink_vertices[i]);
+        }
+        PgrEdgeDisjointPathsGraph<FlowGraph> G;
+
+        // I use a directed graph since I'm dependent on directed graphs
+
+        G.create_edge_disjoint_paths_graph(data_edges, total_tuples,
+                                           set_source_vertices,
+                                           set_sink_vertices, directed);
+        int64_t flow = G.boykov_kolmogorov();
+        G.get_edge_disjoint_paths(path_elements, flow);
+
+        (*return_tuples) = pgr_alloc(path_elements.size(), (*return_tuples));
+        for (size_t i = 0; i < path_elements.size(); ++i) {
+            (*return_tuples)[i] = path_elements[i];
+        }
+        *return_count = path_elements.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/ksp/src/withPoints_ksp_driver.h b/src/max_flow/src/edge_disjoint_paths_many_to_many_driver.h
similarity index 60%
copy from src/ksp/src/withPoints_ksp_driver.h
copy to src/max_flow/src/edge_disjoint_paths_many_to_many_driver.h
index e304dae..3c86396 100644
--- a/src/ksp/src/withPoints_ksp_driver.h
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_many_driver.h
@@ -1,12 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: withPoints_driver.h
+File: edge_disjoint_paths_many_to_one_driver.h
 
+Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -26,37 +27,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#pragma once
+#ifndef SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_MANY_TO_MANY_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_MANY_TO_MANY_DRIVER_H_
+
+#include "./../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "./../../common/src/pgr_types.h"
-
-    //  CREATE OR REPLACE FUNCTION pgr_withPointKsp(
-    //  edges_sql TEXT,
-    //  points_sql TEXT,
-    //  start_pid BIGINT,
-    //  end_pid BIGINT,
-    //  directed BOOLEAN DEFAULT true,
-    int do_pgr_withPointsKsp(
-            pgr_edge_t  *edges,             size_t total_edges,
-            Point_on_edge_t  *points,       size_t total_points,
-            pgr_edge_t  *edges_of_points,   size_t total_edges_of_points,
-            int64_t start_pid,
-            int64_t end_pid,
-            int k,
+    void
+        do_pgr_edge_disjoint_paths_many_to_many(
+            pgr_basic_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t *source_vertices,
+            size_t size_source_verticesArr,
+            int64_t *sink_vertices,
+            size_t size_sink_verticesArr,
             bool directed,
-            bool heap_paths,
-            char driving_side,
-            bool details,
-
             General_path_element_t **return_tuples,
             size_t *return_count,
-            char ** err_msg);
+            char **err_msg);
+
 
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_MANY_TO_MANY_DRIVER_H_
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/max_flow/src/edge_disjoint_paths_many_to_one.c
similarity index 62%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/max_flow/src/edge_disjoint_paths_many_to_one.c
index d099701..953e4d6 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_one.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: edge_disjoint_paths_many_to_one.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
@@ -37,8 +38,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 /*
-  Uncomment when needed
-*/
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
@@ -47,44 +49,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
+#include "./../../common/src/arrays_input.h"
+#include "./edge_disjoint_paths_many_to_one_driver.h"
 
-PG_MODULE_MAGIC;
-
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+edge_disjoint_paths_many_to_one(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t *source_vertices, size_t size_source_verticesArr,
+    int64_t sink_vertex,
+    bool directed,
+    General_path_element_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
     PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
-
-    if (start_vid == end_vid) {
-        (*result_count) = 0;
-        (*result_tuples) = NULL;
-        pgr_SPI_finish();
-        return;
-    }
+    pgr_basic_edge_t *edges = NULL;
 
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+
+    pgr_get_basic_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,18 +87,18 @@ process(
     PGR_DBG("Starting processing");
     clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
-            result_tuples,
-            result_count,
-            &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
+    do_pgr_edge_disjoint_paths_many_to_one(
+        edges,
+        total_tuples,
+        source_vertices,
+        size_source_verticesArr,
+        sink_vertex,
+        directed,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing edge disjoint paths", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
@@ -120,59 +109,58 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(edge_disjoint_paths_many_to_one);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+edge_disjoint_paths_many_to_one(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+
+        int64_t *source_vertices;
+        size_t size_source_verticesArr;
+        source_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_source_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(1));
+        PGR_DBG("source_verticesArr size %ld ", size_source_verticesArr);
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            source_vertices, size_source_verticesArr,
+            PG_GETARG_INT64(2),
+            PG_GETARG_BOOL(3),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -183,39 +171,31 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
-
-        values = palloc(6 * sizeof(Datum));
-        nulls = palloc(6 * sizeof(bool));
 
+        values = palloc(5 * sizeof(Datum));
+        nulls = palloc(5 * sizeof(bool));
 
         size_t i;
-        for (i = 0; i < 6; ++i) {
+        for (i = 0; i < 5; ++i) {
             nulls[i] = false;
         }
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
         values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].start_id);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].node);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].edge);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/edge_disjoint_paths_many_to_one_driver.cpp b/src/max_flow/src/edge_disjoint_paths_many_to_one_driver.cpp
new file mode 100644
index 0000000..d1d637b
--- /dev/null
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_one_driver.cpp
@@ -0,0 +1,103 @@
+/*PGR-GNU*****************************************************************
+File: edge_disjoint_paths_many_to_one_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_edgedisjointpaths.hpp"
+#include "./edge_disjoint_paths_many_to_one_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_edge_disjoint_paths_many_to_one(
+    pgr_basic_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t *source_vertices,
+    size_t size_source_verticesArr,
+    int64_t sink_vertex,
+    bool directed,
+    General_path_element_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        std::vector<General_path_element_t> path_elements;
+        std::set<int64_t> set_source_vertices;
+        std::set<int64_t> set_sink_vertices;
+        for (size_t i = 0; i < size_source_verticesArr; ++i) {
+            set_source_vertices.insert(source_vertices[i]);
+        }
+        set_sink_vertices.insert(sink_vertex);
+        PgrEdgeDisjointPathsGraph<FlowGraph> G;
+
+        // I use a directed graph since I'm dependent on directed graphs
+
+        G.create_edge_disjoint_paths_graph(data_edges, total_tuples,
+                                           set_source_vertices,
+                                           set_sink_vertices, directed);
+        int64_t flow = G.boykov_kolmogorov();
+        G.get_edge_disjoint_paths(path_elements, flow);
+
+        (*return_tuples) = pgr_alloc(path_elements.size(), (*return_tuples));
+        for (size_t i = 0; i < path_elements.size(); ++i) {
+            (*return_tuples)[i] = path_elements[i];
+        }
+        *return_count = path_elements.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/ksp/src/withPoints_ksp_driver.h b/src/max_flow/src/edge_disjoint_paths_many_to_one_driver.h
similarity index 60%
copy from src/ksp/src/withPoints_ksp_driver.h
copy to src/max_flow/src/edge_disjoint_paths_many_to_one_driver.h
index e304dae..9c07464 100644
--- a/src/ksp/src/withPoints_ksp_driver.h
+++ b/src/max_flow/src/edge_disjoint_paths_many_to_one_driver.h
@@ -1,12 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: withPoints_driver.h
+File: edge_disjoint_paths_many_to_one_driver.h
 
+Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -26,37 +27,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#pragma once
+#ifndef SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_MANY_TO_ONE_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_MANY_TO_ONE_DRIVER_H_
+
+#include "./../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "./../../common/src/pgr_types.h"
-
-    //  CREATE OR REPLACE FUNCTION pgr_withPointKsp(
-    //  edges_sql TEXT,
-    //  points_sql TEXT,
-    //  start_pid BIGINT,
-    //  end_pid BIGINT,
-    //  directed BOOLEAN DEFAULT true,
-    int do_pgr_withPointsKsp(
-            pgr_edge_t  *edges,             size_t total_edges,
-            Point_on_edge_t  *points,       size_t total_points,
-            pgr_edge_t  *edges_of_points,   size_t total_edges_of_points,
-            int64_t start_pid,
-            int64_t end_pid,
-            int k,
+    void
+        do_pgr_edge_disjoint_paths_many_to_one(
+            pgr_basic_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t *source_vertices,
+            size_t size_source_verticesArr,
+            int64_t sink_vertex,
             bool directed,
-            bool heap_paths,
-            char driving_side,
-            bool details,
-
             General_path_element_t **return_tuples,
             size_t *return_count,
-            char ** err_msg);
+            char **err_msg);
+
 
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_MANY_TO_ONE_DRIVER_H_
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/max_flow/src/edge_disjoint_paths_one_to_many.c
similarity index 62%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/max_flow/src/edge_disjoint_paths_one_to_many.c
index d099701..c628c7f 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_many.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: edge_disjoint_paths_one_to_many.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -37,8 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 /*
-  Uncomment when needed
-*/
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
@@ -47,44 +48,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
-
-PG_MODULE_MAGIC;
+#include "./../../common/src/arrays_input.h"
+#include "./edge_disjoint_paths_one_to_many_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+edge_disjoint_paths_one_to_many(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t source_vertex,
+    int64_t *sink_vertices, size_t size_sink_verticesArr,
+    bool directed,
+    General_path_element_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
     PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
-
-    if (start_vid == end_vid) {
-        (*result_count) = 0;
-        (*result_tuples) = NULL;
-        pgr_SPI_finish();
-        return;
-    }
+    pgr_basic_edge_t *edges = NULL;
 
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+
+    pgr_get_basic_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,18 +86,18 @@ process(
     PGR_DBG("Starting processing");
     clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
-            result_tuples,
-            result_count,
-            &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
+    do_pgr_edge_disjoint_paths_one_to_many(
+        edges,
+        total_tuples,
+        source_vertex,
+        sink_vertices,
+        size_sink_verticesArr,
+        directed,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing edge disjoint paths", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
@@ -120,59 +108,58 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(edge_disjoint_paths_one_to_many);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+edge_disjoint_paths_one_to_many(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+
+        int64_t *sink_vertices;
+        size_t size_sink_verticesArr;
+        sink_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_sink_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(2));
+        PGR_DBG("sink_verticesArr size %ld ", size_sink_verticesArr);
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            PG_GETARG_INT64(1),
+            sink_vertices, size_sink_verticesArr,
+            PG_GETARG_BOOL(3),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -183,39 +170,31 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
-
-        values = palloc(6 * sizeof(Datum));
-        nulls = palloc(6 * sizeof(bool));
 
+        values = palloc(5 * sizeof(Datum));
+        nulls = palloc(5 * sizeof(bool));
 
         size_t i;
-        for (i = 0; i < 6; ++i) {
+        for (i = 0; i < 5; ++i) {
             nulls[i] = false;
         }
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
         values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].end_id);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].node);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].edge);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/edge_disjoint_paths_one_to_many_driver.cpp b/src/max_flow/src/edge_disjoint_paths_one_to_many_driver.cpp
new file mode 100644
index 0000000..dd15e64
--- /dev/null
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_many_driver.cpp
@@ -0,0 +1,104 @@
+/*PGR-GNU*****************************************************************
+File: edge_disjoint_paths_one_to_many_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_edgedisjointpaths.hpp"
+#include "./edge_disjoint_paths_one_to_many_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+
+void
+do_pgr_edge_disjoint_paths_one_to_many(
+    pgr_basic_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t source_vertex,
+    int64_t *sink_vertices,
+    size_t size_sink_verticesArr,
+    bool directed,
+    General_path_element_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        std::vector<General_path_element_t> path_elements;
+        std::set<int64_t> set_source_vertices;
+        set_source_vertices.insert(source_vertex);
+        std::set<int64_t> set_sink_vertices;
+        for (size_t i = 0; i < size_sink_verticesArr; ++i) {
+            set_sink_vertices.insert(sink_vertices[i]);
+        }
+        PgrEdgeDisjointPathsGraph<FlowGraph> G;
+
+        // I use a directed graph since I'm dependent on directed graphs
+
+        G.create_edge_disjoint_paths_graph(data_edges, total_tuples,
+                                           set_source_vertices,
+                                           set_sink_vertices, directed);
+        int64_t flow = G.boykov_kolmogorov();
+        G.get_edge_disjoint_paths(path_elements, flow);
+
+        (*return_tuples) = pgr_alloc(path_elements.size(), (*return_tuples));
+        for (size_t i = 0; i < path_elements.size(); ++i) {
+            (*return_tuples)[i] = path_elements[i];
+        }
+        *return_count = path_elements.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/ksp/src/withPoints_ksp_driver.h b/src/max_flow/src/edge_disjoint_paths_one_to_many_driver.h
similarity index 60%
copy from src/ksp/src/withPoints_ksp_driver.h
copy to src/max_flow/src/edge_disjoint_paths_one_to_many_driver.h
index e304dae..d17e1c3 100644
--- a/src/ksp/src/withPoints_ksp_driver.h
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_many_driver.h
@@ -1,12 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: withPoints_driver.h
+File: edge_disjoint_paths_one_to_many_driver.h
 
+Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -26,37 +27,30 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#pragma once
+#ifndef SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_ONE_TO_MANY_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_ONE_TO_MANY_DRIVER_H_
+
+#include "./../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "./../../common/src/pgr_types.h"
-
-    //  CREATE OR REPLACE FUNCTION pgr_withPointKsp(
-    //  edges_sql TEXT,
-    //  points_sql TEXT,
-    //  start_pid BIGINT,
-    //  end_pid BIGINT,
-    //  directed BOOLEAN DEFAULT true,
-    int do_pgr_withPointsKsp(
-            pgr_edge_t  *edges,             size_t total_edges,
-            Point_on_edge_t  *points,       size_t total_points,
-            pgr_edge_t  *edges_of_points,   size_t total_edges_of_points,
-            int64_t start_pid,
-            int64_t end_pid,
-            int k,
+    void
+        do_pgr_edge_disjoint_paths_one_to_many(
+            pgr_basic_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t source_vertex,
+            int64_t *sink_vertices,
+            size_t size_sink_verticesArr,
             bool directed,
-            bool heap_paths,
-            char driving_side,
-            bool details,
-
             General_path_element_t **return_tuples,
             size_t *return_count,
-            char ** err_msg);
+            char **err_msg);
+
 
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_ONE_TO_MANY_DRIVER_H_
diff --git a/src/tsp/src/xyd_tsp.c b/src/max_flow/src/edge_disjoint_paths_one_to_one.c
similarity index 65%
copy from src/tsp/src/xyd_tsp.c
copy to src/max_flow/src/edge_disjoint_paths_one_to_one.c
index 9ba3641..bec6512 100644
--- a/src/tsp/src/xyd_tsp.c
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_one.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: xyz_tsp.c
+File: edge_disjoint_paths_one_to_one.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -30,118 +30,121 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
-#include "utils/array.h"
 #include "catalog/pg_type.h"
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
 
+/*
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
+#include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
-#include "./distances_input.h"
-#include "./tsp_driver.h"
-
-// #include "./one_to_one_dijkstra_driver.h"
+#include "./../../common/src/edges_input.h"
+#include "./edge_disjoint_paths_one_to_one_driver.h"
 
-
-PG_FUNCTION_INFO_V1(xyd_tsp);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS);
+edge_disjoint_paths_one_to_one(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* distances_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t source_vertex,
+    int64_t sink_vertex,
+    bool directed,
+    General_path_element_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
     PGR_DBG("Load data");
-    Matrix_cell_t *distances = NULL;
-    size_t total_distances = 0;
-    pgr_get_distances(distances_sql, &distances, &total_distances);
+    pgr_basic_edge_t *edges = NULL;
+
+    if (source_vertex == sink_vertex) {
+        (*result_count) = 0;
+        (*result_tuples) = NULL;
+        pgr_SPI_finish();
+        return;
+    }
+
+    size_t total_tuples = 0;
 
-    if (total_distances == 0) {
-        PGR_DBG("No distances found");
+    pgr_get_basic_edges(edges_sql, &edges, &total_tuples);
+
+    if (total_tuples == 0) {
+        PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_distances);
+    PGR_DBG("Total %ld tuples in query:", total_tuples);
 
     PGR_DBG("Starting processing");
+    clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_tsp(
-            distances,
-            total_distances,
-            start_vid,
-            end_vid,
-            result_tuples,
-            result_count,
-            &err_msg);
+    do_pgr_edge_disjoint_paths_one_to_one(
+        edges,
+        total_tuples,
+        source_vertex,
+        sink_vertex,
+        directed,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing edge disjoint paths", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
     free(err_msg);
-    pfree(distances);
+    pfree(edges);
     pgr_SPI_finish();
 }
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(edge_disjoint_paths_one_to_one);
 PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+edge_disjoint_paths_one_to_one(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text,
-        // start_vid BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            PG_GETARG_INT64(1),
+            PG_GETARG_INT64(2),
+            PG_GETARG_BOOL(3),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
@@ -149,11 +152,11 @@ xyd_tsp(PG_FUNCTION_ARGS) {
         funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -164,25 +167,20 @@ xyd_tsp(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (General_path_element_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT node BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
 
         values = palloc(4 * sizeof(Datum));
         nulls = palloc(4 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 4; ++i) {
             nulls[i] = false;
@@ -190,9 +188,9 @@ xyd_tsp(PG_FUNCTION_ARGS) {
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
-        values[1] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[2] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[3] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/edge_disjoint_paths_one_to_one_driver.cpp b/src/max_flow/src/edge_disjoint_paths_one_to_one_driver.cpp
new file mode 100644
index 0000000..f121616
--- /dev/null
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_one_driver.cpp
@@ -0,0 +1,99 @@
+/*PGR-GNU*****************************************************************
+File: edge_disjoint_paths_one_to_one_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_edgedisjointpaths.hpp"
+#include "./edge_disjoint_paths_one_to_one_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_edge_disjoint_paths_one_to_one(
+    pgr_basic_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t source_vertex,
+    int64_t sink_vertex,
+    bool directed,
+    General_path_element_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        std::vector<General_path_element_t> path_elements;
+        std::set<int64_t> set_source_vertices;
+        set_source_vertices.insert(source_vertex);
+        std::set<int64_t> set_sink_vertices;
+        set_sink_vertices.insert(sink_vertex);
+        PgrEdgeDisjointPathsGraph<FlowGraph> G;
+
+        // I use a directed graph since I'm dependent on directed graphs
+
+        G.create_edge_disjoint_paths_graph(data_edges, total_tuples,
+                                           set_source_vertices,
+                                           set_sink_vertices, directed);
+        int64_t flow = G.boykov_kolmogorov();
+        G.get_edge_disjoint_paths(path_elements, flow);
+
+        (*return_tuples) = pgr_alloc(path_elements.size(), (*return_tuples));
+        for (size_t i = 0; i < path_elements.size(); ++i) {
+            (*return_tuples)[i] = path_elements[i];
+        }
+        *return_count = path_elements.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/max_flow/src/edge_disjoint_paths_one_to_one_driver.h
similarity index 61%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/max_flow/src/edge_disjoint_paths_one_to_one_driver.h
index 801bb6c..1544995 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/max_flow/src/edge_disjoint_paths_one_to_one_driver.h
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: edge_disjoint_paths_one_to_one_driver.h
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -27,28 +27,29 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_ONE_TO_ONE_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_ONE_TO_ONE_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
-
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
+    void
+        do_pgr_edge_disjoint_paths_one_to_one(
+            pgr_basic_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t source_vertex,
+            int64_t sink_vertex,
+            bool directed,
+            General_path_element_t **return_tuples,
+            size_t *return_count,
+            char **err_msg);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_MAX_FLOW_SRC_EDGE_DISJOINT_PATHS_ONE_TO_ONE_DRIVER_H_
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/max_flow/src/max_flow_many_to_many.c
similarity index 60%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/max_flow/src/max_flow_many_to_many.c
index d099701..621c29a 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/max_flow/src/max_flow_many_to_many.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: max_flow_many_to_many.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -37,8 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 /*
-  Uncomment when needed
-*/
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
@@ -47,44 +48,40 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
-
-PG_MODULE_MAGIC;
+#include "./../../common/src/arrays_input.h"
+#include "./max_flow_many_to_many_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+max_flow_many_to_many(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t *source_vertices, size_t size_source_verticesArr,
+    int64_t *sink_vertices, size_t size_sink_verticesArr,
+    char *algorithm,
+    pgr_flow_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
+    if (!(strcmp(algorithm, "push_relabel") == 0
+        || strcmp(algorithm, "edmonds_karp") == 0
+        || strcmp(algorithm, "boykov_kolmogorov") == 0)) {
+        elog(ERROR, "Unknown algorithm");
+    }
+
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
 
-    if (start_vid == end_vid) {
-        (*result_count) = 0;
-        (*result_tuples) = NULL;
-        pgr_SPI_finish();
-        return;
-    }
-
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+
+    /* NOTE:
+     * For flow, cost and reverse_cost are really capacity and reverse_capacity
+     */
+    pgr_get_flow_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,18 +95,17 @@ process(
     PGR_DBG("Starting processing");
     clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
-            result_tuples,
-            result_count,
-            &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
+    do_pgr_max_flow_many_to_many(
+        edges,
+        total_tuples,
+        source_vertices, size_source_verticesArr,
+        sink_vertices, size_sink_verticesArr,
+        algorithm,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing max flow", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
@@ -120,59 +116,65 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(max_flow_many_to_many);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+max_flow_many_to_many(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    pgr_flow_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+        PGR_DBG("Initializing arrays");
+        int64_t *source_vertices;
+        size_t size_source_verticesArr;
+        source_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_source_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(1));
+        PGR_DBG("source_verticesArr size %ld ", size_source_verticesArr);
+
+        int64_t *sink_vertices;
+        size_t size_sink_verticesArr;
+        sink_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_sink_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(2));
+        PGR_DBG("sink_verticesArr size %ld ", size_sink_verticesArr);
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            source_vertices, size_source_verticesArr,
+            sink_vertices, size_sink_verticesArr,
+            pgr_text2char(PG_GETARG_TEXT_P(3)),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -183,27 +185,19 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
-
         values = palloc(6 * sizeof(Datum));
         nulls = palloc(6 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 6; ++i) {
             nulls[i] = false;
@@ -211,11 +205,11 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
-        values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[1] = Int64GetDatum(result_tuples[call_cntr].edge);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].source);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].target);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].flow);
+        values[5] = Int64GetDatum(result_tuples[call_cntr].residual_capacity);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/max_flow_many_to_many_driver.cpp b/src/max_flow/src/max_flow_many_to_many_driver.cpp
new file mode 100644
index 0000000..1e9ad42
--- /dev/null
+++ b/src/max_flow/src/max_flow_many_to_many_driver.cpp
@@ -0,0 +1,116 @@
+/*PGR-GNU*****************************************************************
+File: max_flow_many_to_many_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_maxflow.hpp"
+#include "./max_flow_many_to_many_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_max_flow_many_to_many(
+    pgr_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t *source_vertices,
+    size_t size_source_verticesArr,
+    int64_t *sink_vertices,
+    size_t size_sink_verticesArr,
+    char *algorithm,
+    pgr_flow_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        PgrFlowGraph<FlowGraph> G;
+        std::set<int64_t> set_source_vertices;
+        std::set<int64_t> set_sink_vertices;
+        for (size_t i = 0; i < size_source_verticesArr; ++i) {
+            set_source_vertices.insert(source_vertices[i]);
+        }
+        for (size_t i = 0; i < size_sink_verticesArr; ++i) {
+            set_sink_vertices.insert(sink_vertices[i]);
+        }
+
+        G.create_flow_graph(data_edges, total_tuples, set_source_vertices,
+                            set_sink_vertices, algorithm);
+
+        if (strcmp(algorithm, "push_relabel") == 0) {
+            G.push_relabel();
+        } else if (strcmp(algorithm, "edmonds_karp") == 0) {
+            G.edmonds_karp();
+        } else if (strcmp(algorithm, "boykov_kolmogorov") == 0) {
+            G.boykov_kolmogorov();
+        } else {
+            log << "Unspecified algorithm!\n";
+            *err_msg = strdup(log.str().c_str());
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            return;
+        }
+
+        std::vector<pgr_flow_t> flow_edges;
+        G.get_flow_edges(flow_edges);
+
+        (*return_tuples) = pgr_alloc(flow_edges.size(), (*return_tuples));
+        for (size_t i = 0; i < flow_edges.size(); ++i) {
+            (*return_tuples)[i] = flow_edges[i];
+        }
+        *return_count = flow_edges.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/max_flow/src/max_flow_many_to_many_driver.h
similarity index 59%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/max_flow/src/max_flow_many_to_many_driver.h
index 801bb6c..397f74e 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/max_flow/src/max_flow_many_to_many_driver.h
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: max_flow_many_to_many_driver.h
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_MAX_FLOW_SRC_MAX_FLOW_MANY_TO_MANY_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_MAX_FLOW_MANY_TO_MANY_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
 
@@ -36,19 +36,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
+    void
+        do_pgr_max_flow_many_to_many(
+            pgr_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t* source_vertices,
+            size_t size_source_verticesArr,
+            int64_t* sink_vertices,
+            size_t size_sink_verticesArr,
+            char* algorithm,
+            pgr_flow_t **return_tuples,
+            size_t *return_count,
+            char **err_msg);
 
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_MAX_FLOW_SRC_MAX_FLOW_MANY_TO_MANY_DRIVER_H_
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/max_flow/src/max_flow_many_to_one.c
similarity index 63%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/max_flow/src/max_flow_many_to_one.c
index d099701..c94ec3e 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/max_flow/src/max_flow_many_to_one.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: max_flow_many_to_one.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -37,8 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 /*
-  Uncomment when needed
-*/
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
@@ -47,44 +48,40 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
-
-PG_MODULE_MAGIC;
+#include "./../../common/src/arrays_input.h"
+#include "./max_flow_many_to_one_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+max_flow_many_to_one(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t *source_vertices, size_t size_source_verticesArr,
+    int64_t sink_vertex,
+    char *algorithm,
+    pgr_flow_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
+    if (!(strcmp(algorithm, "push_relabel") == 0
+        || strcmp(algorithm, "edmonds_karp") == 0
+        || strcmp(algorithm, "boykov_kolmogorov") == 0)) {
+        elog(ERROR, "Unknown algorithm");
+    }
+
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
 
-    if (start_vid == end_vid) {
-        (*result_count) = 0;
-        (*result_tuples) = NULL;
-        pgr_SPI_finish();
-        return;
-    }
-
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+
+    /* NOTE:
+     * For flow, cost and reverse_cost are really capacity and reverse_capacity
+     */
+    pgr_get_flow_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,18 +95,17 @@ process(
     PGR_DBG("Starting processing");
     clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
-            result_tuples,
-            result_count,
-            &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
+    do_pgr_max_flow_many_to_one(
+        edges,
+        total_tuples,
+        source_vertices, size_source_verticesArr,
+        sink_vertex,
+        algorithm,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing max flow", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
@@ -120,59 +116,59 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(max_flow_many_to_one);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+max_flow_many_to_one(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    pgr_flow_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+
+
+        int64_t *source_vertices;
+        size_t size_source_verticesArr;
+        source_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_source_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(1));
+        PGR_DBG("source_verticesArr size %ld ", size_source_verticesArr);
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            source_vertices, size_source_verticesArr,
+            PG_GETARG_INT64(2),
+            pgr_text2char(PG_GETARG_TEXT_P(3)),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -183,27 +179,19 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
-
         values = palloc(6 * sizeof(Datum));
         nulls = palloc(6 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 6; ++i) {
             nulls[i] = false;
@@ -211,11 +199,11 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
-        values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[1] = Int64GetDatum(result_tuples[call_cntr].edge);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].source);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].target);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].flow);
+        values[5] = Int64GetDatum(result_tuples[call_cntr].residual_capacity);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/max_flow_many_to_one_driver.cpp b/src/max_flow/src/max_flow_many_to_one_driver.cpp
new file mode 100644
index 0000000..ec81d36
--- /dev/null
+++ b/src/max_flow/src/max_flow_many_to_one_driver.cpp
@@ -0,0 +1,117 @@
+/*PGR-GNU*****************************************************************
+File: max_flow_many_to_one_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_maxflow.hpp"
+#include "./max_flow_many_to_one_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_max_flow_many_to_one(
+    pgr_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t *source_vertices,
+    size_t size_source_verticesArr,
+    int64_t sink_vertex,
+    char *algorithm,
+    pgr_flow_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        PgrFlowGraph<FlowGraph> G;
+        std::set<int64_t> set_source_vertices;
+        std::set<int64_t> set_sink_vertices;
+        for (size_t i = 0; i < size_source_verticesArr; ++i) {
+            set_source_vertices.insert(source_vertices[i]);
+        }
+        set_sink_vertices.insert(sink_vertex);
+
+        G.create_flow_graph(data_edges,
+                            total_tuples,
+                            set_source_vertices,
+                            set_sink_vertices,
+                            algorithm);
+
+        if (strcmp(algorithm, "push_relabel") == 0) {
+            G.push_relabel();
+        } else if (strcmp(algorithm, "edmonds_karp") == 0) {
+            G.edmonds_karp();
+        } else if (strcmp(algorithm, "boykov_kolmogorov") == 0) {
+            G.boykov_kolmogorov();
+        } else {
+            log << "Unspecified algorithm!\n";
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        std::vector<pgr_flow_t> flow_edges;
+        G.get_flow_edges(flow_edges);
+
+        (*return_tuples) = pgr_alloc(flow_edges.size(), (*return_tuples));
+        for (size_t i = 0; i < flow_edges.size(); ++i) {
+            (*return_tuples)[i] = flow_edges[i];
+        }
+        *return_count = flow_edges.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/max_flow/src/max_flow_many_to_one_driver.h
similarity index 61%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/max_flow/src/max_flow_many_to_one_driver.h
index 801bb6c..116fa2b 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/max_flow/src/max_flow_many_to_one_driver.h
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: max_flow_many_to_one_driver.h
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_MAX_FLOW_SRC_MAX_FLOW_MANY_TO_ONE_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_MAX_FLOW_MANY_TO_ONE_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
 
@@ -36,19 +36,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
+    void
+        do_pgr_max_flow_many_to_one(
+            pgr_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t* source_vertices,
+            size_t size_source_verticesArr,
+            int64_t sink_vertex,
+            char* algorithm,
+            pgr_flow_t **return_tuples,
+            size_t *return_count,
+            char **err_msg);
 
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_MAX_FLOW_SRC_MAX_FLOW_MANY_TO_ONE_DRIVER_H_
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/max_flow/src/max_flow_one_to_many.c
similarity index 63%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/max_flow/src/max_flow_one_to_many.c
index d099701..048f528 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/max_flow/src/max_flow_one_to_many.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: max_flow_one_to_many.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -37,8 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 /*
-  Uncomment when needed
-*/
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
@@ -47,44 +48,40 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
-
-PG_MODULE_MAGIC;
+#include "./../../common/src/arrays_input.h"
+#include "./max_flow_one_to_many_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+max_flow_one_to_many(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t source_vertex,
+    int64_t *sink_vertices, size_t size_sink_verticesArr,
+    char *algorithm,
+    pgr_flow_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
+    if (!(strcmp(algorithm, "push_relabel") == 0
+        || strcmp(algorithm, "edmonds_karp") == 0
+        || strcmp(algorithm, "boykov_kolmogorov") == 0)) {
+        elog(ERROR, "Unknown algorithm");
+    }
+
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
 
-    if (start_vid == end_vid) {
-        (*result_count) = 0;
-        (*result_tuples) = NULL;
-        pgr_SPI_finish();
-        return;
-    }
-
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+
+    /* NOTE:
+     * For flow, cost and reverse_cost are really capacity and reverse_capacity
+     */
+    pgr_get_flow_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,18 +95,17 @@ process(
     PGR_DBG("Starting processing");
     clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
-            result_tuples,
-            result_count,
-            &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
+    do_pgr_max_flow_one_to_many(
+        edges,
+        total_tuples,
+        source_vertex,
+        sink_vertices, size_sink_verticesArr,
+        algorithm,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing max flow", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
@@ -120,59 +116,59 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(max_flow_one_to_many);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+max_flow_one_to_many(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    pgr_flow_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+
+
+        int64_t *sink_vertices;
+        size_t size_sink_verticesArr;
+        sink_vertices = (int64_t *)
+            pgr_get_bigIntArray(&size_sink_verticesArr,
+                                PG_GETARG_ARRAYTYPE_P(2));
+        PGR_DBG("sink_verticesArr size %ld ", size_sink_verticesArr);
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            PG_GETARG_INT64(1),
+            sink_vertices, size_sink_verticesArr,
+            pgr_text2char(PG_GETARG_TEXT_P(3)),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -183,27 +179,19 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
-
         values = palloc(6 * sizeof(Datum));
         nulls = palloc(6 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 6; ++i) {
             nulls[i] = false;
@@ -211,11 +199,11 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
-        values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[1] = Int64GetDatum(result_tuples[call_cntr].edge);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].source);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].target);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].flow);
+        values[5] = Int64GetDatum(result_tuples[call_cntr].residual_capacity);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/max_flow_one_to_many_driver.cpp b/src/max_flow/src/max_flow_one_to_many_driver.cpp
new file mode 100644
index 0000000..ce2f2a9
--- /dev/null
+++ b/src/max_flow/src/max_flow_one_to_many_driver.cpp
@@ -0,0 +1,117 @@
+/*PGR-GNU*****************************************************************
+File: max_flow_one_to_many_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_maxflow.hpp"
+#include "./max_flow_one_to_many_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_max_flow_one_to_many(
+    pgr_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t source_vertex,
+    int64_t *sink_vertices,
+    size_t size_sink_verticesArr,
+    char *algorithm,
+    pgr_flow_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        PgrFlowGraph<FlowGraph> G;
+        std::set<int64_t> set_source_vertices;
+        std::set<int64_t> set_sink_vertices;
+        set_source_vertices.insert(source_vertex);
+        for (size_t i = 0; i < size_sink_verticesArr; ++i) {
+            set_sink_vertices.insert(sink_vertices[i]);
+        }
+
+        G.create_flow_graph(data_edges,
+                            total_tuples,
+                            set_source_vertices,
+                            set_sink_vertices,
+                            algorithm);
+
+        if (strcmp(algorithm, "push_relabel") == 0) {
+            G.push_relabel();
+        } else if (strcmp(algorithm, "edmonds_karp") == 0) {
+            G.edmonds_karp();
+        } else if (strcmp(algorithm, "boykov_kolmogorov") == 0) {
+            G.boykov_kolmogorov();
+        } else {
+            log << "Unspecified algorithm!\n";
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        std::vector<pgr_flow_t> flow_edges;
+        G.get_flow_edges(flow_edges);
+
+        (*return_tuples) = pgr_alloc(flow_edges.size(), (*return_tuples));
+        for (size_t i = 0; i < flow_edges.size(); ++i) {
+            (*return_tuples)[i] = flow_edges[i];
+        }
+        *return_count = flow_edges.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/max_flow/src/max_flow_one_to_many_driver.h
similarity index 61%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/max_flow/src/max_flow_one_to_many_driver.h
index 801bb6c..415700d 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/max_flow/src/max_flow_one_to_many_driver.h
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: max_flow_one_to_many_driver.h
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_MAX_FLOW_SRC_MAX_FLOW_ONE_TO_MANY_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_MAX_FLOW_ONE_TO_MANY_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
 
@@ -36,19 +36,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
+    void
+        do_pgr_max_flow_one_to_many(
+            pgr_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t source_vertex,
+            int64_t* sink_vertices,
+            size_t size_sink_verticesArr,
+            char* algorithm,
+            pgr_flow_t **return_tuples,
+            size_t *return_count,
+            char **err_msg);
 
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_MAX_FLOW_SRC_MAX_FLOW_ONE_TO_MANY_DRIVER_H_
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/max_flow/src/max_flow_one_to_one.c
similarity index 64%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/max_flow/src/max_flow_one_to_one.c
index d099701..760bd29 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/max_flow/src/max_flow_one_to_one.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: max_flow_one_to_one.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -30,15 +30,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
-#include "utils/array.h"
 #include "catalog/pg_type.h"
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
 
 /*
-  Uncomment when needed
-*/
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
@@ -47,36 +47,34 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
-
-PG_MODULE_MAGIC;
+#include "./max_flow_one_to_one_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+max_flow_one_to_one(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    int64_t source_vertex,
+    int64_t sink_vertex,
+    char *algorithm,
+    pgr_flow_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
+    if (!(strcmp(algorithm, "push_relabel") == 0
+        || strcmp(algorithm, "edmonds_karp") == 0
+        || strcmp(algorithm, "boykov_kolmogorov") == 0)) {
+        elog(ERROR, "Unknown algorithm");
+    }
+
     PGR_DBG("Load data");
     pgr_edge_t *edges = NULL;
 
-    if (start_vid == end_vid) {
+    if (source_vertex == sink_vertex) {
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
@@ -84,7 +82,11 @@ process(
     }
 
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+
+    /* NOTE:
+     * For flow, cost and reverse_cost are really capacity and reverse_capacity
+     */
+    pgr_get_flow_edges(edges_sql, &edges, &total_tuples);
 
     if (total_tuples == 0) {
         PGR_DBG("No edges found");
@@ -98,18 +100,17 @@ process(
     PGR_DBG("Starting processing");
     clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
-            result_tuples,
-            result_count,
-            &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
+    do_pgr_max_flow_one_to_one(
+        edges,
+        total_tuples,
+        source_vertex,
+        sink_vertex,
+        algorithm,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing max flow", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
@@ -120,59 +121,51 @@ process(
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(max_flow_one_to_one);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+max_flow_one_to_one(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    pgr_flow_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
 
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            PG_GETARG_INT64(1),
+            PG_GETARG_INT64(2),
+            pgr_text2char(PG_GETARG_TEXT_P(3)),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
 
-        funcctx->max_calls = (uint32_t)result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -183,27 +176,20 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (pgr_flow_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
 
         values = palloc(6 * sizeof(Datum));
         nulls = palloc(6 * sizeof(bool));
 
-
         size_t i;
         for (i = 0; i < 6; ++i) {
             nulls[i] = false;
@@ -211,11 +197,11 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
-        values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[1] = Int64GetDatum(result_tuples[call_cntr].edge);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].source);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].target);
+        values[4] = Int64GetDatum(result_tuples[call_cntr].flow);
+        values[5] = Int64GetDatum(result_tuples[call_cntr].residual_capacity);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/max_flow_one_to_one_driver.cpp b/src/max_flow/src/max_flow_one_to_one_driver.cpp
new file mode 100644
index 0000000..9140e5c
--- /dev/null
+++ b/src/max_flow/src/max_flow_one_to_one_driver.cpp
@@ -0,0 +1,114 @@
+/*PGR-GNU*****************************************************************
+File: max_flow_one_to_one_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <vector>
+#include <set>
+
+#include "./pgr_maxflow.hpp"
+#include "./max_flow_one_to_one_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_max_flow_one_to_one(
+    pgr_edge_t *data_edges,
+    size_t total_tuples,
+    int64_t source_vertex,
+    int64_t sink_vertex,
+    char *algorithm,
+    pgr_flow_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        PgrFlowGraph<FlowGraph> G;
+        std::set<int64_t> set_source_vertices;
+        set_source_vertices.insert(source_vertex);
+        std::set<int64_t> set_sink_vertices;
+        set_sink_vertices.insert(sink_vertex);
+
+        G.create_flow_graph(data_edges,
+                            total_tuples,
+                            set_source_vertices,
+                            set_sink_vertices,
+                            algorithm);
+
+        if (strcmp(algorithm, "push_relabel") == 0) {
+            G.push_relabel();
+        } else if (strcmp(algorithm, "edmonds_karp") == 0) {
+            G.edmonds_karp();
+        } else if (strcmp(algorithm, "boykov_kolmogorov") == 0) {
+            G.boykov_kolmogorov();
+        } else {
+            log << "Unspecified algorithm!\n";
+            (*return_tuples) = NULL;
+            (*return_count) = 0;
+            *err_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        std::vector<pgr_flow_t> flow_edges;
+        G.get_flow_edges(flow_edges);
+
+        (*return_tuples) = pgr_alloc(flow_edges.size(), (*return_tuples));
+        for (size_t i = 0; i < flow_edges.size(); ++i) {
+            (*return_tuples)[i] = flow_edges[i];
+        }
+        *return_count = flow_edges.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/max_flow/src/max_flow_one_to_one_driver.h
similarity index 63%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/max_flow/src/max_flow_one_to_one_driver.h
index 801bb6c..b19e023 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/max_flow/src/max_flow_one_to_one_driver.h
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: max_flow_one_to_one_driver.h
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -27,8 +27,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_MAX_FLOW_SRC_MAX_FLOW_ONE_TO_ONE_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_MAX_FLOW_ONE_TO_ONE_DRIVER_H_
+
 
 #include "./../../common/src/pgr_types.h"
 
@@ -36,19 +37,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
+    void
+        do_pgr_max_flow_one_to_one(
+            pgr_edge_t *data_edges,
+            size_t total_tuples,
+            int64_t source_vertex,
+            int64_t sink_vertex,
+            char* algorithm,
+            pgr_flow_t **return_tuples,
+            size_t *return_count,
+            char **err_msg);
 
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_MAX_FLOW_SRC_MAX_FLOW_ONE_TO_ONE_DRIVER_H_
diff --git a/src/tsp/src/xyd_tsp.c b/src/max_flow/src/maximum_cardinality_matching.c
similarity index 65%
copy from src/tsp/src/xyd_tsp.c
copy to src/max_flow/src/maximum_cardinality_matching.c
index 9ba3641..24a2d74 100644
--- a/src/tsp/src/xyd_tsp.c
+++ b/src/max_flow/src/maximum_cardinality_matching.c
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: xyz_tsp.c
+File: maximum_cardinality_matching.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
 Function's developer:
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -30,118 +30,108 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "postgres.h"
 #include "executor/spi.h"
 #include "funcapi.h"
-#include "utils/array.h"
 #include "catalog/pg_type.h"
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
 
+/*
+ * Uncomment when needed
+ */
+
 // #define DEBUG
 
 #include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
+#include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
-#include "./distances_input.h"
-#include "./tsp_driver.h"
-
-// #include "./one_to_one_dijkstra_driver.h"
+#include "./../../common/src/edges_input.h"
+#include "./maximum_cardinality_matching_driver.h"
 
 
-PG_FUNCTION_INFO_V1(xyd_tsp);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS);
+maximum_cardinality_matching(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* distances_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        General_path_element_t **result_tuples,
-        size_t *result_count) {
+    char *edges_sql,
+    bool directed,
+    pgr_basic_edge_t **result_tuples,
+    size_t *result_count) {
     pgr_SPI_connect();
 
     PGR_DBG("Load data");
-    Matrix_cell_t *distances = NULL;
-    size_t total_distances = 0;
-    pgr_get_distances(distances_sql, &distances, &total_distances);
+    pgr_basic_edge_t *edges = NULL;
+
+    size_t total_tuples = 0;
 
-    if (total_distances == 0) {
-        PGR_DBG("No distances found");
+    pgr_get_basic_edges(edges_sql, &edges, &total_tuples);
+
+    if (total_tuples == 0) {
+        PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_distances);
+    PGR_DBG("Total %ld tuples in query:", total_tuples);
 
     PGR_DBG("Starting processing");
+    clock_t start_t = clock();
     char *err_msg = NULL;
-    do_pgr_tsp(
-            distances,
-            total_distances,
-            start_vid,
-            end_vid,
-            result_tuples,
-            result_count,
-            &err_msg);
+    do_pgr_maximum_cardinality_matching(
+        edges,
+        directed,
+        total_tuples,
+        result_tuples,
+        result_count,
+        &err_msg);
+
+    time_msg("processing max flow", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
 
     free(err_msg);
-    pfree(distances);
+    pfree(edges);
     pgr_SPI_finish();
 }
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(maximum_cardinality_matching);
 PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    uint32_t              call_cntr;
-    uint32_t               max_calls;
-    TupleDesc            tuple_desc;
+maximum_cardinality_matching(PG_FUNCTION_ARGS) {
+    FuncCallContext *funcctx;
+    uint32_t call_cntr;
+    uint32_t max_calls;
+    TupleDesc tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    pgr_basic_edge_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
 
     if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
+        MemoryContext oldcontext;
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text,
-        // start_vid BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
-
         PGR_DBG("Calling process");
         process(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                &result_tuples,
-                &result_count);
+            pgr_text2char(PG_GETARG_TEXT_P(0)),
+            PG_GETARG_BOOL(1),
+            &result_tuples,
+            &result_count);
 
         /*                                                                    */
         /**********************************************************************/
@@ -149,11 +139,11 @@ xyd_tsp(PG_FUNCTION_ARGS) {
         funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc)
-                != TYPEFUNC_COMPOSITE) {
+            != TYPEFUNC_COMPOSITE) {
             ereport(ERROR,
                     (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
+                        errmsg("function returning record called in context "
+                                   "that cannot accept type record")));
         }
 
         funcctx->tuple_desc = tuple_desc;
@@ -164,20 +154,16 @@ xyd_tsp(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (pgr_basic_edge_t *) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum        *values;
-        bool*        nulls;
+        HeapTuple tuple;
+        Datum result;
+        Datum *values;
+        bool *nulls;
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT node BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
 
         values = palloc(4 * sizeof(Datum));
         nulls = palloc(4 * sizeof(bool));
@@ -190,9 +176,9 @@ xyd_tsp(PG_FUNCTION_ARGS) {
 
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
-        values[1] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[2] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[3] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
+        values[1] = Int64GetDatum(result_tuples[call_cntr].edge_id);
+        values[2] = Int64GetDatum(result_tuples[call_cntr].source);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].target);
         /**********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
diff --git a/src/max_flow/src/maximum_cardinality_matching_driver.cpp b/src/max_flow/src/maximum_cardinality_matching_driver.cpp
new file mode 100644
index 0000000..9dc41f4
--- /dev/null
+++ b/src/max_flow/src/maximum_cardinality_matching_driver.cpp
@@ -0,0 +1,98 @@
+/*PGR-GNU*****************************************************************
+File: maximum_cardinality_matching_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <vector>
+
+#include "./pgr_maximumcardinalitymatching.hpp"
+#include "./maximum_cardinality_matching_driver.h"
+#include "../../common/src/pgr_alloc.hpp"
+
+// #define DEBUG
+extern "C" {
+#include "./../../common/src/pgr_types.h"
+}
+
+void
+do_pgr_maximum_cardinality_matching(
+    pgr_basic_edge_t *data_edges,
+    bool directed,
+    size_t total_tuples,
+    pgr_basic_edge_t **return_tuples,
+    size_t *return_count,
+    char **err_msg) {
+    std::ostringstream log;
+
+    try {
+        std::vector<pgr_basic_edge_t> matched_vertices;
+
+        if (directed) {
+            PgrCardinalityGraph<BasicDirectedGraph> G;
+            G.create_max_cardinality_graph(data_edges, total_tuples);
+            std::vector<int64_t> mate_map(boost::num_vertices(G.boost_graph));
+            G.maximum_cardinality_matching(mate_map);
+            G.get_matched_vertices(matched_vertices, mate_map);
+        } else {
+            PgrCardinalityGraph<BasicUndirectedGraph> G;
+            G.create_max_cardinality_graph(data_edges, total_tuples);
+            std::vector<int64_t> mate_map(boost::num_vertices(G.boost_graph));
+            G.maximum_cardinality_matching(mate_map);
+            G.get_matched_vertices(matched_vertices, mate_map);
+        }
+
+        (*return_tuples) = pgr_alloc(matched_vertices.size(), (*return_tuples));
+        for (size_t i = 0; i < matched_vertices.size(); ++i) {
+            (*return_tuples)[i] = matched_vertices[i];
+        }
+        *return_count = matched_vertices.size();
+
+#ifndef DEBUG
+        *err_msg = strdup("OK");
+#else
+        *err_msg = strdup(log.str().c_str());
+#endif
+
+        return;
+    } catch (...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        return;
+    }
+}
+
+
+
+
+
diff --git a/src/allpairs/src/floydWarshall_driver.h b/src/max_flow/src/maximum_cardinality_matching_driver.h
similarity index 64%
copy from src/allpairs/src/floydWarshall_driver.h
copy to src/max_flow/src/maximum_cardinality_matching_driver.h
index 801bb6c..958019d 100644
--- a/src/allpairs/src/floydWarshall_driver.h
+++ b/src/max_flow/src/maximum_cardinality_matching_driver.h
@@ -1,13 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: floydWarshall_driver.h
+File: maximum_cardinality_matching_driver.h
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
-Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Function's developer:
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
 
 ------
 
@@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
-#define SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#ifndef SRC_MAX_FLOW_SRC_MAXIMUM_CARDINALITY_MATCHING_DRIVER_H_
+#define SRC_MAX_FLOW_SRC_MAXIMUM_CARDINALITY_MATCHING_DRIVER_H_
 
 #include "./../../common/src/pgr_types.h"
 
@@ -36,19 +36,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-void
-do_pgr_floydWarshall(
-    pgr_edge_t  *data_edges,
-    size_t total_tuples,
-    bool directedFlag,
+    void
+        do_pgr_maximum_cardinality_matching(
+            pgr_basic_edge_t *data_edges,
+            bool directed,
+            size_t total_tuples,
+            pgr_basic_edge_t **return_tuples,
+            size_t *return_count,
+            char **err_msg);
 
-    // return values
-    Matrix_cell_t **ret_matrix,
-    size_t *return_tuple_count,
-    char ** err_msg); 
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_ALLPAIRS_SRC_FLOYDWARSHALL_DRIVER_H_
+#endif  // SRC_MAX_FLOW_SRC_MAXIMUM_CARDINALITY_MATCHING_DRIVER_H_
diff --git a/src/max_flow/src/pgr_edgedisjointpaths.hpp b/src/max_flow/src/pgr_edgedisjointpaths.hpp
new file mode 100644
index 0000000..a3a8d73
--- /dev/null
+++ b/src/max_flow/src/pgr_edgedisjointpaths.hpp
@@ -0,0 +1,269 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#pragma once
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef unlink
+#undef unlink
+#endif
+#endif
+
+#include <boost/config.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/assert.hpp>
+
+#if 0
+#include "./../../common/src/signalhandler.h"
+#endif
+#include "./../../common/src/pgr_types.h"
+
+#include <map>
+#include <utility>
+#include <vector>
+#include <set>
+
+#include "pgr_maxflow.hpp"
+
+// user's functions
+// for development
+
+template<class G>
+class PgrEdgeDisjointPathsGraph {
+ public:
+  G boost_graph;
+
+  typedef typename boost::graph_traits<G>::vertex_descriptor V;
+  typedef typename boost::graph_traits<G>::edge_descriptor E;
+  typedef typename boost::graph_traits<G>::vertex_iterator V_it;
+  typedef typename boost::graph_traits<G>::edge_iterator E_it;
+  typedef typename boost::graph_traits<G>::out_edge_iterator Eout_it;
+
+  typename boost::property_map<G, boost::edge_capacity_t>::type capacity;
+  typename boost::property_map<G, boost::edge_reverse_t>::type rev;
+  typename boost::property_map<G, boost::edge_residual_capacity_t>::type
+      residual_capacity;
+
+  std::map<int64_t, V> id_to_V;
+  std::map<V, int64_t> V_to_id;
+  std::map<E, int64_t> E_to_id;
+
+  V source_vertex;
+  V sink_vertex;
+
+  V get_boost_vertex(int64_t id) {
+      return id_to_V[id];
+  }
+
+  int64_t get_vertex_id(V v) {
+      return V_to_id[v];
+  }
+
+  int64_t get_edge_id(E e) {
+      return E_to_id[e];
+  }
+
+  int64_t boykov_kolmogorov() {
+      size_t num_v = boost::num_vertices(boost_graph);
+      std::vector<boost::default_color_type> color(num_v);
+      std::vector<int64_t> distance(num_v);
+      return boost::boykov_kolmogorov_max_flow(boost_graph,
+                                               source_vertex,
+                                               sink_vertex);
+  }
+
+  void create_edge_disjoint_paths_graph(pgr_basic_edge_t *data_edges,
+                                        size_t total_tuples,
+                                        const std::set<int64_t> &source_vertices,
+                                        const std::set<int64_t> &sink_vertices,
+                                        bool directed) {
+      std::set<int64_t> vertices;
+      for (int64_t source : source_vertices) {
+          vertices.insert(source);
+      }
+      for (int64_t sink : sink_vertices) {
+          vertices.insert(sink);
+      }
+      for (size_t i = 0; i < total_tuples; ++i) {
+          vertices.insert(data_edges[i].source);
+          vertices.insert(data_edges[i].target);
+      }
+      for (int64_t id : vertices) {
+          V v = add_vertex(boost_graph);
+          id_to_V.insert(std::pair<int64_t, V>(id, v));
+          V_to_id.insert(std::pair<V, int64_t>(v, id));
+      }
+      bool added;
+
+      V supersource = add_vertex(boost_graph);
+      for (int64_t source_id : source_vertices) {
+          V source = get_boost_vertex(source_id);
+          E e, e_rev;
+          boost::tie(e, added) =
+              boost::add_edge(supersource, source, boost_graph);
+          boost::tie(e_rev, added) =
+              boost::add_edge(source, supersource, boost_graph);
+          capacity[e] = 999999999;
+          capacity[e_rev] = 0;
+          rev[e] = e_rev;
+          rev[e_rev] = e;
+      }
+
+      V supersink = add_vertex(boost_graph);
+      for (int64_t sink_id : sink_vertices) {
+          V sink = get_boost_vertex(sink_id);
+          E e1, e1_rev;
+          boost::tie(e1, added) =
+              boost::add_edge(sink, supersink, boost_graph);
+          boost::tie(e1_rev, added) =
+              boost::add_edge(supersink, sink, boost_graph);
+          capacity[e1] = 999999999;
+          capacity[e1_rev] = 0;
+          rev[e1] = e1_rev;
+          rev[e1_rev] = e1;
+      }
+
+      source_vertex = supersource;
+      sink_vertex = supersink;
+
+      capacity = get(boost::edge_capacity, boost_graph);
+      rev = get(boost::edge_reverse, boost_graph);
+      residual_capacity =
+          get(boost::edge_residual_capacity, boost_graph);
+
+      for (size_t i = 0; i < total_tuples; ++i) {
+          V v1 = get_boost_vertex(data_edges[i].source);
+          V v2 = get_boost_vertex(data_edges[i].target);
+          if (directed) {
+              E e, e_rev;
+              boost::tie(e, added) =
+                  boost::add_edge(v1, v2, boost_graph);
+              boost::tie(e_rev, added) =
+                  boost::add_edge(v2, v1, boost_graph);
+              E_to_id.insert(std::pair<E, int64_t>(e, data_edges[i].id));
+              E_to_id.insert(std::pair<E, int64_t>(e_rev,
+                                                   data_edges[i].id));
+              capacity[e] = data_edges[i].going ? 1 : 0;
+              capacity[e_rev] = data_edges[i].coming ? 1 : 0;
+              rev[e] = e_rev;
+              rev[e_rev] = e;
+          } else {
+              if (data_edges[i].going || data_edges[i].coming) {
+                  E e, e_rev;
+                  boost::tie(e, added) =
+                      boost::add_edge(v1, v2, boost_graph);
+                  boost::tie(e_rev, added) =
+                      boost::add_edge(v2, v1, boost_graph);
+                  E_to_id.insert(std::pair<E, int64_t>(e, data_edges[i].id));
+                  E_to_id.insert(std::pair<E, int64_t>(e_rev,
+                                                       data_edges[i].id));
+                  capacity[e] = 1;
+                  capacity[e_rev] = 1;
+                  rev[e] = e_rev;
+                  rev[e_rev] = e;
+              }
+          }
+      }
+  }
+
+  void
+  flow_dfs(V vertex,
+           int64_t path_id,
+           std::vector<std::vector<int64_t> > &paths) {
+      Eout_it ei, e_end;
+      if (boost::edge(vertex, sink_vertex, boost_graph).second) {
+          int64_t v_id = get_vertex_id(vertex);
+          paths[path_id].push_back(v_id);
+      } else {
+          for (boost::tie(ei, e_end) =
+                   boost::out_edges(vertex, boost_graph);
+               ei != e_end; ++ei) {
+              if (residual_capacity[*ei] < capacity[*ei]) {
+                  // exclude this edge from subsequent visits
+                  capacity[*ei] = -1;
+                  int64_t v_id = get_vertex_id(vertex);
+                  paths[path_id].push_back(v_id);
+                  flow_dfs((*ei).m_target,
+                           path_id,
+                           paths);
+                  break;
+              }
+          }
+      }
+  }
+
+  void
+  get_edge_disjoint_paths(std::vector<General_path_element_t> &path_elements,
+                          int64_t flow) {
+      std::vector<std::vector<int64_t> > paths(flow, std::vector<int64_t>());
+      int64_t path_id = 0;
+      Eout_it ei, e_end, ei2, e2_end;
+      for (boost::tie(ei, e_end) =
+               boost::out_edges(source_vertex, boost_graph);
+           ei != e_end; ++ei) {
+          if (capacity[*ei] - residual_capacity[*ei] > 0) {
+              for (boost::tie(ei2, e2_end) =
+                       boost::out_edges((*ei).m_target, boost_graph);
+                   ei2 != e2_end; ++ei2) {
+                  if (capacity[*ei2] - residual_capacity[*ei2]
+                      > 0) {
+                      paths[path_id].push_back(get_vertex_id((*ei2).m_source));
+                      flow_dfs((*ei2).m_target, path_id, paths);
+                      path_id++;
+                  }
+              }
+          }
+      }
+      for (int i = 0; i < flow; i++) {
+          size_t size = paths[i].size();
+          E e;
+          bool exists;
+          size_t j;
+          for (j = 0; j < size - 1; j++) {
+              General_path_element_t edge;
+              edge.seq = (int) (j + 1);
+              edge.start_id = paths[i][0];
+              edge.end_id = paths[i][size - 1];
+              edge.node = paths[i][j];
+              boost::tie(e, exists) = boost::edge(get_boost_vertex(paths[i][j]),
+                                                  get_boost_vertex(paths[i][j
+                                                      + 1]),
+                                                  boost_graph);
+              edge.edge = get_edge_id(e);
+              path_elements.push_back(edge);
+          }
+          General_path_element_t edge;
+          edge.seq = (int) (j + 1);
+          edge.start_id = paths[i][0];
+          edge.end_id = paths[i][size - 1];
+          edge.node = paths[i][j];
+          edge.edge = -1;
+          path_elements.push_back(edge);
+      }
+  }
+};
diff --git a/src/max_flow/src/pgr_maxflow.hpp b/src/max_flow/src/pgr_maxflow.hpp
new file mode 100644
index 0000000..4342c9a
--- /dev/null
+++ b/src/max_flow/src/pgr_maxflow.hpp
@@ -0,0 +1,262 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#pragma once
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef unlink
+#undef unlink
+#endif
+#endif
+
+#include <boost/config.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/push_relabel_max_flow.hpp>
+#include <boost/graph/edmonds_karp_max_flow.hpp>
+#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
+
+#if 0
+#include "./../../common/src/signalhandler.h"
+#endif
+#include "./../../common/src/pgr_types.h"
+
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+#include <set>
+
+
+// user's functions
+// for development
+
+typedef boost::adjacency_list_traits<boost::vecS, boost::vecS, boost::directedS>
+    Traits;
+typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS,
+        // Vertex properties
+        boost::property<boost::vertex_name_t, std::string,
+        boost::property<boost::vertex_index_t, int64_t,
+        boost::property<boost::vertex_color_t, boost::default_color_type,
+        boost::property<boost::vertex_distance_t, int64_t,
+        boost::property<boost::vertex_predecessor_t, Traits::edge_descriptor> > > > >,
+        // Edge properties
+        boost::property<boost::edge_capacity_t, int64_t,
+        boost::property<boost::edge_residual_capacity_t, int64_t,
+        boost::property<boost::edge_reverse_t, Traits::edge_descriptor> > > >
+    FlowGraph;
+
+template<class G>
+class PgrFlowGraph {
+ public:
+  G boost_graph;
+
+  typedef typename boost::graph_traits<G>::vertex_descriptor V;
+  typedef typename boost::graph_traits<G>::edge_descriptor E;
+  typedef typename boost::graph_traits<G>::vertex_iterator V_it;
+  typedef typename boost::graph_traits<G>::edge_iterator E_it;
+
+  typename boost::property_map<G, boost::edge_capacity_t>::type capacity;
+  typename boost::property_map<G, boost::edge_reverse_t>::type rev;
+  typename boost::property_map<G, boost::edge_residual_capacity_t>::type
+      residual_capacity;
+
+
+  std::map<int64_t, V> id_to_V;
+  std::map<V, int64_t> V_to_id;
+  std::map<E, int64_t> E_to_id;
+
+  V source_vertex;
+  V sink_vertex;
+
+  V get_boost_vertex(int64_t id) {
+      return id_to_V[id];
+  }
+
+  int64_t get_vertex_id(V v) {
+      return V_to_id[v];
+  }
+
+  int64_t get_edge_id(E e) {
+      return E_to_id[e];
+  }
+
+  int64_t push_relabel() {
+      return boost::push_relabel_max_flow(boost_graph,
+                                          source_vertex,
+                                          sink_vertex);
+  }
+
+  int64_t edmonds_karp() {
+      return boost::edmonds_karp_max_flow(boost_graph,
+                                          source_vertex,
+                                          sink_vertex);
+  }
+
+  int64_t boykov_kolmogorov() {
+      size_t num_v = boost::num_vertices(boost_graph);
+      std::vector<boost::default_color_type> color(num_v);
+      std::vector<int64_t> distance(num_v);
+      return boost::boykov_kolmogorov_max_flow(boost_graph,
+                                               source_vertex,
+                                               sink_vertex);
+  }
+
+  void create_flow_graph(pgr_edge_t *data_edges,
+                         size_t total_tuples,
+                         const std::set<int64_t> &source_vertices,
+                         const std::set<int64_t> &sink_vertices,
+                         char *algorithm) {
+      /* In multi source flow graphs, a super source is created connected to all sources with "infinite" capacity
+       * The same applies for sinks.
+       * To avoid code repetition, a supersource/sink is used even in the one to one signature.
+       */
+      std::set<int64_t> vertices;
+      for (int64_t source : source_vertices) {
+          vertices.insert(source);
+      }
+      for (int64_t sink : sink_vertices) {
+          vertices.insert(sink);
+      }
+      for (size_t i = 0; i < total_tuples; ++i) {
+          vertices.insert(data_edges[i].source);
+          vertices.insert(data_edges[i].target);
+      }
+      for (int64_t id : vertices) {
+          V v = add_vertex(boost_graph);
+          id_to_V.insert(std::pair<int64_t, V>(id, v));
+          V_to_id.insert(std::pair<V, int64_t>(v, id));
+      }
+      bool added;
+
+      V supersource = add_vertex(boost_graph);
+      for (int64_t source_id : source_vertices) {
+          V source = get_boost_vertex(source_id);
+          E e, e_rev;
+          boost::tie(e, added) =
+              boost::add_edge(supersource, source, boost_graph);
+          boost::tie(e_rev, added) =
+              boost::add_edge(source, supersource, boost_graph);
+          capacity[e] = 999999999;
+          capacity[e_rev] = 0;
+          rev[e] = e_rev;
+          rev[e_rev] = e;
+      }
+
+      V supersink = add_vertex(boost_graph);
+      for (int64_t sink_id : sink_vertices) {
+          V sink = get_boost_vertex(sink_id);
+          E e, e_rev;
+          boost::tie(e, added) = boost::add_edge(sink, supersink, boost_graph);
+          boost::tie(e_rev, added) =
+              boost::add_edge(supersink, sink, boost_graph);
+          capacity[e] = 999999999;
+          capacity[e_rev] = 0;
+          rev[e] = e_rev;
+          rev[e_rev] = e;
+      }
+
+      source_vertex = supersource;
+      sink_vertex = supersink;
+
+      capacity = get(boost::edge_capacity, boost_graph);
+      rev = get(boost::edge_reverse, boost_graph);
+      residual_capacity = get(boost::edge_residual_capacity, boost_graph);
+
+      /*
+       * Push-relabel requires each edge to be mapped to its reverse with capacity 0.
+       * The other algorithms have no such requirement. (I can have half as many edges)
+       */
+      if (strcmp(algorithm, "push_relabel") == 0) {
+          for (size_t i = 0; i < total_tuples; ++i) {
+              V v1 = get_boost_vertex(data_edges[i].source);
+              V v2 = get_boost_vertex(data_edges[i].target);
+              E e1, e1_rev, e2, e2_rev;
+              if (data_edges[i].cost > 0) {
+                  boost::tie(e1, added) = boost::add_edge(v1, v2, boost_graph);
+                  boost::tie(e1_rev, added) =
+                      boost::add_edge(v2, v1, boost_graph);
+                  E_to_id.insert(std::pair<E, int64_t>(e1, data_edges[i].id));
+                  E_to_id.insert(std::pair<E, int64_t>(e1_rev,
+                                                       data_edges[i].id));
+                  capacity[e1] = (int64_t) data_edges[i].cost;
+                  capacity[e1_rev] = 0;
+                  rev[e1] = e1_rev;
+                  rev[e1_rev] = e1;
+              }
+              if (data_edges[i].reverse_cost > 0) {
+                  boost::tie(e2, added) = boost::add_edge(v2, v1, boost_graph);
+                  boost::tie(e2_rev, added) =
+                      boost::add_edge(v1, v2, boost_graph);
+                  E_to_id.insert(std::pair<E, int64_t>(e2, data_edges[i].id));
+                  E_to_id.insert(std::pair<E, int64_t>(e2_rev,
+                                                       data_edges[i].id));
+                  capacity[e2] = (int64_t) data_edges[i].reverse_cost;
+                  capacity[e2_rev] = 0;
+                  rev[e2] = e2_rev;
+                  rev[e2_rev] = e2;
+              }
+          }
+      } else {
+          for (size_t i = 0; i < total_tuples; ++i) {
+              V v1 = get_boost_vertex(data_edges[i].source);
+              V v2 = get_boost_vertex(data_edges[i].target);
+              E e, e_rev;
+              boost::tie(e, added) = boost::add_edge(v1, v2, boost_graph);
+              boost::tie(e_rev, added) =
+                  boost::add_edge(v2, v1, boost_graph);
+              E_to_id.insert(std::pair<E, int64_t>(e, data_edges[i].id));
+              E_to_id.insert(std::pair<E, int64_t>(e_rev, data_edges[i].id));
+              capacity[e] =
+                  data_edges[i].cost > 0 ? (int64_t) data_edges[i].cost : 0;
+              capacity[e_rev] = data_edges[i].reverse_cost > 0
+                                ? (int64_t) data_edges[i].reverse_cost : 0;
+              rev[e] = e_rev;
+              rev[e_rev] = e;
+          }
+      }
+  }
+
+  void get_flow_edges(std::vector<pgr_flow_t> &flow_edges) {
+      E_it e, e_end;
+      for (boost::tie(e, e_end) = boost::edges(boost_graph); e != e_end;
+           ++e) {
+          // A supersource/supersink is used internally
+          if (((capacity[*e] - residual_capacity[*e]) > 0) &&
+              ((*e).m_source != source_vertex) &&
+              ((*e).m_target != sink_vertex)) {
+              pgr_flow_t edge;
+              edge.edge = get_edge_id(*e);
+              edge.source = get_vertex_id((*e).m_source);
+              edge.target = get_vertex_id((*e).m_target);
+              edge.flow = capacity[*e] - residual_capacity[*e];
+              edge.residual_capacity = residual_capacity[*e];
+              flow_edges.push_back(edge);
+          }
+      }
+  }
+};
diff --git a/src/max_flow/src/pgr_maximumcardinalitymatching.hpp b/src/max_flow/src/pgr_maximumcardinalitymatching.hpp
new file mode 100644
index 0000000..5999533
--- /dev/null
+++ b/src/max_flow/src/pgr_maximumcardinalitymatching.hpp
@@ -0,0 +1,170 @@
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Copyright (c) 2016 Andrea Nardelli
+Mail: nrd.nardelli at gmail.com
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+********************************************************************PGR-GNU*/
+
+#pragma once
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#ifdef unlink
+#undef unlink
+#endif
+#endif
+
+#include <boost/config.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/max_cardinality_matching.hpp>
+
+#if 0
+#include "./../../common/src/signalhandler.h"
+#endif
+#include "./../../common/src/pgr_types.h"
+
+#include <map>
+#include <vector>
+#include <utility>
+#include <set>
+
+
+// user's functions
+// for development
+
+typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS>
+    BasicUndirectedGraph;
+typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS>
+    BasicDirectedGraph;
+
+template<class G>
+class PgrCardinalityGraph {
+ public:
+  G boost_graph;
+
+  typedef typename boost::graph_traits<G>::vertex_descriptor V;
+  typedef typename boost::graph_traits<G>::edge_descriptor E;
+  typedef typename boost::graph_traits<G>::vertex_iterator V_it;
+  typedef typename boost::graph_traits<G>::edge_iterator E_it;
+
+  std::map<int64_t, V> id_to_V;
+  std::map<V, int64_t> V_to_id;
+  std::map<E, int64_t> E_to_id;
+
+  V get_boost_vertex(int64_t id) {
+      return id_to_V[id];
+  }
+
+  int64_t get_vertex_id(V v) {
+      return V_to_id[v];
+  }
+
+  int64_t get_edge_id(E e) {
+      return E_to_id[e];
+  }
+
+  void create_max_cardinality_graph(pgr_basic_edge_t *data_edges,
+                                    size_t total_tuples) {
+      std::set<int64_t> vertices;
+      for (size_t i = 0; i < total_tuples; ++i) {
+          vertices.insert(data_edges[i].source);
+          vertices.insert(data_edges[i].target);
+      }
+      for (int64_t id : vertices) {
+          V v = add_vertex(boost_graph);
+          id_to_V.insert(std::pair<int64_t, V>(id, v));
+          V_to_id.insert(std::pair<V, int64_t>(v, id));
+      }
+      bool added;
+
+      for (size_t i = 0; i < total_tuples; ++i) {
+          V v1 = get_boost_vertex(data_edges[i].source);
+          V v2 = get_boost_vertex(data_edges[i].target);
+          E e1;
+          E e2;
+          if (data_edges[i].going) {
+              boost::tie(e1, added) = boost::add_edge(v1, v2, boost_graph);
+              E_to_id.insert(std::pair<E, int64_t>(e1, data_edges[i].id));
+          }
+          if (data_edges[i].coming) {
+              boost::tie(e2, added) = boost::add_edge(v2, v1, boost_graph);
+              E_to_id.insert(std::pair<E, int64_t>(e2, data_edges[i].id));
+          }
+      }
+  }
+
+  void get_matched_vertices(std::vector<pgr_basic_edge_t> &matched_vertices,
+                            const std::vector<int64_t> &mate_map) {
+      V_it vi, vi_end;
+      E e;
+      bool exists;
+      if (boost::is_directed(boost_graph)) {
+          std::vector<bool> already_matched(num_vertices(boost_graph), false);
+          for (boost::tie(vi, vi_end) = boost::vertices(boost_graph);
+               vi != vi_end;
+               ++vi) {
+              /*
+               * For each vertex I check:
+               * 1) It is matched with a non-null vertex
+               * 2) An edge exists from this vertex to his mate
+               * 3) The vertices have not been matched already
+               * (this last point prevents having double output with reversed
+               * source and target)
+               */
+              boost::tie(e, exists) =
+                  boost::edge(*vi, mate_map[*vi], boost_graph);
+              if (((uint64_t)mate_map[*vi] != boost::graph_traits<G>::null_vertex())
+                  && exists && !already_matched[*vi]
+                  && !already_matched[mate_map[*vi]]) {
+                  already_matched[*vi] = true;
+                  already_matched[mate_map[*vi]] = true;
+                  pgr_basic_edge_t matched_couple;
+                  matched_couple.source = get_vertex_id(*vi);
+                  matched_couple.target = get_vertex_id(mate_map[*vi]);
+                  matched_couple.edge_id = get_edge_id(e);
+                  matched_vertices.push_back(matched_couple);
+              }
+          }
+      } else {
+          for (boost::tie(vi, vi_end) = boost::vertices(boost_graph);
+               vi != vi_end;
+               ++vi) {
+              boost::tie(e, exists) =
+                  boost::edge(*vi, mate_map[*vi], boost_graph);
+              if (((uint64_t)mate_map[*vi] != boost::graph_traits<G>::null_vertex())
+                  && (*vi < (uint64_t)mate_map[*vi])) {
+                  pgr_basic_edge_t matched_couple;
+                  matched_couple.source = get_vertex_id(*vi);
+                  matched_couple.target = get_vertex_id(mate_map[*vi]);
+                  matched_couple.edge_id = get_edge_id(e);
+                  matched_vertices.push_back(matched_couple);
+              }
+          }
+      }
+  }
+
+  void maximum_cardinality_matching(std::vector<int64_t> &mate_map) {
+      edmonds_maximum_cardinality_matching(boost_graph,
+                                           &mate_map[0]);
+  }
+};
diff --git a/src/astar/doc/CMakeLists.txt b/src/max_flow/test/CMakeLists.txt
similarity index 100%
rename from src/astar/doc/CMakeLists.txt
rename to src/max_flow/test/CMakeLists.txt
diff --git a/src/max_flow/test/doc-pgr_edgeDisjointPaths.result b/src/max_flow/test/doc-pgr_edgeDisjointPaths.result
new file mode 100644
index 0000000..18a4df2
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_edgeDisjointPaths.result
@@ -0,0 +1,44 @@
+-- q1
+1|1|3|2
+2|2|2|4
+3|3|5|-1
+4|1|3|5
+5|2|6|8
+6|3|5|-1
+-- q2
+1|1|3|2
+2|2|2|4
+3|3|5|-1
+4|1|3|3
+5|2|4|16
+6|3|9|9
+7|4|6|8
+8|5|5|-1
+9|1|3|5
+10|2|6|11
+11|3|11|12
+12|4|10|10
+13|5|5|-1
+-- q3
+1|1|5|3|2
+2|2|5|2|4
+3|3|5|5|-1
+4|1|5|3|5
+5|2|5|6|8
+6|3|5|5|-1
+-- q4
+1|1|3|3|2
+2|2|3|2|4
+3|3|3|5|-1
+4|1|6|6|8
+5|2|6|5|-1
+-- q5
+1|1|3|5|3|2
+2|2|3|5|2|4
+3|3|3|5|5|-1
+4|1|6|5|6|8
+5|2|6|5|5|-1
+6|1|6|4|6|9
+7|2|6|4|9|16
+8|3|6|4|4|-1
+-- q6
diff --git a/src/max_flow/test/doc-pgr_edgeDisjointPaths.test.sql b/src/max_flow/test/doc-pgr_edgeDisjointPaths.test.sql
new file mode 100644
index 0000000..74a1d35
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_edgeDisjointPaths.test.sql
@@ -0,0 +1,38 @@
+--These tests used the sample data provided here: http://docs.pgrouting.org/2.2/en/doc/src/developer/sampledata.html#sampledata
+
+BEGIN;
+SET client_min_messages TO NOTICE;
+
+\echo -- q1
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, 5
+);
+
+\echo -- q2
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, 5,
+    directed := false
+);
+
+\echo -- q3
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, ARRAY[4, 5, 10]
+);
+
+\echo -- q4
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    ARRAY[3, 6], 5
+);
+
+\echo -- q5
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    ARRAY[3, 6], ARRAY[4, 5, 10]
+);
+
+\echo -- q6
+ROLLBACK;
diff --git a/src/max_flow/test/doc-pgr_maxFlowBoykovKolmogorov.result b/src/max_flow/test/doc-pgr_maxFlowBoykovKolmogorov.result
new file mode 100644
index 0000000..97b9a3d
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maxFlowBoykovKolmogorov.result
@@ -0,0 +1,41 @@
+-- q1
+1|10|5|10|100|30
+2|8|6|5|100|30
+3|9|6|9|50|80
+4|11|6|11|130|0
+5|15|9|12|50|30
+6|12|10|11|100|0
+7|13|12|11|50|0
+-- q2
+1|1|2|1|50|80
+2|3|4|3|80|50
+3|4|5|2|50|0
+4|10|5|10|80|50
+5|5|6|3|50|0
+6|8|6|5|130|0
+7|9|6|9|130|0
+8|11|6|11|130|0
+9|15|9|12|50|30
+10|16|9|4|80|0
+11|12|10|11|80|20
+12|13|12|11|50|0
+-- q3
+1|10|5|10|100|30
+2|8|6|5|100|30
+3|11|6|11|130|0
+4|12|10|11|100|0
+5|13|12|11|50|0
+-- q4
+1|1|2|1|50|80
+2|3|4|3|80|50
+3|4|5|2|50|0
+4|10|5|10|100|30
+5|5|6|3|50|0
+6|8|6|5|130|0
+7|9|6|9|80|50
+8|11|6|11|130|0
+9|7|8|5|20|30
+10|16|9|4|80|0
+11|12|10|11|100|0
+12|13|12|11|50|0
+-- q5
diff --git a/src/max_flow/test/doc-pgr_maxFlowBoykovKolmogorov.test.sql b/src/max_flow/test/doc-pgr_maxFlowBoykovKolmogorov.test.sql
new file mode 100644
index 0000000..314acb5
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maxFlowBoykovKolmogorov.test.sql
@@ -0,0 +1,60 @@
+--These tests used the sample data provided here: http://docs.pgrouting.org/2.2/en/doc/src/developer/sampledata.html#sampledata
+--The edge in the edge table are augmented with road-like categories for capacity values.
+
+BEGIN;
+SET client_min_messages TO NOTICE;
+
+\echo -- q1
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, 11
+);
+
+\echo -- q2
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, ARRAY[1, 3, 11]
+);
+
+\echo -- q3
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], 11
+);
+
+\echo -- q4
+SELECT * FROM pgr_maxFlowBoykovKolmogorov(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], ARRAY[1, 3, 11]
+);
+
+\echo -- q5
+ROLLBACK;
diff --git a/src/max_flow/test/doc-pgr_maxFlowEdmondsKarp.result b/src/max_flow/test/doc-pgr_maxFlowEdmondsKarp.result
new file mode 100644
index 0000000..97b9a3d
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maxFlowEdmondsKarp.result
@@ -0,0 +1,41 @@
+-- q1
+1|10|5|10|100|30
+2|8|6|5|100|30
+3|9|6|9|50|80
+4|11|6|11|130|0
+5|15|9|12|50|30
+6|12|10|11|100|0
+7|13|12|11|50|0
+-- q2
+1|1|2|1|50|80
+2|3|4|3|80|50
+3|4|5|2|50|0
+4|10|5|10|80|50
+5|5|6|3|50|0
+6|8|6|5|130|0
+7|9|6|9|130|0
+8|11|6|11|130|0
+9|15|9|12|50|30
+10|16|9|4|80|0
+11|12|10|11|80|20
+12|13|12|11|50|0
+-- q3
+1|10|5|10|100|30
+2|8|6|5|100|30
+3|11|6|11|130|0
+4|12|10|11|100|0
+5|13|12|11|50|0
+-- q4
+1|1|2|1|50|80
+2|3|4|3|80|50
+3|4|5|2|50|0
+4|10|5|10|100|30
+5|5|6|3|50|0
+6|8|6|5|130|0
+7|9|6|9|80|50
+8|11|6|11|130|0
+9|7|8|5|20|30
+10|16|9|4|80|0
+11|12|10|11|100|0
+12|13|12|11|50|0
+-- q5
diff --git a/src/max_flow/test/doc-pgr_maxFlowEdmondsKarp.test.sql b/src/max_flow/test/doc-pgr_maxFlowEdmondsKarp.test.sql
new file mode 100644
index 0000000..0be2d91
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maxFlowEdmondsKarp.test.sql
@@ -0,0 +1,60 @@
+--These tests used the sample data provided here: http://docs.pgrouting.org/2.2/en/doc/src/developer/sampledata.html#sampledata
+--The edge in the edge table are augmented with road-like categories for capacity values.
+
+BEGIN;
+SET client_min_messages TO NOTICE;
+
+\echo -- q1
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, 11
+);
+
+\echo -- q2
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+   , 6, ARRAY[1, 3, 11]
+);
+
+\echo -- q3
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+   , ARRAY[6, 8, 12], 11
+);
+
+\echo -- q4
+SELECT * FROM pgr_maxFlowEdmondsKarp(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+   , ARRAY[6, 8, 12], ARRAY[1, 3, 11]
+);
+
+\echo -- q5
+ROLLBACK;
diff --git a/src/max_flow/test/doc-pgr_maxFlowPushRelabel.result b/src/max_flow/test/doc-pgr_maxFlowPushRelabel.result
new file mode 100644
index 0000000..86ec9d5
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maxFlowPushRelabel.result
@@ -0,0 +1,48 @@
+-- q1
+1|10|5|10|100|30
+2|8|6|5|100|30
+3|9|6|9|50|80
+4|11|6|11|130|0
+5|15|9|12|50|30
+6|12|10|11|100|0
+7|13|12|11|50|0
+-- q2
+1|1|2|1|130|0
+2|4|2|5|20|80
+3|2|3|2|100|0
+4|3|4|3|50|80
+5|4|5|2|50|0
+6|7|5|8|50|80
+7|10|5|10|100|30
+8|5|6|3|50|0
+9|8|6|5|130|0
+10|9|6|9|100|30
+11|11|6|11|130|0
+12|6|7|8|50|0
+13|6|8|7|50|50
+14|7|8|5|50|0
+15|15|9|12|50|30
+16|16|9|4|50|30
+17|12|10|11|100|0
+18|13|12|11|50|0
+-- q3
+1|10|5|10|100|30
+2|8|6|5|100|30
+3|11|6|11|130|0
+4|12|10|11|100|0
+5|13|12|11|50|0
+-- q4
+1|1|2|1|50|80
+2|3|4|3|80|50
+3|4|5|2|50|0
+4|10|5|10|100|30
+5|5|6|3|50|0
+6|8|6|5|130|0
+7|9|6|9|30|100
+8|11|6|11|130|0
+9|7|8|5|20|30
+10|16|9|4|80|0
+11|12|10|11|100|0
+12|13|12|11|50|0
+13|15|12|9|50|0
+-- q5
diff --git a/src/max_flow/test/doc-pgr_maxFlowPushRelabel.test.sql b/src/max_flow/test/doc-pgr_maxFlowPushRelabel.test.sql
new file mode 100644
index 0000000..f8c5056
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maxFlowPushRelabel.test.sql
@@ -0,0 +1,62 @@
+--These tests used the sample data provided here: http://docs.pgrouting.org/2.2/en/doc/src/developer/sampledata.html#sampledata
+--The edge in the edge table are augmented with road-like categories for capacity values.
+
+BEGIN;
+
+SET client_min_messages TO NOTICE;
+
+\echo -- q1
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, 11
+);
+
+\echo -- q2
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , 6, ARRAY[11, 1, 13]
+);
+
+\echo -- q3
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], 11
+);
+
+\echo -- q4
+SELECT * FROM pgr_maxFlowPushRelabel(
+    'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id
+    ORDER BY id'
+    , ARRAY[6, 8, 12], ARRAY[1, 3, 11]
+);
+
+\echo -- q5
+
+ROLLBACK;
diff --git a/src/max_flow/test/doc-pgr_maximumCardinalityMatching.result b/src/max_flow/test/doc-pgr_maximumCardinalityMatching.result
new file mode 100644
index 0000000..155e204
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maximumCardinalityMatching.result
@@ -0,0 +1,19 @@
+-- q1
+1|1|1|2
+2|3|4|3
+3|9|6|9
+4|6|7|8
+5|14|10|13
+6|13|11|12
+7|17|14|15
+8|18|16|17
+-- q2
+1|1|1|2
+2|3|3|4
+3|9|6|9
+4|6|7|8
+5|14|10|13
+6|13|11|12
+7|17|14|15
+8|18|16|17
+-- q3
diff --git a/src/max_flow/test/doc-pgr_maximumCardinalityMatching.test.sql b/src/max_flow/test/doc-pgr_maximumCardinalityMatching.test.sql
new file mode 100644
index 0000000..bb887f4
--- /dev/null
+++ b/src/max_flow/test/doc-pgr_maximumCardinalityMatching.test.sql
@@ -0,0 +1,18 @@
+--These tests used the sample data provided here: http://docs.pgrouting.org/2.2/en/doc/src/developer/sampledata.html#sampledata
+
+BEGIN;
+SET client_min_messages TO NOTICE;
+
+\echo -- q1
+SELECT * FROM pgr_maximumCardinalityMatching(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table'
+);
+
+\echo -- q2
+SELECT * FROM pgr_maximumCardinalityMatching(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    directed := false
+);
+
+\echo -- q3
+ROLLBACK;
diff --git a/src/max_flow/test/pgtap/flow-types-check.sql b/src/max_flow/test/pgtap/flow-types-check.sql
new file mode 100644
index 0000000..6b96ce6
--- /dev/null
+++ b/src/max_flow/test/pgtap/flow-types-check.sql
@@ -0,0 +1,1368 @@
+\i setup.sql
+SET client_min_messages TO WARNING;
+
+SELECT plan(114);
+--Boykov-Kolmogorov
+SELECT has_function('pgr_maxflowboykovkolmogorov');
+
+SELECT has_function('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'bigint', 'bigint'
+    ]);
+SELECT has_function('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'anyarray', 'bigint'
+    ]);
+SELECT has_function('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'bigint', 'anyarray'
+    ]);
+SELECT has_function('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'anyarray', 'anyarray'
+    ]);
+
+SELECT function_returns('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'bigint', 'bigint'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'bigint', 'anyarray'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'anyarray', 'bigint'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowboykovkolmogorov', ARRAY[
+    'text', 'anyarray', 'anyarray'
+    ], 'setof record');
+
+--Edmonds-Karp
+SELECT has_function('pgr_maxflowedmondskarp');
+
+SELECT has_function('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'bigint', 'bigint'
+    ]);
+SELECT has_function('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'anyarray', 'bigint'
+    ]);
+SELECT has_function('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'bigint', 'anyarray'
+    ]);
+SELECT has_function('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'anyarray', 'anyarray'
+    ]);
+
+SELECT function_returns('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'bigint', 'bigint'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'bigint', 'anyarray'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'anyarray', 'bigint'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowedmondskarp', ARRAY[
+    'text', 'anyarray', 'anyarray'
+    ], 'setof record');
+
+--Push-Relabel
+SELECT has_function('pgr_maxflowpushrelabel');
+
+SELECT has_function('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'bigint', 'bigint'
+    ]);
+SELECT has_function('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'anyarray', 'bigint'
+    ]);
+SELECT has_function('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'bigint', 'anyarray'
+    ]);
+SELECT has_function('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'anyarray', 'anyarray'
+    ]);
+
+
+SELECT function_returns('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'bigint', 'bigint'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'bigint', 'anyarray'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'anyarray', 'bigint'
+    ], 'setof record');
+SELECT function_returns('pgr_maxflowpushrelabel', ARRAY[
+    'text', 'anyarray', 'anyarray'
+    ], 'setof record');
+
+-- Push-relabel
+PREPARE pl_q_o2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowpushrelabel(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            2, 3) ) AS a
+    limit 1
+;
+PREPARE pl_v_o2o AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+PREPARE pl_q_o2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowpushrelabel(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            2, ARRAY[3]) ) AS a
+    limit 1
+;
+PREPARE pl_v_o2m AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+
+PREPARE pl_q_m2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowpushrelabel(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            ARRAY[2], 3) ) AS a
+    limit 1
+;
+PREPARE pl_v_m2o AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+PREPARE pl_q_m2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowpushrelabel(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            ARRAY[2], ARRAY[3]) ) AS a
+    limit 1
+;
+PREPARE pl_v_m2m AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+-- Edmonds-Karp
+PREPARE ek_q_o2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowedmondskarp(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            2, 3) ) AS a
+    limit 1
+;
+PREPARE ek_v_o2o AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+PREPARE ek_q_o2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowedmondskarp(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            2, ARRAY[3]) ) AS a
+    limit 1
+;
+PREPARE ek_v_o2m AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+
+PREPARE ek_q_m2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowedmondskarp(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            ARRAY[2], 3) ) AS a
+    limit 1
+;
+PREPARE ek_v_m2o AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+PREPARE ek_q_m2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowedmondskarp(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            ARRAY[2], ARRAY[3]) ) AS a
+    limit 1
+;
+PREPARE ek_v_m2m AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+-- Boykov-Kolmogorov
+PREPARE bk_q_o2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowboykovkolmogorov(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            2, 3) ) AS a
+    limit 1
+;
+PREPARE bk_v_o2o AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+PREPARE bk_q_o2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowboykovkolmogorov(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            2, ARRAY[3]) ) AS a
+    limit 1
+;
+PREPARE bk_v_o2m AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+
+PREPARE bk_q_m2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowboykovkolmogorov(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            ARRAY[2], 3) ) AS a
+    limit 1
+;
+PREPARE bk_v_m2o AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+PREPARE bk_q_m2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4,
+    pg_typeof(flow)::text AS t5, pg_typeof(residual_capacity)::TEXT AS t6
+    FROM (
+        SELECT * FROM pgr_maxflowboykovkolmogorov(
+            'SELECT id,
+            source,
+            target,
+            c1.capacity as capacity,
+            c2.capacity as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+            ARRAY[2], ARRAY[3]) ) AS a
+    limit 1
+;
+PREPARE bk_v_m2m AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+-- testing
+-- Push-relabel
+SELECT set_eq('pl_v_o2o', 'pl_q_o2o','1 to 1: Expected returning, columns names & types');
+SELECT set_eq('pl_v_o2m', 'pl_q_o2m','1 to many: Expected returning, columns names & types');
+SELECT set_eq('pl_v_m2o', 'pl_q_m2o','many to 1: Expected returning, columns names & types');
+SELECT set_eq('pl_v_m2m', 'pl_q_m2m','many to many: Expected returning, columns names & types');
+
+-- Edmonds-Karp
+SELECT set_eq('ek_v_o2o', 'ek_q_o2o','1 to 1: Expected returning, columns names & types');
+SELECT set_eq('ek_v_o2m', 'ek_q_o2m','1 to many: Expected returning, columns names & types');
+SELECT set_eq('ek_v_m2o', 'ek_q_m2o','many to 1: Expected returning, columns names & types');
+SELECT set_eq('ek_v_m2m', 'ek_q_m2m','many to many: Expected returning, columns names & types');
+
+-- Boykov-Kolmogorov
+SELECT set_eq('bk_v_o2o', 'bk_q_o2o','1 to 1: Expected returning, columns names & types');
+SELECT set_eq('bk_v_o2m', 'bk_q_o2m','1 to many: Expected returning, columns names & types');
+SELECT set_eq('bk_v_m2o', 'bk_q_m2o','many to 1: Expected returning, columns names & types');
+SELECT set_eq('bk_v_m2m', 'bk_q_m2m','many to many: Expected returning, columns names & types');
+
+
+-- Testing inner query
+
+-- Push-relabel
+-- id is ANY-INTEGER
+PREPARE pl_id1 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::SMALLINT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_id2 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::BIGINT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_id3 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::REAL,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_id4 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::FLOAT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_id5 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::TEXT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('pl_id1',
+    'lives because id is SMALLINT');
+SELECT lives_ok('pl_id2',
+    'lives because id is BIGINT');
+SELECT throws_ok('pl_id3',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is REAL');
+SELECT throws_ok('pl_id4',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is FLOAT');
+SELECT throws_ok('pl_id5',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is TEXT');
+
+-- source is ANY-INTEGER
+PREPARE pl_s1 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::SMALLINT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_s2 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::BIGINT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_s3 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::REAL,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_s4 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::FLOAT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_s5 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::TEXT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('pl_s1',
+    'lives because source is SMALLINT');
+SELECT lives_ok('pl_s2',
+    'lives because source is BIGINT');
+SELECT throws_ok('pl_s3',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is REAL');
+SELECT throws_ok('pl_s4',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is FLOAT');
+SELECT throws_ok('pl_s5',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is TEXT');
+        
+-- target is ANY-INTEGER
+PREPARE pl_t1 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::SMALLINT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_t2 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::BIGINT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_t3 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::REAL,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_t4 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::FLOAT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_t5 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::TEXT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('pl_t1',
+    'lives because target is SMALLINT');
+SELECT lives_ok('pl_t2',
+    'lives because target is BIGINT');
+SELECT throws_ok('pl_t3',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is REAL');
+SELECT throws_ok('pl_t4',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is FLOAT');
+SELECT throws_ok('pl_t5',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is TEXT');
+
+-- capacity is ANY-INTEGER
+PREPARE pl_c1 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::SMALLINT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_c2 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::BIGINT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_c3 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::REAL as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_c4 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::FLOAT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_c5 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::TEXT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('pl_c1',
+    'lives because capacity is SMALLINT');
+SELECT lives_ok('pl_c2',
+    'lives because capacity is BIGINT');
+SELECT throws_ok('pl_c3',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is REAL');
+SELECT throws_ok('pl_c4',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is FLOAT');
+SELECT throws_ok('pl_c5',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is TEXT');
+
+-- reverse_capacity is ANY-INTEGER
+PREPARE pl_rc1 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::SMALLINT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_rc2 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::BIGINT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_rc3 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::REAL as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_rc4 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::FLOAT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE pl_rc5 AS
+SELECT * FROM pgr_maxflowpushrelabel(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::TEXT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('pl_rc1',
+    'lives because reverse_capacity is SMALLINT');
+SELECT lives_ok('pl_rc2',
+    'lives because reverse_capacity is BIGINT');
+SELECT throws_ok('pl_rc3',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is REAL');
+SELECT throws_ok('pl_rc4',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is FLOAT');
+SELECT throws_ok('pl_rc5',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is TEXT');
+
+
+-- Edmonds-Karp
+-- id is ANY-INTEGER
+PREPARE ek_id1 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::SMALLINT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_id2 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::BIGINT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_id3 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::REAL,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_id4 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::FLOAT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_id5 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::TEXT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('ek_id1',
+    'lives because id is SMALLINT');
+SELECT lives_ok('ek_id2',
+    'lives because id is BIGINT');
+SELECT throws_ok('ek_id3',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is REAL');
+SELECT throws_ok('ek_id4',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is FLOAT');
+SELECT throws_ok('ek_id5',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is TEXT');
+
+-- source is ANY-INTEGER
+PREPARE ek_s1 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::SMALLINT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_s2 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::BIGINT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_s3 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::REAL,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_s4 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::FLOAT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_s5 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::TEXT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('ek_s1',
+    'lives because source is SMALLINT');
+SELECT lives_ok('ek_s2',
+    'lives because source is BIGINT');
+SELECT throws_ok('ek_s3',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is REAL');
+SELECT throws_ok('ek_s4',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is FLOAT');
+SELECT throws_ok('ek_s5',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is TEXT');
+        
+-- target is ANY-INTEGER
+PREPARE ek_t1 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::SMALLINT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_t2 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::BIGINT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_t3 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::REAL,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_t4 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::FLOAT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_t5 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::TEXT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('ek_t1',
+    'lives because target is SMALLINT');
+SELECT lives_ok('ek_t2',
+    'lives because target is BIGINT');
+SELECT throws_ok('ek_t3',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is REAL');
+SELECT throws_ok('ek_t4',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is FLOAT');
+SELECT throws_ok('ek_t5',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is TEXT');
+
+-- capacity is ANY-INTEGER
+PREPARE ek_c1 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::SMALLINT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_c2 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::BIGINT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_c3 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::REAL as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_c4 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::FLOAT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_c5 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::TEXT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('ek_c1',
+    'lives because capacity is SMALLINT');
+SELECT lives_ok('ek_c2',
+    'lives because capacity is BIGINT');
+SELECT throws_ok('ek_c3',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is REAL');
+SELECT throws_ok('ek_c4',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is FLOAT');
+SELECT throws_ok('ek_c5',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is TEXT');
+
+-- reverse_capacity is ANY-INTEGER
+PREPARE ek_rc1 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::SMALLINT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_rc2 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::BIGINT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_rc3 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::REAL as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_rc4 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::FLOAT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE ek_rc5 AS
+SELECT * FROM pgr_maxflowedmondskarp(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::TEXT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('ek_rc1',
+    'lives because reverse_capacity is SMALLINT');
+SELECT lives_ok('ek_rc2',
+    'lives because reverse_capacity is BIGINT');
+SELECT throws_ok('ek_rc3',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is REAL');
+SELECT throws_ok('ek_rc4',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is FLOAT');
+SELECT throws_ok('ek_rc5',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is TEXT');
+
+-- Edmonds-Karp
+-- id is ANY-INTEGER
+PREPARE bk_id1 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::SMALLINT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_id2 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::BIGINT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_id3 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::REAL,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_id4 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::FLOAT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_id5 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::TEXT,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('bk_id1',
+    'lives because id is SMALLINT');
+SELECT lives_ok('bk_id2',
+    'lives because id is BIGINT');
+SELECT throws_ok('bk_id3',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is REAL');
+SELECT throws_ok('bk_id4',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is FLOAT');
+SELECT throws_ok('bk_id5',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is TEXT');
+
+-- source is ANY-INTEGER
+PREPARE bk_s1 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::SMALLINT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_s2 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::BIGINT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_s3 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::REAL,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_s4 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::FLOAT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_s5 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::TEXT,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('bk_s1',
+    'lives because source is SMALLINT');
+SELECT lives_ok('bk_s2',
+    'lives because source is BIGINT');
+SELECT throws_ok('bk_s3',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is REAL');
+SELECT throws_ok('bk_s4',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is FLOAT');
+SELECT throws_ok('bk_s5',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is TEXT');
+        
+-- target is ANY-INTEGER
+PREPARE bk_t1 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::SMALLINT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_t2 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::BIGINT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_t3 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::REAL,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_t4 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::FLOAT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_t5 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::TEXT,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('bk_t1',
+    'lives because target is SMALLINT');
+SELECT lives_ok('bk_t2',
+    'lives because target is BIGINT');
+SELECT throws_ok('bk_t3',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is REAL');
+SELECT throws_ok('bk_t4',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is FLOAT');
+SELECT throws_ok('bk_t5',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is TEXT');
+
+-- capacity is ANY-INTEGER
+PREPARE bk_c1 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::SMALLINT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_c2 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::BIGINT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_c3 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::REAL as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_c4 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::FLOAT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_c5 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::TEXT as capacity,
+            c2.capacity::INTEGER as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('bk_c1',
+    'lives because capacity is SMALLINT');
+SELECT lives_ok('bk_c2',
+    'lives because capacity is BIGINT');
+SELECT throws_ok('bk_c3',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is REAL');
+SELECT throws_ok('bk_c4',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is FLOAT');
+SELECT throws_ok('bk_c5',
+    'XX000','Unexpected Column ''capacity'' type. Expected ANY-INTEGER',
+    'throws because capacity is TEXT');
+
+-- reverse_capacity is ANY-INTEGER
+PREPARE bk_rc1 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::SMALLINT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_rc2 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::BIGINT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_rc3 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::REAL as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_rc4 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::FLOAT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+PREPARE bk_rc5 AS
+SELECT * FROM pgr_maxflowboykovkolmogorov(
+    'SELECT id::INTEGER,
+            source::INTEGER,
+            target::INTEGER,
+            c1.capacity::INTEGER as capacity,
+            c2.capacity::TEXT as reverse_capacity
+    FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
+    WHERE edge_table.reverse_category_id = c2.category_id',
+    2, 3);
+
+SELECT lives_ok('bk_rc1',
+    'lives because reverse_capacity is SMALLINT');
+SELECT lives_ok('bk_rc2',
+    'lives because reverse_capacity is BIGINT');
+SELECT throws_ok('bk_rc3',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is REAL');
+SELECT throws_ok('bk_rc4',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is FLOAT');
+SELECT throws_ok('bk_rc5',
+    'XX000','Unexpected Column ''reverse_capacity'' type. Expected ANY-INTEGER',
+    'throws because reverse_capacity is TEXT');
+
+SELECT * FROM finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/src/max_flow/test/pgtap/flowapplications-types-check.sql b/src/max_flow/test/pgtap/flowapplications-types-check.sql
new file mode 100644
index 0000000..220023e
--- /dev/null
+++ b/src/max_flow/test/pgtap/flowapplications-types-check.sql
@@ -0,0 +1,740 @@
+\i setup.sql
+SET client_min_messages TO WARNING;
+
+SELECT plan(71);
+
+SELECT has_function('pgr_edgedisjointpaths');
+
+SELECT has_function('pgr_edgedisjointpaths', ARRAY[
+    'text', 'bigint', 'bigint', 'boolean'
+    ]);
+SELECT has_function('pgr_edgedisjointpaths', ARRAY[
+    'text', 'bigint', 'anyarray', 'boolean'
+    ]);
+SELECT has_function('pgr_edgedisjointpaths', ARRAY[
+    'text', 'anyarray', 'bigint', 'boolean'
+    ]);
+SELECT has_function('pgr_edgedisjointpaths', ARRAY[
+    'text', 'anyarray', 'anyarray', 'boolean'
+    ]);
+
+SELECT has_function('pgr_maximumcardinalitymatching');
+
+SELECT has_function('pgr_maximumcardinalitymatching', ARRAY[
+    'text', 'boolean'
+    ]);
+
+SELECT function_returns('pgr_edgedisjointpaths', ARRAY[
+    'text', 'bigint', 'bigint', 'boolean'
+    ], 'setof record');
+SELECT function_returns('pgr_edgedisjointpaths', ARRAY[
+    'text', 'bigint', 'anyarray', 'boolean'
+    ], 'setof record');
+SELECT function_returns('pgr_edgedisjointpaths', ARRAY[
+    'text', 'anyarray', 'bigint', 'boolean'
+    ], 'setof record');
+SELECT function_returns('pgr_edgedisjointpaths', ARRAY[
+    'text', 'anyarray', 'anyarray', 'boolean'
+    ], 'setof record');
+
+SELECT function_returns('pgr_maximumcardinalitymatching', ARRAY[
+    'text', 'boolean'
+    ], 'setof record');
+
+-- Maximum cardinality matching
+PREPARE mcm_dir AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table'
+);
+PREPARE mcm_undir AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    directed := false
+);
+
+SELECT lives_ok('mcm_dir','directed');
+SELECT lives_ok('mcm_undir','undirected');
+
+PREPARE mcm_q AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(edge_id)::text AS t2,
+    pg_typeof(source)::text AS t3, pg_typeof(target)::text AS t4
+    FROM (
+        SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table'
+        ) ) AS a
+    limit 1
+;
+
+PREPARE mcm_v AS
+SELECT  'integer'::text AS t1,'bigint'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4;
+
+SELECT set_eq('mcm_q', 'mcm_v','Expected returning, columns names & types');
+
+PREPARE mcm_id1 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::SMALLINT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_id2 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::BIGINT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_id3 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::REAL,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_id4 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::FLOAT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_id5 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::TEXT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+
+SELECT lives_ok('mcm_id1',
+    'lives because id is SMALLINT');
+SELECT lives_ok('mcm_id2',
+    'lives because id is BIGINT');
+SELECT throws_ok('mcm_id3',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is REAL');
+SELECT throws_ok('mcm_id4',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is FLOAT');
+SELECT throws_ok('mcm_id5',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is TEXT');
+
+-- source is ANY-INTEGER
+PREPARE mcm_s1 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::SMALLINT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_s2 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::BIGINT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_s3 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::REAL, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_s4 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::FLOAT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_s5 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::TEXT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+
+SELECT lives_ok('mcm_s1',
+    'lives because source is SMALLINT');
+SELECT lives_ok('mcm_s2',
+    'lives because source is BIGINT');
+SELECT throws_ok('mcm_s3',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is REAL');
+SELECT throws_ok('mcm_s4',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is FLOAT');
+SELECT throws_ok('mcm_s5',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is TEXT');
+        
+-- target is ANY-INTEGER
+PREPARE mcm_t1 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::SMALLINT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_t2 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::BIGINT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_t3 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::REAL,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_t4 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::FLOAT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_t5 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::TEXT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+
+SELECT lives_ok('mcm_t1',
+    'lives because target is SMALLINT');
+SELECT lives_ok('mcm_t2',
+    'lives because target is BIGINT');
+SELECT throws_ok('mcm_t3',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is REAL');
+SELECT throws_ok('mcm_t4',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is FLOAT');
+SELECT throws_ok('mcm_t5',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is TEXT');
+
+-- GOING is ANY-NUMERIC
+PREPARE mcm_g1 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::SMALLINT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_g2 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::BIGINT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_g3 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::REAL AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_g4 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::FLOAT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+PREPARE mcm_g5 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::TEXT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table'
+);
+
+SELECT lives_ok('mcm_g1',
+    'lives because going is SMALLINT');
+SELECT lives_ok('mcm_g2',
+    'lives because going is BIGINT');
+SELECT lives_ok('mcm_g3',
+    'lives because going is REAL');
+SELECT lives_ok('mcm_g4',
+    'lives because going is FLOAT');
+SELECT throws_ok('mcm_g5',
+    'XX000','Unexpected Column ''going'' type. Expected ANY-NUMERICAL',
+    'throws because going is TEXT');
+        
+
+-- coming is ANY-NUMERIC
+PREPARE mcm_c1 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::SMALLINT AS coming FROM edge_table'
+);
+PREPARE mcm_c2 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::BIGINT AS coming FROM edge_table'
+);
+PREPARE mcm_c3 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::REAL AS coming FROM edge_table'
+);
+PREPARE mcm_c4 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::FLOAT AS coming FROM edge_table'
+);
+PREPARE mcm_c5 AS
+SELECT * FROM pgr_maximumCardinalityMatching(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::TEXT AS coming FROM edge_table'
+);
+
+SELECT lives_ok('mcm_c1',
+    'lives because coming is SMALLINT');
+SELECT lives_ok('mcm_c2',
+    'lives because coming is BIGINT');
+SELECT lives_ok('mcm_c3',
+    'lives because coming is REAL');
+SELECT lives_ok('mcm_c4',
+    'lives because coming is FLOAT');
+SELECT throws_ok('mcm_c5',
+    'XX000','Unexpected Column ''coming'' type. Expected ANY-NUMERICAL',
+    'throws because coming is TEXT');
+
+
+-- Edge disjoint paths
+PREPARE edp_dir AS
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, 5
+);
+PREPARE edp_undir AS
+SELECT * FROM pgr_edgeDisjointPaths(
+    'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+    3, 5,
+    directed := false
+);
+
+SELECT lives_ok('edp_dir','directed');
+SELECT lives_ok('edp_undir','undirected');
+
+-- Boykov-Kolmogorov
+PREPARE edp_q_o2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2,
+    pg_typeof(node)::text AS t3, pg_typeof(edge)::text AS t4
+    FROM (
+        SELECT * FROM pgr_edgeDisjointPaths(
+            'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+        3, 5
+        ) ) AS a
+    limit 1
+;
+PREPARE edp_v_o2o AS
+SELECT  'integer'::text AS t1,'integer'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4;
+
+PREPARE edp_q_o2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2,
+    pg_typeof(end_vid)::text as t3,
+    pg_typeof(node)::text AS t4, pg_typeof(edge)::text AS t5
+    FROM (
+        SELECT * FROM pgr_edgeDisjointPaths(
+            'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+        3, ARRAY[5]
+        ) ) AS a
+    limit 1
+;
+PREPARE edp_v_o2m AS
+SELECT  'integer'::text AS t1,'integer'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5;
+
+
+PREPARE edp_q_m2o AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2,
+    pg_typeof(start_vid)::text as t3,
+    pg_typeof(node)::text AS t4, pg_typeof(edge)::text AS t5
+    FROM (
+        SELECT * FROM pgr_edgeDisjointPaths(
+            'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+        ARRAY[3], 5
+        ) ) AS a
+    limit 1
+;
+PREPARE edp_v_m2o AS
+SELECT  'integer'::text AS t1,'integer'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5;
+
+PREPARE edp_q_m2m AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2,
+    pg_typeof(start_vid)::text as t3, pg_typeof(end_vid)::text as t4,
+    pg_typeof(node)::text AS t5, pg_typeof(edge)::text AS t6
+    FROM (
+        SELECT * FROM pgr_edgeDisjointPaths(
+            'SELECT id, source, target, cost AS going, reverse_cost AS coming FROM edge_table',
+        ARRAY[3], ARRAY[5]
+        ) ) AS a
+    limit 1
+;
+PREPARE edp_v_m2m AS
+SELECT  'integer'::text AS t1,'integer'::text AS t2,
+    'bigint'::text AS t3, 'bigint'::text AS t4,
+    'bigint'::text AS t5, 'bigint'::text AS t6;
+
+SELECT set_eq('edp_v_o2o', 'edp_q_o2o','1 to 1: Expected returning, columns names & types');
+SELECT set_eq('edp_v_o2m', 'edp_q_o2m','1 to many: Expected returning, columns names & types');
+SELECT set_eq('edp_v_m2o', 'edp_q_m2o','many to 1: Expected returning, columns names & types');
+SELECT set_eq('edp_v_m2m', 'edp_q_m2m','many to many: Expected returning, columns names & types');
+
+PREPARE edp_id1 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::SMALLINT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_id2 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::BIGINT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_id3 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::REAL,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_id4 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::FLOAT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_id5 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::TEXT,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+
+SELECT lives_ok('edp_id1',
+    'lives because id is SMALLINT');
+SELECT lives_ok('edp_id2',
+    'lives because id is BIGINT');
+SELECT throws_ok('edp_id3',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is REAL');
+SELECT throws_ok('edp_id4',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is FLOAT');
+SELECT throws_ok('edp_id5',
+    'XX000','Unexpected Column ''id'' type. Expected ANY-INTEGER',
+    'throws because id is TEXT');
+
+-- source is ANY-INTEGER
+PREPARE edp_s1 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::SMALLINT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_s2 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::BIGINT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_s3 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::REAL, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_s4 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::FLOAT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_s5 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::TEXT, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+
+SELECT lives_ok('edp_s1',
+    'lives because source is SMALLINT');
+SELECT lives_ok('edp_s2',
+    'lives because source is BIGINT');
+SELECT throws_ok('edp_s3',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is REAL');
+SELECT throws_ok('edp_s4',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is FLOAT');
+SELECT throws_ok('edp_s5',
+    'XX000','Unexpected Column ''source'' type. Expected ANY-INTEGER',
+    'throws because source is TEXT');
+        
+-- target is ANY-INTEGER
+PREPARE edp_t1 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::SMALLINT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_t2 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::BIGINT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_t3 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::REAL,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_t4 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::FLOAT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_t5 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::TEXT,
+                cost::INTEGER AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+
+SELECT lives_ok('edp_t1',
+    'lives because target is SMALLINT');
+SELECT lives_ok('edp_t2',
+    'lives because target is BIGINT');
+SELECT throws_ok('edp_t3',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is REAL');
+SELECT throws_ok('edp_t4',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is FLOAT');
+SELECT throws_ok('edp_t5',
+    'XX000','Unexpected Column ''target'' type. Expected ANY-INTEGER',
+    'throws because target is TEXT');
+
+-- GOING is ANY-NUMERIC
+PREPARE edp_g1 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::SMALLINT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_g2 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::BIGINT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_g3 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::REAL AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_g4 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::FLOAT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_g5 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::TEXT AS going,
+                reverse_cost::INTEGER AS coming FROM edge_table',
+                3, 5
+);
+
+SELECT lives_ok('edp_g1',
+    'lives because going is SMALLINT');
+SELECT lives_ok('edp_g2',
+    'lives because going is BIGINT');
+SELECT lives_ok('edp_g3',
+    'lives because going is REAL');
+SELECT lives_ok('edp_g4',
+    'lives because going is FLOAT');
+SELECT throws_ok('edp_g5',
+    'XX000','Unexpected Column ''going'' type. Expected ANY-NUMERICAL',
+    'throws because going is TEXT');
+        
+
+-- coming is ANY-NUMERIC
+PREPARE edp_c1 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::SMALLINT AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_c2 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::BIGINT AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_c3 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::REAL AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_c4 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::FLOAT AS coming FROM edge_table',
+                3, 5
+);
+PREPARE edp_c5 AS
+SELECT * FROM pgr_edgeDisjointPaths(
+        'SELECT id::INTEGER,
+                source::INTEGER, 
+                target::INTEGER,
+                cost::INTEGER AS going,
+                reverse_cost::TEXT AS coming FROM edge_table',
+                3, 5
+);
+
+SELECT lives_ok('edp_c1',
+    'lives because coming is SMALLINT');
+SELECT lives_ok('edp_c2',
+    'lives because coming is BIGINT');
+SELECT lives_ok('edp_c3',
+    'lives because coming is REAL');
+SELECT lives_ok('edp_c4',
+    'lives because coming is FLOAT');
+SELECT throws_ok('edp_c5',
+    'XX000','Unexpected Column ''coming'' type. Expected ANY-NUMERICAL',
+    'throws because coming is TEXT');
+
+
+
+SELECT * FROM finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/src/max_flow/test/sample_data_categories.sql b/src/max_flow/test/sample_data_categories.sql
new file mode 100644
index 0000000..f5dc20f
--- /dev/null
+++ b/src/max_flow/test/sample_data_categories.sql
@@ -0,0 +1,33 @@
+CREATE TEMPORARY TABLE category (
+    category_id SERIAL,
+	category text,
+	capacity BIGINT
+);
+
+INSERT INTO category VALUES
+('Motorway', 130),
+('Primary', 100),
+('Regional', 80),
+('Local', 50);
+
+ALTER TABLE edge_table ADD COLUMN category TEXT;
+ALTER TABLE edge_table ADD COLUMN reverse_category TEXT;
+
+UPDATE edge_table SET category = 'Regional', reverse_category = 'Motorway' WHERE id = 1;
+UPDATE edge_table SET category = 'Regional', reverse_category = 'Primary' WHERE id = 2;
+UPDATE edge_table SET category = 'Primary', reverse_category = 'Motorway' WHERE id = 3;
+UPDATE edge_table SET category = 'Primary', reverse_category = 'Local' WHERE id = 4;
+UPDATE edge_table SET category = 'Motorway', reverse_category = 'Local' WHERE id = 5;
+UPDATE edge_table SET category = 'Local', reverse_category = 'Primary' WHERE id = 6;
+UPDATE edge_table SET category = 'Local', reverse_category = 'Motorway' WHERE id = 7;
+UPDATE edge_table SET category = 'Primary', reverse_category = 'Motorway' WHERE id = 8;
+UPDATE edge_table SET category = 'Motorway', reverse_category = 'Regional' WHERE id = 9;
+UPDATE edge_table SET category = 'Motorway', reverse_category = 'Local' WHERE id = 10;
+UPDATE edge_table SET category = 'Motorway', reverse_category = 'Primary' WHERE id = 11;
+UPDATE edge_table SET category = 'Primary', reverse_category = 'Regional' WHERE id = 12;
+UPDATE edge_table SET category = 'Primary', reverse_category = 'Local' WHERE id = 13;
+UPDATE edge_table SET category = 'Regional', reverse_category = 'Motorway' WHERE id = 14;
+UPDATE edge_table SET category = 'Regional', reverse_category = 'Local' WHERE id = 15;
+UPDATE edge_table SET category = 'Regional', reverse_category = 'Regional' WHERE id = 16;
+UPDATE edge_table SET category = 'Motorway', reverse_category = 'Primary' WHERE id = 17;
+UPDATE edge_table SET category = 'Local', reverse_category = 'Motorway' WHERE id = 18;
diff --git a/src/max_flow/test/test.conf b/src/max_flow/test/test.conf
new file mode 100644
index 0000000..d22d99f
--- /dev/null
+++ b/src/max_flow/test/test.conf
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+%main::tests = (
+    'any' => {
+        'comment' => 'Max flow and applications test for any versions.',
+        'data' => [ ],
+        'tests' => [qw(
+            doc-pgr_maxFlowBoykovKolmogorov
+            doc-pgr_maxFlowPushRelabel
+            doc-pgr_maxFlowEdmondsKarp
+            doc-pgr_maximumCardinalityMatching
+            doc-pgr_edgeDisjointPaths
+            )],
+        'documentation' => [qw(
+            doc-pgr_maxFlowBoykovKolmogorov
+            doc-pgr_maxFlowPushRelabel
+            doc-pgr_maxFlowEdmondsKarp
+            doc-pgr_maximumCardinalityMatching
+            doc-pgr_edgeDisjointPaths
+            )]
+    },
+);
+
+1;
diff --git a/src/pickDeliver/CMakeLists.txt b/src/pickDeliver/CMakeLists.txt
deleted file mode 100644
index 302fdcd..0000000
--- a/src/pickDeliver/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-SUBDIRS(doc src test)
-
diff --git a/src/pickDeliver/doc/doc-pickDeliver.queries b/src/pickDeliver/doc/doc-pickDeliver.queries
new file mode 100644
index 0000000..3bf9baa
--- /dev/null
+++ b/src/pickDeliver/doc/doc-pickDeliver.queries
@@ -0,0 +1,245 @@
+--q1
+SELECT * FROM _pgr_pickDeliver(
+    'select * from customer order by id', 25, 200, 1, 30);
+ seq | vehicle_id | vehicle_seq | stop_id |   travel_time    |   arrival_time   | wait_time | service_time |  departure_time  
+-----+------------+-------------+---------+------------------+------------------+-----------+--------------+------------------
+   1 |          1 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+   2 |          1 |           2 |       5 | 15.1327459504216 | 15.1327459504216 |         0 |           90 | 105.132745950422
+   3 |          1 |           3 |       3 |                1 | 106.132745950422 |         0 |           90 | 196.132745950422
+   4 |          1 |           4 |       7 |                2 | 198.132745950422 |         0 |           90 | 288.132745950422
+   5 |          1 |           5 |       8 | 2.82842712474619 | 290.961173075168 |         0 |           90 | 380.961173075168
+   6 |          1 |           6 |      10 | 3.60555127546399 | 384.566724350632 |         0 |           90 | 474.566724350632
+   7 |          1 |           7 |      11 |                3 | 477.566724350632 |         0 |           90 | 567.566724350632
+   8 |          1 |           8 |       9 | 3.16227766016838 |   570.7290020108 |         0 |           90 |   660.7290020108
+   9 |          1 |           9 |       6 | 2.23606797749979 |   662.9650699883 |         0 |           90 |   752.9650699883
+  10 |          1 |          10 |       4 | 2.23606797749979 |   755.2011379658 |         0 |           90 |   845.2011379658
+  11 |          1 |          11 |       2 | 3.60555127546399 | 848.806689241264 |         0 |           90 | 938.806689241264
+  12 |          1 |          12 |       1 |                2 | 940.806689241264 |         0 |           90 | 1030.80668924126
+  13 |          1 |          13 |      75 |                3 | 1033.80668924126 |         0 |           90 | 1123.80668924126
+  14 |          1 |          14 |       0 | 15.8113883008419 | 1139.61807754211 |         0 |            0 | 1139.61807754211
+  15 |          2 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+  16 |          2 |           2 |      13 | 30.8058436014987 | 30.8058436014987 |         0 |           90 | 120.805843601499
+  17 |          2 |           3 |      17 |                4 | 124.805843601499 |         0 |           90 | 214.805843601499
+  18 |          2 |           4 |      18 |                3 | 217.805843601499 |         0 |           90 | 307.805843601499
+  19 |          2 |           5 |      19 |                5 | 312.805843601499 |         0 |           90 | 402.805843601499
+  20 |          2 |           6 |      15 |                5 | 407.805843601499 |         0 |           90 | 497.805843601499
+  21 |          2 |           7 |      16 |                5 | 502.805843601499 |         0 |           90 | 592.805843601499
+  22 |          2 |           8 |      14 |                2 | 594.805843601499 |         0 |           90 | 684.805843601499
+  23 |          2 |           9 |      12 |                3 | 687.805843601499 |         0 |           90 | 777.805843601499
+  24 |          2 |          10 |       0 | 38.0788655293195 | 815.884709130818 |         0 |            0 | 815.884709130818
+  25 |          3 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+  26 |          3 |           2 |      20 |               10 |               10 |         0 |           90 |              100
+  27 |          3 |           3 |      24 |                5 |              105 |         0 |           90 |              195
+  28 |          3 |           4 |      25 |                2 |              197 |         0 |           90 |              287
+  29 |          3 |           5 |      27 |                2 |              289 |         0 |           90 |              379
+  30 |          3 |           6 |      29 | 3.60555127546399 | 382.605551275464 |         0 |           90 | 472.605551275464
+  31 |          3 |           7 |      30 |                5 | 477.605551275464 |         0 |           90 | 567.605551275464
+  32 |          3 |           8 |      28 |                3 | 570.605551275464 |         0 |           90 | 660.605551275464
+  33 |          3 |           9 |      26 |                2 | 662.605551275464 |         0 |           90 | 752.605551275464
+  34 |          3 |          10 |      23 |                3 | 755.605551275464 |         0 |            0 | 755.605551275464
+  35 |          3 |          11 |     103 |                0 | 755.605551275464 |         0 |           90 | 845.605551275464
+  36 |          3 |          12 |      22 |                3 | 848.605551275464 |         0 |           90 | 938.605551275464
+  37 |          3 |          13 |      21 |                2 | 940.605551275464 |         0 |           90 | 1030.60555127546
+  38 |          3 |          14 |       0 | 10.1980390271856 | 1040.80359030265 |         0 |            0 | 1040.80359030265
+  39 |          4 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+  40 |          4 |           2 |      32 | 31.6227766016838 | 31.6227766016838 |         0 |           90 | 121.622776601684
+  41 |          4 |           3 |      33 |                2 | 123.622776601684 |         0 |           90 | 213.622776601684
+  42 |          4 |           4 |      31 |  5.3851648071345 | 219.007941408818 |         0 |           90 | 309.007941408818
+  43 |          4 |           5 |      35 |                5 | 314.007941408818 |         0 |           90 | 404.007941408818
+  44 |          4 |           6 |      37 |  5.8309518948453 | 409.838893303664 |         0 |           90 | 499.838893303664
+  45 |          4 |           7 |      38 |                2 | 501.838893303664 |         0 |           90 | 591.838893303664
+  46 |          4 |           8 |      39 |                5 | 596.838893303664 |         0 |           90 | 686.838893303664
+  47 |          4 |           9 |      36 |                5 | 691.838893303664 |         0 |            0 | 691.838893303664
+  48 |          4 |          10 |     105 |                0 | 691.838893303664 |         0 |           90 | 781.838893303664
+  49 |          4 |          11 |      34 |                3 | 784.838893303664 |         0 |           90 | 874.838893303664
+  50 |          4 |          12 |       0 | 32.3882694814033 | 907.227162785067 |         0 |            0 | 907.227162785067
+  51 |          5 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+  52 |          5 |           2 |      43 | 16.5529453572468 | 16.5529453572468 |         0 |           90 | 106.552945357247
+  53 |          5 |           3 |      42 |                3 | 109.552945357247 |         0 |           90 | 199.552945357247
+  54 |          5 |           4 |      41 |                2 | 201.552945357247 |         0 |           90 | 291.552945357247
+  55 |          5 |           5 |      40 |                2 | 293.552945357247 |         0 |           90 | 383.552945357247
+  56 |          5 |           6 |      44 |                3 | 386.552945357247 |         0 |           90 | 476.552945357247
+  57 |          5 |           7 |      46 | 2.82842712474619 | 479.381372481993 |         0 |           90 | 569.381372481993
+  58 |          5 |           8 |      45 |                2 | 571.381372481993 |         0 |           90 | 661.381372481993
+  59 |          5 |           9 |      48 |                2 | 663.381372481993 |         0 |           90 | 753.381372481993
+  60 |          5 |          10 |      51 |                3 | 756.381372481993 |         0 |            0 | 756.381372481993
+  61 |          5 |          11 |     101 |                0 | 756.381372481993 |         0 |           90 | 846.381372481993
+  62 |          5 |          12 |      50 | 2.23606797749979 | 848.617440459493 |         0 |           90 | 938.617440459493
+  63 |          5 |          13 |      52 | 3.16227766016838 | 941.779718119661 |         0 |           90 | 1031.77971811966
+  64 |          5 |          14 |      49 |                3 | 1034.77971811966 |         0 |           90 | 1124.77971811966
+  65 |          5 |          15 |      47 |                2 | 1126.77971811966 |         0 |           90 | 1216.77971811966
+  66 |          5 |          16 |       0 | 18.0277563773199 | 1234.80747449698 |         0 |            0 | 1234.80747449698
+  67 |          6 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+  68 |          6 |           2 |      57 |               35 |               35 |         0 |           90 |              125
+  69 |          6 |           3 |      55 |                2 |              127 |         0 |           90 |              217
+  70 |          6 |           4 |      54 |                5 |              222 |         0 |           90 |              312
+  71 |          6 |           5 |      53 |  5.3851648071345 | 317.385164807135 |         0 |           90 | 407.385164807135
+  72 |          6 |           6 |      56 |                4 | 411.385164807135 |         0 |           90 | 501.385164807135
+  73 |          6 |           7 |      58 |                2 | 503.385164807135 |         0 |           90 | 593.385164807135
+  74 |          6 |           8 |      60 |                3 | 596.385164807135 |         0 |           90 | 686.385164807135
+  75 |          6 |           9 |      59 | 10.4403065089106 | 696.825471316045 |         0 |           90 | 786.825471316045
+  76 |          6 |          10 |       0 | 35.0570962859162 | 821.882567601961 |         0 |            0 | 821.882567601961
+  77 |          7 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+  78 |          7 |           2 |      67 | 12.2065556157337 | 12.2065556157337 |         0 |           90 | 102.206555615734
+  79 |          7 |           3 |      65 |                1 | 103.206555615734 |         0 |           90 | 193.206555615734
+  80 |          7 |           4 |      63 |                2 | 195.206555615734 |         0 |           90 | 285.206555615734
+  81 |          7 |           5 |      62 |                5 | 290.206555615734 |         0 |           90 | 380.206555615734
+  82 |          7 |           6 |      74 |                3 | 383.206555615734 |         0 |           90 | 473.206555615734
+  83 |          7 |           7 |      72 |                5 | 478.206555615734 |         0 |           90 | 568.206555615734
+  84 |          7 |           8 |      61 |                3 | 571.206555615734 |         0 |           90 | 661.206555615734
+  85 |          7 |           9 |      64 |                2 | 663.206555615734 |         0 |            0 | 663.206555615734
+  86 |          7 |          10 |     102 |                0 | 663.206555615734 |         0 |           90 | 753.206555615734
+  87 |          7 |          11 |      68 |                3 | 756.206555615734 |         0 |           90 | 846.206555615734
+  88 |          7 |          12 |      66 |  5.3851648071345 | 851.591720422868 |         0 |           90 | 941.591720422868
+  89 |          7 |          13 |      69 |                2 | 943.591720422868 |         0 |           90 | 1033.59172042287
+  90 |          7 |          14 |       0 | 15.8113883008419 | 1049.40310872371 |         0 |            0 | 1049.40310872371
+  91 |          8 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+  92 |          8 |           2 |      81 | 47.4341649025257 | 47.4341649025257 |         0 |           90 | 137.434164902526
+  93 |          8 |           3 |      78 |                3 | 140.434164902526 |         0 |            0 | 140.434164902526
+  94 |          8 |           4 |     104 |                0 | 140.434164902526 |         0 |           90 | 230.434164902526
+  95 |          8 |           5 |      76 |                2 | 232.434164902526 |         0 |           90 | 322.434164902526
+  96 |          8 |           6 |      71 |                5 | 327.434164902526 |         0 |           90 | 417.434164902526
+  97 |          8 |           7 |      70 |                5 | 422.434164902526 |         0 |           90 | 512.434164902526
+  98 |          8 |           8 |      73 |                3 | 515.434164902526 |         0 |           90 | 605.434164902526
+  99 |          8 |           9 |      77 |                4 | 609.434164902526 |         0 |           90 | 699.434164902526
+ 100 |          8 |          10 |      79 |                1 | 700.434164902526 |         0 |           90 | 790.434164902526
+ 101 |          8 |          11 |      80 |  5.3851648071345 |  795.81932970966 |         0 |           90 |  885.81932970966
+ 102 |          8 |          12 |       0 |  51.478150704935 | 937.297480414595 |         0 |            0 | 937.297480414595
+ 103 |          9 |           1 |       0 |                0 |                0 |         0 |            0 |                0
+ 104 |          9 |           2 |      90 | 20.6155281280883 | 20.6155281280883 |         0 |           90 | 110.615528128088
+ 105 |          9 |           3 |      87 |                5 | 115.615528128088 |         0 |           90 | 205.615528128088
+ 106 |          9 |           4 |      86 |                1 | 206.615528128088 |         0 |           90 | 296.615528128088
+ 107 |          9 |           5 |      83 |                6 | 302.615528128088 |         0 |           90 | 392.615528128088
+ 108 |          9 |           6 |      82 |                3 | 395.615528128088 |         0 |           90 | 485.615528128088
+ 109 |          9 |           7 |      84 |  5.8309518948453 | 491.446480022934 |         0 |           90 | 581.446480022934
+ 110 |          9 |           8 |      85 | 2.82842712474619 |  584.27490714768 |         0 |           90 |  674.27490714768
+ 111 |          9 |           9 |      88 |                3 |  677.27490714768 |         0 |           90 |  767.27490714768
+ 112 |          9 |          10 |      89 | 2.82842712474619 | 770.103334272426 |         0 |           90 | 860.103334272426
+ 113 |          9 |          11 |      91 | 3.60555127546399 |  863.70888554789 |         0 |           90 |  953.70888554789
+ 114 |          9 |          12 |       0 | 22.3606797749979 | 976.069565322888 |         0 |            0 | 976.069565322888
+ 115 |         -1 |           0 |       0 | 732.993736320776 |                0 |         0 |         8190 | 8922.99373632078
+(115 rows)
+
+--q2
+SELECT * FROM _pgr_pickDeliver(
+    'select * from customer order by id', 25, 200, 10, 30);
+ seq | vehicle_id | vehicle_seq | stop_id |    travel_time    |   arrival_time   |     wait_time     | service_time |  departure_time  
+-----+------------+-------------+---------+-------------------+------------------+-------------------+--------------+------------------
+   1 |          1 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+   2 |          1 |           2 |       5 |  1.51327459504216 | 1.51327459504216 |  13.4867254049578 |           90 |              105
+   3 |          1 |           3 |       3 |               0.1 |            105.1 |                 0 |           90 |            195.1
+   4 |          1 |           4 |       7 |               0.2 |            195.3 |                 0 |           90 |            285.3
+   5 |          1 |           5 |       8 | 0.282842712474619 | 285.582842712475 |                 0 |           90 | 375.582842712475
+   6 |          1 |           6 |      10 | 0.360555127546399 | 375.943397840021 |                 0 |           90 | 465.943397840021
+   7 |          1 |           7 |      11 |               0.3 | 466.243397840021 |                 0 |           90 | 556.243397840021
+   8 |          1 |           8 |       9 | 0.316227766016838 | 556.559625606038 |                 0 |           90 | 646.559625606038
+   9 |          1 |           9 |       6 | 0.223606797749979 | 646.783232403788 |                 0 |           90 | 736.783232403788
+  10 |          1 |          10 |       4 | 0.223606797749979 | 737.006839201538 |                 0 |           90 | 827.006839201538
+  11 |          1 |          11 |       2 | 0.360555127546399 | 827.367394329084 |                 0 |           90 | 917.367394329084
+  12 |          1 |          12 |       1 |               0.2 | 917.567394329084 |                 0 |           90 | 1007.56739432908
+  13 |          1 |          13 |      75 |               0.3 | 1007.86739432908 |                 0 |           90 | 1097.86739432908
+  14 |          1 |          14 |       0 |  1.58113883008419 | 1099.44853315917 |                 0 |            0 | 1099.44853315917
+  15 |          2 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+  16 |          2 |           2 |      13 |  3.08058436014987 | 3.08058436014987 |  26.9194156398501 |           90 |              120
+  17 |          2 |           3 |      17 |               0.4 |            120.4 |                 0 |           90 |            210.4
+  18 |          2 |           4 |      18 |               0.3 |            210.7 |                 0 |           90 |            300.7
+  19 |          2 |           5 |      19 |               0.5 |            301.2 |                 0 |           90 |            391.2
+  20 |          2 |           6 |      15 |               0.5 |            391.7 |                 0 |           90 |            481.7
+  21 |          2 |           7 |      16 |               0.5 |            482.2 |                 0 |           90 |            572.2
+  22 |          2 |           8 |      14 |               0.2 |            572.4 |                 0 |           90 |            662.4
+  23 |          2 |           9 |      12 |               0.3 |            662.7 |                 0 |           90 |            752.7
+  24 |          2 |          10 |       0 |  3.80788655293195 | 756.507886552932 |                 0 |            0 | 756.507886552932
+  25 |          3 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+  26 |          3 |           2 |      20 |                 1 |                1 |                 9 |           90 |              100
+  27 |          3 |           3 |      24 |               0.5 |            100.5 |                 0 |           90 |            190.5
+  28 |          3 |           4 |      25 |               0.2 |            190.7 |                 0 |           90 |            280.7
+  29 |          3 |           5 |      27 |               0.2 |            280.9 |                 0 |           90 |            370.9
+  30 |          3 |           6 |      29 | 0.360555127546399 | 371.260555127546 |                 0 |           90 | 461.260555127546
+  31 |          3 |           7 |      30 |               0.5 | 461.760555127546 |                 0 |           90 | 551.760555127546
+  32 |          3 |           8 |      28 |               0.3 | 552.060555127546 |                 0 |           90 | 642.060555127546
+  33 |          3 |           9 |      26 |               0.2 | 642.260555127546 |                 0 |           90 | 732.260555127546
+  34 |          3 |          10 |      23 |               0.3 | 732.560555127546 |                 0 |            0 | 732.560555127546
+  35 |          3 |          11 |     103 |                 0 | 732.560555127546 |                 0 |           90 | 822.560555127546
+  36 |          3 |          12 |      22 |               0.3 | 822.860555127546 |                 0 |           90 | 912.860555127546
+  37 |          3 |          13 |      21 |               0.2 | 913.060555127546 | 0.939444872453691 |           90 |             1004
+  38 |          3 |          14 |       0 |  1.01980390271856 | 1005.01980390272 |                 0 |            0 | 1005.01980390272
+  39 |          4 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+  40 |          4 |           2 |      32 |  3.16227766016838 | 3.16227766016838 |  27.8377223398316 |           90 |              121
+  41 |          4 |           3 |      33 |               0.2 |            121.2 |                 0 |           90 |            211.2
+  42 |          4 |           4 |      31 |  0.53851648071345 | 211.738516480713 |                 0 |           90 | 301.738516480713
+  43 |          4 |           5 |      35 |               0.5 | 302.238516480713 |                 0 |           90 | 392.238516480713
+  44 |          4 |           6 |      37 |  0.58309518948453 | 392.821611670198 |                 0 |           90 | 482.821611670198
+  45 |          4 |           7 |      38 |               0.2 | 483.021611670198 |                 0 |           90 | 573.021611670198
+  46 |          4 |           8 |      39 |               0.5 | 573.521611670198 |                 0 |           90 | 663.521611670198
+  47 |          4 |           9 |      36 |               0.5 | 664.021611670198 | 0.978388329802101 |            0 |              665
+  48 |          4 |          10 |     105 |                 0 |              665 |                 0 |           90 |              755
+  49 |          4 |          11 |      34 |               0.3 |            755.3 |                 0 |           90 |            845.3
+  50 |          4 |          12 |       0 |  3.23882694814033 |  848.53882694814 |                 0 |            0 |  848.53882694814
+  51 |          5 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+  52 |          5 |           2 |      43 |  1.65529453572468 | 1.65529453572468 |  14.3447054642753 |           90 |              106
+  53 |          5 |           3 |      42 |               0.3 |            106.3 |                 0 |           90 |            196.3
+  54 |          5 |           4 |      41 |               0.2 |            196.5 |                 0 |           90 |            286.5
+  55 |          5 |           5 |      40 |               0.2 |            286.7 |                 0 |           90 |            376.7
+  56 |          5 |           6 |      44 |               0.3 |              377 |                 0 |           90 |              467
+  57 |          5 |           7 |      46 | 0.282842712474619 | 467.282842712475 |                 0 |           90 | 557.282842712475
+  58 |          5 |           8 |      45 |               0.2 | 557.482842712475 |                 0 |           90 | 647.482842712475
+  59 |          5 |           9 |      48 |               0.2 | 647.682842712475 |                 0 |           90 | 737.682842712475
+  60 |          5 |          10 |      51 |               0.3 | 737.982842712475 |                 0 |            0 | 737.982842712475
+  61 |          5 |          11 |     101 |                 0 | 737.982842712475 |                 0 |           90 | 827.982842712475
+  62 |          5 |          12 |      50 | 0.223606797749979 | 828.206449510225 |                 0 |           90 | 918.206449510225
+  63 |          5 |          13 |      52 | 0.316227766016838 | 918.522677276241 |                 0 |           90 | 1008.52267727624
+  64 |          5 |          14 |      49 |               0.3 | 1008.82267727624 |                 0 |           90 | 1098.82267727624
+  65 |          5 |          15 |      47 |               0.2 | 1099.02267727624 |                 0 |           90 | 1189.02267727624
+  66 |          5 |          16 |       0 |  1.80277563773199 | 1190.82545291397 |                 0 |            0 | 1190.82545291397
+  67 |          6 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+  68 |          6 |           2 |      57 |               3.5 |              3.5 |              31.5 |           90 |              125
+  69 |          6 |           3 |      55 |               0.2 |            125.2 |                 0 |           90 |            215.2
+  70 |          6 |           4 |      54 |               0.5 |            215.7 |                 0 |           90 |            305.7
+  71 |          6 |           5 |      53 |  0.53851648071345 | 306.238516480713 |                 0 |           90 | 396.238516480713
+  72 |          6 |           6 |      56 |               0.4 | 396.638516480713 |                 0 |           90 | 486.638516480713
+  73 |          6 |           7 |      58 |               0.2 | 486.838516480713 |                 0 |           90 | 576.838516480713
+  74 |          6 |           8 |      60 |               0.3 | 577.138516480713 |                 0 |           90 | 667.138516480713
+  75 |          6 |           9 |      59 |  1.04403065089106 | 668.182547131604 |                 0 |           90 | 758.182547131604
+  76 |          6 |          10 |       0 |  3.50570962859162 | 761.688256760196 |                 0 |            0 | 761.688256760196
+  77 |          7 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+  78 |          7 |           2 |      67 |  1.22065556157337 | 1.22065556157337 |  10.7793444384266 |           90 |              102
+  79 |          7 |           3 |      65 |               0.1 |            102.1 |                 0 |           90 |            192.1
+  80 |          7 |           4 |      63 |               0.2 |            192.3 |                 0 |           90 |            282.3
+  81 |          7 |           5 |      62 |               0.5 |            282.8 |                 0 |           90 |            372.8
+  82 |          7 |           6 |      74 |               0.3 |            373.1 |                 0 |           90 |            463.1
+  83 |          7 |           7 |      72 |               0.5 |            463.6 |                 0 |           90 |            553.6
+  84 |          7 |           8 |      61 |               0.3 |            553.9 |                 0 |           90 |            643.9
+  85 |          7 |           9 |      64 |               0.2 |            644.1 |                 0 |            0 |            644.1
+  86 |          7 |          10 |     102 |                 0 |            644.1 |                 0 |           90 |            734.1
+  87 |          7 |          11 |      68 |               0.3 |            734.4 |                 0 |           90 |            824.4
+  88 |          7 |          12 |      66 |  0.53851648071345 | 824.938516480713 |  1.06148351928664 |           90 |              916
+  89 |          7 |          13 |      69 |               0.2 |            916.2 |                 0 |           90 |           1006.2
+  90 |          7 |          14 |       0 |  1.58113883008419 | 1007.78113883008 |                 0 |            0 | 1007.78113883008
+  91 |          8 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+  92 |          8 |           2 |      81 |  4.74341649025257 | 4.74341649025257 |  42.2565835097474 |           90 |              137
+  93 |          8 |           3 |      78 |               0.3 |            137.3 |                 0 |            0 |            137.3
+  94 |          8 |           4 |     104 |                 0 |            137.3 |                 0 |           90 |            227.3
+  95 |          8 |           5 |      76 |               0.2 |            227.5 |                 0 |           90 |            317.5
+  96 |          8 |           6 |      71 |               0.5 |              318 |                 0 |           90 |              408
+  97 |          8 |           7 |      70 |               0.5 |            408.5 |                 0 |           90 |            498.5
+  98 |          8 |           8 |      73 |               0.3 |            498.8 |                 0 |           90 |            588.8
+  99 |          8 |           9 |      77 |               0.4 |            589.2 |                 0 |           90 |            679.2
+ 100 |          8 |          10 |      79 |               0.1 |            679.3 |                 0 |           90 |            769.3
+ 101 |          8 |          11 |      80 |  0.53851648071345 | 769.838516480713 |                 0 |           90 | 859.838516480713
+ 102 |          8 |          12 |       0 |   5.1478150704935 | 864.986331551207 |                 0 |            0 | 864.986331551207
+ 103 |          9 |           1 |       0 |                 0 |                0 |                 0 |            0 |                0
+ 104 |          9 |           2 |      90 |  2.06155281280883 | 2.06155281280883 |  17.9384471871912 |           90 |              110
+ 105 |          9 |           3 |      87 |               0.5 |            110.5 |                 0 |           90 |            200.5
+ 106 |          9 |           4 |      86 |               0.1 |            200.6 |                 0 |           90 |            290.6
+ 107 |          9 |           5 |      83 |               0.6 |            291.2 |                 0 |           90 |            381.2
+ 108 |          9 |           6 |      82 |               0.3 |            381.5 |                 0 |           90 |            471.5
+ 109 |          9 |           7 |      84 |  0.58309518948453 | 472.083095189485 |                 0 |           90 | 562.083095189485
+ 110 |          9 |           8 |      85 | 0.282842712474619 | 562.365937901959 |                 0 |           90 | 652.365937901959
+ 111 |          9 |           9 |      88 |               0.3 | 652.665937901959 |                 0 |           90 | 742.665937901959
+ 112 |          9 |          10 |      89 | 0.282842712474619 | 742.948780614434 |                 0 |           90 | 832.948780614434
+ 113 |          9 |          11 |      91 | 0.360555127546399 |  833.30933574198 |  2.69066425801998 |           90 |              926
+ 114 |          9 |          12 |       0 |  2.23606797749979 |   928.2360679775 |                 0 |            0 |   928.2360679775
+ 115 |         -1 |           0 |       0 |  73.2993736320776 |                0 |  199.732924963843 |         8190 | 8463.03229859592
+(115 rows)
+
+--q3
diff --git a/src/pickDeliver/doc/index.rst b/src/pickDeliver/doc/index.rst
deleted file mode 100755
index ffe5cad..0000000
--- a/src/pickDeliver/doc/index.rst
+++ /dev/null
@@ -1,85 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _pgr_gsocvrppdtw:
-
-pgr_vrppdtw - Pickup and Delivery problem 
-===============================================================================
-
-.. index:: 
-	single: pgr_gsocvrppdtw(text,integer,integer)
-	module: vrppdtw
-
-Name
--------------------------------------------------------------------------------
-
-``pgr_gsoc_vrppdtw`` — Returns optimized  solution
-
-
-Synopsis
--------------------------------------------------------------------------------
-
-Vehicle Routing Problem with Pickup and Delivery (VRPPD): A number of goods need to be moved from certain pickup locations to other delivery locations. The goal is to find optimal routes for a fleet of vehicles to visit the pickup and drop-off locations.
-
-.. code-block:: sql
-
-	 pgr_gsoc_vrppdtw(text sql, integer , integer;
-
-
-Description
--------------------------------------------------------------------------------
-
-:sql: a SQL query, which should return a set of rows with the following columns:
-
-	.. code-block:: sql
-
-		select * from pgr_gsoc_vrppdtw(
-                                                'select * from customer order by id'::text, 25,200
-                                                                );
-                                                                                                 
-                                                                                                               
-
-Returns set of :ref:`type_cost_result`:
-
-:seq:   row sequence
-:rid:   route ID
-:nid:   node ID (``-1`` for the last row)
-:cost:  cost to traverse to ``seq``
-
-Examples
--------------------------------------------------------------------------------
-
-
-.. code-block:: sql
-
-	
-                SELECT  * from pgr_gsoc_vrppdtw(
-                                                'select * from customer order by id'::text, 25,200
-                                                                );
-                                                                                                 
-                                                                                                 
-
-
-	 seq | rid  | nid  | cost 
-	-----+------+------+------
-	   0 |    7 |    8 |    1
-	   1 |    8 |    9 |    1
-	   2 |    9 |   15 |    1
-	   3 |   12 |   -1 |    0
-           . |   .  |   .  |    .  
-           . |   .  |   .  |    .
- 
-
-
-
-See Also
--------------------------------------------------------------------------------
-
-* :ref:`type_cost_result`
-* http://en.wikipedia.org/wiki/Vehicle_routing_problem
diff --git a/src/pickDeliver/doc/pgr_pickDeliver.rst b/src/pickDeliver/doc/pgr_pickDeliver.rst
new file mode 100644
index 0000000..16a65b4
--- /dev/null
+++ b/src/pickDeliver/doc/pgr_pickDeliver.rst
@@ -0,0 +1,229 @@
+..
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+   INSTRUCTIONS
+   - if section consists of only one value then use this file as index.rst
+   - change [...] (including the square braquets) to appropriate values
+   - one file / function,  may signatures of the same function go in the same file
+
+.. _pgr_pickDeliver:
+
+__pgr_pickDeliver
+===============================================================================
+
+
+Name
+-------------------------------------------------------------------------------
+
+``_pgr_pickDeliver`` - Pickup and delivery Vehicle Routing Problem
+
+.. warning::  This is developers function.
+
+   - Is not officially in the current release
+   - Functionality currently is incomplete
+   - Final name currently is undecided
+   - Signature can and will change without notice.
+   - Please use :ref:`pgr_gsocvrppdtw` for a non changing Signature between releases
+   - It has the underscore until final functionality and name are decided
+
+
+
+
+
+Synopsis
+-------------------------------------------------------------------------------
+
+Problem: Distribute and optimize the pickup-delivery pairs into a fleet of vehicles.
+
+- Optimization problem is NP-hard.
+- pickup and Delivery with time windows.
+- All vehicles are equal.
+
+  - Same Starting location.
+  - Same Ending location which is the same as Starting location.
+  - All vehicles travel at the same speed.
+
+- A customer is for doing a pickup or doing a deliver.
+
+  - has an open time.
+  - has a closing time.
+  - has a service time.
+  - has an (x, y) location.
+
+- There is a customer where to deliver a pickup.
+
+  - travel time between customers is distance / speed
+  - pickup and delivery pair is done with the same vehicle.
+  - A pickup is done before the delivery.
+
+
+Characteristics:
+----------------
+
+- All trucks depart at time 0.
+- No multiple time windows for a location.
+- Less vehicle used is considered better.
+- Less total duration is better.
+- Less wait time is better.
+- the algorithm will raise an exception when
+
+  - If there is a pickup-deliver pair than violates time window
+  - The speed, max_cycles, ma_capacity have illegal values
+
+- Six different initial will be optimized
+  - the best solution found will be result
+
+
+Signature Summary
+-----------------
+
+.. code-block:: none
+
+    _pgr_pickDeliver(customers_sql, max_vehicles, capacity)
+    _pgr_pickDeliver(customers_sql, max_vehicles, capacity, speed, max_cycles)
+    RETURNS SET OF (seq, vehicle_id, vehicle_seq, stop_id,
+         travel_time, arrival_time, wait_time, service_time,  departure_time)
+
+
+
+Signatures
+-----------
+
+..
+    Minimal signature
+    .. index::
+    single: _pgr_pickDeliver(Minimal Signature) - developing
+
+Minimal signature
+...................
+
+..
+   Small description, example:
+
+The minimal signature is for `speed = 1`, for a `max_cycles = 30`
+
+.. code-block:: none
+
+    _pgr_pickDeliver(customers_sql, max_vehicles, capacity)
+    RETURNS SET OF (seq, vehicle_id, vehicle_seq, stop_id,
+         travel_time, arrival_time, wait_time, service_time,  departure_time)
+
+:Example:
+
+This example use the following data: TODO put link
+
+.. literalinclude:: doc-pickDeliver.queries
+   :start-after: --q1
+   :end-before: --q2
+
+..
+    Complete signature
+    .. index::
+    single: _pgr_pickDeliver(Cmplete Signature) - developing
+
+
+Complete signature
+....................
+
+This signature performs the optimization based on the optional parameters
+
+
+.. code-block:: none
+
+    _pgr_pickDeliver(customers_sql, max_vehicles, capacity, speed, max_cycles)
+    RETURNS SET OF (seq, vehicle_id, vehicle_seq, stop_id,
+         travel_time, arrival_time, wait_time, service_time,  departure_time)
+
+
+:Example:
+
+This example use the following data: TODO put link
+
+.. literalinclude:: doc-pickDeliver.queries
+   :start-after: --q2
+   :end-before: --q3
+
+Description of the Signatures
+-------------------------------
+
+
+Description of the customers_sql query
+.........................................................................................
+
+================  ===================   =================================================
+Column            Type                  Description
+================  ===================   =================================================
+**id**            ``ANY-INTEGER``       Identifier of the customer.
+
+                                        - A value of ``0`` identifies the starting location
+
+**x**             ``ANY-NUMERICAL``     ``X`` coordinate of the location.
+**y**             ``ANY-NUMERICAL``     ``Y`` coordinate of the location.
+**demand**        ``ANY-NUMERICAL``     How much is added / removed from the vehicle.
+
+                                        - Negative value is a delivery,
+                                        - Positive value is a pickup,
+
+**openTime**      ``ANY-NUMERICAL``     The time relative to 0, when the customer opens.
+**closeTime**     ``ANY-NUMERICAL``     The time relative to 0, when the customer closes.
+**serviceTime**   ``ANY-NUMERICAL``     The duration of the loading / unloading.
+**pickup_id**     ``ANY-INTEGER``       Value used when the current customer is a Delivery to find the corresponding Pickup
+**deliver_id**    ``ANY-INTEGER``       Value used when the current customer is a Pickup to find the corresponding Delivery
+================  ===================   =================================================
+
+Where:
+
+:ANY-INTEGER: SMALLINT, INTEGER, BIGINT
+:ANY-NUMERICAL: SMALLINT, INTEGER, BIGINT, REAL, FLOAT
+
+
+Description of the parameters of the signatures
+.........................................................................................
+
+================== =========== ======== =================================================
+Column             Type        Default     Description
+================== =========== ======== =================================================
+**customers_sql**  ``TEXT``             SQL query as described above.
+**max_vehicles**   ``INTEGER``          Maximum number of vehicles in the result. (currently is ignored)
+**capacity**       ``FLOAT``            Capacity of the vehicle.
+**speed**          ``FLOAT``   1        Speed of the vehicle.
+**max_cycles**     ``INTEGER`` 30       A multiplier for internal cycles (currently is ignored)
+================== =========== ======== =================================================
+
+Description of the result
+.........................................................................................
+
+:RETURNS SET OF: (seq, vehicle_id, vehicle_seq, stop_id, travel_time, arrival_time, wait_time, service_time,  departure_time)
+
+=================== ============= =================================================
+Column              Type           Description
+=================== ============= =================================================
+**seq**              INTEGER      Sequential value starting from **1**.
+**vehicle_id**       INTEGER      Current vehicle identifier.
+**vehicle_seq**      INTEGER      Sequential value starting from **1** for the current vehicle.
+**stop_id**          BIGINT       Visited customer identifier.
+**travel_time**      FLOAT        Travel time from previous ``stop_id`` to current ``stop_id``.
+**arrival_time**     FLOAT        Previous ``departure_time`` plus current ``travel_time``.
+**wait_time**        FLOAT        Time spent waiting for ``stop_id`` to open.
+**service_time**     FLOAT        Service time at current stop_id.
+**departure_time**   FLOAT        Previous :math:`departure\_time + travel\_time + wait\_time + service\_time`.
+                                    - When ``stop_id = 0`` and ``vehicle_seq != 1`` has the total time for the current ``vehicle_id``.
+                                    - When ``vehicle_id = -1`` has the aggregate total time
+=================== ============= =================================================
+
+
+
+See Also
+-------------------------------------------------------------------------------
+
+.. rubric:: Indices and tables
+
+* :ref:`genindex`
+* :ref:`search`
+
diff --git a/src/pickDeliver/sql/CMakeLists.txt b/src/pickDeliver/sql/CMakeLists.txt
index afbdc3c..dc7e23f 100644
--- a/src/pickDeliver/sql/CMakeLists.txt
+++ b/src/pickDeliver/sql/CMakeLists.txt
@@ -1,8 +1,7 @@
 # Append in local scope
 LIST(APPEND PACKAGE_SQL_FILES
-    ${CMAKE_CURRENT_SOURCE_DIR}/routing_vrppdtw.sql
-    )
+    ${CMAKE_CURRENT_SOURCE_DIR}/pickDeliver.sql
+)
 
 # set in parent scope
 SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-
diff --git a/src/dijkstra/sql/dijkstraVia.sql b/src/pickDeliver/sql/pickDeliver.sql
similarity index 67%
copy from src/dijkstra/sql/dijkstraVia.sql
copy to src/pickDeliver/sql/pickDeliver.sql
index f18a54b..9c98ff6 100644
--- a/src/dijkstra/sql/dijkstraVia.sql
+++ b/src/pickDeliver/sql/pickDeliver.sql
@@ -1,11 +1,13 @@
 /*PGR-GNU*****************************************************************
-File: dijkstraViaVertex.sql
+File: pickDeliver.sql
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
 
 Function's developer: 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail: 
 
 ------
 
@@ -25,27 +27,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-CREATE OR REPLACE FUNCTION pgr_dijkstraVia(
-    edges_sql TEXT,
-    via_vertices ANYARRAY,
-    directed BOOLEAN DEFAULT TRUE,
-    strict BOOLEAN DEFAULT FALSE,
-    U_turn_on_edge BOOLEAN DEFAULT TRUE,
-
+CREATE OR REPLACE FUNCTION _pgr_pickDeliver(
+    customers_sql TEXT,
+    max_vehicles INTEGER,
+    capacity FLOAT,
+    speed FLOAT DEFAULT 1, 
+    max_cycles INTEGER DEFAULT 10, 
 
     OUT seq INTEGER,
-    OUT path_id INTEGER,
-    OUT path_seq INTEGER,
-    OUT start_vid BIGINT,
-    OUT end_vid BIGINT,
-    OUT node BIGINT,
-    OUT edge BIGINT,
-    OUT cost FLOAT,
-    OUT agg_cost FLOAT,
-    OUT route_agg_cost FLOAT)
+    OUT vehicle_id INTEGER,
+    OUT vehicle_seq INTEGER,
+    OUT stop_id BIGINT,
+    OUT travel_time FLOAT,
+    OUT arrival_time FLOAT,
+    OUT wait_time FLOAT,
+    OUT service_time FLOAT,
+    OUT departure_time FLOAT
+)
 
   RETURNS SETOF RECORD AS
- '$libdir/${PGROUTING_LIBRARY_NAME}', 'dijkstraVia'
+ '$libdir/${PGROUTING_LIBRARY_NAME}', 'pickDeliver'
     LANGUAGE c IMMUTABLE STRICT;
 
-
diff --git a/src/pickDeliver/sql/routing_vrppdtw.sql b/src/pickDeliver/sql/routing_vrppdtw.sql
deleted file mode 100644
index 3d2dcd5..0000000
--- a/src/pickDeliver/sql/routing_vrppdtw.sql
+++ /dev/null
@@ -1,43 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
------------------------------------------------------------------------
--- Core function for vrp with sigle depot computation
--- See README for description
------------------------------------------------------------------------
---
---
-create or replace function pgr_gsoc_vrppdtw(
-    sql text,
-    vehicle_num INTEGER,
-    capacity FLOAT,
-    OUT seq integer,
-    OUT route_id BIGINT,
-    OUT node_id BIGINT,
-    OUT cost FLOAT
-)
-returns setof record as
-'$libdir/${PGROUTING_LIBRARY_NAME}', 'vrppdtw'
-LANGUAGE c VOLATILE STRICT;
-
-
diff --git a/src/pickDeliver/src/CMakeLists.txt b/src/pickDeliver/src/CMakeLists.txt
index bd0e6f3..4d5641b 100644
--- a/src/pickDeliver/src/CMakeLists.txt
+++ b/src/pickDeliver/src/CMakeLists.txt
@@ -1,7 +1,20 @@
-add_library(vrppdtw OBJECT
-    pdp.c
-    customers_input.c
-    pdp_solver.cpp
-    )
+ADD_LIBRARY(pickDeliver OBJECT
+    #   point.cpp
+    node.cpp
+    tw_node.cpp
+    vehicle_node.cpp
+    order.cpp
+    vehicle.cpp
+    vehicle_pickDeliver.cpp
+
+    solution.cpp
+    initial_solution.cpp
+    optimize.cpp
 
+    pgr_pickDeliver.cpp
 
+    pickDeliver_driver.cpp
+    customers_input.c
+    pickDeliver.c
+
+    )
diff --git a/src/pickDeliver/src/Route.h b/src/pickDeliver/src/Route.h
deleted file mode 100644
index 9e7e847..0000000
--- a/src/pickDeliver/src/Route.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-
-#pragma once
-
-#include <vector>
-#include <algorithm>
-#include "pdp.hpp"
-
-class Route  {
- public:
-     int twv;
-     int cv;
-     double dis;
-     std::vector < int64_t > path;
-     double capacity;
-     Depot depot;
-
-     Route(int _capacity, const Depot &_depot) :
-         twv(0),
-         cv(0),
-         dis(0),
-         capacity(_capacity),
-         depot(_depot) {
-             path.clear();
-         }
-     void update(const Customers &c);
-     double cost() const;
-     bool insertOrder(const Customers &c, const Pickup &order);
-     void append(const Customers &c, const Pickup &order);
-     void remove(const State &S);
-     int RemoveOrder(
-             const Customers &customers,
-             const Pickup &p);
-     bool has_violation(const Customers &customers);
-     bool has_twv(const Customers &customers);
-};
-
-
-/*
- * Returns:
- * 1 - when the order was found and removed
- * 0 - When the order was not found
- */
-int
-Route::RemoveOrder(
-        const Customers &customers,
-        const Pickup &pickup) {
-    Route oldRoute = *this;
-    oldRoute.update(customers);
-
-
-    auto pickup_pos = find(path.begin(), path.end(), pickup.Pid);
-
-    if (pickup_pos != path.end())  {
-        path.erase(pickup_pos);
-        auto delivery_pos = find(path.begin(), path.end(), pickup.Did);
-        path.erase(delivery_pos);
-
-        update(customers);
-        return ((dis < depot.Ltime)
-                && (twv < oldRoute.twv || cv < oldRoute.cv || dis < oldRoute.dis))? 1: 2;
-    } else {
-        return 0;
-    }
-}
-
-void
-Route::append(const Customers &customers,
-        const Pickup &pickup) {
-    path.push_back(pickup.Pid);
-    path.push_back(pickup.Did);
-    update(customers);
-}
-
-
-void
-Route::update(const Customers &customers)  {
-    dis = 0;
-    twv = 0;
-    cv = 0;
-    int load = 0;
-    double agg_cost = 0;
-    int prev_node = 0;
-    for (const auto &node : path) {
-        /*
-         * Between nodes
-         */
-        agg_cost += CalculateDistance(customers[prev_node], customers[node]);
-
-        if (agg_cost < customers[node].Etime) {
-            /*
-             * Arrving before the opening time, adjust time, moving it to the opening time
-             */
-            agg_cost = customers[node].Etime;
-        }
-        if (customers[node].Ltime < agg_cost) {
-            /*
-             * arrived after closing time
-             */
-            ++twv;
-        }
-        agg_cost += customers[node].Stime;
-        load += customers[node].demand;
-        if (load > capacity || load < 0) {
-            ++cv;
-        }
-        prev_node = node;
-    }
-    /*
-     * Going back to the depot
-     */
-    agg_cost += CalculateDistance(customers[prev_node], depot);
-    if (depot.Ltime < agg_cost) {
-        ++twv;
-    }
-
-    if (load != 0)  {
-        ++cv;
-    }
-    dis = agg_cost;
-    return;
-}
-
-
-double
-Route::cost() const  {
-    return (0.3*dis)+(0.5*twv)+(0.2*cv);
-}
-
-bool
-Route::has_violation(const Customers &customers) {
-    update(customers);
-    return (twv > 0 || cv > 0);
-}
-
-bool
-Route::has_twv(const Customers &customers) {
-    update(customers);
-    return (twv > 0);
-}
-
-
-bool
-Route::insertOrder(const Customers &customers, const Pickup &order) {
-    /*
-     *  inserting only on a route that does not have twv or cv
-     */
-    if (has_violation(customers)) return false;
-
-
-    path.insert(path.begin(), order.Pid);
-    /*
-     * The pickup is in:
-     */
-    int Ppos = 0;
-    int i;
-    for (i = 1; i < (int)path.size(); i++)  {
-        /*
-         * Inserting without creating violation
-         */
-        if (!has_twv(customers)) break;
-        std::swap(path[Ppos], path[i]);
-        Ppos = i;
-    }
-
-    path.push_back(order.Did);
-    /*
-     * The delivery is in:
-     */
-    int Dpos = path.size() - 1;
-
-    int j;
-    for (j = Dpos; Ppos < j; --j)  {
-        if (!has_violation(customers)) break;
-        std::swap(path[j], path[Dpos]);
-        Dpos = j;
-    }
-
-    /*
-     * Here 2 thngs can happen
-     * We inserted succesfully without violation
-     * Inserting created a violation
-     */
-
-
-    if (has_violation(customers)) {
-        RemoveOrder(customers, order);
-        return false;
-    }
-
-    /* 
-     * ....  Ppos a b c d Dpos ....
-     *
-     * The current route
-     */
-    update(customers);
-    Route bestRoute = *this;
-    Route currRoute = *this;
-
-    for (i = Ppos; i < Dpos; i++) {
-        *this = currRoute;
-        /* 
-         * ....  Ppos a b c d Dpos ....
-         */
-        std::swap(path[Ppos], path[i]);
-        Ppos = i;
-        currRoute = *this;
-
-        /*
-         * for the same position of Ppos
-         * - move the D
-         * - keep track of the best
-         */
-        for (j = Dpos; Ppos < j; j--) {
-            std::swap(path[j], path[Dpos]);
-            Dpos = j;
-            if (!has_violation(customers)
-                    && dis < bestRoute.dis) {
-                bestRoute = *this;
-                bestRoute.update(customers);
-            }
-        }
-    }
-
-    *this = bestRoute;
-
-    return true;
-}
-
-void Route::remove(const State &S)  {
-    twv = S.twv;
-    cv = S.cv;
-    dis = S.dis;
-    path  = S.path;
-}
diff --git a/src/pickDeliver/src/Solution.h b/src/pickDeliver/src/Solution.h
deleted file mode 100644
index 8b12c36..0000000
--- a/src/pickDeliver/src/Solution.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright  (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#pragma once
-
-#include <vector>
-
-#include "./Route.h"
-
-class Solution {
- public:
-     Solution() {
-         cost_total = 0, twv_total = 0, cv_total = 0, dis_total = 0;
-     }
-     // Variables
-     int twv_total;
-     int cv_total;
-     int dis_total;
-     double cost_total;
-     std::vector<Route> routes;
-     // Methods
-     void dump() const;
-     double getCost() const;
-     Solution getBestofNeighborhood(const Solution S,
-             const std::vector<Customer> &c,
-             const std::vector<Pickup> &p) const;
-     void UpdateSol(const Customers &customers);
-};
-
-class Neighborhoods {
- public:
-     Neighborhoods() {}
-     Solution BestSPI(const Solution S,
-             const std::vector<Customer> &customers,
-             const std::vector<Pickup> &pickups) const;
-};
-
-void
-Solution::UpdateSol(const Customers &customers) {
-    cost_total = 0, twv_total = 0, cv_total = 0, dis_total = 0;
-    routes.erase(std::remove_if(routes.begin(), routes.end(),
-                [] (const Route &r)
-                {return r.path.empty();}),
-            routes.end());
-    for (auto &r : routes) {
-        r.update(customers);
-        twv_total += r.twv;
-        dis_total += r.dis;
-        cv_total  += r.cv;
-        cost_total += r.cost();
-    }
-}
-
-
-// Methods in Solution
-
-
-double
-Solution::getCost() const {
-    double cost_total = 0;
-    for  (const auto &r : routes) {
-        cost_total += r.cost();
-    }
-    return cost_total;
-}
-
-Solution
-Solution::getBestofNeighborhood(const Solution S,
-        const std::vector<Customer> &customers,
-        const std::vector<Pickup> &pickups) const {
-    Neighborhoods N;
-    Solution S1;
-    S1 = N.BestSPI(S, customers, pickups);
-    return S1;
-}
-
-
-Solution
-Neighborhoods::BestSPI(const Solution S,
-        const Customers &customers,
-        const Pickups &pickups) const {
-    Solution CurrSol, BestSol, TempSol;
-    CurrSol = BestSol = S;
-    std::vector<Pickup> OrderRequests = pickups;
-    State TempState;
-
-    BestSol.UpdateSol(customers);
-    // Main SPI
-    for (const auto &order : OrderRequests) {
-        // Order Find and Remove it!
-        CurrSol = BestSol;
-        for (unsigned int route_remove = 0;
-                route_remove < CurrSol.routes.size();
-                route_remove++) {
-
-            int OK = CurrSol.routes[route_remove].RemoveOrder(customers,order);
-
-            if  (OK != 1) continue;
-            TempSol = CurrSol;
-            TempSol.UpdateSol(customers);
-
-            for (auto &route : TempSol.routes) {
-                int OK = route.insertOrder(customers, order);
-                if (!OK) continue;
-                TempSol.UpdateSol(customers);
-                if (TempSol.getCost() < BestSol.getCost()) {
-                    BestSol = TempSol;
-                    CurrSol = TempSol;
-                    break;
-                }
-                /*
-                 * the order was inserted but the distance was not best
-                 */
-                route.RemoveOrder(customers, order);
-            }
-        }
-    }
-
-    return BestSol;
-}
diff --git a/src/pickDeliver/src/customers_input.c b/src/pickDeliver/src/customers_input.c
index a001679..e94c1e6 100644
--- a/src/pickDeliver/src/customers_input.c
+++ b/src/pickDeliver/src/customers_input.c
@@ -20,9 +20,11 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-********************************************************************PGR-GNU*/
+ ********************************************************************PGR-GNU*/
+
+#include "postgres.h"
+#include "executor/spi.h"
 
-// #define DEBUG
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
@@ -30,17 +32,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./customers_input.h"
 
 
-
-
 static
-void pgr_fetch_customer(
+void fetch_customer(
         HeapTuple *tuple,
         TupleDesc *tupdesc,
         Column_info_t info[9],
-        Customer *customer) {
-
+        Customer_t *customer) {
     customer->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
-    customer->x = pgr_SPI_getFloat8(tuple, tupdesc,  info[1]);
+    customer->x = pgr_SPI_getFloat8(tuple, tupdesc, info[1]);
     customer->y = pgr_SPI_getFloat8(tuple, tupdesc, info[2]);
     customer->demand = pgr_SPI_getFloat8(tuple, tupdesc, info[3]);
     customer->Etime = pgr_SPI_getFloat8(tuple, tupdesc, info[4]);
@@ -51,25 +50,28 @@ void pgr_fetch_customer(
     customer->Ddist = 0;
 }
 
+
+
 void
-pgr_get_customers(
-        char *sql,
-        Customer **customers,
+pgr_get_customers_data(
+        char *customers_sql,
+        Customer_t **customers,
         size_t *total_customers) {
-    const int tuple_limit = 1000;
+    const int tuple_limit = 1000000;
 
-    size_t ntuples;
-    size_t total_tuples = 0;
+    PGR_DBG("pgr_get_customers_data");
+    PGR_DBG("%s", customers_sql);
 
     Column_info_t info[9];
 
     int i;
     for (i = 0; i < 9; ++i) {
         info[i].colNumber = -1;
-        info[i].type = -1;
+        info[i].type = 0;
         info[i].strict = true;
         info[i].eType = ANY_NUMERICAL;
     }
+
     /*!
       int64_t id;
       double x;
@@ -82,13 +84,14 @@ pgr_get_customers(
       int64_t Dindex;
       double Ddist;
       */
+
     info[0].name = strdup("id");
     info[1].name = strdup("x");
     info[2].name = strdup("y");
     info[3].name = strdup("demand");
-    info[4].name = strdup("etime");
-    info[5].name = strdup("ltime");
-    info[6].name = strdup("stime");
+    info[4].name = strdup("opentime");
+    info[5].name = strdup("closetime");
+    info[6].name = strdup("servicetime");
     info[7].name = strdup("pindex");
     info[8].name = strdup("dindex");
 
@@ -97,43 +100,46 @@ pgr_get_customers(
     info[8].eType = ANY_INTEGER;
 
 
-    void *SPIplan;
-    SPIplan = pgr_SPI_prepare(sql);
+    size_t ntuples;
+    size_t total_tuples;
 
+    void *SPIplan;
+    SPIplan = pgr_SPI_prepare(customers_sql);
     Portal SPIportal;
     SPIportal = pgr_SPI_cursor_open(SPIplan);
 
-
     bool moredata = TRUE;
-    (*total_customers) = total_tuples;
+    (*total_customers) = total_tuples = 0;
 
+    /* on the first tuple get the column numbers */
 
     while (moredata == TRUE) {
         SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
-        if (total_tuples == 0)
+        if (total_tuples == 0) {
             pgr_fetch_column_info(info, 9);
-
+        }
         ntuples = SPI_processed;
         total_tuples += ntuples;
-
+        PGR_DBG("SPI_processed %ld", ntuples);
         if (ntuples > 0) {
             if ((*customers) == NULL)
-                (*customers) = (Customer *)palloc0(total_tuples * sizeof(Customer));
+                (*customers) = (Customer_t *)palloc0(
+                        total_tuples * sizeof(Customer_t));
             else
-                (*customers) = (Customer *)repalloc((*customers), total_tuples * sizeof(Customer));
+                (*customers) = (Customer_t *)repalloc(
+                        (*customers), total_tuples * sizeof(Customer_t));
 
             if ((*customers) == NULL) {
                 elog(ERROR, "Out of memory");
             }
 
-            int t;
+            size_t t;
             SPITupleTable *tuptable = SPI_tuptable;
             TupleDesc tupdesc = SPI_tuptable->tupdesc;
-            PGR_DBG("processing %d customer tupĺes", ntuples);
-
+            PGR_DBG("processing %ld", ntuples);
             for (t = 0; t < ntuples; t++) {
                 HeapTuple tuple = tuptable->vals[t];
-                pgr_fetch_customer(&tuple, &tupdesc, info,
+                fetch_customer(&tuple, &tupdesc, info,
                         &(*customers)[total_tuples - ntuples + t]);
             }
             SPI_freetuptable(tuptable);
@@ -144,12 +150,10 @@ pgr_get_customers(
 
     if (total_tuples == 0) {
         (*total_customers) = 0;
-        PGR_DBG("NO _customers");
+        PGR_DBG("NO customers");
         return;
     }
 
-
     (*total_customers) = total_tuples;
-    PGR_DBG("Finish reading %ld customers, %ld", total_tuples, (*total_customers));
+    PGR_DBG("Finish reading %ld data, %ld", total_tuples, (*total_customers));
 }
-
diff --git a/src/pickDeliver/src/customers_input.h b/src/pickDeliver/src/customers_input.h
index eb8055e..f295869 100644
--- a/src/pickDeliver/src/customers_input.h
+++ b/src/pickDeliver/src/customers_input.h
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: edges_input.h
+File: customers_input.h
 
 Copyright (c) 2015 Celia Virginia Vergara Castillo
 vicky_vergara at hotmail.com
@@ -20,27 +20,13 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-********************************************************************PGR-GNU*/
+ ********************************************************************PGR-GNU*/
 
 #pragma once
 
-#include "./pgr_types.h"
-#include "./pdp.h"
-
-
-/*!
-  int64_t id;
-  double x;
-  double y;
-  double demand;
-  double Etime;
-  double Ltime;
-  double Stime;
-  int64_t Pindex;
-  int64_t Dindex;
-  double Ddist;
-*/
-void pgr_get_customers(
-        char *sql,
-        Customer **customers,
+#include "./../../common/src/pgr_types.h"
+
+void pgr_get_customers_data(
+        char *customers_sql,
+        Customer_t **customers,
         size_t *total_customers);
diff --git a/src/pickDeliver/src/initial_solution.cpp b/src/pickDeliver/src/initial_solution.cpp
new file mode 100644
index 0000000..ef60c8f
--- /dev/null
+++ b/src/pickDeliver/src/initial_solution.cpp
@@ -0,0 +1,559 @@
+/*PGR-GNU*****************************************************************
+
+FILE: initial_solution.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+#include "./initial_solution.h"
+#include <deque>
+#include <algorithm>
+#include <set>
+#include "./../../common/src/pgr_assert.h"
+#include "./solution.h"
+#include "./pgr_pickDeliver.h"
+
+namespace pgrouting {
+namespace vrp {
+
+void
+Initial_solution::invariant() const {
+    std::set<size_t> orders(assigned);
+
+    orders.insert(unassigned.begin(), unassigned.end());
+
+    /* check the local book keeping is ok */
+    pgassert(all_orders == orders);
+
+    /* this checks there is no order duplicated */
+    pgassert(all_orders.size() == orders.size());
+}
+
+
+Initial_solution::Initial_solution(
+        int kind,
+        const Pgr_pickDeliver *p_problem) :
+    Solution(p_problem) {
+        for (const auto &order : problem->orders()) {
+            unassigned.insert(order.id());
+        }
+        all_orders = unassigned;
+        assigned.clear();
+
+        switch (kind) {
+            case 0:
+                one_truck_all_orders();
+                break;
+            case 1:
+                one_truck_per_order();
+                break;
+            case 2:
+                push_back_while_feasable();
+                break;
+            case 3:
+                push_front_while_feasable();
+                break;
+            case 4:
+                insert_while_feasable();
+                break;
+            case 5:
+                insert_while_compatibleJ();
+                break;
+            case 6:
+                insert_while_compatibleI();
+                break;
+        }
+    }
+
+
+
+void
+Initial_solution::fill_truck_while_compatibleJ(
+        Vehicle_pickDeliver &truck,
+        std::set<size_t> &possible_orders) {
+    invariant();
+    /*
+     * Precondition:
+     * truck.orders_in_vehicle intersection assigned == truck.orders_in_vehicle
+     * (all orders in the truck are in the assigned set)
+     */
+    std::set<size_t> invariant_set;
+    std::set_intersection(
+            truck.orders_in_vehicle.begin(),
+            truck.orders_in_vehicle.end(),
+            assigned.begin(), assigned.end(),
+            std::inserter(invariant_set, invariant_set.begin()));
+    pgassert(invariant_set == truck.orders_in_vehicle);
+
+    invariant_set.clear();
+    /*
+     * Precondition:
+     * possible_orders intersection unassigned == possible_orders
+     * (all possible orders are not in the assigned set)
+     */
+    std::set_intersection(possible_orders.begin(), possible_orders.end(),
+            assigned.begin(), assigned.end(),
+            std::inserter(invariant_set, invariant_set.begin()));
+    pgassert(invariant_set.empty());
+
+    /*
+     * termination of recursion
+     */
+    if (possible_orders.empty())
+        return;
+
+    /*
+     * CODE
+     */
+    auto best_order = *possible_orders.begin();
+    size_t max_size(0);
+
+    /*
+     * In the possible orders set look for the order that
+     * has more compatible orders with the current possible orders
+     */
+    for (auto &o : possible_orders) {
+        auto other_orders = problem->orders()[o].m_compatibleJ;
+        auto intersect_orders = problem->orders()[o].subsetJ(possible_orders);
+        if (max_size < intersect_orders.size()) {
+            max_size = intersect_orders.size();
+            best_order = o;
+        }
+    }
+    auto intersect_orders = problem->orders()[best_order].subsetJ(possible_orders);
+
+    truck.insert(problem->orders()[best_order]);
+    if (!truck.is_feasable()) {
+        truck.erase(problem->orders()[best_order]);
+    } else {
+        assigned.insert(best_order);
+        unassigned.erase(unassigned.find(best_order));
+    }
+
+    possible_orders.erase(possible_orders.find(best_order));
+    fill_truck_while_compatibleJ(truck, possible_orders);
+    invariant();
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+std::deque<size_t>
+Initial_solution::first_ordersIJ() const {
+    /*
+     * Sorted as:
+     * (| {I}|, | {J}|)
+     * orders: keep sorted based on the number of orders it is compatible with
+     */
+    std::deque<size_t> orders(unassigned.begin(), unassigned.end());
+    const Pgr_pickDeliver *prob = problem;
+    std::sort(orders.begin(), orders.end(), [&prob]
+            (const size_t &lhs, const size_t &rhs) -> bool
+            {return prob->orders()[lhs].m_compatibleJ.size()
+            < prob->orders()[rhs].m_compatibleJ.size();
+            });
+    std::stable_sort(orders.begin(), orders.end(), [&prob]
+            (const size_t &lhs, const size_t &rhs) -> bool
+            {return prob->orders()[lhs].m_compatibleI.size()
+            < prob->orders()[rhs].m_compatibleI.size();
+            });
+    return orders;
+}
+
+
+
+
+
+void
+Initial_solution::insert_while_compatibleJ() {
+    problem->log << "\nInitial_solution::insert_while_compatible\n";
+    invariant();
+
+
+    size_t v_id(0);
+    Vehicle_pickDeliver truck(
+            v_id++,
+            problem->m_starting_site,
+            problem->m_ending_site,
+            problem->max_capacity,
+            problem);
+
+    while (!unassigned.empty()) {
+        std::deque<size_t> orders(first_ordersIJ());
+
+        if (truck.empty()) {
+            auto order(problem->orders()[orders.front()]);
+            truck.insert(order);
+            assigned.insert(order.id());
+            orders.pop_front();
+            unassigned.erase(unassigned.find(order.id()));
+            invariant();
+
+            std::set<size_t> compatible_orders(
+                    problem->orders()[order.id()].m_compatibleJ);
+            std::set<size_t> possible_orders;
+            std::set_intersection(
+                    compatible_orders.begin(), compatible_orders.end(),
+                    unassigned.begin(), unassigned.end(),
+                    std::inserter(possible_orders, possible_orders.begin()));
+
+
+            fill_truck_while_compatibleJ(truck, possible_orders);
+            fleet.push_back(truck);
+
+            if (unassigned.empty())
+                break;
+
+            Vehicle_pickDeliver newtruck(
+                    v_id++,
+                    problem->m_starting_site,
+                    problem->m_ending_site,
+                    problem->max_capacity,
+                    problem);
+            truck = newtruck;
+        }
+        invariant();
+    }
+}
+
+
+
+void
+Initial_solution::fill_truck_while_compatibleI(
+        Vehicle_pickDeliver &truck,
+        std::set<size_t> &possible_orders) {
+    invariant();
+    /*
+     * Precondition:
+     * truck.orders_in_vehicle intersection assigned == truck.orders_in_vehicle
+     * (all orders in the truck are in the assigned set)
+     */
+    std::set<size_t> invariant_set;
+    std::set_intersection(truck.orders_in_vehicle.begin(), truck.orders_in_vehicle.end(),
+            assigned.begin(), assigned.end(),
+            std::inserter(invariant_set, invariant_set.begin()));
+    pgassert(invariant_set == truck.orders_in_vehicle);
+
+    invariant_set.clear();
+    /*
+     * Precondition:
+     * possible_orders intersection unassigned == possible_orders
+     * (all possible orders are not in the assigned set)
+     */
+    std::set_intersection(possible_orders.begin(), possible_orders.end(),
+            assigned.begin(), assigned.end(),
+            std::inserter(invariant_set, invariant_set.begin()));
+    pgassert(invariant_set.empty());
+
+    /*
+     * termination of recursion
+     */
+    if (possible_orders.empty())
+        return;
+
+    /*
+     * CODE
+     */
+    auto best_order = *possible_orders.begin();
+    size_t max_size(0);
+
+    /*
+     * In the possible orders set look for the order that
+     * has more compatible orders with the current possible orders
+     */
+    for (auto &o : possible_orders) {
+        auto other_orders = problem->orders()[o].m_compatibleI;
+        auto intersect_orders = problem->orders()[o].subsetI(possible_orders);
+        if (max_size < intersect_orders.size()) {
+            max_size = intersect_orders.size();
+            best_order = o;
+        }
+    }
+    auto intersect_orders = problem->orders()[best_order].subsetI(possible_orders);
+
+    truck.insert(problem->orders()[best_order]);
+    if (!truck.is_feasable()) {
+        truck.erase(problem->orders()[best_order]);
+    } else {
+        assigned.insert(best_order);
+        unassigned.erase(unassigned.find(best_order));
+    }
+
+    possible_orders.erase(possible_orders.find(best_order));
+    fill_truck_while_compatibleI(truck, possible_orders);
+    invariant();
+}
+
+
+
+
+
+
+
+
+
+
+
+std::deque<size_t>
+Initial_solution::first_ordersJI() const {
+    /*
+     * Sorted as:
+     * (| {J}|, | {I}|)
+     * orders: keep sorted based on the number of orders it is compatible with
+     */
+    std::deque<size_t> orders(unassigned.begin(), unassigned.end());
+    const Pgr_pickDeliver *prob = problem;
+    std::sort(orders.begin(), orders.end(), [&prob]
+            (const size_t &lhs, const size_t &rhs) -> bool
+            {return prob->orders()[lhs].m_compatibleI.size()
+            < prob->orders()[rhs].m_compatibleI.size();
+            });
+    std::stable_sort(orders.begin(), orders.end(), [&prob]
+            (const size_t &lhs, const size_t &rhs) -> bool
+            {return prob->orders()[lhs].m_compatibleJ.size()
+            < prob->orders()[rhs].m_compatibleJ.size();
+            });
+    return orders;
+}
+
+
+
+void
+Initial_solution::insert_while_compatibleI() {
+    problem->log << "\nInitial_solution::insert_while_compatible\n";
+    invariant();
+
+
+    size_t v_id(0);
+    Vehicle_pickDeliver truck(
+            v_id++,
+            problem->m_starting_site,
+            problem->m_ending_site,
+            problem->max_capacity,
+            problem);
+
+    while (!unassigned.empty()) {
+        std::deque<size_t> orders(first_ordersJI());
+
+        if (truck.empty()) {
+            auto order(problem->orders()[orders.front()]);
+            truck.insert(order);
+            assigned.insert(order.id());
+            orders.pop_front();
+            unassigned.erase(unassigned.find(order.id()));
+            invariant();
+
+            std::set<size_t> compatible_orders(
+                    problem->orders()[order.id()].m_compatibleI);
+            std::set<size_t> possible_orders;
+            std::set_intersection(
+                    compatible_orders.begin(), compatible_orders.end(),
+                    unassigned.begin(), unassigned.end(),
+                    std::inserter(possible_orders, possible_orders.begin()));
+
+
+            fill_truck_while_compatibleI(truck, possible_orders);
+            fleet.push_back(truck);
+
+            if (unassigned.empty())
+                break;
+
+            Vehicle_pickDeliver newtruck(
+                    v_id++,
+                    problem->m_starting_site,
+                    problem->m_ending_site,
+                    problem->max_capacity,
+                    problem);
+            truck = newtruck;
+        }
+        invariant();
+    }
+}
+
+
+
+
+
+void
+Initial_solution::insert_while_feasable() {
+    invariant();
+
+    size_t v_id(0);
+    Vehicle_pickDeliver truck(
+            v_id++,
+            problem->m_starting_site,
+            problem->m_ending_site,
+            problem->max_capacity,
+            problem);
+    problem->log << "\nInitial_solution::insert_while_feasable\n";
+    while (!unassigned.empty()) {
+        auto order(problem->orders()[*unassigned.begin()]);
+
+        truck.insert(order);
+
+        if (!truck.is_feasable()) {
+            truck.erase(order);
+            fleet.push_back(truck);
+            Vehicle_pickDeliver newtruck(
+                    v_id++,
+                    problem->m_starting_site,
+                    problem->m_ending_site,
+                    problem->max_capacity,
+                    problem);
+            truck = newtruck;
+        } else {
+            assigned.insert(*unassigned.begin());
+            unassigned.erase(unassigned.begin());
+        }
+
+        invariant();
+    }
+}
+
+void
+Initial_solution::push_front_while_feasable() {
+    size_t v_id(0);
+    Vehicle_pickDeliver truck(
+            v_id++,
+            problem->m_starting_site,
+            problem->m_ending_site,
+            problem->max_capacity,
+            problem);
+    while (!unassigned.empty()) {
+        auto order(problem->orders()[*unassigned.begin()]);
+
+        truck.push_front(order);
+        if (!truck.is_feasable()) {
+            truck.pop_front();
+            fleet.push_back(truck);
+            Vehicle_pickDeliver newtruck(
+                    v_id++,
+                    problem->m_starting_site,
+                    problem->m_ending_site,
+                    problem->max_capacity,
+                    problem);
+            truck = newtruck;
+        } else {
+            assigned.insert(*unassigned.begin());
+            unassigned.erase(unassigned.begin());
+        }
+
+        invariant();
+    }
+}
+
+void
+Initial_solution::push_back_while_feasable() {
+    size_t v_id(0);
+    Vehicle_pickDeliver truck(
+            v_id++,
+            problem->m_starting_site,
+            problem->m_ending_site,
+            problem->max_capacity,
+            problem);
+    while (!unassigned.empty()) {
+        auto order(problem->orders()[*unassigned.begin()]);
+
+        truck.push_back(order);
+        if (!truck.is_feasable()) {
+            truck.pop_back();
+            fleet.push_back(truck);
+            Vehicle_pickDeliver newtruck(
+                    v_id++,
+                    problem->m_starting_site,
+                    problem->m_ending_site,
+                    problem->max_capacity,
+                    problem);
+            truck = newtruck;
+        } else {
+            assigned.insert(*unassigned.begin());
+            unassigned.erase(unassigned.begin());
+        }
+
+        invariant();
+    }
+}
+
+
+
+void
+Initial_solution::one_truck_per_order() {
+    size_t v_id(0);
+    while (!unassigned.empty()) {
+        auto order(problem->orders()[*unassigned.begin()]);
+
+        Vehicle_pickDeliver truck(
+                v_id++,
+                problem->m_starting_site,
+                problem->m_ending_site,
+                problem->max_capacity,
+                problem);
+        truck.push_back(order);
+        fleet.push_back(truck);
+
+        assigned.insert(*unassigned.begin());
+        unassigned.erase(unassigned.begin());
+
+        invariant();
+    }
+}
+
+
+
+
+void
+Initial_solution::one_truck_all_orders() {
+    size_t v_id(0);
+    Vehicle_pickDeliver truck(
+            v_id++,
+            problem->m_starting_site,
+            problem->m_ending_site,
+            problem->max_capacity,
+            problem);
+    while (!unassigned.empty()) {
+        auto order(problem->orders()[*unassigned.begin()]);
+
+        truck.insert(order);
+
+        assigned.insert(*unassigned.begin());
+        unassigned.erase(unassigned.begin());
+
+        invariant();
+    }
+    fleet.push_back(truck);
+}
+
+
+
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/initial_solution.h b/src/pickDeliver/src/initial_solution.h
new file mode 100644
index 0000000..f89c0a4
--- /dev/null
+++ b/src/pickDeliver/src/initial_solution.h
@@ -0,0 +1,77 @@
+/*PGR-GNU*****************************************************************
+
+FILE: initial_solution.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#pragma once
+
+#include <set>
+#include <deque>
+#include "./solution.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+class Pgr_pickDeliver;
+
+
+class Initial_solution : public Solution {
+ public:
+     Initial_solution(
+             int kind,
+             const Pgr_pickDeliver *problem);
+
+     void invariant() const;
+
+ private:
+     /*
+      * one truck per order
+      */
+     void one_truck_per_order();
+     void one_truck_all_orders();
+     void push_back_while_feasable();
+     void push_front_while_feasable();
+     void insert_while_feasable();
+
+     void insert_while_compatibleJ();
+     void fill_truck_while_compatibleJ(
+             Vehicle_pickDeliver &truck,
+             std::set<size_t> &possible_orders);
+     std::deque<size_t> first_ordersIJ() const;
+
+     void insert_while_compatibleI();
+     void fill_truck_while_compatibleI(
+             Vehicle_pickDeliver &truck,
+             std::set<size_t> &possible_orders);
+     std::deque<size_t> first_ordersJI() const;
+
+
+ private:
+     std::set<size_t> all_orders;
+     std::set<size_t> unassigned;
+     std::set<size_t> assigned;
+};
+
+}  //  namespace vrp
+}  //  namespace pgRouting
diff --git a/src/pickDeliver/src/node.cpp b/src/pickDeliver/src/node.cpp
new file mode 100644
index 0000000..5eeb5e1
--- /dev/null
+++ b/src/pickDeliver/src/node.cpp
@@ -0,0 +1,81 @@
+/*PGR-GNU*****************************************************************
+
+FILE: node.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#include "./node.h"
+
+namespace pgrouting {
+namespace vrp {
+
+bool Node::isSamePos(const Node &other) const {
+    return comparable_distance(other) == 0;
+}
+
+#if 0
+double Node::travel_time_to(const Node &other) const {
+    return distance(other);
+}
+#endif
+
+std::ostream& operator << (std::ostream &log, const Node &node) {
+    log << node.m_original_id
+        << "(" << node.m_id << ")"
+       << "(" << node.m_point.x() << ", " << node.m_point.y() << ")";
+    return log;
+}
+
+double
+Node::distance(const Node &other) const {
+    auto dx = m_point.x() - other.m_point.x();
+    auto dy = m_point.y() - other.m_point.y();
+    return sqrt(dx * dx + dy * dy);
+}
+
+double
+Node::comparable_distance(const Node &other) const {
+    auto dx = m_point.x() - other.m_point.x();
+    auto dy = m_point.y() - other.m_point.y();
+    return dx * dx + dy * dy;
+}
+
+
+Node::Node(size_t id, int64_t original_id, double _x, double _y)
+    : m_point(_x, _y),
+    m_id(id),
+    m_original_id(original_id) {
+    }
+
+bool
+Node::operator ==(const Node &rhs) const {
+    if (&rhs == this) return true;
+    return
+        (id() == rhs.id())
+         && (original_id() == rhs.original_id())
+         && (m_point == rhs.m_point);
+}
+
+}  //  namespace vrp
+}  //  namespace pgrouting
+
+
diff --git a/src/pickDeliver/src/node.h b/src/pickDeliver/src/node.h
new file mode 100644
index 0000000..25e790f
--- /dev/null
+++ b/src/pickDeliver/src/node.h
@@ -0,0 +1,80 @@
+/*PGR-GNU*****************************************************************
+
+FILE: node.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#pragma once
+
+#include <string>
+// #include "./point.h"
+#include "../../common/src/xy_vertex.h"
+
+namespace pgrouting {
+namespace vrp {
+
+/*! \class Node
+ * \brief The Node class defines a point in 2D space with an id.
+ *
+ * A Node is a point that defines a location in 2D space. It maintains
+ * a user \c id and an internal \c nid along with its \c x, \c y location.
+ * This is the base object that things like depots, customer locations, etc.
+ * are built upon.
+ *
+ */
+
+// class Node : public Point {
+class Node {
+ public:
+     /** @name accessors */
+     ///@ {
+
+     inline size_t id() const {return m_id;}
+     inline int64_t original_id() const {return m_original_id;}
+
+     ///@}
+
+     Node(size_t id, int64_t original_id, double _x, double _y);
+
+
+     /** @name state */
+     ///@ {
+
+     bool isSamePos(const Node &other) const;
+#if 0
+     double travel_time_to(const Node &node2) const;
+#endif
+     friend std::ostream& operator << (std::ostream &log, const Node &node);
+     bool operator ==(const Node &rhs) const;
+
+     double distance(const Node &other) const;
+     double comparable_distance(const Node &other) const;
+
+
+ private:
+     pgrouting::Point m_point;
+     size_t m_id;                ///< internal node number
+     int64_t m_original_id;  // /< user supplied node number
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/optimize.cpp b/src/pickDeliver/src/optimize.cpp
new file mode 100644
index 0000000..c0e187c
--- /dev/null
+++ b/src/pickDeliver/src/optimize.cpp
@@ -0,0 +1,497 @@
+/*PGR-GNU*****************************************************************
+
+FILE: optimize.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+#include <algorithm>
+#include <limits>
+#include <set>
+#include "./solution.h"
+#include "./../../common/src/pgr_assert.h"
+#include "./optimize.h"
+#include "./pgr_pickDeliver.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+Optimize::Optimize(
+        int kind,
+        const Solution &old_solution) :
+    Solution(old_solution),
+    best_solution(old_solution)  {
+        switch (kind) {
+            case 0:
+                sort_by_duration();
+                break;
+            case 1:
+                decrease_truck();
+                break;
+            case 2:
+                move_duration_based();
+                break;
+            case 3:
+                move_wait_time_based();
+                break;
+            case 4:
+                inter_swap();
+                break;
+        }
+        this->fleet = best_solution.fleet;
+        sort_by_duration();
+        delete_empty_truck();
+    }
+
+
+void
+Optimize::inter_swap() {
+    auto local_limit(fleet.size());
+    size_t i(0);
+    while (inter_swap(false) && (++i < local_limit)) {
+    }
+    i = 0;
+    while (inter_swap(true) && (++i < local_limit)) {
+    }
+    sort_by_duration();
+    delete_empty_truck();
+    this->fleet = best_solution.fleet;
+}
+
+bool
+Optimize::inter_swap(bool reversed) {
+//    problem->log << tau("before sort");
+    sort_by_duration();
+    delete_empty_truck();
+    save_if_best();
+    if (reversed) {
+        std::reverse(fleet.begin(), fleet.end());
+    }
+//    problem->log << tau("after sort");
+    auto swapped = false;
+    size_t from_pos(fleet.size()-1);
+    while (from_pos > 1) {
+        for (size_t to_pos = 0; to_pos < from_pos; ++to_pos) {
+            swapped = swap_worse(from_pos, to_pos)? true : swapped;
+            swapped = move_reduce_cost(from_pos, to_pos)? true : swapped;
+        }
+        delete_empty_truck();
+        --from_pos;
+    }
+    return swapped;
+}
+
+bool
+Optimize::swap_worse(size_t from_pos, size_t to_pos) {
+    pgassert(to_pos < from_pos);
+    auto from_truck = fleet[from_pos];
+    auto to_truck = fleet[to_pos];
+    auto swapped(false);
+    auto from_orders(from_truck.orders_in_vehicle);
+    auto to_orders(to_truck.orders_in_vehicle);
+    auto local_limit(from_orders.size() * to_orders.size() + 1);
+
+    while (!from_orders.empty() && --local_limit > 0) {
+        auto from_order(from_truck.get_worse_order(from_orders));
+        from_orders.erase(from_order.id());
+
+        while (!to_orders.empty()) {
+            auto to_order(to_truck.get_worse_order(to_orders));
+            to_orders.erase(to_order.id());
+
+            /*
+             * delete from_order, and to order from their trucks
+             */
+            auto curr_from_duration(from_truck.duration());
+            auto curr_to_duration(to_truck.duration());
+
+            from_truck.erase(from_order);
+            to_truck.erase(to_order);
+
+            /*
+             * insert them in the other truck
+             */
+            from_truck.insert(to_order);
+            to_truck.insert(from_order);
+
+            if (from_truck.is_feasable() && to_truck.is_feasable()) {
+                /*
+                 * Can swap but:
+                 *   - only swap when the total duration is reduced
+                 *   - or from_truck duration is reduced 
+                 */
+
+                if (((from_truck.duration() + to_truck.duration())
+                            < (curr_from_duration + curr_to_duration))
+                        || (from_truck.duration() < curr_from_duration)) {
+                    problem->log
+                        << "\n    Swap order " << from_order.id()
+                        << " from truck " << from_truck.id()
+                        << " with order " << to_order.id() << " of truck " << to_truck.id();
+#ifndef NDEBUG
+                    problem->dbg_log << "\nswappping before:";
+                    problem->dbg_log << "\n" << fleet[to_pos].tau();
+                    problem->dbg_log << "\n" << fleet[from_pos].tau();
+#endif
+
+                    swap_order(from_order, fleet[from_pos], to_order, fleet[to_pos]);
+                    swapped = true;
+                    save_if_best();
+                    from_orders.insert(to_order.id());
+#ifndef NDEBUG
+                    problem->dbg_log << "\nswappping after:";
+                    problem->dbg_log << "\n" << fleet[to_pos].tau();
+                    problem->dbg_log << "\n" << fleet[from_pos].tau();
+#endif
+                    break;
+                }
+            }
+            /*
+             * wasn't swapped
+             */
+            to_truck = fleet[to_pos];
+            from_truck = fleet[from_pos];
+        }
+    }
+    return swapped;
+}
+
+/*
+ * from_truck: position of the truck where the order is
+ * to truck: truck to put the order
+ */
+void
+Optimize::swap_order(
+        const Order from_order,
+        Vehicle_pickDeliver &from_truck,
+        const Order to_order,
+        Vehicle_pickDeliver &to_truck) {
+    pgassert(from_truck.has_order(from_order));
+    pgassert(to_truck.has_order(to_order));
+
+    from_truck.erase(from_order);
+    to_truck.erase(to_order);
+
+    from_truck.insert(to_order);
+    to_truck.insert(from_order);
+
+
+    pgassert(from_truck.has_order(to_order));
+    pgassert(to_truck.has_order(from_order));
+}
+
+void
+Optimize::sort_by_duration() {
+    std::sort(fleet.begin(), fleet.end(), []
+            (const Vehicle_pickDeliver &lhs, const Vehicle_pickDeliver &rhs)
+            -> bool {
+            return lhs.duration() > rhs.duration();
+            });
+}
+
+void
+Optimize::delete_empty_truck() {
+    while (fleet.back().empty()) {
+        problem->log << "\nEmpty truck";
+        fleet.pop_back();
+        save_if_best();
+    }
+    save_if_best();
+}
+
+void
+Optimize::move_duration_based() {
+    auto local_limit(fleet.size());
+    size_t i(0);
+
+    sort_by_duration();
+    problem->log << tau("\nmove duration based");
+    while (move_reduce_cost() && (++i < local_limit)) { }
+    delete_empty_truck();
+
+    i = 0;
+    sort_by_duration();
+    std::reverse(fleet.begin(), fleet.end());
+    problem->log << tau("\nmove duration based");
+    while (move_reduce_cost() && (++i < local_limit)) { }
+    sort_by_duration();
+    delete_empty_truck();
+    this->fleet = best_solution.fleet;
+}
+
+
+void
+Optimize::move_wait_time_based() {
+    this->fleet = best_solution.fleet;
+
+    auto local_limit(fleet.size());
+    size_t i(0);
+
+    sort_for_move();
+    problem->log << tau("\nmove wait_time based");
+    while (move_reduce_cost() && (++i < local_limit)) { }
+    delete_empty_truck();
+
+    i = 0;
+    sort_for_move();
+    std::reverse(fleet.begin(), fleet.end());
+    problem->log << tau("\nmove wait_time based");
+    while (move_reduce_cost() && (++i < local_limit)) { }
+    sort_by_duration();
+    delete_empty_truck();
+    this->fleet = best_solution.fleet;
+}
+
+/*
+ * On the current order of the fleet
+ * T1 .......Tn-1  Tn Tn+1...... Tsize
+ * Tn tries to move orders to trucks
+ *      T1 .... Tn-1 
+ * So that it gets space for the orders given by
+ *      Tn+1 .... Tsize
+ * On the first move possible it returns
+ *
+ * When a truck is emptied, then it removes the truck from the fleet
+ *
+ * Returns true: when a move was possible
+ * Returns false: when a move was not possible
+ */ 
+
+
+bool
+Optimize::move_reduce_cost() {
+    if (fleet.size() < 2) return false;
+
+    size_t from_pos(fleet.size() - 1);
+    while (from_pos > 1) {
+        for (size_t to_pos = 0; to_pos < from_pos; ++to_pos) {
+            // problem->log << "\nmove_reduce_cost (" << fleet[from_pos].id()  << ", " << fleet[to_pos].id() << ")";
+            if (move_reduce_cost(from_pos, to_pos)) {
+                if (fleet[from_pos].empty()) {
+                    fleet.erase(fleet.begin() + from_pos);
+                    save_if_best();
+                }
+                return true;
+            }
+        }
+        --from_pos;
+    }
+    return false;
+}
+
+/*
+ * from_truck trying to make from_truck's duration smaller
+ * - maybe all orders can be moved
+ *   - if that is the case, the from_truck could be removed
+ *
+ * Deleting an order on the from_truck
+ * - number of truck remains the same
+ * - from_truk duration() can not get larger
+ * - the overall duration can get larger
+ * 
+ */
+bool
+Optimize::move_reduce_cost(size_t from_pos, size_t to_pos) {
+    pgassert(to_pos < from_pos);
+    auto from_truck = fleet[from_pos];
+    auto to_truck = fleet[to_pos];
+    auto moved(false);
+
+    auto orders(from_truck.orders_in_vehicle);
+    while (!orders.empty()) {
+        /*
+         * get the order that decreases the duration the most
+         * (there is always a worse)
+         */
+        auto order = from_truck.get_worse_order(orders);
+        orders.erase(order.id());
+
+        /*
+         * insert it in the next truck
+         */
+        to_truck.insert(order);
+        if (to_truck.is_feasable()) {
+            problem->log
+                << "\n    Move order " << order.id()
+                << " from truck " << from_truck.id()
+                << " to truck " << to_truck.id();
+#ifndef NDEBUG
+            problem->dbg_log << "\nMove before:";
+            problem->dbg_log << "\n" << fleet[to_pos].tau();
+            problem->dbg_log << "\n" << fleet[from_pos].tau();
+#endif
+
+            from_truck.erase(order);
+            move_order(order, fleet[from_pos], fleet[to_pos]);
+            moved = true;
+            save_if_best();
+
+#ifndef NDEBUG
+            problem->dbg_log << "\nMove after:";
+            problem->dbg_log << "\n" << fleet[to_pos].tau();
+            problem->dbg_log << "\n" << fleet[from_pos].tau();
+#endif
+        }
+    }
+    return moved;
+}
+
+
+
+/*
+ * from_truck: position of the truck where the order is
+ * to truck: truck to put the order
+ */
+void
+Optimize::move_order(
+        Order order,
+        Vehicle_pickDeliver &from_truck,
+        Vehicle_pickDeliver &to_truck) {
+    pgassert(from_truck.has_order(order));
+    pgassert(!to_truck.has_order(order));
+
+    from_truck.erase(order);
+    to_truck.insert(order);
+
+    pgassert(!from_truck.has_order(order));
+    pgassert(to_truck.has_order(order));
+}
+
+void
+Optimize::sort_for_move() {
+    std::sort(fleet.begin(), fleet.end(), []
+            (const Vehicle_pickDeliver &lhs, const Vehicle_pickDeliver &rhs)
+            -> bool {
+            return lhs.total_wait_time() > rhs.total_wait_time();
+            });
+
+    std::stable_sort(fleet.begin(), fleet.end(), []
+            (const Vehicle_pickDeliver &lhs, const Vehicle_pickDeliver &rhs)
+            -> bool {
+            return lhs.orders_size() > rhs.orders_size();
+            });
+}
+
+
+/*
+ * Optimize decreasing truck
+ *
+ * - Objective: try to remove truck with less duration
+ *
+ * Step 1: Sort the fleet, duration DESC
+ * Step 2: grab an order from the back of the the fleet
+ * Step 3: cycle the fleet & insert in best truck possible
+ */
+void
+Optimize::decrease_truck() {
+    bool decreased(true);
+    while (decreased) {
+        decreased = false;
+        sort_by_duration();
+        std::reverse(fleet.begin(), fleet.end());
+        decrease_truck(fleet.size(), decreased);
+    }
+    this->fleet = best_solution.fleet;
+}
+
+void
+Optimize::decrease_truck(size_t cycle, bool &decreased) {
+    /* end recursion */
+    if (cycle == 0) return;
+
+    std::ostringstream err_log;
+    err_log << " --- Cycle " << cycle << "\n";
+
+    /* the front truck move to back */
+    std::rotate(fleet.begin(), fleet.begin() + 1, fleet.end());
+    err_log << "\n after rotate" << tau();
+
+    auto orders(fleet.back().orders_in_vehicle);
+    while (!orders.empty()) {
+        /* Step 2: grab an order */
+        auto order(problem->orders()[*orders.begin()]);
+        orders.erase(orders.begin());
+        err_log << "\n truck with order: " << fleet.back().tau();
+        err_log << "\nOrder" << order << "\n";
+
+        /* Step 3: delete the order from the back of the fleet */
+        pgassertwm(fleet.back().has_order(order), err_log.str());
+        fleet.back().erase(order);
+        pgassertwm(!fleet.back().has_order(order), err_log.str());
+
+        /* Step 3: cycle the fleet & insert in best truck possible */
+        /* current truck is tried last */
+        err_log << " trying ";
+        auto best_truck(fleet.size() - 1);
+        auto current_duration(duration());
+        auto min_delta_duration = (std::numeric_limits<double>::max)();
+        size_t t_i(0);
+        for (auto &truck : fleet) {
+            truck.insert(order);
+            if (!truck.is_feasable()) {
+                err_log << "\n" << truck.tau();
+            } else {
+                err_log << "\n ******* success " << truck.tau() << "\n";
+                auto delta_duration = duration()-current_duration;
+                if (t_i != fleet.size() - 1
+                        && (delta_duration < min_delta_duration)) {
+                    min_delta_duration = delta_duration;
+                    best_truck = t_i;
+                }
+            }
+            truck.erase(order);
+            ++t_i;
+        }
+        fleet[best_truck].insert(order);
+        save_if_best();
+    }
+
+    if (fleet.back().empty()) {
+        decreased = true;
+        fleet.pop_back();
+        save_if_best();
+    }
+    decrease_truck(--cycle, decreased);
+}
+
+void
+Optimize::save_if_best() {
+    if (duration() < best_solution.duration()) {
+        best_solution = (*this);
+        problem->log << "\n*********** best by duration" << best_solution.cost_str();
+#ifndef NDEBUG
+        problem->dbg_log << best_solution.tau("best by duration");
+#endif
+    }
+    if (fleet.size() < best_solution.fleet.size()) {
+        best_solution = (*this);
+        problem->log << "\n*********** best by fleet size" << best_solution.cost_str();
+#ifndef NDEBUG
+        problem->dbg_log << best_solution.tau("best by fleet size");
+#endif
+    }
+}
+
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/optimize.h b/src/pickDeliver/src/optimize.h
new file mode 100644
index 0000000..b27166c
--- /dev/null
+++ b/src/pickDeliver/src/optimize.h
@@ -0,0 +1,76 @@
+/*PGR-GNU*****************************************************************
+
+FILE: optimize.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#pragma once
+
+#include "./optimize.h"
+
+namespace pgrouting {
+namespace vrp {
+
+class Solution;
+class Pgr_pickDeliver;
+
+
+class Optimize : public Solution {
+ public:
+     Optimize(int kind,
+             const Solution &solution);
+
+     /* @brief decrease_truck
+      *
+      * Optimization by decreasing trucks
+      */
+     void decrease_truck();
+     bool move_reduce_cost();
+     void move_wait_time_based();
+     void move_duration_based();
+     void inter_swap();
+     Solution best_solution;
+ private:
+     void decrease_truck(size_t, bool&);
+     bool move_reduce_cost(size_t, size_t);
+     void sort_for_move();
+     void sort_by_duration();
+     void delete_empty_truck();
+
+     bool swap_worse(size_t from_pos, size_t to_pos);
+     bool inter_swap(bool reversed);
+
+     void move_order(
+             Order order,
+             Vehicle_pickDeliver &from_truck,
+             Vehicle_pickDeliver &to_truck); 
+     void swap_order(
+             Order from_order,
+             Vehicle_pickDeliver &from_truck,
+             Order to_order,
+             Vehicle_pickDeliver &to_truck); 
+     void save_if_best();
+
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/order.cpp b/src/pickDeliver/src/order.cpp
new file mode 100644
index 0000000..0bd5cb6
--- /dev/null
+++ b/src/pickDeliver/src/order.cpp
@@ -0,0 +1,190 @@
+/*PGR-GNU*****************************************************************
+
+FILE: order.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+
+#include <set>
+#include "./../../common/src/pgr_assert.h"
+#include "pgr_pickDeliver.h"
+#include "./order.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+std::set<size_t>
+Order::subsetI(const std::set<size_t> &I) const {
+    std::set<size_t> intersect;
+    std::set_intersection(m_compatibleI.begin(), m_compatibleI.end(),
+            I.begin(), I.end(),
+            std::inserter(intersect, intersect.begin()));
+    return intersect;
+}
+
+std::set<size_t>
+Order::subsetJ(const std::set<size_t> &J) const {
+    std::set<size_t> intersect;
+    std::set_intersection(m_compatibleJ.begin(), m_compatibleJ.end(),
+            J.begin(), J.end(),
+            std::inserter(intersect, intersect.begin()));
+    return intersect;
+}
+
+
+Order::Order(size_t p_id,
+        const Vehicle_node &p_pickup,
+        const Vehicle_node &p_delivery,
+        const Pgr_pickDeliver *p_problem) :
+    m_id(p_id),
+    pickup_id(p_pickup.id()),
+    delivery_id(p_delivery.id()),
+    problem(p_problem) {
+        pgassert(pickup().is_pickup());
+        pgassert(delivery().is_delivery());
+    }
+
+std::ostream&
+operator << (std::ostream &log, const Order &order) {
+    log << "\n\nOrder " << order.m_id << ":\n"
+        << "\tPickup: " << order.pickup() << "\n"
+        << "\tDelivery: " << order.delivery() << "\n\n";
+    if (order.delivery().is_partially_compatible_IJ(order.pickup())) {
+        log << "\tis_partially_compatible_IJ: ";
+    } else if (order.delivery().is_tight_compatible_IJ(order.pickup())) {
+        log << "\tis_tight_compatible_IJ: ";
+    } else if (order.delivery().is_waitTime_compatible_IJ(order.pickup())) {
+        log << "\tis_waitTime_compatible_IJ: ";
+    } else {
+        pgassert(false);
+    }
+    log << "\nThere are | {I}| = "
+        << order.m_compatibleI.size()
+        << " -> order(" << order.id()
+        << ") -> | {J}| = " << order.m_compatibleJ.size()
+        << "\n\n {";
+    for (const auto o : order.m_compatibleI) {
+        log << o << ", ";
+    }
+    log << "} -> " << order.id() << " -> {";
+    for (const auto o : order.m_compatibleJ) {
+        log << o << ", ";
+    }
+    log << "}";
+
+    return log;
+}
+
+
+
+const Vehicle_node&
+Order::delivery() const {return problem->node(delivery_id);}
+
+
+const Vehicle_node&
+Order::pickup() const {return problem->node(pickup_id);}
+
+
+bool
+Order::is_valid() const {
+    return
+        pickup().is_pickup()
+        && delivery().is_delivery()
+        /* P -> D */
+        && delivery().is_compatible_IJ(pickup());
+}
+
+
+/*
+ * Initializing the set of nodes that can be placed
+ * inmediately after \bthis node
+ *
+ * (*this) -> J
+ *
+ */
+
+void
+Order::setCompatibles() {
+    for (const auto J : problem->orders()) {
+        if (J.id() == id()) continue;
+        if (J.isCompatibleIJ(*this)) {
+            /*
+             * this -> {J}
+             */
+            m_compatibleJ.insert(J.id());
+        }
+        if (this->isCompatibleIJ(J)) {
+            /*
+             * {J} -> this
+             */
+            m_compatibleI.insert(J.id());
+        }
+    }
+}
+
+/*
+ * True when
+ *
+ * I -> (*this)
+ *
+ */
+
+bool
+Order::isCompatibleIJ(const Order &I) const {
+    /* this is true in all cases */
+    auto all_cases(
+            pickup().is_compatible_IJ(I.pickup())
+            && delivery().is_compatible_IJ(I.pickup()));
+
+    /* case other(P) other(D) this(P) this(D) */
+    auto case1(pickup().is_compatible_IJ(I.delivery())
+            && delivery().is_compatible_IJ(I.delivery()));
+
+    /* case other(P) this(P) other(D) this(D) */
+    auto case2(I.delivery().is_compatible_IJ(pickup())
+            && delivery().is_compatible_IJ(I.delivery()));
+
+    /* case other(P) this(P) this(D) other(D) */
+    auto case3(I.delivery().is_compatible_IJ(pickup())
+            && I.delivery().is_compatible_IJ(delivery()));
+
+    return all_cases &&  (case1 ||  case2 ||  case3);
+}
+
+
+#if 0
+bool
+Order::isOrderCompatibleEnd(const Vehicle_node &node) const {
+    return false;
+}
+
+bool
+Order::isOrderCompatibleStart(const Vehicle_node &node) const {
+    return false;
+}
+#endif
+
+}  //  namespace vrp
+}  //  namespace pgrouting
+
diff --git a/src/pickDeliver/src/order.h b/src/pickDeliver/src/order.h
new file mode 100644
index 0000000..37a3b65
--- /dev/null
+++ b/src/pickDeliver/src/order.h
@@ -0,0 +1,106 @@
+/*PGR-GNU*****************************************************************
+
+FILE: order.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+#pragma once
+
+#include <set>
+#include <iostream>
+#include "./vehicle_node.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+class Pgr_pickDeliver;
+class Initial_solution;
+
+
+class Order {
+ public:
+     friend class Initial_solution;
+     friend class Pgr_pickDeliver;
+
+     Order(size_t p_id,
+             const Vehicle_node &p_pickup,
+             const Vehicle_node &p_deliver,
+             const Pgr_pickDeliver *p_problem);
+
+     Order(const Order &) = default;
+
+
+
+     /*************accesosrs*/
+
+     inline size_t id() const {return m_id;}
+     const Vehicle_node& delivery() const;
+     const Vehicle_node& pickup() const;
+     void setCompatibles();
+
+     /*!
+      * An order is valid when:
+      *   - The pickup is well formed
+      *   - The delivery is well formed
+      *   - isCompatibleIJ to go to delivery after inmediatly visiting pickup
+      */
+     bool is_valid() const;
+
+
+     bool isCompatibleIJ(const Order &other) const;
+#if 0
+     bool isOrderCompatibleStart(const Vehicle_node &node) const;
+     bool isOrderCompatibleEnd(const Vehicle_node &node) const;
+#endif
+     std::set<size_t> subsetJ(const std::set<size_t> &J) const;
+     std::set<size_t> subsetI(const std::set<size_t> &I) const;
+
+     friend std::ostream& operator << (std::ostream&, const Order &);
+
+     //    void moveOrder(const int toRoute);
+ private:
+     size_t m_id;
+
+     size_t pickup_id;
+     size_t delivery_id;
+
+     /*
+      * I = this
+      * I -> {J}
+      */
+     std::set<size_t> m_compatibleJ;
+
+     /*
+      * J = this
+      * {I} -> J
+      */
+     std::set<size_t> m_compatibleI;
+
+
+     /* order belongs to this problem */
+     const Pgr_pickDeliver *problem;
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/pdp.c b/src/pickDeliver/src/pdp.c
deleted file mode 100644
index 49f5b44..0000000
--- a/src/pickDeliver/src/pdp.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-#include "postgres.h"
-#include "executor/spi.h"
-#include "funcapi.h"
-#include "catalog/pg_type.h"
-#if PGSQL_VERSION > 92
-#include "access/htup_details.h"
-#endif
-
-#include "fmgr.h"
-#include "./pdp.h"
-
-
-Datum vrppdtw(PG_FUNCTION_ARGS);
-
-
-// #define DEBUG 1
-#include "../../common/src/debug_macro.h"
-#include "../../common/src/postgres_connection.h"
-#include "./customers_input.h"
-
-
-
-
-static
-int compute_shortest_path(
-        char* sql,
-        int64_t vehicle_count,
-        double capacity,
-        path_element **results,
-        size_t *length_results_struct) {
-    PGR_DBG("start shortest_path\n");
-
-    pgr_SPI_connect();
-    char *err_msg = NULL;
-    size_t total_customers = 0;
-    Customer *customers = NULL;
-    pgr_get_customers(sql, &customers, &total_customers);
-
-
-    PGR_DBG("Calling Solver Instance\n");
-
-    int ret = Solver(customers, total_customers, vehicle_count,
-            capacity, &err_msg, results, length_results_struct);
-
-    if (ret < -2) {
-        ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED),
-                    errmsg("Error computing path: %s", err_msg)));
-    }
-
-
-    PGR_DBG("*length_results_count  = %i\n", *length_results_struct);
-    PGR_DBG("ret = %i\n", ret);
-
-    pfree(customers);
-    free(err_msg);
-    pgr_SPI_finish();
-    return 0;
-}
-
-
-
-PG_FUNCTION_INFO_V1(vrppdtw);
-Datum
-vrppdtw(PG_FUNCTION_ARGS) {
-    FuncCallContext     *funcctx;
-    int                  call_cntr;
-    int                  max_calls;
-    TupleDesc            tuple_desc;
-    path_element     *results = 0;
-
-
-    /* stuff done only on the first call of the function */
-
-    if (SRF_IS_FIRSTCALL()) {
-        MemoryContext   oldcontext;
-        size_t length_results_struct = 0;
-        funcctx = SRF_FIRSTCALL_INIT();
-        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-        results = (path_element *)palloc(sizeof(path_element)*((length_results_struct) + 1));
-
-        PGR_DBG("Calling compute_shortes_path");
-
-        compute_shortest_path(
-                pgr_text2char(PG_GETARG_TEXT_P(0)),  // customers sql
-                PG_GETARG_INT64(1),  // vehicles  count
-                PG_GETARG_FLOAT8(2),  // capacity 
-                &results, &length_results_struct);
-
-        PGR_DBG("Back from solve_vrp, length_results: %d", length_results_struct);
-
-        /* total number of tuples to be returned */
-        funcctx->max_calls = length_results_struct;
-        funcctx->user_fctx = results;
-
-        /* Build a tuple descriptor for our result type */
-        if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
-            ereport(ERROR,
-                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     errmsg("function returning record called in context "
-                         "that cannot accept type record")));
-
-        funcctx->tuple_desc = BlessTupleDesc(tuple_desc);
-        MemoryContextSwitchTo(oldcontext);
-    }
-
-    /* stuff done on every call of the function */
-    funcctx = SRF_PERCALL_SETUP();
-
-    call_cntr = funcctx->call_cntr;
-    max_calls = funcctx->max_calls;
-    tuple_desc = funcctx->tuple_desc;
-    results = (path_element *) funcctx->user_fctx;
-
-    /* do when there is more left to send */
-    if (call_cntr < max_calls) {
-        HeapTuple    tuple;
-        Datum        result;
-        Datum *values;
-        bool* nulls;
-
-        PGR_DBG("Till hereee ", NULL);
-        values = palloc(4 * sizeof(Datum));
-        nulls = palloc(4 * sizeof(bool));
-
-        nulls[0] = false;
-        nulls[1] = false;
-        nulls[2] = false;
-        nulls[3] = false;
-        values[0] = Int32GetDatum(results[call_cntr].seq);
-        values[1] = Int64GetDatum(results[call_cntr].rid);
-        values[2] = Int64GetDatum(results[call_cntr].nid);
-        values[3] = Float8GetDatum(results[call_cntr].cost);
-        tuple = heap_form_tuple(tuple_desc, values, nulls);
-
-        /* make the tuple into a datum */
-        result = HeapTupleGetDatum(tuple);
-
-        /* clean up (this is not really necessary) */
-        pfree(values);
-        pfree(nulls);
-
-        SRF_RETURN_NEXT(funcctx, result);
-    } else {
-        /* do when there is no more left */
-        free(results);
-        SRF_RETURN_DONE(funcctx);
-    }
-}
diff --git a/src/pickDeliver/src/pdp.h b/src/pickDeliver/src/pdp.h
deleted file mode 100644
index e569756..0000000
--- a/src/pickDeliver/src/pdp.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#include<stdio.h>
-#include<stdlib.h>
-#include<math.h>
-#include "postgres.h"
-
-#pragma once
-
-// For C and C++ inclusion
-
-typedef struct {
-        int64_t id;
-        double x;
-        double y;
-        double demand;
-        double Etime;
-        double Ltime;
-        double Stime;
-        int64_t Pindex;
-        int64_t Dindex;
-        double Ddist;
-} Customer;
-
-typedef struct  {
-         int64_t seq;
-         int64_t rid;
-         int64_t nid;
-         double cost;
-} path_element;
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-int64_t Solver(Customer *c,
-        size_t total_tuples,
-        int64_t vehicle_count,
-        int64_t capacity ,
-        char **msg,
-        path_element **results,
-        size_t *length_results);
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/src/pickDeliver/src/pdp.hpp b/src/pickDeliver/src/pdp.hpp
deleted file mode 100644
index 9477675..0000000
--- a/src/pickDeliver/src/pdp.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-#pragma once
-
-#include <math.h>
-#include <vector>
-
-// Exclusive for c++ inclusion
-
-typedef struct {
-        int64_t id;
-        double x;
-        double y;
-        double demand;
-        double Etime;
-        double Ltime;
-        double Stime;
-        int64_t Pindex;
-        int64_t Dindex;
-} Depot;
-
-
-typedef struct {
-        int64_t Pid;
-        double Ddist;
-        int64_t Did;
-} Pickup;
-
-typedef std::vector< Customer > Customers;
-typedef std::vector< Pickup > Pickups;
-
-
-// It is used to save some variables and helps if we need to revisit
-// previous state.
-
-typedef struct {
-        int64_t twv;
-        int64_t cv;
-        int64_t dis;
-        std::vector< int64_t > path;
-} State;
-
-template <class T1, class T2>
-double
-CalculateDistance(const T1 &from, const T2 &to) {
-        return sqrt((from.x - to.x) * (from.x - to.x)
-                + (from.y - to.y) * (from.y - to.y));
-}
diff --git a/src/pickDeliver/src/pdp_solver.cpp b/src/pickDeliver/src/pdp_solver.cpp
deleted file mode 100644
index 1425df9..0000000
--- a/src/pickDeliver/src/pdp_solver.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-
-/*
-
- *****list of files in this dir*******
- pdp.cpp --> Main solver
- pdp.h  ---> Structures defined in this header file
- Solution.h -----> It contains the Solution Class and Code related to Neighborhoods
- Route.h   -----> Explains all about Route Class.
- pdp.c ---> Contains all the details on pgRouting integration.
-
- The main problem is in two steps. 1.)Getting the initial solutiion and 2.)Optimizing it.
-
- 1.) "Initial solution":
- A few heuristics are applied to find a feasible initial solution. Sequential Construction and Hill climbing. More implementation details are found here:: https://github.com/pgRouting/pgrouting/wiki/VRP-Pickup-Delivery-Problem
-
- 2.) "Optimizing the Solution":
- A reactive tabu search is applied on the initial solution to get a feasible optimized solution. TabuSearch comes under local search methods. We have three neighborhoods
-            i) Single Paired Insertion
-            ii) Swapping pairs between routes
-            iii)Within Route Insertion.
-            Tabu attributes plays an important role in giving the best solution(it includes TabuLength, A vector containing feasible solutions and a counter for number of solutions).
-            Reactive part discussed in the paper is to modify TabuLength based on the solution cycle.
-
- */
-#ifdef __MINGW32__
-#include <winsock2.h>
-#include <windows.h>
-#endif
-
-
-#include <vector>
-#include <algorithm>
-
-#include "./pdp.h"
-#include "./pdp.hpp"
-#include "./Solution.h"
-#include "./Route.h"
-
-
-//forward declaration
-static
-int
-TabuSearch(
-        const std::vector<Customer> &customers,
-        const std::vector<Pickup> &pickups,
-        int maxIter,
-        std::vector<Solution> &T);
-
-static
-void
-get_result(
-        Solution &solution,
-        const std::vector < Customer > &customers,
-        const Depot &depot,
-        int64_t VehicleLength,
-        std::vector< path_element > &result);
-
-int64_t Solver(Customer *c1,
-        size_t total_tuples,
-        int64_t VehicleLength,
-        int64_t capacity,
-        char **msg,
-        path_element **results,
-        size_t *length_results_struct) {
-    std::vector<Customer> customers(c1, c1 + total_tuples);
-    std::vector<Pickup> pickups;
-    std::vector<Route> routes;
-
-    Depot depot({c1[0].id, c1[0].x, c1[0].y,
-            c1[0].demand,
-            c1[0].Etime, c1[0].Ltime, c1[0].Stime,
-            c1[0].Pindex, c1[0].Dindex
-            });
-
-    if (total_tuples != 107) {
-        return 0;
-    }
-
-
-    // Customer Data
-    for (auto &c : customers) {
-        if (c.id == 0) continue; 
-        c.Ddist = CalculateDistance(c, depot);
-        if (c.Pindex == 0) {
-            // From Customers put aside all the Pickup's;
-            Pickup pickup({c.id, c.Ddist, c.Dindex});
-            pickups.push_back(pickup);
-        }
-    }
-
-    if (pickups.size() != 53) {
-        (*results) = NULL;
-        (*length_results_struct) = 0;
-        return 0;
-    }
-
-    /* Sort Pickup's
-     * The sequential construction inserts from largest distance to smallest
-     * but he had it ordered from smallest to largest
-     */
-    std::sort(pickups.begin(), pickups.end(),
-            [] (const Pickup &p1, const Pickup &p2)
-            {return p2.Ddist < p1.Ddist;});
-
-
-    // Sequential Construction
-    size_t v = 0;
-    Route route(capacity, depot);
-    routes.push_back(route);
-    for (auto &pickup : pickups) {
-        int OK = 0;
-        OK = routes[v].insertOrder(customers, pickup);
-        if (OK) continue;
-        Route route(capacity, depot);
-        routes.push_back(route);
-        /* adding a new vehicle*/
-        ++v;
-        routes[v].insertOrder(customers, pickup);
-    }
-
-
-    std::sort(pickups.begin(), pickups.end(),
-            [] (const Pickup &p1, const Pickup &p2)
-            {return p1.Ddist < p2.Ddist;});
-
-    // Initial Solution
-    Solution S0;
-    S0.routes = routes;
-    //S0.UpdateSol(customers);
-
-    std::vector<Solution> T;
-    T.push_back(S0);
-
-    // Starting the TABU SEARCH
-
-    TabuSearch(customers, pickups, 30, T);
-
-
-    std::vector< path_element > result;
-#ifdef DEBUG
-    for (auto &solution: T) {
-        get_result(solution, customers, depot, VehicleLength, result);
-    }
-#else
-    T.back().UpdateSol(customers);
-    get_result(T.back(), customers, depot, VehicleLength, result);
-#endif
-
-
-
-    // Getting memory to store results
-    *results = static_cast<path_element *>(malloc(sizeof(path_element) * (result.size())));
-
-    //store the results
-    int seq = 0;
-    for (const auto &row : result) {
-        (*results)[seq] = row;
-        ++seq;
-    }
-
-    *length_results_struct = result.size();
-
-    (*msg) = NULL;
-    return 0;
-}
-
-
-
-
-
-
-
-/* TABU search helps us to store the solutions after every different move.
- * The overview of TABU search will be a list containing list of solutions
-
- **********Before*********
- int n = 0; //Counter
-
- Create Tabu List Vector of Solutions std::vector<Solution> T;
-
- **********After**********
- Solution S,S0,SBest; //S0 is initial
- S = S0;
- Double CBest,SBest;
- CBest = S.getCost();
- SBest = S0;
- n = 0; //Counter
- while(1)
- {
- S = S.getBextofNeighborhood();
- if (S ==NULL)
- break;
- if (S.getCost() < CBest){
- SBest = S;
- CBest = S.getCost();
- }
- T.push_back(S);
- n++;
- if (n>maxItr)
- break;
- }
-
-*/
-static
-int
-TabuSearch(const std::vector<Customer> &customers,
-        const std::vector<Pickup> &pickups,
-        int maxItr,
-        std::vector<Solution> &T) {
-    Solution S;
-    Solution SBest;
-    double CBest;
-    S = T[0];
-    CBest = S.getCost();
-    SBest = S;
-
-    S.UpdateSol(customers);
-
-    int n = 0;
-    while (n++ < maxItr) {
-        S = S.getBestofNeighborhood(S, customers, pickups);
-        S.UpdateSol(customers);
-        T.push_back(S);
-        if (S.getCost() == 0) break;
-        if (S.getCost() < CBest) {
-            SBest = S;
-            CBest = S.getCost();
-        } else if (S.getCost() == CBest) {
-            // printf("\n****************Repeated Solution****************\n");
-            int k = ((12)*maxItr)/100;
-            maxItr = maxItr-k;
-            // printf("Maxitr after repeating %d k = %d\n",maxItr,k);
-        }
-    }
-    T.push_back(SBest);
-    return T.size()-1;
-}
-
-
-/*
- * For each route in the solution:
- *    For each node in the route in the solution:
- *       this is the route.
- *       d, p0, p1 .... pn, d
- *       (rid, nid, cost) 
- *       (1, d, 0)
- *       (1, p0, 0 + dist(d, p0) OR etime)
- */
-static
-void
-get_result(
-        Solution &solution,
-        const Customers &customers,
-        const Depot &depot,
-        int64_t VehicleLength,
-        std::vector< path_element > &result) {
-#if DEBUG
-    double last_cost = 0;
-    int twv = 0;
-    int cv = 0;
-#endif
-    int route_id = 0;
-    int seq = 1;
-    solution.UpdateSol(customers);
-    for (const auto &route : solution.routes) {
-        double agg_cost = 0;
-        double distance = 0;
-        int agg_load = 0;
-        result.push_back({seq, route_id, depot.id, agg_cost});
-        ++seq;
-
-        int prev_node = -1;
-        for (const auto &node : route.path) {
-
-            if (node == route.path.front()) {
-                /*
-                 * Is the first node or last node in the path
-                 */
-                distance = CalculateDistance(depot, customers[node]);
-                agg_cost += distance;
-            } else {
-                /*
-                 * Between nodes
-                 */
-                distance = CalculateDistance(customers[prev_node], customers[node]);
-                agg_cost += distance;
-            }
-
-            if (agg_cost < customers[node].Etime) {
-                /*
-                 * Arrving before the opening time, adjust time, moving it to the opening time
-                 */
-                agg_cost = customers[node].Etime;
-            }
-
-            agg_load +=  customers[node].demand;
-
-            result.push_back({
-                    seq,
-                    route_id,
-                    customers[node].id,
-                    agg_cost});
-#ifdef DEBUG
-            result.push_back({
-                    customers[node].id,
-                    customers[node].Etime,
-                    customers[node].Ltime,
-                    distance});
-            result.push_back({
-                    seq,
-                    agg_cost > customers[node].Ltime? ++twv: twv,
-                    agg_load > 200? ++cv: cv,
-                    0});
-            last_cost = agg_cost;
-#endif
-            agg_cost +=  customers[node].Stime;
-            prev_node = node;
-            ++seq;
-        }
-        /*
-         * Going back to the depot
-         */
-        agg_cost += CalculateDistance(customers[prev_node], depot);
-        result.push_back({seq, route_id, depot.id, agg_cost});
-        ++seq;
-        ++route_id;
-#if 1
-        if (VehicleLength < route_id) break;
-#endif
-    }
-    result.push_back({0, 0, 0, solution.getCost()});
-}
-
diff --git a/src/pickDeliver/src/pgr_pickDeliver.cpp b/src/pickDeliver/src/pgr_pickDeliver.cpp
new file mode 100644
index 0000000..26849fc
--- /dev/null
+++ b/src/pickDeliver/src/pgr_pickDeliver.cpp
@@ -0,0 +1,357 @@
+/*PGR-GNU*****************************************************************
+
+FILE: pgr_pickDeliver.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include <algorithm>
+
+#include "./../../common/src/pgr_types.h"
+#include "./../../common/src/pgr_assert.h"
+
+#include "./vehicle_node.h"
+#include "./vehicle_pickDeliver.h"
+#include "./order.h"
+#include "./solution.h"
+#include "./initial_solution.h"
+#include "./optimize.h"
+#include "./pgr_pickDeliver.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+
+Solution
+Pgr_pickDeliver::solve(const Solution init_solution) {
+    Optimize solution(0, init_solution);
+    solution.decrease_truck();
+    solution.move_duration_based();
+    solution.move_wait_time_based();
+    solution.inter_swap();
+    return solution.best_solution;
+}
+
+void
+Pgr_pickDeliver::solve() {
+#if 0
+    solutions.push_back(Initial_solution(0, this));
+#endif
+    solutions.push_back(Initial_solution(1, this));
+
+    solutions.push_back(solve(solutions.back()));
+
+#if 1
+    solutions.push_back(Initial_solution(2, this));
+    solutions.push_back(solve(solutions.back()));
+    solutions.push_back(Initial_solution(3, this));
+    solutions.push_back(solve(solutions.back()));
+    solutions.push_back(Initial_solution(4, this));
+    solutions.push_back(solve(solutions.back()));
+    solutions.push_back(Initial_solution(5, this));
+    solutions.push_back(solve(solutions.back()));
+    solutions.push_back(Initial_solution(6, this));
+    solutions.push_back(solve(solutions.back()));
+#endif
+
+#if 1
+    /*
+     * Sorting solutions: the best is at the back
+     */
+    std::sort(solutions.begin(), solutions.end(), []
+            (const Solution &lhs, const Solution &rhs) -> bool {
+            return rhs < lhs;
+            });
+#endif
+}
+
+
+
+void
+Pgr_pickDeliver::get_postgres_result(
+        std::vector< General_vehicle_orders_t > &result) const {
+    solutions.back().get_postgres_result(result);
+
+    General_vehicle_orders_t aggregates = {
+            /*
+             * Vehicle id = -1 indicates its an aggregate row
+             *
+             * (twv, cv, fleet, wait, duration)
+             */
+            -1,
+            solutions.back().twvTot(),
+            solutions.back().cvTot(),
+            solutions.back().total_travel_time(),
+            0,  // not accounting arrival_travel_time
+            solutions.back().wait_time(),
+            solutions.back().total_service_time(),
+            solutions.back().duration(),
+            };
+    result.push_back(aggregates);
+
+
+    for (const auto sol : solutions) {
+        log << sol.tau();
+    }
+}
+
+
+
+/***** Constructor *******/
+
+Pgr_pickDeliver::Pgr_pickDeliver(
+        const Customer_t *customers_data, size_t total_customers,
+        int p_max_vehicles,
+        double p_capacity,
+        double p_speed,
+        size_t p_max_cycles,
+        std::string &error) :
+    /* Set the depot to be the first ddata found */
+    max_capacity(p_capacity),
+    m_speed(p_speed),
+    m_max_cycles(p_max_cycles),
+    max_vehicles(p_max_vehicles),
+    m_starting_site({0, customers_data[0], Tw_node::NodeType::kStart, this}),
+    m_ending_site({0, customers_data[0], Tw_node::NodeType::kEnd, this}),
+    m_original_data(customers_data, customers_data + total_customers) {
+        pgassert(m_speed > 0);
+        pgassert(m_max_cycles > 0);
+        pgassert(max_vehicles > 0);
+        std::ostringstream tmplog;
+        error = "";
+
+        log << "\n *** Constructor of problem ***\n";
+
+        /* sort data by id */
+        std::sort(m_original_data.begin(), m_original_data.end(),
+                [] (const Customer_t &c1, const Customer_t &c2)
+                {return c1.id < c2.id;});
+
+        /*
+         * starting node:
+         * id must be 0
+         */
+        if (m_original_data[0].id != 0) {
+            error = "Depot node not found";
+            return;
+        }
+
+        m_starting_site = Vehicle_node(
+                {0, customers_data[0], Tw_node::NodeType::kStart, this});
+        m_ending_site = Vehicle_node(
+                {1, customers_data[0], Tw_node::NodeType::kEnd, this});
+        if (!m_starting_site.is_start()) {
+            log << "DEPOT" << m_starting_site;
+            error = "Illegal values found on the starting site";
+            return;
+        }
+        pgassert(m_starting_site.is_start());
+        pgassert(m_ending_site.is_end());
+
+        m_nodes.push_back(m_starting_site);
+        m_nodes.push_back(m_ending_site);
+
+
+        ID order_id(0);
+        ID node_id(2);
+        for (const auto p : m_original_data) {
+            /*
+             * skip Starting site
+             */
+            if (p.id == 0) continue;
+
+            /*
+             * SAMPLE CORRECT INFORMATION
+             *
+             * The Pickup is 11 (pindex == 0)
+             * The Deliver is 1 (dindex == 0)
+             *
+             * id | x | y | demand | etime | Ltime | Stime | pindex | dindex
+             * 1 | 45 | 68 |    -10 |   912 |   967 |    90 |     11 |      0
+             * 11 | 35 | 69 |     10 |   448 |   505 |    90 |      0 |      1
+             *
+             */
+
+            /*
+             * skip deliveries
+             */
+            if (p.Dindex == 0) continue;
+
+            /*
+             * pickup is found
+             */
+            Tw_node pickup({node_id++, p, Tw_node::NodeType::kPickup, this});
+            if (!pickup.is_pickup()) {
+                log << "PICKUP" << pickup;
+                tmplog << "Illegal values found on Pickup " << p.id;
+                error = tmplog.str();
+                return;
+            }
+            pgassert(pickup.is_pickup());
+
+
+            /*
+             * look for corresponding the delivery of the pickup
+             */
+            auto deliver_ptr = std::lower_bound(
+                    m_original_data.begin(),
+                    m_original_data.end(),
+                    p,
+                    [] (const Customer_t &delivery, const Customer_t &pick)
+                    -> bool
+                    {return delivery.id < pick.Dindex;});
+
+            if (deliver_ptr == m_original_data.end()
+                     || deliver_ptr->id != p.Dindex) {
+                tmplog << "For Pickup "
+                    << p.id
+                    << " the corresponding Delivery was not found";
+                error = tmplog.str();
+                return;
+            }
+
+
+            /*
+             * delivery is found
+             */
+            Tw_node delivery(
+                    node_id++,
+                    (*deliver_ptr),
+                    Tw_node::NodeType::kDelivery,
+                    this);
+            if (!delivery.is_delivery()) {
+                log << "DELIVERY" << delivery;
+                tmplog << "Illegal values found on Delivery "
+                    << deliver_ptr->id;
+                error = tmplog.str();
+                return;
+            }
+            pgassert(delivery.is_delivery());
+
+
+            /*
+             * add into an order & check the order
+             */
+            pickup.set_Did(delivery.id());
+            delivery.set_Pid(pickup.id());
+            m_nodes.push_back(pickup);
+            m_nodes.push_back(delivery);
+
+            m_orders.push_back(
+                    Order(order_id, node(node_id - 2),
+                        node(node_id - 1),
+                        this));
+            pgassert(m_orders.back().pickup().is_pickup());
+            pgassert(m_orders.back().delivery().is_delivery());
+            pgassert(static_cast<Tw_node> (m_orders.back().pickup()) == pickup);
+
+            /*
+             * check the (S, P, D, E) order
+             */
+            {
+                Vehicle_pickDeliver truck(
+                        order_id,
+                        m_starting_site,
+                        m_ending_site,
+                        max_capacity,
+                        this);
+                truck.push_back(m_orders.back());
+
+                if (!truck.is_feasable()) {
+                    log << truck << "\n";
+                    tmplog << "The (pickup, delivery) = ("
+                        << m_orders.back().pickup().original_id() << ", "
+                        << m_orders.back().delivery().original_id()
+                        << ") is not feasible";
+                    error = tmplog.str();
+                    return;
+                }
+                pgassert(truck.is_feasable());
+            }  //  check
+
+            ++order_id;
+        }  //  for
+
+        /*
+         * double check we found all orders
+         */
+        if (((m_orders.size() * 2 + 1) - m_original_data.size()) != 0) {
+            error = "A pickup was not found";
+            return;
+        }
+
+        for (auto &o : m_orders) {
+            o.setCompatibles();
+        }
+
+        for (auto o : m_orders) {
+            log << o;
+        }
+    }  //  constructor
+
+
+const Order
+Pgr_pickDeliver::order_of(const Vehicle_node &node) const {
+    pgassert(node.is_pickup() ||  node.is_delivery());
+    if (node.is_pickup()) {
+        for (const auto o : m_orders) {
+            if (o.pickup().id() == node.id()) {
+                return o;
+            }
+        }
+    }
+    pgassert(node.is_delivery());
+
+    for (const auto o : m_orders) {
+        if (o.delivery().id() == node.id()) {
+            return o;
+        }
+    }
+#ifndef NDEBUG
+    std::ostringstream err_log;
+    err_log << "Order of" << node << " not found";
+#endif
+    pgassertwm(false, err_log.str());
+    return m_orders[0];
+}
+
+
+const Vehicle_node&
+Pgr_pickDeliver::node(ID id) const {
+    pgassert(id < m_nodes.size());
+    pgassert(id == m_nodes[id].id());
+    return m_nodes[id];
+}
+
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/pgr_pickDeliver.h b/src/pickDeliver/src/pgr_pickDeliver.h
new file mode 100644
index 0000000..9941a4e
--- /dev/null
+++ b/src/pickDeliver/src/pgr_pickDeliver.h
@@ -0,0 +1,108 @@
+/*PGR-GNU*****************************************************************
+
+FILE: pgr_pickDeliver.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#pragma once
+
+#ifdef __MINGW32__
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include "./../../common/src/pgr_types.h"
+
+#include <string>
+#include <vector>
+#include <sstream>
+
+#include "./vehicle_node.h"
+#include "./order.h"
+#include "./solution.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+class Optimize;
+class Initial_solution;
+
+class Pgr_pickDeliver {
+    friend class Vehicle_pickDeliver;
+    friend class Optimize;
+    friend class Initial_solution;
+    friend class Solution;
+    typedef size_t ID;
+
+ public:
+    Pgr_pickDeliver(
+            const Customer_t *c1, size_t total_customers,
+            int VehicleLength,
+            double capacity,
+            double speed,
+            size_t max_cycles,
+            std::string &error);
+
+    void solve();
+
+    void get_postgres_result(
+            std::vector< General_vehicle_orders_t > &result) const;
+    /*****************/
+
+    const Order order_of(const Vehicle_node &node) const;
+    const Vehicle_node& node(ID id) const;
+    const std::vector<Order>& orders() const {return m_orders;}
+    double speed() const {return m_speed;}
+
+    /*! \brief get_log
+     *
+     * \returns the current contents of the log and clears the log
+     *
+     */
+    std::ostream& get_log(std::ostream &p_log) const {
+        p_log << log.str() << "\n";
+        log.str("");
+        log.clear();
+        return p_log;
+    }
+
+    Solution solve(const Solution init_solution);
+    size_t max_cycles() const {return m_max_cycles;};
+
+ private:
+    double max_capacity;
+    double m_speed;
+    size_t m_max_cycles;
+    int max_vehicles;
+    Vehicle_node m_starting_site, m_ending_site;
+    std::vector<Customer_t> m_original_data;
+    std::vector<Vehicle_node> m_nodes;
+    std::vector<Order> m_orders;
+    std::vector<Solution> solutions;
+    mutable std::ostringstream log;
+#ifndef NDEBUG
+    mutable std::ostringstream dbg_log;
+#endif
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/dijkstra/src/one_to_one_dijkstra.c b/src/pickDeliver/src/pickDeliver.c
similarity index 56%
copy from src/dijkstra/src/one_to_one_dijkstra.c
copy to src/pickDeliver/src/pickDeliver.c
index d099701..cd2cb88 100644
--- a/src/dijkstra/src/one_to_one_dijkstra.c
+++ b/src/pickDeliver/src/pickDeliver.c
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: one_to_one_dijkstra.c
+File: pickDeliver.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
@@ -7,7 +7,7 @@ Mail: project at pgrouting.org
 
 Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: vicky_vergara at hotmail.com
+Mail:
 
 ------
 
@@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-********************************************************************PGR-GNU*/
+ ********************************************************************PGR-GNU*/
 
 #include "postgres.h"
 #include "executor/spi.h"
@@ -35,97 +35,108 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
+#include "fmgr.h"
 
-/*
-  Uncomment when needed
-*/
 // #define DEBUG
 
-#include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
-#include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
-#include "./../../common/src/edges_input.h"
-#include "./one_to_one_dijkstra_driver.h"
+#include "./customers_input.h"
 
-PG_MODULE_MAGIC;
+#include "./pickDeliver_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_dijkstra);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS);
+pickDeliver(PG_FUNCTION_ARGS);
 
-/******************************************************************************/
-/*                          MODIFY AS NEEDED                                  */
+
+/*********************************************************************/
+/*                MODIFY AS NEEDED                                   */
 static
 void
-process(
-        char* edges_sql,
-        int64_t start_vid,
-        int64_t end_vid,
-        bool directed,
-        bool only_cost,
-        General_path_element_t **result_tuples,
+process(char* customers_sql,
+        int max_vehicles,
+        double capacity,
+        double speed,
+        int max_cycles,
+        General_vehicle_orders_t **result_tuples,
         size_t *result_count) {
-    pgr_SPI_connect();
-
-    PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
 
-    if (start_vid == end_vid) {
+    if (max_vehicles <= 0) {
+        elog(ERROR, "Illegal value in parameter: max_vehicles");
+        (*result_count) = 0;
+        (*result_tuples) = NULL;
+        return;
+    }
+    if (capacity <= 0) {
+        elog(ERROR, "Illegal value in parameter: capacity");
+        (*result_count) = 0;
+        (*result_tuples) = NULL;
+        return;
+    }
+    if (speed <= 0) {
+        elog(ERROR, "Illegal value in parameter: speed");
+        (*result_count) = 0;
+        (*result_tuples) = NULL;
+        return;
+    }
+    if (max_cycles <= 0) {
+        elog(ERROR, "Illegal value in parameter: max_cycles");
         (*result_count) = 0;
         (*result_tuples) = NULL;
-        pgr_SPI_finish();
         return;
     }
 
-    size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    pgr_SPI_connect();
+
+    PGR_DBG("Load data");
+    Customer_t *customers_arr = NULL;
+    size_t total_customers = 0;
+    pgr_get_customers_data(customers_sql, &customers_arr, &total_customers);
 
-    if (total_tuples == 0) {
-        PGR_DBG("No edges found");
+    if (total_customers == 0) {
+        PGR_DBG("No customers found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_tuples);
+    PGR_DBG("Total %ld customers in query:", total_customers);
 
     PGR_DBG("Starting processing");
-    clock_t start_t = clock();
+    char *log_msg = NULL;
     char *err_msg = NULL;
-    do_pgr_one_to_one_dijkstra(
-            edges,
-            total_tuples,
-            start_vid,
-            end_vid,
-            directed,
-            only_cost,
+    do_pgr_pickDeliver(
+            customers_arr, total_customers,
+            max_vehicles,
+            capacity,
+            speed,
+            max_cycles,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
-
-    time_msg(" processing Dijkstra one to one", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    PGR_DBG("Returned log = %s\n", log_msg);
+    if (log_msg) {
+        elog(DEBUG1, "%s", log_msg);
+        free(log_msg);
+    }
+    if (err_msg) {
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
+
 
-    free(err_msg);
-    pfree(edges);
+    pfree(customers_arr);
     pgr_SPI_finish();
 }
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(pickDeliver);
 PGDLLEXPORT Datum
-#endif
-one_to_one_dijkstra(PG_FUNCTION_ARGS) {
+pickDeliver(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
     uint32_t               max_calls;
@@ -134,7 +145,7 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    General_vehicle_orders_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
@@ -144,26 +155,28 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
         funcctx = SRF_FIRSTCALL_INIT();
         oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
-
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text, start_vids BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+        /*
+           orders_sql TEXT,
+           max_vehicles INTEGER,
+           capacity FLOAT,
+           speed FLOAT,
+           max_cycles INTEGER,
+         **********************************************************************/
 
         PGR_DBG("Calling process");
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
-                PG_GETARG_INT64(1),
-                PG_GETARG_INT64(2),
-                PG_GETARG_BOOL(3),
-                PG_GETARG_BOOL(4),
+                PG_GETARG_INT32(1),
+                PG_GETARG_FLOAT8(2),
+                PG_GETARG_FLOAT8(3),
+                PG_GETARG_INT32(4),
                 &result_tuples,
                 &result_count);
 
-        /*                                                                    */
-        /**********************************************************************/
+        /*                                                                   */
+        /*********************************************************************/
 
         funcctx->max_calls = (uint32_t)result_count;
         funcctx->user_fctx = result_tuples;
@@ -183,7 +196,7 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
     call_cntr = funcctx->call_cntr;
     max_calls = funcctx->max_calls;
     tuple_desc = funcctx->tuple_desc;
-    result_tuples = (General_path_element_t*) funcctx->user_fctx;
+    result_tuples = (General_vehicle_orders_t*) funcctx->user_fctx;
 
     if (call_cntr < max_calls) {
         HeapTuple    tuple;
@@ -191,32 +204,40 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
         Datum        *values;
         bool*        nulls;
 
-        /**********************************************************************/
-        /*                          MODIFY AS NEEDED                          */
-        // OUT seq INTEGER,
-        // OUT path_seq INTEGER,
-        // OUT node BIGINT,
-        // OUT edge BIGINT,
-        // OUT cost FLOAT,
-        // OUT agg_cost FLOAT
+        /*********************************************************************/
+        /*                          MODIFY!!!!!                              */
+        /* This has to match you output otherwise the server crashes          */
+        /*
+           OUT seq INTEGER,
+           OUT vehicle_id INTEGER,
+           OUT vehicle_seq INTEGER,
+           OUT order_id BIGINT,
+           OUT cost FLOAT,
+           OUT agg_cost FLOAT
+         *********************************************************************/
 
-        values = palloc(6 * sizeof(Datum));
-        nulls = palloc(6 * sizeof(bool));
 
+        values = palloc(9 * sizeof(Datum));
+        nulls = palloc(9 * sizeof(bool));
 
         size_t i;
-        for (i = 0; i < 6; ++i) {
+        for (i = 0; i < 9; ++i) {
             nulls[i] = false;
         }
 
+
         // postgres starts counting from 1
         values[0] = Int32GetDatum(call_cntr + 1);
-        values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
-        values[2] = Int64GetDatum(result_tuples[call_cntr].node);
-        values[3] = Int64GetDatum(result_tuples[call_cntr].edge);
-        values[4] = Float8GetDatum(result_tuples[call_cntr].cost);
-        values[5] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
-        /**********************************************************************/
+        values[1] = Int32GetDatum(result_tuples[call_cntr].vehicle_id);
+        values[2] = Int32GetDatum(result_tuples[call_cntr].vehicle_seq);
+        values[3] = Int64GetDatum(result_tuples[call_cntr].order_id);
+        values[4] = Float8GetDatum(result_tuples[call_cntr].travelTime);
+        values[5] = Float8GetDatum(result_tuples[call_cntr].arrivalTime);
+        values[6] = Float8GetDatum(result_tuples[call_cntr].waitTime);
+        values[7] = Float8GetDatum(result_tuples[call_cntr].serviceTime);
+        values[8] = Float8GetDatum(result_tuples[call_cntr].departureTime);
+
+        /*********************************************************************/
 
         tuple = heap_form_tuple(tuple_desc, values, nulls);
         result = HeapTupleGetDatum(tuple);
@@ -228,4 +249,3 @@ one_to_one_dijkstra(PG_FUNCTION_ARGS) {
         SRF_RETURN_DONE(funcctx);
     }
 }
-
diff --git a/src/pickDeliver/src/pickDeliver_driver.cpp b/src/pickDeliver/src/pickDeliver_driver.cpp
new file mode 100644
index 0000000..72c8379
--- /dev/null
+++ b/src/pickDeliver/src/pickDeliver_driver.cpp
@@ -0,0 +1,127 @@
+/*PGR-GNU*****************************************************************
+File: pickDeliver_driver.cpp
+
+Generated with Template by:
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+Function's developer:
+Copyright (c) 2015 Celia Virginia Vergara Castillo
+Mail:
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include "./pickDeliver_driver.h"
+#include <string.h>
+#include <sstream>
+#include <string>
+#include <deque>
+#include <vector>
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_types.h"
+#include "./../../common/src/pgr_alloc.hpp"
+#include "./pgr_pickDeliver.h"
+
+/************************************************************
+  customers_sql TEXT,
+  max_vehicles INTEGER,
+  capacity FLOAT,
+  max_cycles INTEGER,
+ ***********************************************************/
+void
+do_pgr_pickDeliver(
+        Customer_t *customers_arr,
+        size_t total_customers,
+        int max_vehicles,
+        double capacity,
+        double speed,
+        int max_cycles,
+        General_vehicle_orders_t **result_tuples,
+        size_t *total_count,
+        char ** log_msg,
+        char ** err_msg) {
+    std::ostringstream log;
+    try {
+        std::ostringstream tmp_log;
+        *result_tuples = NULL;
+        *total_count = 0;
+
+        log << "Read data\n";
+        std::string error("");
+        pgrouting::vrp::Pgr_pickDeliver pd_problem(
+                customers_arr,
+                total_customers,
+                max_vehicles,
+                capacity,
+                speed,
+                max_cycles,
+                error);
+        if (error.compare("")) {
+            pd_problem.get_log(log);
+            *log_msg = strdup(log.str().c_str());
+            *err_msg = strdup(error.c_str());
+            return;
+        }
+        pd_problem.get_log(tmp_log);
+        log << "Finish Reading data\n";
+
+        try {
+            pd_problem.solve();
+        } catch (AssertFailedException &except) {
+            pd_problem.get_log(log);
+            throw except;
+        }
+
+        pd_problem.get_log(log);
+        log << "Finish solve\n";
+
+        std::vector<General_vehicle_orders_t> solution;
+        pd_problem.get_postgres_result(solution);
+        pd_problem.get_log(tmp_log);
+        log << "solution size: " << solution.size() << "\n";
+
+
+        (*result_tuples) = pgr_alloc(solution.size(), (*result_tuples));
+        int seq = 0;
+        for (const auto &row : solution) {
+            (*result_tuples)[seq] = row;
+            ++seq;
+        }
+        (*total_count) = solution.size();
+
+        pd_problem.get_log(log);
+        *log_msg = strdup(log.str().c_str());
+    } catch (AssertFailedException &except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+    } catch(...) {
+        log << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+    }
+}
+
diff --git a/src/ksp/src/withPoints_ksp_driver.h b/src/pickDeliver/src/pickDeliver_driver.h
similarity index 56%
copy from src/ksp/src/withPoints_ksp_driver.h
copy to src/pickDeliver/src/pickDeliver_driver.h
index e304dae..babbc8b 100644
--- a/src/ksp/src/withPoints_ksp_driver.h
+++ b/src/pickDeliver/src/pickDeliver_driver.h
@@ -1,12 +1,12 @@
 /*PGR-GNU*****************************************************************
-File: withPoints_driver.h
+File: pickDeliver_driver.h
 
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -24,39 +24,38 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-********************************************************************PGR-GNU*/
-
+ ********************************************************************PGR-GNU*/
 #pragma once
+#ifndef SRC_PICKDELIVER_SRC_PICKDELIVER_DRIVER_H_
+#define SRC_PICKDELIVER_SRC_PICKDELIVER_DRIVER_H_
+
+#include <stddef.h>
+#include "./../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "./../../common/src/pgr_types.h"
-
-    //  CREATE OR REPLACE FUNCTION pgr_withPointKsp(
-    //  edges_sql TEXT,
-    //  points_sql TEXT,
-    //  start_pid BIGINT,
-    //  end_pid BIGINT,
-    //  directed BOOLEAN DEFAULT true,
-    int do_pgr_withPointsKsp(
-            pgr_edge_t  *edges,             size_t total_edges,
-            Point_on_edge_t  *points,       size_t total_points,
-            pgr_edge_t  *edges_of_points,   size_t total_edges_of_points,
-            int64_t start_pid,
-            int64_t end_pid,
-            int k,
-            bool directed,
-            bool heap_paths,
-            char driving_side,
-            bool details,
-
-            General_path_element_t **return_tuples,
+    /*********************************************************
+      orders_sql TEXT,
+      max_vehicles INTEGER,
+      capacity FLOAT,
+      max_cycles INTEGER,
+     ********************************************************/
+    void do_pgr_pickDeliver(
+            Customer_t *customers_arr, size_t total_customers,
+            int max_vehicles,
+            double capacity,
+            double speed,
+            int max_cycles,
+            General_vehicle_orders_t **return_tuples,
             size_t *return_count,
+            char ** log_msg,
             char ** err_msg);
 
+
 #ifdef __cplusplus
 }
 #endif
 
+#endif  //  SRC_PICKDELIVER_SRC_PICKDELIVER_DRIVER_H_
diff --git a/src/pickDeliver/src/solution.cpp b/src/pickDeliver/src/solution.cpp
new file mode 100644
index 0000000..c210701
--- /dev/null
+++ b/src/pickDeliver/src/solution.cpp
@@ -0,0 +1,225 @@
+/*PGR-GNU*****************************************************************
+
+FILE: solution.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+
+#include <string>
+#include <vector>
+
+#include "./solution.h"
+#include "./pgr_pickDeliver.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+void
+Solution::get_postgres_result(
+        std::vector< General_vehicle_orders_t > &result) const {
+    /* postgres numbering starts with 1 */
+    int i(1);
+    for (const auto truck : fleet) {
+        std::vector< General_vehicle_orders_t > data;
+        truck.get_postgres_result(i, data);
+        result.insert(result.end(), data.begin(), data.end());
+
+        ++i;
+    }
+}
+
+
+
+bool
+Solution::is_feasable() const {
+    for (const auto v : fleet) {
+        if (v.is_feasable()) continue;
+        return false;
+    }
+    return true;
+}
+
+double
+Solution::duration() const {
+    double total(0);
+    for (const auto v : fleet) {
+        total += v.duration();
+    }
+    return total;
+}
+
+int
+Solution::twvTot() const {
+    int total(0);
+    for (const auto v : fleet) {
+        total += v.twvTot();
+    }
+    return total;
+}
+
+double
+Solution::wait_time() const {
+    double total(0);
+    for (const auto v : fleet) {
+        total += v.total_wait_time();
+    }
+    return total;
+}
+
+double
+Solution::total_travel_time() const {
+    double total(0);
+    for (const auto v : fleet) {
+        total += v.total_travel_time();
+    }
+    return total;
+}
+
+double
+Solution::total_service_time() const {
+    double total(0);
+    for (const auto v : fleet) {
+        total += v.total_service_time();
+    }
+    return total;
+}
+
+int
+Solution::cvTot() const {
+    int total(0);
+    for (const auto v : fleet) {
+        total += v.cvTot();
+    }
+    return total;
+}
+
+Vehicle::Cost
+Solution::cost() const {
+    double total_duration(0);
+    double total_wait_time(0);
+    int total_twv(0);
+    int total_cv(0);
+    for (const auto v : fleet) {
+        total_duration += v.duration();
+        total_wait_time += v.total_wait_time();
+        total_twv += v.twvTot();
+        total_cv += v.cvTot();
+    }
+    return std::make_tuple(
+            total_twv, total_cv, fleet.size(),
+            total_wait_time, total_duration);
+}
+
+
+
+std::string
+Solution::cost_str() const {
+    Vehicle::Cost s_cost(cost());
+    std::ostringstream log;
+
+    log << "(twv, cv, fleet, wait, duration) = ("
+        << std::get<0>(s_cost) << ", "
+        << std::get<1>(s_cost) << ", "
+        << std::get<2>(s_cost) << ", "
+        << std::get<3>(s_cost) << ", "
+        << std::get<4>(s_cost) << ")";
+
+    return log.str();
+}
+
+std::string
+Solution::tau(const std::string &title) const {
+    Vehicle::Cost s_cost(cost());
+    std::ostringstream log;
+
+    log << "\n" << title << ": " << std::endl;
+    for (const auto v : fleet) {
+        log << "\n" << v.tau();
+    }
+    log << "\n" << cost_str() << "\n";
+    return log.str();
+}
+
+std::ostream&
+operator << (std::ostream &log, const Solution &solution) {
+    for (const auto vehicle : solution.fleet) {
+        log << vehicle;
+    }
+
+    log << "\n SOLUTION:\n\n "
+        << solution.tau();
+
+    return log;
+}
+
+bool
+Solution::operator<(const Solution &s_rhs) const {
+    Vehicle::Cost lhs(cost());
+    Vehicle::Cost rhs(s_rhs.cost());
+
+    /*
+     * capacity violations
+     */
+    if (std::get<0>(lhs) < std::get<0>(rhs))
+        return true;
+    if (std::get<0>(lhs) > std::get<0>(rhs))
+        return false;
+
+    /*
+     * time window violations
+     */
+    if (std::get<1>(lhs) < std::get<1>(rhs))
+        return true;
+    if (std::get<1>(lhs) > std::get<1>(rhs))
+        return false;
+
+    /*
+     * fleet size
+     */
+    if (std::get<2>(lhs) < std::get<2>(rhs))
+        return true;
+    if (std::get<2>(lhs) > std::get<2>(rhs))
+        return false;
+
+    /*
+     * waiting time
+     */
+    if (std::get<3>(lhs) < std::get<3>(rhs))
+        return true;
+    if (std::get<3>(lhs) > std::get<3>(rhs))
+        return false;
+
+    /*
+     * duration
+     */
+    if (std::get<4>(lhs) < std::get<4>(rhs))
+        return true;
+    if (std::get<4>(lhs) > std::get<4>(rhs))
+        return false;
+
+    return false;
+}
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/solution.h b/src/pickDeliver/src/solution.h
new file mode 100644
index 0000000..786561c
--- /dev/null
+++ b/src/pickDeliver/src/solution.h
@@ -0,0 +1,125 @@
+/*PGR-GNU*****************************************************************
+
+FILE: solution.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#pragma once
+
+#include <deque>
+#include <tuple>
+#include <string>
+#include <vector>
+
+#include "./vehicle_pickDeliver.h"
+#include "./order.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+class Pgr_pckDeliver;
+class Optimize;
+
+class Solution {
+    friend class Optimize;
+ protected:
+     double EPSILON;
+     std::deque<Vehicle_pickDeliver> fleet;
+
+     /* this solution belongs to this problem*/
+     const Pgr_pickDeliver *problem;
+
+
+ public:
+     void get_postgres_result(
+             std::vector< General_vehicle_orders_t > &result) const;
+
+
+     /* @brief constructor
+      *
+      * @params [in] p_problem \t pointer to problem
+      *
+      */
+     explicit Solution(const Pgr_pickDeliver *p_problem) :
+         EPSILON(0.0001),
+         problem(p_problem)
+    {};
+
+
+     /* @brief move constructor */
+     Solution(const Solution && sol) :
+         EPSILON(0.0001),
+         fleet(std::move(sol.fleet)),
+         problem(std::move(sol.problem))
+         {};
+
+     /* @brief copy constructor */
+     Solution(const Solution &sol) :
+         EPSILON(0.0001),
+         fleet(sol.fleet),
+         problem(sol.problem)
+    {};
+
+     /* @brief move assignment */
+     Solution& operator = (const Solution && sol) {
+         EPSILON = 0.0001,
+         fleet = sol.fleet;
+         return *this;
+     };
+
+     /* @brief copy assignment */
+     Solution& operator = (const Solution& sol) {
+         EPSILON = 0.0001,
+         fleet = sol.fleet;
+         return *this;
+     };
+
+     std::string cost_str() const;
+     std::string tau(const std::string &title = "Tau") const;
+     friend std::ostream& operator<<(
+             std::ostream &log,
+             const Solution &solution);
+     bool operator <(const Solution &s_rhs) const;
+
+     bool is_feasable() const;
+     double duration() const;
+     double wait_time() const;
+     double total_travel_time() const;
+     double total_service_time() const;
+     int twvTot() const;
+     int cvTot() const;
+     size_t fleet_size() const {return fleet.size();}
+
+     /*
+      * Cost in terms of a tuple
+      * <0> time window violations
+      * <1> capacity violations
+      * <2> fleet size TODO
+      * <3> wait_time
+      * <4> duration
+      */
+     Vehicle::Cost cost() const;
+};
+
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/tw_node.cpp b/src/pickDeliver/src/tw_node.cpp
new file mode 100644
index 0000000..4a45521
--- /dev/null
+++ b/src/pickDeliver/src/tw_node.cpp
@@ -0,0 +1,279 @@
+/*PGR-GNU*****************************************************************
+
+FILE: tw_node.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#include "./tw_node.h"
+
+#include <limits>
+#include <string>
+
+
+#include "./../../common/src/pgr_assert.h"
+#include "./pgr_pickDeliver.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+double
+Tw_node::travel_time_to(const Node &other) const {
+    pgassert(problem->speed() > 0);
+    return distance(other) / problem->speed();
+}
+
+
+/*
+ * I -> J = (*this)
+ */
+double
+Tw_node::arrival_j_opens_i(const Tw_node &I) const {
+    if (m_type == kStart) return (std::numeric_limits<double>::max)();
+    return I.opens() + I.service_time() + I.travel_time_to(*this);
+}
+
+double
+Tw_node::arrival_j_closes_i(const Tw_node &I) const {
+    if (m_type == kStart) return  (std::numeric_limits<double>::max)();
+    return I.closes() + I.service_time() + I.travel_time_to(*this);
+}
+
+
+
+
+bool
+Tw_node::is_compatible_IJ(const Tw_node &I) const {
+    /*
+     * I /->  kStart
+     */
+    if (m_type == kStart) return false;
+    /*
+     * kEnd /-> (*this)
+     */
+    if (I.m_type == kEnd) return false;
+
+    return !is_late_arrival(arrival_j_opens_i(I));
+}
+
+bool
+Tw_node::is_partially_compatible_IJ(const Tw_node &I) const {
+    return
+        is_compatible_IJ(I)
+         && !is_early_arrival(arrival_j_opens_i(I))
+         && is_late_arrival(arrival_j_closes_i(I));
+}
+
+bool
+Tw_node::is_tight_compatible_IJ(const Tw_node &I) const {
+    return
+        is_compatible_IJ(I)
+         && !is_early_arrival(arrival_j_opens_i(I))
+         && !is_late_arrival(arrival_j_closes_i(I));
+}
+
+bool
+Tw_node::is_partially_waitTime_compatible_IJ(const Tw_node &I) const {
+    return
+        is_compatible_IJ(I)
+         && is_early_arrival(arrival_j_opens_i(I));
+}
+
+bool
+Tw_node::is_waitTime_compatible_IJ(const Tw_node &I) const {
+    return
+        is_compatible_IJ(I)
+         && is_early_arrival(arrival_j_opens_i(I));
+}
+
+
+std::string Tw_node::type_str() const {
+    switch (type()) {
+        case kStart: return "START"; break;
+        case kEnd: return "END"; break;
+        case kDump: return "DUMP"; break;
+        case kLoad: return "LOAD"; break;
+        case kPickup: return "PICKUP"; break;
+        case kDelivery: return "DELIVERY"; break;
+        default: return "UNKNOWN";
+    }
+}
+
+bool
+Tw_node::is_start() const {
+    return
+        m_type == kStart
+         && (0 <= opens())
+         && (opens() < closes())
+         && (service_time() >= 0)
+         && (demand() == 0);
+}
+
+bool
+Tw_node::is_pickup() const {
+    return m_type == kPickup
+         && (0 <= opens())
+         && (opens() < closes())
+         && (service_time() >= 0)
+         && (demand() > 0);
+}
+
+
+bool
+Tw_node::is_delivery() const {
+    return m_type == kDelivery
+         && (0 <= opens())
+         && (opens() < closes())
+         && (service_time() >= 0)
+         && (demand() < 0);
+}
+
+
+bool
+Tw_node::is_dump() const {
+    return m_type == kDump
+         && (0 <= opens())
+         && (opens() < closes())
+         && (service_time() >= 0)
+         && (demand() <= 0);
+}
+
+
+bool
+Tw_node::is_load() const {
+    return m_type == kLoad
+         && (0 <= opens())
+         && (opens() < closes())
+         && (service_time() >= 0)
+         && (demand() >= 0);
+}
+
+
+bool
+Tw_node::is_end() const {
+    return m_type == kEnd
+         && (0 <= opens())
+         && (opens() < closes())
+         && (service_time() >= 0)
+         && (demand() == 0);
+}
+
+
+bool
+Tw_node::operator ==(const Tw_node &rhs) const {
+    if (&rhs == this) return true;
+    return (static_cast<Node>(*this) == static_cast<Node>(rhs));
+}
+
+
+
+bool Tw_node::is_valid() const {
+    switch (type()) {
+        case kStart:
+            return is_start();
+            break;
+
+        case kEnd:
+            return is_end();
+            break;
+
+        case kDump:
+            return is_dump();
+            break;
+
+        case kDelivery:
+            return is_delivery();
+            break;
+
+        case kPickup:
+            return is_pickup();
+            break;
+
+        case kLoad:
+            return is_load();
+            break;
+
+        default:
+            return false;
+            break;
+    }
+
+    return false;
+}
+
+
+Tw_node::Tw_node(
+        size_t id,
+        Customer_t data,
+        NodeType type,
+        const Pgr_pickDeliver *p_problem) :
+    Node(id, data.id, data.x, data.y),
+    m_opens(data.Etime),
+    m_closes(data.Ltime),
+    m_service_time(data.Stime),
+    m_demand(data.demand),
+    m_type(type),
+    problem(p_problem) {
+    }
+
+
+Tw_node::Tw_node(
+        size_t id,
+        int64_t original_id,
+        double x,
+        double y,
+        double opens,
+        double closes,
+        double service_time,
+        double demand,
+        NodeType type,
+        const Pgr_pickDeliver *p_problem) :
+    Node(id, original_id, x, y),
+    m_opens(opens),
+    m_closes(closes),
+    m_service_time(service_time),
+    m_demand(demand),
+    m_type(type),
+    problem(p_problem) {
+    }
+
+
+/*! * \brief Print the contents of a Twnode object. */
+std::ostream& operator << (std::ostream &log, const Tw_node &n) {
+    log << static_cast<const Node&>(n)
+        << "[opens = " << n.m_opens
+        << "\tcloses = " << n.m_closes
+        << "\tservice = " << n.m_service_time
+        << "\tdemand = " << n.m_demand
+        << "\ttype = " << n.type_str()
+        << "]";
+    if (n.is_pickup() ||  n.is_delivery()) {
+        log << "->" << n.m_otherid << "\n";
+    } else {
+        log << "\n";
+    }
+    return log;
+}
+
+}  //  namespace vrp
+}  //  namespace pgrouting
+
diff --git a/src/pickDeliver/src/tw_node.h b/src/pickDeliver/src/tw_node.h
new file mode 100644
index 0000000..1ff2756
--- /dev/null
+++ b/src/pickDeliver/src/tw_node.h
@@ -0,0 +1,299 @@
+/*PGR-GNU*****************************************************************
+
+FILE: tw_node.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#pragma once
+#include <string>
+
+#include "./../../common/src/pgr_types.h"
+#include "./../../common/src/pgr_assert.h"
+
+#include "./node.h"
+
+namespace pgrouting {
+namespace vrp {
+
+ class Pgr_pickDeliver;
+
+/*! \class Tw_node
+ * \brief Extends the \ref Node class to create a Node with time window attributes.
+ *
+ * A Time Window node is a Node with addition attributes and methods to
+ * to support Time Windows and to model a more complex Node need in many
+ * vehicle routing problems.
+ *
+ * Most application specific code will extend this class and define the specific
+ * values and requirements for \c type and \c streetid.
+ *
+ */
+class Tw_node: public Node {
+ public:
+     typedef enum {
+         kStart = 0,  // /< starting site
+         kPickup,  // /< pickup site
+         kDelivery,  // /< delivery site
+         kDump,  // /< dump site, empties truck
+         kLoad,  // /< load site, fills the truck
+         kEnd        ///< ending site
+     } NodeType;
+
+
+     inline void set_Pid(size_t id) {
+         pgassert(is_delivery());
+         m_otherid = id;
+     }
+
+     inline void set_Did(size_t id) {
+         pgassert(is_pickup());
+         m_otherid = id;
+     }
+
+     inline size_t Did() const {
+         pgassert(is_pickup());
+         return m_otherid;
+     }
+
+     inline size_t Pid() const {
+         pgassert(is_delivery());
+         return m_otherid;
+     }
+
+
+     /** @name accessors */
+     ///@ {
+
+
+     /*! \brief Returns the opening time.*/
+     inline double opens() const {return m_opens;}
+
+     /*! \brief Returns the closing time. */
+     inline double closes() const {return m_closes;}
+
+     /*! \brief Returns the demand associated with this node. */
+     inline double demand() const {return m_demand;}
+
+     /*! * \brief Returns the service time for this node. */
+     inline double service_time() const { return m_service_time;}
+
+     /*! * \brief Returns the type of this node. */
+     inline NodeType type() const { return m_type;}
+
+     /*! \brief Returns the length of time between the opening and closing. */
+     inline double window_length() const {return m_closes - m_opens;}
+
+     /*! \brief time = distance / speed. */
+     double travel_time_to(const Node &other) const;
+
+     ///@}
+
+     /** @name kind of node
+      *
+      * A true value when;
+      *
+      *   - 0 < opens < closes
+      *   - the type is the requested type
+      *   - the demand are valid for the requested type
+      */
+
+     ///@ {
+
+
+     /*! \brief is_start
+      *
+      * To be a start node:
+      *   - type is kStart
+      *   - demand == 0
+      *
+      **/
+     bool is_start() const;
+
+
+     /*! \brief is_pickup
+      *
+      * To be a pickup node:
+      *   - type is kPickup
+      *   - demand > 0
+      *
+      **/
+     bool is_pickup() const;
+
+
+     /*! \brief is_delivery
+      *
+      * To be a delivery node:
+      *   - type is kDelivery
+      *   - demand < 0
+      *
+      **/
+     bool is_delivery() const;
+
+
+     /*! \brief is_dump
+      *
+      * To be a dump node:
+      *   - type is kDump
+      *   - demand <= 0
+      *
+      **/
+     bool is_dump() const;
+
+
+     /*! \brief is_Load
+      *
+      * To be a Load node:
+      *   - type is kLoad
+      *   - demand >= 0
+      *
+      **/
+     bool is_load() const;
+
+
+     /*! \brief is_end
+      *
+      * To be a End node:
+      *   - type is kEnd
+      *   - demand == 0
+      *
+      **/
+     bool is_end() const;
+
+
+     std::string type_str() const;
+
+     ///@}
+
+
+
+     /*! * \brief Print the contents of a Twnode object. */
+     friend std::ostream& operator << (std::ostream &log, const Tw_node &node);
+
+     bool operator ==(const Tw_node &rhs) const;
+
+
+
+     /*! \brief True when \b arrivalTime is before it \b opens */
+     inline bool is_early_arrival(double arrival_time) const {
+         return arrival_time < m_opens;
+     }
+
+     /*! \brief True when \b arrivalTime is after it \b closes */
+     inline bool is_late_arrival(double arrival_time) const {
+         return arrival_time > m_closes;
+     }
+     /*! \brief True when \b arrivalTime in the time window */
+     inline bool is_on_time(double arrival_time) const {
+         return !is_early_arrival(arrival_time)
+             && !is_late_arrival(arrival_time);
+     }
+
+
+
+
+
+     /** @name document functions */
+     ///@ {
+     /*!
+      * The actual arrival time at \b This node, given that:
+      * \b this node is visited directly after \b other node
+      *   and that the actual arrival time at \b other node was opens(other)
+      **/
+     double arrival_j_opens_i(const Tw_node &I) const;
+
+     /*!
+      * The actual arrival time at \b this node, given that:
+      * \b this node is visited directly after \b other node
+      * and that the actual arrival time at \b other node was closes(other)
+      **/
+     double arrival_j_closes_i(const Tw_node &I) const;
+
+
+     /*
+      * is possible to arrive to \b this after visiting \bother
+      *   - departing as early as possible from \b other it can arrives to \b this
+      */
+     bool is_compatible_IJ(const Tw_node &I) const;
+
+     /*
+      * is possible to arrive to \b this after visiting \bother
+      *   - departing as late as possible from \b other it can arrives to \b this
+      */
+     bool is_partially_compatible_IJ(const Tw_node &I) const;
+
+     /*
+      * is possible to arrive to \b this after visiting \bother
+      *   - departing as late as possible from \b other it can arrives to \b this
+      */
+     bool is_tight_compatible_IJ(const Tw_node &I) const;
+
+     /*
+      * is possible to arrive to \b this after visiting \b other
+      *   - departing as late as possible from \b other it can arrives to \b this
+      */
+     bool is_partially_waitTime_compatible_IJ(const Tw_node &I) const;
+
+     /*
+      * is compatible to arrive to \b this after visiting \b other
+      * - is fully compatible
+      * - does not have a waiting time when arriving as earliest as possible after
+      */
+     bool is_waitTime_compatible_IJ(const Tw_node &I) const;
+
+
+     ///@}
+
+
+
+     Tw_node(const Tw_node &other) = default;
+     Tw_node(
+             size_t id,
+             Customer_t data,
+             NodeType type,
+             const Pgr_pickDeliver *problem);
+
+     Tw_node(
+             size_t id,
+             int64_t p_original_id,
+             double x,
+             double y,
+             double opens,
+             double closes,
+             double service_time,
+             double demand,
+             NodeType type,
+             const Pgr_pickDeliver *problem);
+
+ protected:
+     bool is_valid() const;
+
+     double m_opens;        ///< opening time of the node
+     double m_closes;       ///< closing time of the node
+     double m_service_time;  // /< time it takes to be served
+     double m_demand;       ///< The demand for the Node
+     size_t m_otherid;      ///< the other's internal id
+     NodeType m_type;       ///< The demand for the Node
+     const Pgr_pickDeliver *problem;
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/vehicle.cpp b/src/pickDeliver/src/vehicle.cpp
new file mode 100644
index 0000000..8755e46
--- /dev/null
+++ b/src/pickDeliver/src/vehicle.cpp
@@ -0,0 +1,516 @@
+/*PGR-GNU*****************************************************************
+
+FILE: vehicle.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#include <deque>
+#include <iostream>
+#include <algorithm>
+#include <tuple>
+#include <limits>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "../../common/src/pgr_assert.h"
+
+
+#include "./pgr_pickDeliver.h"
+#include "./vehicle.h"
+
+
+namespace pgrouting {
+namespace vrp {
+
+
+void
+Vehicle::invariant() const {
+    pgassert(m_path.size() >= 2);
+    pgassert(m_path.front().is_start());
+    pgassert(m_path.back().is_end());
+}
+
+size_t
+Vehicle::insert(std::pair<POS, POS> position_limits, const Vehicle_node &node) {
+    invariant();
+    pgassert(position_limits.first <= m_path.size());
+    pgassert(position_limits.second <= m_path.size());
+
+    auto low = position_limits.first;
+    auto high = position_limits.second;
+    auto best = low;
+
+
+    insert(low, node);
+
+    Vehicle::Cost best_cost(cost());
+
+
+    while (low < high) {
+        swap(low, low + 1);
+        ++low;
+        if (cost_compare(best_cost, cost())) {
+            best_cost = cost();
+            best = low;
+        }
+    }
+    return best;
+
+    pgassert(best < m_path.size());
+    pgassert(m_path[best].id() == node.id());
+    invariant();
+}
+
+
+
+
+bool
+Vehicle::cost_compare(const Cost &lhs, const Cost &rhs) const {
+    /*
+     * capacity violations
+     */
+    if (std::get<1>(lhs) < std::get<1>(rhs))
+        return true;
+    if (std::get<1>(lhs) > std::get<1>(rhs))
+        return false;
+
+    /*
+     * time window violations
+     */
+    if (std::get<0>(lhs) < std::get<0>(rhs))
+        return true;
+    if (std::get<0>(lhs) > std::get<0>(rhs))
+        return false;
+
+    /*
+     * waiting time
+     */
+    if (std::get<3>(lhs) < std::get<3>(rhs))
+        return true;
+    if (std::get<3>(lhs) > std::get<3>(rhs))
+        return false;
+
+    /*
+     * duration
+     */
+    if (std::get<4>(lhs) < std::get<4>(rhs))
+        return true;
+    if (std::get<4>(lhs) > std::get<4>(rhs))
+        return false;
+
+    /*
+     * truck size
+     */
+    if (std::get<2>(lhs) < std::get<2>(rhs))
+        return true;
+    if (std::get<2>(lhs) > std::get<2>(rhs))
+        return false;
+
+    return false;
+}
+
+
+
+void
+Vehicle::get_postgres_result(
+        int vid,
+        std::vector< General_vehicle_orders_t > &result) const {
+    /* postgres numbering starts with 1 */
+    int i(1);
+    for (const auto p_stop : m_path) {
+        General_vehicle_orders_t data =
+                {vid, i,
+                p_stop.original_id(),
+                p_stop.travel_time(),
+                p_stop.arrival_time(),
+                p_stop.wait_time(),
+                p_stop.service_time(),
+                p_stop.departure_time()};
+        result.push_back(data);
+        ++i;
+    }
+}
+
+
+Vehicle::Cost
+Vehicle::cost() const {
+    return std::make_tuple(
+            twvTot(), cvTot(), m_path.size(),
+            total_wait_time(), duration());
+}
+
+
+void
+Vehicle::insert(POS at, Vehicle_node node) {
+    invariant();
+    pgassert(at <= m_path.size());
+
+    m_path.insert(m_path.begin() + at, node);
+    evaluate(at);
+
+    pgassert(at < m_path.size());
+    pgassert(m_path[at].id() == node.id());
+    invariant();
+}
+
+
+double
+Vehicle::deltaTime(const Vehicle_node &node, POS pos) const {
+    /*
+     * .... POS POS+1 ....
+     * .... POS node POS+1 ....
+     *
+     */
+    auto prev = m_path[pos-1];
+    auto next = m_path[pos];
+    auto original_time = next.travel_time();
+    auto tt_p_n = prev.travel_time_to(node);
+    tt_p_n = node.is_early_arrival(prev.departure_time() + tt_p_n) ?
+        node.closes() - prev.departure_time()
+        : tt_p_n;
+
+    auto tt_n_x = node.travel_time_to(next);
+    tt_p_n = next.is_early_arrival(
+            prev.departure_time() + tt_p_n + node.service_time() + tt_n_x) ?
+        next.closes() - (prev.departure_time() + tt_p_n + node.service_time())
+        : tt_n_x;
+
+    return (tt_p_n + tt_n_x) - original_time;
+}
+
+
+
+
+size_t
+Vehicle::insert_less_travel_time(const Vehicle_node &node, POS after_pos) {
+    invariant();
+
+    double min_delta = (std::numeric_limits<double>::max)();
+    POS min_pos = after_pos;
+
+    for (POS pos = after_pos; pos < m_path.size(); ++pos) {
+        if (!m_path[pos].is_start()) {
+            auto tt = deltaTime(node, pos);
+
+            if (tt < min_delta) {
+                min_delta = tt;
+                min_pos = pos;
+            }
+        }
+    }
+    insert(min_pos, node);
+
+    invariant();
+    return min_pos;
+}
+
+void
+Vehicle::erase(const Vehicle_node &node) {
+    invariant();
+
+    POS pos = 0;
+    for ( ; pos < m_path.size() ; ++pos) {
+        if (node.id() == m_path[pos].id())
+            break;
+    }
+
+    erase(pos);
+    evaluate(pos);
+
+    invariant();
+}
+
+
+/*
+ * before: S E
+ * after: S N E
+ *
+ * before: S n1 n2 ... n E
+ * after: S N n1 n2 ... n E
+ */
+void
+Vehicle::push_front(const Vehicle_node &node) {
+    invariant();
+
+    /* insert evaluates */
+    insert(1, node);
+
+    invariant();
+}
+
+/*
+ * before: S E
+ * after: S N E
+ *
+ * before: S n1 n2 ... n E
+ * after: S n1 n2 ... n N E
+ */
+void
+Vehicle::push_back(const Vehicle_node &node) {
+    invariant();
+
+    /* insert evaluates */
+    insert(m_path.size() - 1, node);
+
+    invariant();
+}
+
+void
+Vehicle::pop_back() {
+    invariant();
+    pgassert(m_path.size() > 2);
+
+    /* erase evaluates */
+    erase(m_path.size() - 2);
+
+    invariant();
+}
+
+void
+Vehicle::pop_front() {
+    invariant();
+    pgassert(m_path.size() > 2);
+
+    /* erase evaluates */
+    erase(1);
+
+    invariant();
+}
+
+
+
+void
+Vehicle::erase(POS at) {
+    invariant();
+
+    pgassert(m_path.size() > 2);
+    pgassert(at < m_path.size());
+    pgassert(!m_path[at].is_start());
+    pgassert(!m_path[at].is_end());
+
+    m_path.erase(m_path.begin() + at);
+    evaluate(at);
+
+    invariant();
+}
+
+void
+Vehicle::swap(POS i, POS j) {
+    invariant();
+    pgassert(m_path.size() > 3);
+    pgassert(!m_path[i].is_start());
+    pgassert(!m_path[i].is_end());
+    pgassert(!m_path[j].is_start());
+    pgassert(!m_path[j].is_end());
+
+    std::swap(m_path[i], m_path[j]);
+    i < j ? evaluate(i) : evaluate(j);
+
+    invariant();
+}
+
+
+void
+Vehicle::evaluate() {
+    invariant();
+
+    evaluate(0);
+
+    invariant();
+}
+
+bool
+Vehicle::empty() const {
+    invariant();
+    return m_path.size() <= 2;
+}
+
+void
+Vehicle::evaluate(POS from) {
+    invariant();
+    // preconditions
+    pgassert(from < m_path.size());
+
+
+    auto node = m_path.begin() + from;
+
+    while (node != m_path.end()) {
+        if (node == m_path.begin()) {
+            node->evaluate(max_capacity);
+        } else {
+            node->evaluate(*(node - 1), max_capacity);
+        }
+
+        ++node;
+    }
+    invariant();
+}
+
+std::deque< Vehicle_node >
+Vehicle::path() const {
+    invariant();
+    return m_path;
+}
+
+
+std::pair<size_t, size_t>
+Vehicle::position_limits(const Vehicle_node node) const {
+    POS high = getPosHighLimit(node);
+    POS low = getPosLowLimit(node);
+    return std::make_pair(low, high);
+}
+
+
+/*
+ * start searching from postition low = pos(E)
+ *
+ * S 1 2 3 4 5 6 7 ..... E
+ * node -> E
+ * node -> ...
+ * node -> 7
+ * node -> 6
+ * node -> 5
+ * node /-> 4
+ *
+ * return low_limit = 5
+ *
+ */
+size_t
+Vehicle::getPosLowLimit(const Vehicle_node &nodeI) const {
+    invariant();
+
+    POS low = 0;
+    POS high = m_path.size();
+    POS low_limit = high;
+
+    /* J == m_path[low_limit - 1] */
+    while (low_limit > low
+             && m_path[low_limit - 1].is_compatible_IJ(nodeI)) {
+        --low_limit;
+    }
+
+    invariant();
+    return low_limit;
+}
+
+
+/*
+ * start searching from postition low = pos(S)
+ *
+ * S 1 2 3 4 5 6 7 ..... E
+ * S -> node
+ * 1 -> node
+ * 2 -> node
+ * ...
+ * 6 -> node
+ * 7 /-> node
+ *
+ * returns high_limit = 7
+ */
+size_t
+Vehicle::getPosHighLimit(const Vehicle_node &nodeJ) const {
+    invariant();
+
+    POS low = 0;
+    POS high = m_path.size();
+    POS high_limit = low;
+
+    /* I == m_path[high_limit] */
+    while (high_limit < high
+             && nodeJ.is_compatible_IJ(m_path[high_limit])) {
+        ++high_limit;
+    }
+
+    invariant();
+    return high_limit;
+}
+
+
+
+Vehicle::Vehicle(
+        ID p_id,
+        const Vehicle_node &starting_site,
+        const Vehicle_node &ending_site,
+        double p_max_capacity) :
+    m_id(p_id),
+    max_capacity(p_max_capacity) {
+        m_path.clear();
+        m_path.push_back(starting_site);
+        m_path.push_back(ending_site);
+        evaluate(0);
+        invariant();
+    }
+
+
+
+
+std::string
+Vehicle::tau() const {
+    std::ostringstream log;
+    log << "Truck " << id() << " (";
+    for (const auto p_stop : m_path) {
+        if (!(p_stop == m_path.front()))
+            log << ", ";
+        log << p_stop.original_id();
+    }
+    log << ")" << " \t(cv, twv, wait_time, duration) = ("
+        << cvTot() << ", "
+        << twvTot() << ", "
+        << total_wait_time() << ", "
+        << duration() << ")";
+
+    return log.str();
+}
+
+/****** FRIENDS *******/
+
+std::ostream&
+operator << (std::ostream &log, const Vehicle &v) {
+    v.invariant();
+    int i(0);
+    log << "\n\n****************** TRUCK " << v.id() << "***************";
+    for (const auto &path_stop : v.path()) {
+        log << "\nPath_stop" << ++i << "\n";
+        log << path_stop;
+    }
+    return log;
+}
+
+bool
+operator<(const Vehicle &lhs, const Vehicle &rhs) {
+    lhs.invariant();
+    rhs.invariant();
+
+    if (lhs.m_path.size() < rhs.m_path.size()) return true;
+
+    /* here because sizes are equal */
+
+    if (lhs.m_path.back().total_travel_time()
+            < lhs.m_path.back().total_travel_time()) return true;
+
+    return false;
+}
+
+}  //  namespace vrp
+}  //  namespace pgrouting
+
diff --git a/src/pickDeliver/src/vehicle.h b/src/pickDeliver/src/vehicle.h
new file mode 100644
index 0000000..d09a351
--- /dev/null
+++ b/src/pickDeliver/src/vehicle.h
@@ -0,0 +1,325 @@
+/*PGR-GNU*****************************************************************
+
+FILE: vehicle.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#pragma once
+
+#include <deque>
+#include <iostream>
+#include <algorithm>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
+
+
+#include "./vehicle_node.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+/*! @class Vehicle
+ *  @brief Vehicle with time windows
+ *
+ * General functionality for a vehicle in a VRP problem
+ *
+ * Recommended use:
+ *
+ * ~~~~{.c}
+ *   Class my_vehicle : public vechicle
+ * ~~~~
+ *
+ * @note All members return @b true when the operation is succesfull
+ *
+ * A vehicle is a sequence of @ref Vehicle_node 
+ * from @b starting site to @b ending site.
+ *
+ * @sa @ref Vehicle_node
+ */
+
+class Vehicle {
+ protected:
+     typedef size_t ID;
+     typedef size_t POS;
+     ID m_id;
+     std::deque< Vehicle_node > m_path;
+     double max_capacity;
+
+ public:
+     /*
+      * (twv, cv, fleet_size, wait_time, dureation)
+      */
+     typedef std::tuple< int, int, size_t, double, double > Cost;
+     void get_postgres_result(
+             int vid,
+             std::vector< General_vehicle_orders_t > &result) const;
+
+     Vehicle(
+             ID id,
+             const Vehicle_node &starting_site,
+             const Vehicle_node &ending_site,
+             double max_capacity);
+
+
+
+     /*! @name deque like functions
+
+       @returns True if the operation was performed
+       @warning Assertions are performed for out of range operations
+       @warning no feasability nor time window or capacity violations
+       checks are performed
+       @todo TODO more deque like functions here
+       */
+
+     /*! @brief Invariant
+      * The path must:
+      *   - have at least 2 nodes
+      *   - first node of the path must be Start node
+      *   - last node of the path must be End node
+      *
+      * path: S ..... E
+      */
+     void invariant() const;
+
+
+     /// @ {
+
+     /*! @brief Insert @b node at @b pos position.
+      *
+      * @param[in] pos The position that the node should be inserted.
+      * @param[in] node The node to insert.
+      *
+      */
+     void insert(POS pos, Vehicle_node node);
+
+
+     /*! @brief Insert @b node in best position of the @b position_limits.
+      *
+      * @param[in] position_limits
+      * @param[in] node The node to insert
+      *
+      * @returns position where it was inserted
+      */
+     POS insert(std::pair<POS, POS> position_limits, const Vehicle_node &node);
+
+
+
+
+
+     /*! @brief Evaluated: push_back a node to the path.
+      *
+      * ~~~~{.c}
+      * before: S <nodes> E
+      * after: S <nodes> n E
+      * ~~~~
+      *
+      * @param[in] node to be push_back.
+      */
+     void push_back(const Vehicle_node &node);
+
+     /*! @brief Evaluated: push_back a node to the path.
+      *
+      * ~~~~{.c}
+      * before: S <nodes> E
+      * after: S n <nodes> E
+      * ~~~~
+      *
+      * @param[in] node to be push_back.
+      */
+     void push_front(const Vehicle_node &node);
+
+
+     /*! @brief Evaluated: pop_back a node to the path.
+      *
+      * ~~~~{.c}
+      * before: S <nodes> n E
+      * after: S <nodes> E
+      * ~~~~
+      */
+     void pop_back();
+
+     /*! @brief Evaluated: pop_front a node to the path.
+      *
+      * ~~~~{.c}
+      * before: S n <nodes> E
+      * after: S <nodes> E
+      * ~~~~
+      */
+     void pop_front();
+
+     /*! @brief Erase node.id()
+      *
+      * @note start and ending nodes cannot be erased
+      *
+      * Numbers are positions
+      * before: S .... node.id() .... E
+      * after: S .... .... E
+      *
+      */
+     void erase(const Vehicle_node &node);
+
+
+
+     /*! @brief Erase node at `pos` from the path.
+      *
+      * @note start and ending nodes cannot be erased
+      *
+      * Numbers are positions
+      * before: S 1 2 3 4 5 6 pos 8 9 E
+      * after: S 1 2 3 4 5 6 8 9 E
+      *
+      * @param[in] pos to be erased.
+      */
+     void erase(POS pos);
+
+     /*! @brief return true when no nodes are in the truck 
+      *
+      * ~~~~{.c}
+      * True: S E
+      * False: S <nodes> E
+      * ~~~~
+      */
+     bool empty() const;
+
+     ID id() const {return m_id;}
+
+
+     /// @ {
+     Cost cost() const;
+     bool cost_compare(const Cost&, const Cost&) const;
+
+     double duration() const {
+         return m_path.back().departure_time();
+     }
+     double total_wait_time() const {
+         return m_path.back().total_wait_time();
+     } 
+     double total_travel_time() const {
+         return m_path.back().total_travel_time();
+     } 
+     double total_service_time() const {
+         return m_path.back().total_service_time();
+     } 
+     double free_time() const {
+         return total_wait_time() + (m_path[0].closes() - duration());
+     }
+     int twvTot() const {
+         return m_path.back().twvTot();
+     }
+     int cvTot() const {
+         return m_path.back().cvTot();
+     }
+     bool has_twv() const {
+         return twvTot() != 0;
+     }
+     bool has_cv() const {
+         return cvTot() != 0;
+     }
+     bool is_feasable() const {
+         return !(has_twv() ||  has_cv());
+     }
+     /// @}
+
+
+
+     /*!
+      * @brief Swap two nodes in the path.
+      *
+      * ~~~~{.c}
+      * Before: S <nodesA> I <nodesB> J <nodesC> E
+      * After: S <nodesA> J <nodesB> I <nodesC> E
+      * ~~~~
+      *
+      * @param[in] i The position of the first node to swap.
+      * @param[in] j The position of the second node to swap.
+      */
+     void swap(POS i, POS j);
+
+
+     /*! @name Evaluation
+      *
+      *
+      *
+      * Path evaluation is done incrementally: from a given position to the
+      * end of the path, and intermediate values are cached on each node.
+      * So, for example, changing the path at position 100:
+      * the evaluation function should be called as
+      * @c evaluate(100, maxcapacity)
+      * and from that position to the end of the path will be evaluated.
+      * None of the "unaffected" positions get reevaluated
+      *
+      *
+      *
+      */
+
+     ///@ {
+
+     /*! @brief Evaluate: Evaluate the whole path from the start. */
+     void evaluate();
+
+     /*! @brief Evaluate: Evaluate a path from the given position.
+      *
+      * @param[in] from The starting position in the path for evaluation to
+      * the end of the path.
+      */
+     void evaluate(POS from);
+
+     ///@}
+
+     double deltaTime(const Vehicle_node &node, POS pos) const;
+     POS insert_less_travel_time(const Vehicle_node &node, POS after_pos = 0);
+
+
+
+     /*! @name accessors */
+     ///@ {
+
+     std::deque< Vehicle_node > path() const;
+
+     ///@}
+
+     /*! @name operators */
+     ///@ {
+
+
+     friend std::ostream& operator << (std::ostream &log, const Vehicle &v);
+
+     std::string tau() const;
+
+     friend bool operator<(const Vehicle &lhs, const Vehicle &rhs);
+
+     ///@}
+
+
+
+     std::pair<POS, POS> position_limits(const Vehicle_node node) const;
+
+    private:
+     POS getPosLowLimit(const Vehicle_node &node) const;
+     POS getPosHighLimit(const Vehicle_node &node) const;
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/vehicle_node.cpp b/src/pickDeliver/src/vehicle_node.cpp
new file mode 100644
index 0000000..68caea3
--- /dev/null
+++ b/src/pickDeliver/src/vehicle_node.cpp
@@ -0,0 +1,154 @@
+/*PGR-GNU*****************************************************************
+
+FILE: vehicle_node.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+
+
+#include <cassert>
+#include "./vehicle_node.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+/*!
+ * \param[in] cargoLimit of the vehicle
+ */
+void
+Vehicle_node::evaluate(double cargoLimit) {
+    if (is_start()) {
+        /* time */
+        m_travel_time = 0;
+        m_arrival_time = opens();
+        m_wait_time = 0;
+        m_departure_time = arrival_time() + service_time();
+
+        /* time aggregates */
+        m_tot_travel_time = 0;
+        m_tot_wait_time = 0;
+        m_tot_service_time = service_time();
+
+        /* cargo aggregates */
+        m_cargo = demand();
+
+        /* violation aggregates */
+        m_twvTot = m_cvTot = 0;
+        m_cvTot = has_cv(cargoLimit) ? 1 : 0;
+        m_delta_time = 0;
+    }
+}
+
+/*!
+  \param[in] pred The node preceding this node (in the path).
+  \param[in] cargoLimit The cargo limit of the vehicle.
+  */
+void
+Vehicle_node::evaluate(const Vehicle_node &pred, double cargoLimit) {
+    /* time */
+    m_travel_time    = pred.travel_time_to(*this);
+    m_arrival_time   = pred.departure_time() + travel_time();
+    m_wait_time      = is_early_arrival(arrival_time()) ?
+        opens() - m_arrival_time :
+        0;
+    m_departure_time = arrival_time() + wait_time() + service_time();
+
+    /* time aggregates */
+    m_tot_travel_time = pred.total_travel_time() + travel_time();
+    m_tot_wait_time    = pred.total_wait_time()    + wait_time();
+    m_tot_service_time = pred.total_service_time() + service_time();
+
+    /* cargo aggregates */
+    if (is_dump() &&  pred.cargo() >= 0) {
+        m_demand = -pred.cargo();
+    }
+    m_cargo = pred.cargo() + demand();
+
+    /* cargo aggregates */
+
+    m_twvTot = has_twv() ? pred.twvTot() + 1 : pred.twvTot();
+    m_cvTot = has_cv(cargoLimit) ? pred.cvTot() + 1 : pred.cvTot();
+    m_delta_time = departure_time() - pred.departure_time();
+}
+
+
+
+std::ostream&
+operator << (std::ostream &log, const Vehicle_node &v) {
+    log << static_cast<Tw_node>(v)
+        << " twv = " << v.has_twv()
+        << ", twvTot = " << v.twvTot()
+        << ", cvTot = " << v.cvTot()
+        << ", cargo = " << v.cargo()
+        << ", travel _time = " << v.travel_time()
+        << ", arrival _time = " << v.arrival_time()
+        << ", wait _time = " << v.wait_time()
+        << ", service _time = " << v.service_time()
+        << ", departure _time = " << v.departure_time();
+    return log;
+}
+
+
+/*! @brief Creates a disconected vehicle node
+ *
+ * A node that is not served by any vehicle
+ *
+ * @param[in] node Time window node
+ */
+Vehicle_node::Vehicle_node(const Tw_node &node)
+    : Tw_node(node),
+    m_travel_time(0),
+    m_arrival_time(0),
+    m_wait_time(0),
+    m_departure_time(0),
+    m_delta_time(0),
+    m_cargo(0),
+    m_twvTot(0),
+    m_cvTot(0),
+    m_tot_wait_time(0),
+    m_tot_travel_time(0),
+    m_tot_service_time(0) {
+    }
+
+
+
+bool
+Vehicle_node::deltaGeneratesTWV(double delta_time) const {
+    return is_late_arrival(m_arrival_time + delta_time);
+}
+
+
+/*!
+  The actual arrival time at \b This node, given that:
+  \b this node is visited directly after \b other node
+  and that the actual arrival time at \b other node was arrival(other)
+  */
+double
+Vehicle_node::arrival_i_arrives_j(const Vehicle_node &other) const {
+    return other.arrival_time()
+        + other.service_time()
+        + other.travel_time_to(*this);
+}
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/vehicle_node.h b/src/pickDeliver/src/vehicle_node.h
new file mode 100644
index 0000000..1a981ff
--- /dev/null
+++ b/src/pickDeliver/src/vehicle_node.h
@@ -0,0 +1,183 @@
+/*PGR-GNU*****************************************************************
+
+FILE: vehicle_node.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#pragma once
+
+
+#include <string>
+
+#include "./tw_node.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+/*! \class Vehicle_node;
+ * \brief Extend Tw_node to evaluate the vehicle at node level
+ *
+ * This class extends Twnode by adding attributes to store information
+ * about the node in a path and provides the tools evaluate the node
+ * and to set and get these attribute values.
+ */
+
+
+class Vehicle_node: public Tw_node {
+ public:
+     /** @name log */
+     ///@ {
+
+     friend std::ostream& operator<<(
+             std::ostream &log, const Vehicle_node &node);
+
+     ///@}
+
+     /** @name Node evaluation accessors */
+     ///@ {
+
+     /*! \brief Truck's travel_time from previous node to this node. */
+     inline double travel_time() const {return m_travel_time;}
+
+     /*! \brief Truck's arrival_time to this node. */
+     inline double arrival_time() const {return m_arrival_time;}
+
+     /*! \brief Truck's wait_time at this node. */
+     inline double wait_time() const {return m_wait_time;}
+
+     /*! \brief Truck's departure_time from this node. */
+     inline double departure_time() const {return m_departure_time;}
+
+     /*! \brief delta_time = departure_time(this) - departure_time(previous) */
+     inline double delta_time() const {return m_delta_time;}
+
+     ///@}
+
+
+
+
+
+
+     /** @name Accumulated evaluation accessors */
+     ///@ {
+
+     /*! \brief Truck's total times it has violated time windows. */
+     inline int twvTot() const {return m_twvTot;}
+
+     /*! \brief Truck's total times it has violated cargo limits. */
+     inline int cvTot() const {return m_cvTot;}
+
+     /*! \brief Truck's total cargo after the node was served. */
+     inline double cargo() const {return m_cargo;}
+
+     /*! \brief Truck's travel duration up to this node. */
+     inline double total_time() const {return m_departure_time;}
+
+     /*! \brief _time spent moving between nodes by the truck */
+     inline double total_travel_time() const {return m_tot_travel_time;}
+
+     /*! \brief _time spent by the truck waiting for nodes to open */
+     inline double total_wait_time() const {return m_tot_wait_time;}
+
+     /*! \brief _time spent by the truck servicing the nodes */
+     inline double total_service_time() const {return m_tot_service_time;}
+
+     ///@}
+
+     /*! \brief True when \b arrival_time + \b delta_time generates TWV.*/
+     bool deltaGeneratesTWV(double delta_time) const;
+
+     /** @name State */
+     ///@ {
+
+     /*! \brief True when the total count for violations are 0 */
+     bool feasible() const {return m_twvTot == 0 &&  m_cvTot == 0;}
+
+     /*! \brief True doesn't have twc nor cv (including total counts) */
+     bool feasible(double cargoLimit) const {
+         return feasible() &&  !has_twv() &&  !has_cv(cargoLimit);
+     }
+
+     /*! \brief True when at this node does not violate time windows */
+     bool has_twv() const {
+         return is_late_arrival(m_arrival_time);
+     }
+
+     /*! \brief True when not violation
+      *
+      * Ending's or start's cargo should be 0
+      **/
+     bool has_cv(double cargoLimit) const {
+         return is_end() ||  is_start() ? m_cargo != 0
+             : m_cargo > cargoLimit ||  m_cargo < 0;
+     }
+     ///@}
+
+     /** @name mutators */
+     ///@ {
+     void evaluate(double cargoLimit);
+     void evaluate(const Vehicle_node &pred, double cargoLimit);
+     ///@}
+
+     /** @name Document*/
+     ///@ {
+
+     /*! \brief returns the arrval time at \b this visited after \b other */
+     double arrival_i_arrives_j(
+             const Vehicle_node &other) const;
+
+     ///@}
+
+
+
+     /*! \brief Construct from parameters */
+     Vehicle_node(const Vehicle_node &node) = default;
+     Vehicle_node(const Tw_node &node);
+
+ protected:
+     /** @name Node evaluation members */
+     ///@ {
+
+     double m_travel_time;     ///< Travel time from last node
+     double m_arrival_time;    ///< Arrival time at this node
+     double m_wait_time;       ///< Wait time at this node when early arrival
+     double m_departure_time;  // /< Departure time from this node
+     double m_delta_time;      ///< Departure time - last nodes departure time
+
+     ///@}
+
+     /** @name Accumulated evaluation members */
+     ///@ {
+
+     double m_cargo;           ///< Accumulated cargo
+     int    m_twvTot;          ///< Total count of TWV
+     int    m_cvTot;           ///< Total count of CV
+     double m_tot_wait_time;     ///< Accumulated wait time
+     double m_tot_travel_time;   ///< Accumulated travel time
+     double m_tot_service_time;  // /< Accumulated service time
+
+     ///@}
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
diff --git a/src/pickDeliver/src/vehicle_pickDeliver.cpp b/src/pickDeliver/src/vehicle_pickDeliver.cpp
new file mode 100644
index 0000000..0cb64f5
--- /dev/null
+++ b/src/pickDeliver/src/vehicle_pickDeliver.cpp
@@ -0,0 +1,352 @@
+/*PGR-GNU*****************************************************************
+
+FILE: vehicle_pickDeliver.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#include <iostream>
+#include <deque>
+#include <set>
+#include <string>
+#include <sstream>
+#include <limits>
+
+
+#include "./../../common/src/pgr_assert.h"
+#include "./order.h"
+#include "./vehicle.h"
+#include "./vehicle_pickDeliver.h"
+#include "./pgr_pickDeliver.h"
+
+
+
+namespace pgrouting {
+namespace vrp {
+
+Order
+Vehicle_pickDeliver::get_worse_order(
+        std::set<size_t> orders) const {
+    invariant();
+    pgassert(!empty());
+
+    // auto orders(of_this_subset);
+    auto worse_order(problem->orders()[*orders.begin()]);
+    auto delta_duration((std::numeric_limits<double>::max)());
+    auto curr_duration(duration());
+    while (!orders.empty()) {
+        auto truck(*this);
+        auto order(problem->orders()[*orders.begin()]);
+        pgassert(truck.has_order(order));
+        orders.erase(orders.begin());
+        truck.erase(order);
+        auto delta = truck.duration() - curr_duration;
+        if (delta < delta_duration) {
+            worse_order = order;
+            delta_duration = delta;
+        }
+    }
+    return worse_order;
+}
+
+
+Order
+Vehicle_pickDeliver::get_first_order() const {
+    invariant();
+    pgassert(!empty());
+    return problem->order_of(m_path[1]);
+}
+
+
+Vehicle_pickDeliver::Vehicle_pickDeliver(
+        size_t id,
+        const Vehicle_node &starting_site,
+        const Vehicle_node &ending_site,
+        double max_capacity,
+        const Pgr_pickDeliver *p_problem) :
+    Vehicle(id, starting_site, ending_site, max_capacity),
+    cost((std::numeric_limits<double>::max)()),
+    problem(p_problem) {
+        orders_in_vehicle.clear();
+
+        invariant();
+    }
+
+
+
+bool
+Vehicle_pickDeliver::has_order(const Order &order) const {
+    return !(orders_in_vehicle.find(order.id()) == orders_in_vehicle.end());
+}
+
+
+void
+Vehicle_pickDeliver::insert(const Order &order) {
+    invariant();
+    pgassert(!has_order(order));
+
+    auto pick_pos(position_limits(order.pickup()));
+    auto deliver_pos(position_limits(order.delivery()));
+#ifndef NDEBUG
+    std::ostringstream err_log;
+    err_log << "\n\tpickup limits (low, high) = ("
+        << pick_pos.first << ", "
+        << pick_pos.second << ") "
+        << "\n\tdeliver limits (low, high) = ("
+        << deliver_pos.first << ", "
+        << deliver_pos.second << ") "
+        << "\noriginal" << tau();
+#endif
+
+    if (pick_pos.second < pick_pos.first) {
+        /* pickup generates twv evrywhere,
+         *  so put the order as last */
+        push_back(order);
+        return;
+    }
+
+    if (deliver_pos.second < deliver_pos.first) {
+        /* delivery generates twv evrywhere,
+         *  so put the order as last */
+        push_back(order);
+        return;
+    }
+    /*
+     * Because delivery positions were estimated without
+     * the pickup:
+     *   - increase the upper limit position estimation
+     */
+    ++deliver_pos.second;
+
+
+    auto d_pos_backup(deliver_pos);
+    auto best_pick_pos = m_path.size();
+    auto best_deliver_pos = m_path.size() + 1;
+    auto current_duration(duration());
+    auto min_delta_duration = (std::numeric_limits<double>::max)();
+    auto found(false);
+    pgassertwm(!has_order(order), err_log.str());
+    while (pick_pos.first <= pick_pos.second) {
+#ifndef NDEBUG
+        err_log << "\n\tpickup cycle limits (low, high) = ("
+            << pick_pos.first << ", "
+            << pick_pos.second << ") ";
+#endif
+        Vehicle::insert(pick_pos.first, order.pickup());
+#ifndef NDEBUG
+        err_log << "\npickup inserted: " << tau();
+#endif
+
+        while (deliver_pos.first <= deliver_pos.second) {
+            Vehicle::insert(deliver_pos.first, order.delivery());
+            orders_in_vehicle.insert(order.id());
+            pgassertwm(has_order(order), err_log.str());
+#ifndef NDEBUG
+            err_log << "\ndelivery inserted: " << tau();
+#endif
+            if (is_feasable()) {
+                pgassert(is_feasable());
+                auto delta_duration = duration()-current_duration;
+                if (delta_duration < min_delta_duration) {
+#ifndef NDEBUG
+                    err_log << "\nsuccess" << tau();
+#endif
+                    min_delta_duration = delta_duration;
+                    best_pick_pos = pick_pos.first;
+                    best_deliver_pos = deliver_pos.first;
+                    found = true;
+                }
+            }
+            Vehicle::erase(deliver_pos.first);
+#ifndef NDEBUG
+            err_log << "\ndelivery erased: " << tau();
+#endif
+            ++deliver_pos.first;
+        }
+        Vehicle::erase(pick_pos.first);
+#ifndef NDEBUG
+        err_log << "\npickup erased: " << tau();
+#endif
+        orders_in_vehicle.erase(order.id());
+        pgassertwm(!has_order(order), err_log.str());
+
+        deliver_pos = d_pos_backup;
+#ifndef NDEBUG
+        err_log << "\n\trestoring deliver limits (low, high) = ("
+            << deliver_pos.first << ", "
+            << deliver_pos.second << ") ";
+#endif
+        ++pick_pos.first;
+    }
+    pgassertwm(!has_order(order), err_log.str());
+    if (!found) {
+        /* order causes twv
+         *  so put the order as last */
+        push_back(order);
+        return;
+    }
+    Vehicle::insert(best_pick_pos, order.pickup());
+    Vehicle::insert(best_deliver_pos, order.delivery());
+
+    orders_in_vehicle.insert(order.id());
+    pgassertwm(is_feasable(), err_log.str());
+    pgassertwm(has_order(order), err_log.str());
+    pgassertwm(!has_cv(), err_log.str());
+    invariant();
+}
+
+void
+Vehicle_pickDeliver::push_back(const Order &order) {
+    invariant();
+    pgassert(!has_order(order));
+
+    orders_in_vehicle.insert(order.id());
+    m_path.insert(m_path.end() - 1, order.pickup());
+    m_path.insert(m_path.end() - 1, order.delivery());
+    evaluate(m_path.size() - 3);
+
+    pgassert(has_order(order));
+    pgassert(!has_cv());
+    invariant();
+}
+
+void
+Vehicle_pickDeliver::push_front(const Order &order) {
+    invariant();
+    pgassert(!has_order(order));
+
+    orders_in_vehicle.insert(order.id());
+    m_path.insert(m_path.begin() + 1, order.delivery());
+    m_path.insert(m_path.begin() + 1, order.pickup());
+    evaluate(1);
+
+    pgassert(has_order(order));
+    pgassert(!has_cv());
+    invariant();
+}
+
+
+void
+Vehicle_pickDeliver::erase(const Order &order) {
+    invariant();
+    pgassert(has_order(order));
+
+
+    Vehicle::erase(order.pickup());
+    Vehicle::erase(order.delivery());
+    orders_in_vehicle.erase(orders_in_vehicle.find(order.id()));
+
+    invariant();
+    pgassert(!has_order(order));
+}
+
+
+
+size_t
+Vehicle_pickDeliver::pop_back() {
+    invariant();
+    pgassert(!empty());
+
+    auto pick_itr = m_path.rbegin();
+    while (pick_itr != m_path.rend() &&  !pick_itr->is_pickup()) {
+        ++pick_itr;
+    }
+
+    pgassert(pick_itr->is_pickup());
+
+    ID deleted_pick_id = pick_itr->id();
+
+
+    auto delivery_id = problem->node(deleted_pick_id).Did();
+
+    m_path.erase((pick_itr + 1).base());
+
+    auto delivery_itr = m_path.rbegin();
+    while (delivery_itr != m_path.rend()
+            && !(delivery_itr->id() ==delivery_id)) {
+        ++delivery_itr;
+    }
+
+    pgassert(delivery_itr->is_delivery());
+    pgassert(delivery_itr->Pid() == deleted_pick_id);
+
+    m_path.erase((delivery_itr + 1).base());
+
+
+    /* figure out from where the evaluation is needed */
+    evaluate(1);
+
+    ID deleted_order_id(
+            problem->order_of(problem->node(deleted_pick_id)).id());
+
+    orders_in_vehicle.erase(orders_in_vehicle.find(deleted_order_id));
+
+    invariant();
+    return deleted_order_id;
+}
+
+
+
+size_t
+Vehicle_pickDeliver::pop_front() {
+    invariant();
+    pgassert(!empty());
+
+    auto pick_itr = m_path.begin();
+    while (pick_itr != m_path.end() &&  !pick_itr->is_pickup()) {
+        ++pick_itr;
+    }
+
+    pgassert(pick_itr->is_pickup());
+
+    ID deleted_pick_id = pick_itr->id();
+
+
+    auto delivery_id = problem->node(deleted_pick_id).Did();
+
+    m_path.erase(pick_itr);
+
+    auto delivery_itr = m_path.begin();
+    while (delivery_itr != m_path.end()
+            && !(delivery_itr->id() == delivery_id)) {
+        ++delivery_itr;
+    }
+
+    pgassert(delivery_itr->is_delivery());
+    pgassert(delivery_itr->Pid() == deleted_pick_id);
+
+    m_path.erase(delivery_itr);
+
+    evaluate(1);
+
+    ID deleted_order_id(
+            problem->order_of(problem->node(deleted_pick_id)).id());
+
+    orders_in_vehicle.erase(orders_in_vehicle.find(deleted_order_id));
+
+    invariant();
+    return deleted_order_id;
+}
+
+
+}  //  namespace vrp
+}  //  namespace pgrouting
+
+
diff --git a/src/pickDeliver/src/vehicle_pickDeliver.h b/src/pickDeliver/src/vehicle_pickDeliver.h
new file mode 100644
index 0000000..6832d96
--- /dev/null
+++ b/src/pickDeliver/src/vehicle_pickDeliver.h
@@ -0,0 +1,155 @@
+/*PGR-GNU*****************************************************************
+
+FILE: vehicle_pickDeliver.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#pragma once
+
+#include <set>
+#include "./order.h"
+#include "./tw_node.h"
+#include "./vehicle.h"
+
+namespace pgrouting {
+namespace vrp {
+
+
+class Initial_solution;
+class Optimize;
+
+class Vehicle_pickDeliver : public Vehicle {
+ protected:
+     double cost;
+     std::set<ID> orders_in_vehicle;  // /< orders inserted in this vehicle
+     const Pgr_pickDeliver *problem;  // /< The vehicle belongs to this problem
+
+
+ public:
+     friend class Initial_solution;
+     friend class Optimize;
+
+     Vehicle_pickDeliver(
+             ID id,
+             const Vehicle_node &starting_site,
+             const Vehicle_node &ending_site,
+             double max_capacity,
+             const Pgr_pickDeliver *p_problem);
+
+     Vehicle_pickDeliver(const Vehicle_pickDeliver &) = default;
+
+     size_t orders_size() const {return orders_in_vehicle.size();}
+
+     bool has_order(const Order &order) const;
+
+     /*! @brief puts an order at the end of the truck
+      *
+      * Precondition:
+      * !has_order(order)
+      *
+      * Postcondition:
+      * has_order(order)
+      * !has_cv();
+      *
+      * ~~~~{.c}
+      * Before: S <nodes> E
+      *   After: S <nodes> P D E
+      * ~~~~
+      *
+      * Can generate time window violation
+      * No capacity violation
+      */
+     void push_back(const Order &order);
+
+
+
+     /*! @brief Puts an order at the end front of the truck
+      *
+      * Precondition:
+      * !has_order(order)
+      *
+      * Postcondition:
+      * has_order(order)
+      * !has_cv();
+      *
+      * ~~~~{.c}
+      * Before: S <nodes> E
+      *   After: S P D <nodes> E
+      * ~~~~
+      *
+      * Can generate time window violation
+      * No capacity violation
+      */
+     void push_front(const Order &order);
+
+
+
+     /*! @brief Inserts an order
+      *
+      * Precondition:
+      * !has_order(order)
+      *
+      * Postcondition:
+      * has_order(order)
+      * !has_cv();
+      *
+      * ~~~~{.c}
+      * Before: S <nodes> E
+      *   After: S ....P .... D .... E
+      * ~~~~
+      *
+      * push_back is performed when
+      *   - pickup
+      *
+      * Can generate time window violation
+      * No capacity violation
+      */
+     void insert(const Order &order);
+
+     /* @brief erases the order from the vehicle
+      *
+      * Precondition:
+      * has_order(order)
+      *
+      * Precondition:
+      * !has_order(order)
+      */
+     void erase(const Order &order);
+
+     /* @brief 
+      */
+     Order get_first_order() const;
+     Order get_worse_order(std::set<size_t> of_this_subset) const;
+
+
+     /*!
+      * The order that is picked last is removed
+      *
+      * \returns id of the removed order
+      */
+
+     ID pop_back();
+     ID pop_front();
+};
+
+}  //  namespace vrp
+}  //  namespace pgrouting
+
diff --git a/src/pickDeliver/test/CMakeLists.txt b/src/pickDeliver/test/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/pickDeliver/test/bencharkTest/README.vrpdptw-testdata b/src/pickDeliver/test/bencharkTest/README.vrpdptw-testdata
new file mode 100644
index 0000000..93b9849
--- /dev/null
+++ b/src/pickDeliver/test/bencharkTest/README.vrpdptw-testdata
@@ -0,0 +1,33 @@
+
+# Li & Lim benchmark
+
+Here you find instance definitions and the best known solutions
+(to our knowledge) for the 100, 200, 400, 600, 800, and 1000 customer
+instances of Li & Lim's PDPTW benchmark problems. The version reported
+here has a hierarchical objective:
+
+ 1. Minimize number of vehicles
+ 2. Minimize total distance.
+
+Distance and time should be calculated with double precision, total
+distance results are rounded to two decimals. Exact methods typically
+use a total distance objective and use integral or low precision distance
+and time calculations. Hence, results are not directly comparable.
+
+This data base was built from data published at
+http://www.sintef.no/Projectweb/TOP/PDPTW/Li--Lim-benchmark/
+
+The data loads into a schema named "testdata" and there are 352 test cases
+with each test cases loaded into a table. there is a summary table called
+"pdp_problems" which lists each data table as "instance" and provides
+additional information about the best know result and the number of
+vehicles and vehicle capacity for each test cases.
+
+You might load these with commands like:
+
+```
+createdb -U postgres -h localhost pickdelivery_tests
+zcat vrpdptw-testdata.sql.gz | psql -U postgres -h localhost pickdelivery_tests
+```
+
+
diff --git a/src/pickDeliver/test/bencharkTest/lc101_test.sql b/src/pickDeliver/test/bencharkTest/lc101_test.sql
new file mode 100644
index 0000000..6f33f4f
--- /dev/null
+++ b/src/pickDeliver/test/bencharkTest/lc101_test.sql
@@ -0,0 +1,9 @@
+
+DROP EXTENSION pgrouting;
+CREATE EXTENSION pgrouting;
+
+
+SET search_path TO testdata, public;
+SELECT * FROM pgr_pickDeliver(
+    'select nid as id, service as stime, tw_open as etime, tw_close as ltime, pid as pindex, did as dindex, x, y, demand from lc101'::text, 25, 200, 30)
+;
diff --git a/src/pickDeliver/test/bencharkTest/vrpdptw-testdata.sql.gz b/src/pickDeliver/test/bencharkTest/vrpdptw-testdata.sql.gz
new file mode 100644
index 0000000..efda4b2
Binary files /dev/null and b/src/pickDeliver/test/bencharkTest/vrpdptw-testdata.sql.gz differ
diff --git a/src/pickDeliver/test/doc-pickDeliver.result b/src/pickDeliver/test/doc-pickDeliver.result
new file mode 100644
index 0000000..06e1baa
--- /dev/null
+++ b/src/pickDeliver/test/doc-pickDeliver.result
@@ -0,0 +1,233 @@
+--q1
+1|1|1|0|0|0|0|0|0
+2|1|2|5|15.1327459504216|15.1327459504216|0|90|105.132745950422
+3|1|3|3|1|106.132745950422|0|90|196.132745950422
+4|1|4|7|2|198.132745950422|0|90|288.132745950422
+5|1|5|8|2.82842712474619|290.961173075168|0|90|380.961173075168
+6|1|6|10|3.60555127546399|384.566724350632|0|90|474.566724350632
+7|1|7|11|3|477.566724350632|0|90|567.566724350632
+8|1|8|9|3.16227766016838|570.7290020108|0|90|660.7290020108
+9|1|9|6|2.23606797749979|662.9650699883|0|90|752.9650699883
+10|1|10|4|2.23606797749979|755.2011379658|0|90|845.2011379658
+11|1|11|2|3.60555127546399|848.806689241264|0|90|938.806689241264
+12|1|12|1|2|940.806689241264|0|90|1030.80668924126
+13|1|13|75|3|1033.80668924126|0|90|1123.80668924126
+14|1|14|0|15.8113883008419|1139.61807754211|0|0|1139.61807754211
+15|2|1|0|0|0|0|0|0
+16|2|2|13|30.8058436014987|30.8058436014987|0|90|120.805843601499
+17|2|3|17|4|124.805843601499|0|90|214.805843601499
+18|2|4|18|3|217.805843601499|0|90|307.805843601499
+19|2|5|19|5|312.805843601499|0|90|402.805843601499
+20|2|6|15|5|407.805843601499|0|90|497.805843601499
+21|2|7|16|5|502.805843601499|0|90|592.805843601499
+22|2|8|14|2|594.805843601499|0|90|684.805843601499
+23|2|9|12|3|687.805843601499|0|90|777.805843601499
+24|2|10|0|38.0788655293195|815.884709130818|0|0|815.884709130818
+25|3|1|0|0|0|0|0|0
+26|3|2|20|10|10|0|90|100
+27|3|3|24|5|105|0|90|195
+28|3|4|25|2|197|0|90|287
+29|3|5|27|2|289|0|90|379
+30|3|6|29|3.60555127546399|382.605551275464|0|90|472.605551275464
+31|3|7|30|5|477.605551275464|0|90|567.605551275464
+32|3|8|28|3|570.605551275464|0|90|660.605551275464
+33|3|9|26|2|662.605551275464|0|90|752.605551275464
+34|3|10|23|3|755.605551275464|0|0|755.605551275464
+35|3|11|103|0|755.605551275464|0|90|845.605551275464
+36|3|12|22|3|848.605551275464|0|90|938.605551275464
+37|3|13|21|2|940.605551275464|0|90|1030.60555127546
+38|3|14|0|10.1980390271856|1040.80359030265|0|0|1040.80359030265
+39|4|1|0|0|0|0|0|0
+40|4|2|32|31.6227766016838|31.6227766016838|0|90|121.622776601684
+41|4|3|33|2|123.622776601684|0|90|213.622776601684
+42|4|4|31|5.3851648071345|219.007941408818|0|90|309.007941408818
+43|4|5|35|5|314.007941408818|0|90|404.007941408818
+44|4|6|37|5.8309518948453|409.838893303664|0|90|499.838893303664
+45|4|7|38|2|501.838893303664|0|90|591.838893303664
+46|4|8|39|5|596.838893303664|0|90|686.838893303664
+47|4|9|36|5|691.838893303664|0|0|691.838893303664
+48|4|10|105|0|691.838893303664|0|90|781.838893303664
+49|4|11|34|3|784.838893303664|0|90|874.838893303664
+50|4|12|0|32.3882694814033|907.227162785067|0|0|907.227162785067
+51|5|1|0|0|0|0|0|0
+52|5|2|43|16.5529453572468|16.5529453572468|0|90|106.552945357247
+53|5|3|42|3|109.552945357247|0|90|199.552945357247
+54|5|4|41|2|201.552945357247|0|90|291.552945357247
+55|5|5|40|2|293.552945357247|0|90|383.552945357247
+56|5|6|44|3|386.552945357247|0|90|476.552945357247
+57|5|7|46|2.82842712474619|479.381372481993|0|90|569.381372481993
+58|5|8|45|2|571.381372481993|0|90|661.381372481993
+59|5|9|48|2|663.381372481993|0|90|753.381372481993
+60|5|10|51|3|756.381372481993|0|0|756.381372481993
+61|5|11|101|0|756.381372481993|0|90|846.381372481993
+62|5|12|50|2.23606797749979|848.617440459493|0|90|938.617440459493
+63|5|13|52|3.16227766016838|941.779718119661|0|90|1031.77971811966
+64|5|14|49|3|1034.77971811966|0|90|1124.77971811966
+65|5|15|47|2|1126.77971811966|0|90|1216.77971811966
+66|5|16|0|18.0277563773199|1234.80747449698|0|0|1234.80747449698
+67|6|1|0|0|0|0|0|0
+68|6|2|57|35|35|0|90|125
+69|6|3|55|2|127|0|90|217
+70|6|4|54|5|222|0|90|312
+71|6|5|53|5.3851648071345|317.385164807135|0|90|407.385164807135
+72|6|6|56|4|411.385164807135|0|90|501.385164807135
+73|6|7|58|2|503.385164807135|0|90|593.385164807135
+74|6|8|60|3|596.385164807135|0|90|686.385164807135
+75|6|9|59|10.4403065089106|696.825471316045|0|90|786.825471316045
+76|6|10|0|35.0570962859162|821.882567601961|0|0|821.882567601961
+77|7|1|0|0|0|0|0|0
+78|7|2|67|12.2065556157337|12.2065556157337|0|90|102.206555615734
+79|7|3|65|1|103.206555615734|0|90|193.206555615734
+80|7|4|63|2|195.206555615734|0|90|285.206555615734
+81|7|5|62|5|290.206555615734|0|90|380.206555615734
+82|7|6|74|3|383.206555615734|0|90|473.206555615734
+83|7|7|72|5|478.206555615734|0|90|568.206555615734
+84|7|8|61|3|571.206555615734|0|90|661.206555615734
+85|7|9|64|2|663.206555615734|0|0|663.206555615734
+86|7|10|102|0|663.206555615734|0|90|753.206555615734
+87|7|11|68|3|756.206555615734|0|90|846.206555615734
+88|7|12|66|5.3851648071345|851.591720422868|0|90|941.591720422868
+89|7|13|69|2|943.591720422868|0|90|1033.59172042287
+90|7|14|0|15.8113883008419|1049.40310872371|0|0|1049.40310872371
+91|8|1|0|0|0|0|0|0
+92|8|2|81|47.4341649025257|47.4341649025257|0|90|137.434164902526
+93|8|3|78|3|140.434164902526|0|0|140.434164902526
+94|8|4|104|0|140.434164902526|0|90|230.434164902526
+95|8|5|76|2|232.434164902526|0|90|322.434164902526
+96|8|6|71|5|327.434164902526|0|90|417.434164902526
+97|8|7|70|5|422.434164902526|0|90|512.434164902526
+98|8|8|73|3|515.434164902526|0|90|605.434164902526
+99|8|9|77|4|609.434164902526|0|90|699.434164902526
+100|8|10|79|1|700.434164902526|0|90|790.434164902526
+101|8|11|80|5.3851648071345|795.81932970966|0|90|885.81932970966
+102|8|12|0|51.478150704935|937.297480414595|0|0|937.297480414595
+103|9|1|0|0|0|0|0|0
+104|9|2|90|20.6155281280883|20.6155281280883|0|90|110.615528128088
+105|9|3|87|5|115.615528128088|0|90|205.615528128088
+106|9|4|86|1|206.615528128088|0|90|296.615528128088
+107|9|5|83|6|302.615528128088|0|90|392.615528128088
+108|9|6|82|3|395.615528128088|0|90|485.615528128088
+109|9|7|84|5.8309518948453|491.446480022934|0|90|581.446480022934
+110|9|8|85|2.82842712474619|584.27490714768|0|90|674.27490714768
+111|9|9|88|3|677.27490714768|0|90|767.27490714768
+112|9|10|89|2.82842712474619|770.103334272426|0|90|860.103334272426
+113|9|11|91|3.60555127546399|863.70888554789|0|90|953.70888554789
+114|9|12|0|22.3606797749979|976.069565322888|0|0|976.069565322888
+115|-1|0|0|732.993736320776|0|0|8190|8922.99373632078
+--q2
+1|1|1|0|0|0|0|0|0
+2|1|2|5|1.51327459504216|1.51327459504216|13.4867254049578|90|105
+3|1|3|3|0.1|105.1|0|90|195.1
+4|1|4|7|0.2|195.3|0|90|285.3
+5|1|5|8|0.282842712474619|285.582842712475|0|90|375.582842712475
+6|1|6|10|0.360555127546399|375.943397840021|0|90|465.943397840021
+7|1|7|11|0.3|466.243397840021|0|90|556.243397840021
+8|1|8|9|0.316227766016838|556.559625606038|0|90|646.559625606038
+9|1|9|6|0.223606797749979|646.783232403788|0|90|736.783232403788
+10|1|10|4|0.223606797749979|737.006839201538|0|90|827.006839201538
+11|1|11|2|0.360555127546399|827.367394329084|0|90|917.367394329084
+12|1|12|1|0.2|917.567394329084|0|90|1007.56739432908
+13|1|13|75|0.3|1007.86739432908|0|90|1097.86739432908
+14|1|14|0|1.58113883008419|1099.44853315917|0|0|1099.44853315917
+15|2|1|0|0|0|0|0|0
+16|2|2|13|3.08058436014987|3.08058436014987|26.9194156398501|90|120
+17|2|3|17|0.4|120.4|0|90|210.4
+18|2|4|18|0.3|210.7|0|90|300.7
+19|2|5|19|0.5|301.2|0|90|391.2
+20|2|6|15|0.5|391.7|0|90|481.7
+21|2|7|16|0.5|482.2|0|90|572.2
+22|2|8|14|0.2|572.4|0|90|662.4
+23|2|9|12|0.3|662.7|0|90|752.7
+24|2|10|0|3.80788655293195|756.507886552932|0|0|756.507886552932
+25|3|1|0|0|0|0|0|0
+26|3|2|20|1|1|9|90|100
+27|3|3|24|0.5|100.5|0|90|190.5
+28|3|4|25|0.2|190.7|0|90|280.7
+29|3|5|27|0.2|280.9|0|90|370.9
+30|3|6|29|0.360555127546399|371.260555127546|0|90|461.260555127546
+31|3|7|30|0.5|461.760555127546|0|90|551.760555127546
+32|3|8|28|0.3|552.060555127546|0|90|642.060555127546
+33|3|9|26|0.2|642.260555127546|0|90|732.260555127546
+34|3|10|23|0.3|732.560555127546|0|0|732.560555127546
+35|3|11|103|0|732.560555127546|0|90|822.560555127546
+36|3|12|22|0.3|822.860555127546|0|90|912.860555127546
+37|3|13|21|0.2|913.060555127546|0.939444872453691|90|1004
+38|3|14|0|1.01980390271856|1005.01980390272|0|0|1005.01980390272
+39|4|1|0|0|0|0|0|0
+40|4|2|32|3.16227766016838|3.16227766016838|27.8377223398316|90|121
+41|4|3|33|0.2|121.2|0|90|211.2
+42|4|4|31|0.53851648071345|211.738516480713|0|90|301.738516480713
+43|4|5|35|0.5|302.238516480713|0|90|392.238516480713
+44|4|6|37|0.58309518948453|392.821611670198|0|90|482.821611670198
+45|4|7|38|0.2|483.021611670198|0|90|573.021611670198
+46|4|8|39|0.5|573.521611670198|0|90|663.521611670198
+47|4|9|36|0.5|664.021611670198|0.978388329802101|0|665
+48|4|10|105|0|665|0|90|755
+49|4|11|34|0.3|755.3|0|90|845.3
+50|4|12|0|3.23882694814033|848.53882694814|0|0|848.53882694814
+51|5|1|0|0|0|0|0|0
+52|5|2|43|1.65529453572468|1.65529453572468|14.3447054642753|90|106
+53|5|3|42|0.3|106.3|0|90|196.3
+54|5|4|41|0.2|196.5|0|90|286.5
+55|5|5|40|0.2|286.7|0|90|376.7
+56|5|6|44|0.3|377|0|90|467
+57|5|7|46|0.282842712474619|467.282842712475|0|90|557.282842712475
+58|5|8|45|0.2|557.482842712475|0|90|647.482842712475
+59|5|9|48|0.2|647.682842712475|0|90|737.682842712475
+60|5|10|51|0.3|737.982842712475|0|0|737.982842712475
+61|5|11|101|0|737.982842712475|0|90|827.982842712475
+62|5|12|50|0.223606797749979|828.206449510225|0|90|918.206449510225
+63|5|13|52|0.316227766016838|918.522677276241|0|90|1008.52267727624
+64|5|14|49|0.3|1008.82267727624|0|90|1098.82267727624
+65|5|15|47|0.2|1099.02267727624|0|90|1189.02267727624
+66|5|16|0|1.80277563773199|1190.82545291397|0|0|1190.82545291397
+67|6|1|0|0|0|0|0|0
+68|6|2|57|3.5|3.5|31.5|90|125
+69|6|3|55|0.2|125.2|0|90|215.2
+70|6|4|54|0.5|215.7|0|90|305.7
+71|6|5|53|0.53851648071345|306.238516480713|0|90|396.238516480713
+72|6|6|56|0.4|396.638516480713|0|90|486.638516480713
+73|6|7|58|0.2|486.838516480713|0|90|576.838516480713
+74|6|8|60|0.3|577.138516480713|0|90|667.138516480713
+75|6|9|59|1.04403065089106|668.182547131604|0|90|758.182547131604
+76|6|10|0|3.50570962859162|761.688256760196|0|0|761.688256760196
+77|7|1|0|0|0|0|0|0
+78|7|2|67|1.22065556157337|1.22065556157337|10.7793444384266|90|102
+79|7|3|65|0.1|102.1|0|90|192.1
+80|7|4|63|0.2|192.3|0|90|282.3
+81|7|5|62|0.5|282.8|0|90|372.8
+82|7|6|74|0.3|373.1|0|90|463.1
+83|7|7|72|0.5|463.6|0|90|553.6
+84|7|8|61|0.3|553.9|0|90|643.9
+85|7|9|64|0.2|644.1|0|0|644.1
+86|7|10|102|0|644.1|0|90|734.1
+87|7|11|68|0.3|734.4|0|90|824.4
+88|7|12|66|0.53851648071345|824.938516480713|1.06148351928664|90|916
+89|7|13|69|0.2|916.2|0|90|1006.2
+90|7|14|0|1.58113883008419|1007.78113883008|0|0|1007.78113883008
+91|8|1|0|0|0|0|0|0
+92|8|2|81|4.74341649025257|4.74341649025257|42.2565835097474|90|137
+93|8|3|78|0.3|137.3|0|0|137.3
+94|8|4|104|0|137.3|0|90|227.3
+95|8|5|76|0.2|227.5|0|90|317.5
+96|8|6|71|0.5|318|0|90|408
+97|8|7|70|0.5|408.5|0|90|498.5
+98|8|8|73|0.3|498.8|0|90|588.8
+99|8|9|77|0.4|589.2|0|90|679.2
+100|8|10|79|0.1|679.3|0|90|769.3
+101|8|11|80|0.53851648071345|769.838516480713|0|90|859.838516480713
+102|8|12|0|5.1478150704935|864.986331551207|0|0|864.986331551207
+103|9|1|0|0|0|0|0|0
+104|9|2|90|2.06155281280883|2.06155281280883|17.9384471871912|90|110
+105|9|3|87|0.5|110.5|0|90|200.5
+106|9|4|86|0.1|200.6|0|90|290.6
+107|9|5|83|0.6|291.2|0|90|381.2
+108|9|6|82|0.3|381.5|0|90|471.5
+109|9|7|84|0.58309518948453|472.083095189485|0|90|562.083095189485
+110|9|8|85|0.282842712474619|562.365937901959|0|90|652.365937901959
+111|9|9|88|0.3|652.665937901959|0|90|742.665937901959
+112|9|10|89|0.282842712474619|742.948780614434|0|90|832.948780614434
+113|9|11|91|0.360555127546399|833.30933574198|2.69066425801998|90|926
+114|9|12|0|2.23606797749979|928.2360679775|0|0|928.2360679775
+115|-1|0|0|73.2993736320776|0|199.732924963843|8190|8463.03229859592
+--q3
diff --git a/src/pickDeliver/test/doc-pickDeliver.test.sql b/src/pickDeliver/test/doc-pickDeliver.test.sql
new file mode 100644
index 0000000..1882959
--- /dev/null
+++ b/src/pickDeliver/test/doc-pickDeliver.test.sql
@@ -0,0 +1,8 @@
+
+\echo --q1
+SELECT * FROM _pgr_pickDeliver(
+    'select * from customer order by id', 25, 200, 1, 30);
+\echo --q2
+SELECT * FROM _pgr_pickDeliver(
+    'select * from customer order by id', 25, 200, 10, 30);
+\echo --q3
diff --git a/src/pickDeliver/test/pdp-any-01.result b/src/pickDeliver/test/pdp-any-01.result
deleted file mode 100644
index c3bc989..0000000
--- a/src/pickDeliver/test/pdp-any-01.result
+++ /dev/null
@@ -1,3 +0,0 @@
-t
-137
-t
diff --git a/src/pickDeliver/test/pgtap/pickDeliver_types_check.sql b/src/pickDeliver/test/pgtap/pickDeliver_types_check.sql
new file mode 100644
index 0000000..aa11961
--- /dev/null
+++ b/src/pickDeliver/test/pgtap/pickDeliver_types_check.sql
@@ -0,0 +1,39 @@
+
+\i setup.sql
+
+SELECT plan(3);
+
+SELECT has_function('_pgr_pickdeliver', ARRAY['text','integer','double precision','double precision', 'integer']);
+SELECT function_returns('_pgr_pickdeliver', ARRAY['text','integer','double precision','double precision', 'integer'],'setof record');
+
+PREPARE expected_types AS
+SELECT
+'integer'::text AS t1,
+'integer'::text AS t2,
+'integer'::text AS t3,
+'bigint'::text AS t4,
+'double precision'::text AS t5,
+'double precision'::text AS t6,
+'double precision'::text AS t7,
+'double precision'::text AS t8,
+'double precision'::text AS t9;
+
+SELECT * INTO pickDeliverResults FROM _pgr_pickdeliver('SELECT * from customer order by id', 25, 200, 1, 30);
+
+
+PREPARE real_types AS
+SELECT pg_typeof(seq)::text AS t1,
+pg_typeof(vehicle_id)::text AS t2,
+pg_typeof(vehicle_seq)::text AS t3,
+pg_typeof(stop_id)::text AS t4,
+pg_typeof(travel_time)::text AS t5,
+pg_typeof(arrival_time)::text AS t6,
+pg_typeof(wait_time)::TEXT AS t7,
+pg_typeof(service_time)::TEXT AS t8,
+pg_typeof(departure_time)::TEXT AS t9
+FROM  pickdeliverResults LIMIT 1;
+
+SELECT set_eq('expected_types', 'real_types','_pgr_pickdeliver: SHOULD RETURN expected columns names & types');
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/pickDeliver/test/pgtap/wrong_data.sql b/src/pickDeliver/test/pgtap/wrong_data.sql
new file mode 100644
index 0000000..e0f367f
--- /dev/null
+++ b/src/pickDeliver/test/pgtap/wrong_data.sql
@@ -0,0 +1,130 @@
+
+\i setup.sql
+
+SELECT plan(11);
+
+PREPARE q1 AS
+SELECT * FROM _pgr_pickDeliver(
+    'SELECT *
+    FROM customer ORDER BY id'::text, 25, 200, 1, 30);
+
+
+SELECT lives_ok('q1', 'Original query should not fail');
+
+/*
+ id | x  | y  | demand | etime | ltime | stime | pindex | dindex 
+----+----+----+--------+-------+-------+-------+--------+--------
+  0 | 40 | 50 |      0 |     0 |  1236 |     0 |      0 |      0
+*/
+PREPARE q2 AS
+SELECT * FROM _pgr_pickDeliver(
+    'SELECT *
+    FROM customer WHERE id != 0 ORDER BY id'::text, 25, 200, 30);
+
+SELECT throws_ok('q2',
+    'XX000',
+    'Depot node not found',
+    'Should fail: depot is not included in data');
+
+/*
+ 11 | 35 | 69 |     10 |   448 |   505 |    90 |      0 |      1
+*/
+PREPARE q3 AS
+SELECT * FROM _pgr_pickDeliver(
+    'SELECT *
+    FROM customer WHERE id != 11 ORDER BY id'::text, 25, 200, 30);
+
+SELECT throws_ok('q3',
+    'XX000',
+    'A pickup was not found',
+    'Should fail: 11 is a Pickup and is missing');
+
+/*
+  1 | 45 | 68 |    -10 |   912 |   967 |    90 |     11 |      0
+*/
+PREPARE q4 AS
+SELECT * FROM _pgr_pickDeliver(
+    'SELECT *
+    FROM customer WHERE id != 1 ORDER BY id'::text, 25, 200, 30);
+
+SELECT throws_ok('q4',
+    'XX000',
+    'For Pickup 11 the corresponding Delivery was not found',
+    'Should fail: id 1 is a delivery and is missing');
+
+UPDATE customer SET closetime = 500 WHERE id =0;
+
+PREPARE q5 AS
+SELECT * FROM _pgr_pickDeliver(
+    'SELECT *
+    FROM customer WHERE id in (0,1,11) ORDER BY id'::text, 25, 200, 30);
+
+SELECT throws_ok('q5',
+    'XX000',
+    'The (pickup, delivery) = (11, 1) is not feasible',
+    'Should fail: Closing time of depot is too small and (pick,deliver) pair generates TWV');
+
+--------------------------------------
+-- testing wrong data on DEPOT 
+--------------------------------------
+UPDATE customer SET opentime = 3000, closetime = 1236 WHERE id =0;
+
+SELECT throws_ok('q5',
+    'XX000',
+    'Illegal values found on the starting site',
+    'Should fail: Opens(DEPOT) > closes(DEPOT)');
+
+UPDATE customer SET opentime = 0, demand = 20 WHERE id =0;
+
+SELECT throws_ok('q5',
+    'XX000',
+    'Illegal values found on the starting site',
+    'Should fail: Demand(DEPOT) != 0');
+
+UPDATE customer SET demand = 0 WHERE id =0;
+
+--------------------------------------
+-- testing wrong data on pickup 
+--------------------------------------
+UPDATE customer SET opentime = 600 WHERE id =11;
+
+SELECT throws_ok('q5',
+    'XX000',
+    'Illegal values found on Pickup 11',
+    'Should fail: Opens(PICKUP) > closes(PICKUP)');
+
+UPDATE customer SET opentime = 448, demand= -20 WHERE id =11;
+
+SELECT throws_ok('q5',
+    'XX000',
+    'Illegal values found on Pickup 11',
+    'Should fail: demand(PICKUP) < 0');
+
+UPDATE customer SET demand= 10 WHERE id =11;
+
+--------------------------------------
+-- testing wrong data on delivery 
+--------------------------------------
+UPDATE customer SET opentime = 1000 WHERE id =1;
+
+SELECT throws_ok('q5',
+    'XX000',
+    'Illegal values found on Delivery 1',
+    'Should fail: Opens(DELIVERY) > closes(DELIVERY)');
+
+UPDATE customer SET opentime = 912, demand= 20 WHERE id =1;
+
+SELECT throws_ok('q5',
+    'XX000',
+    'Illegal values found on Delivery 1',
+    'Should fail: demand(DELIVERY) > 0');
+
+UPDATE customer SET demand = -10 WHERE id =11;
+
+
+
+
+
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/pickDeliver/test/pdp-any-00.data b/src/pickDeliver/test/pickDeliver.data
similarity index 83%
rename from src/pickDeliver/test/pdp-any-00.data
rename to src/pickDeliver/test/pickDeliver.data
index 9347f06..aecce0d 100644
--- a/src/pickDeliver/test/pdp-any-00.data
+++ b/src/pickDeliver/test/pickDeliver.data
@@ -1,16 +1,16 @@
-drop table if exists customer cascade;
-create table customer (
-                id integer not null primary key,
-                x integer,
-                y integer,
-                demand integer,
-                etime integer,
-                ltime integer, 
-                stime integer, 
-                pindex integer,
-                dindex integer 
-                );
-copy customer (id,x,y,demand,etime,ltime, stime,pindex, dindex) from stdin;
+DROP TABLE IF EXISTS customer CASCADE;
+CREATE TABLE customer (
+    id INTEGER NOT NULL PRIMARY KEY,
+    x INTEGER,
+    y INTEGER,
+    demand INTEGER,
+    openTime INTEGER,
+    closeTime INTEGER, 
+    serviceTime INTEGER, 
+    pindex INTEGER,
+    dindex INTEGER 
+    );
+copy customer (id, x, y, demand, openTime, closeTime, serviceTime, pindex, dindex) from stdin;
 0	40	50	0	0	1236	0	0	0
 1	45	68	-10	912	967	90	11	0
 2	45	70	-20	825	870	90	6	0
diff --git a/src/allpairs/test/test.conf b/src/pickDeliver/test/test.conf
similarity index 51%
copy from src/allpairs/test/test.conf
copy to src/pickDeliver/test/test.conf
index 528a981..fabe259 100644
--- a/src/allpairs/test/test.conf
+++ b/src/pickDeliver/test/test.conf
@@ -2,24 +2,24 @@
 
 %main::tests = (
     'any' => {
-        'comment' => 'All pairs tests.',
-        'data' => [''],
+        'comment' => 'Function test for any versions.',
+        'data' => ['pickDeliver.data'],
         'tests' => [qw(
-            doc-johnson
-            doc-floydWarshall
+            doc-pickDeliver
             )],
-
         'documentation' => [qw(
-            doc-johnson
-            doc-floydWarshall
+            doc-pickDeliver
+            )],
+
+#put here the ones that you are not testing (just a place holder)
+        'nottesting' => [qw(
             )]
     },
-# I dont know what this are for or how to use them.
+# I don't know what this are for or how to use them.
 #  TODO ask Steve 
 #    'vpg-vpgis' => {}, # for version specific tests
 #    '8-1' => {},       # for pg 8.x and postgis 1.x
 #    '9.2-2.1' => {},   # for pg 9.2 and postgis 2.1
-
 );
 
 1;
diff --git a/src/proposed.rst b/src/proposed.rst
index 8257271..12caf6e 100644
--- a/src/proposed.rst
+++ b/src/proposed.rst
@@ -14,87 +14,93 @@ Experimental and Proposed functions
 
 :ref:`proposed`
 
-These are proposed functions
+
+..
+   begin-warning
+
+.. warning:: These are proposed functions
 
   - They are not officially of the current release.
-  - They likely will not be officialy be part of the version 2.3 release:
+  - They likely will not be officially be part of the next release:
 
     - The functions might not make use of ANY-INTEGER and ANY-NUMERICAL
     - Name might change.
     - Signature might change.
     - Functionality might change.
-    - pgTap tests might not being done.
+    - pgTap tests might be missing.
     - Might need c/c++ coding.
-    - May lack documentation,
+    - May lack documentation.
     - Documentation if any might need to be rewritten.
     - Documentation examples might need to be automatically generated.
     - Might need a lot of feedback from the comunity.
-    - Might need a non official function of pgRouting
-    - Might need a deprecated function of pgRouting
+    - Might depend on a proposed function of pgRouting
+    - Might depend on a deprecated function of pgRouting
 
+..
+   end-warning
 
-Proposed functions: Proposed by Steve Woodbridge
+
+Proposed functions
 ------------------------------------------------
 
-:ref:`convenience_functions`
-  -  :ref:`pgr_point_to_edgenode` - convert a point geometry to a ``vertex_id`` based on closest edge.
-  -  :ref:`pgr_flip_edges` - flip the edges in an array of geometries so the connect end to end.
-  -  :ref:`pgr_text_to_points` - convert a string of ``x,y;x,y;...`` locations into point geometries.
-  -  :ref:`pgr_points_to_vids` - convert an array of point geometries into vertex ids.
-  -  :ref:`pgr_points_to_dmatrix` - Create a distance matrix from an array of points.
-  -  :ref:`pgr_vids_to_dmatrix` - Create a distance matrix from an array of ``vertix_id``.
-  -  :ref:`pgr_vids_to_dmatrix2` - Create a distance matrix from an array of ``vertix_id``.
+- :ref:`contraction` - Reduce network size using contraction techniques
 
-Proposed functions: Proposed by Zia Mohammed
----------------------------------------------
+  - :ref:`pgr_contractgraph` - Reduce network size using contraction techniques
 
-  -  :ref:`pgr_labelGraph` - Analyze / label  subgraphs within a network
+- :ref:`maxFlow`
 
-.. toctree::
-  :hidden:
+  - :ref:`pgr_maxFlowPushRelabel` - Maximum flow using push&relabel algorithm.
+  - :ref:`pgr_maxFlowEdmondsKarp` - Maximum flow using Edmonds&Karp algorithm.
+  - :ref:`pgr_maxFlowBoykovKolmogorov` - Maximum flow using Boykov&Kolmogorov algorithm.
+  
+- :ref:`maxFlowApplications`
 
-  ../src/label_graph/doc/pgr_labelGraph.rst
+  - :ref:`pgr_maximumCardinalityMatching` - Calculates a maximum cardinality matching.
+  - :ref:`pgr_edgeDisjointPaths` - Calculates edge disjoint paths.
 
-.. toctree::
-   :hidden:
+- convenience
 
-   ../src/convinience/doc/convenience
+  -  :ref:`pgr_point_to_edgenode` - convert a point geometry to a ``vertex_id`` based on closest edge.
+  -  :ref:`pgr_points_to_vids` - convert an array of point geometries into vertex ids.
 
+- graph analysis
 
-Proposed functions: Proposed by Rohith Reddy
----------------------------------------------
+  -  :ref:`pgr_labelGraph` - Analyze / label  subgraphs within a network
 
-  -  :ref:`contraction` - Reduce network size using contraction techniques
+- Vehicle Routing Problems
 
-.. toctree::
-  :hidden:
+  -  :ref:`pgr_gsocvrppdtw` - VRP Pickup & Delivery (Euclidean)
+  -  :ref:`pgr_vrp_basic` - VRP One Depot
 
-  ../src/contraction/doc/contraction.rst
 
 .. toctree::
   :hidden:
 
   ../src/contraction/doc/contraction
+  ../src/contraction/doc/pgr_contractGraph
+  ../src/max_flow/doc/maxFlow
+  ../src/max_flow/doc/maxFlowApplications
 
-Experimental functions: by GSoC Students
-----------------------------------------
+  ../src/convenience/doc/pgr_pointToEdgeNode
+  ../src/convenience/doc/pgr_pointsToVids
+  ../src/label_graph/doc/pgr_labelGraph
+  ../src/vrppdtw/doc/pgr_gsoc_vrppdtw
+  ../src/vrp_basic/doc/pgr_vrpOneDepot
 
-  -  :ref:`pgr_vrp_basic` - VRP One Depot
-  -  :ref:`pgr_gsocvrppdtw` - VRP Pickup & Delivery
+  ../src/pickDeliver/doc/pgr_pickDeliver
 
-..
-    The template
-    ------------
 
-    - :ref:`pgr_funnyDijkstra`
 
-.. toctree::
-    :hidden:
 
-    ../src/vrp_basic/doc/pgr_vrpOneDepot
-    ../src/vrppdtw/doc/index
 
-..
-    ../src/funnyDijkstra/doc/pgr_funnyDijkstra.rst
-    ../src/vrppdtw/doc/index.rst
+
+
+..  
+  The template
+   ------------
+    - :ref:`pgr_funnyDijkstra`
+    .. toctree::
+    :hidden:
+    ..
+     ../src/funnyDijkstra/doc/pgr_funnyDijkstra.rst
 
diff --git a/src/proposedNext.rst b/src/proposedNext.rst
index 36d9507..68200e2 100644
--- a/src/proposedNext.rst
+++ b/src/proposedNext.rst
@@ -9,44 +9,63 @@
 
 .. _proposedNext:
 
-Proposed Functions for version 2.3
+Stable proposed Functions
 ==================================
 
-:ref:`proposedNext`
+..
+    from-here
+    :ref:`proposedNext`
 
-This are proposed functions for version 2.3.
+..
+    begin-warning
 
-  - They are not officially in the version 2.2 release.
-  - They will likely officialy be part of the version 2.3 release:
+.. warning::
 
-    - The functions make use of ANY-INTEGER and ANY-NUMERICAL
-    - Name might not change.
-    - Signature might not  change.
-    - Functionality might not change.
-    - pgTap tests have being done.
-    - Needs feedback from the comunity.
+    These are proposed functions for next mayor release.
 
+      - They are not officially in the current release.
+      - They will likely officially be part of the next mayor release:
 
-Proposed Routing Functions
---------------------------
+        - The functions make use of ANY-INTEGER and ANY-NUMERICAL
+        - Name might not change. (But still can)
+        - Signature might not change. (But still can)
+        - Functionality might not change. (But still can)
+        - pgTap tests have being done. But might need more.
+        - Documentation might need refinement.
 
-:author: Vicky Vergara
+..
+    end-warning
 
-  - As part of Dijkstra Family of functions
 
-    - :ref:`pgr_dijkstraVia` - Use pgr_dijkstra to make a route via vertices.
+- As part of the :ref:`dijkstra`
 
-  - :ref:`pgr_withPoints<withPoints>` - withPoints family functions
+  - :ref:`pgr_dijkstraCostMatrix` Use pgr_dijkstra to calculate a cost matrix.
+  - :ref:`pgr_dijkstraVia` - Use pgr_dijkstra to make a route via vertices.
 
-    - :ref:`pgr_withPoints` - Route from/to points anywhere on the graph.
-    - :ref:`pgr_withPointsCost` - Costs of the shortest paths.
-    - :ref:`pgr_withPointsKSP<pgr_withPointsKSP>` - K shortest paths with points.
-    - :ref:`pgr_withPointsDD<pgr_withPointsDD>` - Driving distance.
+- A new :ref:`withPoints`
 
+  - :ref:`pgr_withPoints` - Route from/to points anywhere on the graph.
+  - :ref:`pgr_withPointsCost` - Costs of the shortest paths.
+  - :ref:`pgr_withPointsCostMatrix` - Use pgr_withPoints to calculate a cost matrix.
+  - :ref:`pgr_withPointsKSP` - K shortest paths with points.
+  - :ref:`pgr_withPointsDD` - Driving distance.
+
+
+- A new Section
+
+  - :ref:`CostMatrix`
+
+
+..
+    to-here
 
 .. toctree::
-   :hidden: 
+    :hidden:
+
+    ../src/costMatrix/doc/pgr_dijkstraCostMatrix
+    ../src/dijkstra/doc/pgr_dijkstraVia
+
+    ../src/withPoints/doc/withPoints
 
-   ../src/dijkstra/doc/pgr_dijkstraVia
-   ../src/withPoints/doc/withPoints
+    ../src/costMatrix/doc/costMatrix
 
diff --git a/src/routingFunctions.rst b/src/routingFunctions.rst
index ee22063..828ce75 100644
--- a/src/routingFunctions.rst
+++ b/src/routingFunctions.rst
@@ -7,57 +7,59 @@
     Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
    ****************************************************************************
 
-.. _routing_functions:
 
+.. _routing_functions:
 
+*******************************************************************************
 Routing Functions
-=================
+*******************************************************************************
 
 ..
     from-here
 
-:ref:`routing_functions`
 
-  - :ref:`All pairs<all_pairs>` - All pair of vertices.
+- :ref:`All pairs<all_pairs>` - All pair of vertices.
 
-    - :ref:`pgr_floydWarshall<pgr_floydWarshall>` - Floyd-Warshall's Algorithm
-    - :ref:`pgr_johnson<pgr_johnson>`- Johnson’s Algorithm
+  - :ref:`pgr_floydWarshall<pgr_floydWarshall>` - Floyd-Warshall's Algorithm
+  - :ref:`pgr_johnson<pgr_johnson>`- Johnson’s Algorithm
 
-  - :ref:`pgr_astar<pgr_astar>` - Shortest Path A*
-  - :ref:`pgr_bdAstar<bd_astar>` - Bi-directional A* Shortest Path
-  - :ref:`pgr_bdDijkstra<bd_dijkstra>` - Bi-directional Dijkstra Shortest Path
-  - :ref:`dijkstra<dijkstra>` - Dijkstra family functions
+- :ref:`pgr_astar<pgr_astar>` - Shortest Path A*
+- :ref:`pgr_bdAstar<bd_astar>` - Bi-directional A* Shortest Path
+- :ref:`pgr_bdDijkstra<bd_dijkstra>` - Bi-directional Dijkstra Shortest Path
+- :ref:`dijkstra<dijkstra>` - Dijkstra family functions
 
-    - :ref:`pgr_dijkstra` - Dijkstra's shortest path algorithm.
-    - :ref:`pgr_dijkstraCost` - Use pgr_dijkstra to calculate the costs of the shortest paths.
-        
-  - :ref:`Driving Distance<drivingDistance>` - Driving Distance
+  - :ref:`pgr_dijkstra` - Dijkstra's shortest path algorithm.
+  - :ref:`pgr_dijkstraCost` - Use pgr_dijkstra to calculate the costs of the shortest paths.
+      
+- :ref:`Driving Distance<drivingDistance>` - Driving Distance
 
-    - :ref:`pgr_drivingDistance<pgr_drivingDistance>` - Driving Distance
+  - :ref:`pgr_drivingDistance<pgr_drivingDistance>` - Driving Distance
 
-    - Post processing
+  - Post processing
 
-      - :ref:`pgr_alphaShape` - Alpha shape computation
-      - :ref:`pgr_points_as_polygon` - Polygon around set of points
+    - :ref:`pgr_alphaShape` - Alpha shape computation
+    - :ref:`pgr_points_as_polygon` - Polygon around set of points
 
-  - :ref:`pgr_ksp<pgr_ksp>` - K-Shortest Path
-  - :ref:`pgr_trsp<trsp>` - Turn Restriction Shortest Path (TRSP)
-  - :ref:`pgr_tsp<pgr_tsp>` - Traveling Sales Person
+- :ref:`pgr_ksp<pgr_ksp>` - K-Shortest Path
+- :ref:`pgr_trsp<trsp>` - Turn Restriction Shortest Path (TRSP)
+- :ref:`tsp`
+
+  - :ref:`pgr_TSP<pgr_TSP>` - When input is a cost matrix.
+  - :ref:`pgr_eucledianTSP<pgr_eucledianTSP>` - When input are coordinates.
 
 ..
     to-here
 
 .. toctree::
-	:hidden: 
-
-	allpairs/doc/allpairs
-	astar/doc/pgr_astar
-	bd_astar/doc/pgr_bdAstar
-	bd_dijkstra/doc/pgr_bdDijkstra
-	dijkstra/doc/dijkstra
-	driving_distance/doc/drivingDistance
-	ksp/doc/pgr_ksp
-	tsp/doc/pgr_tsp
-	trsp/doc/pgr_trsp
-
+    :hidden:
+
+    ../src/allpairs/doc/allpairs
+    ../src/astar/doc/pgr_astar
+    ../src/bd_astar/doc/pgr_bdAstar
+    ../src/bd_dijkstra/doc/pgr_bdDijkstra
+    ../src/dijkstra/doc/dijkstra
+    ../src/driving_distance/doc/drivingDistance
+    ../src/ksp/doc/pgr_ksp
+    ../src/tsp/doc/tsp
+    ../src/trsp/doc/pgr_trsp
 
diff --git a/src/shooting_star/CMakeLists.txt b/src/shooting_star/CMakeLists.txt
deleted file mode 100644
index 463da30..0000000
--- a/src/shooting_star/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-#MESSAGE("core/shooting_star: ${PACKAGE_SQL_FILES}")
-SUBDIRS(doc src test)
diff --git a/src/shooting_star/doc/CMakeLists.txt b/src/shooting_star/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/shooting_star/doc/index.rst b/src/shooting_star/doc/index.rst
deleted file mode 100644
index a4a8f77..0000000
--- a/src/shooting_star/doc/index.rst
+++ /dev/null
@@ -1,155 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-.. _shooting_star-index:
-
-================================================================
- Shortest Path Shooting Star
-================================================================
-
-Function:
----------
-
-The shortest_path_shooting_star function has the following declaration:
-
-.. code-block:: sql
-
-	CREATE OR REPLACE FUNCTION shortest_path_shooting_star(
-						sql text, 
-						source_id integer, 
-						target_id integer,
-						directed boolean, 
-						has_reverse_cost boolean)
-        RETURNS SETOF path_result
-
-
-Where path_result is:
-
-.. code-block:: sql
-
-	CREATE TYPE path_result AS (vertex_id integer, edge_id integer, cost float8);
-
-
-Arguments:
-----------
-
-**sql**: a SQL query, which should return a set of rows with the following columns:
-
-.. code-block:: sql
-
-	SELECT id, source, target, cost, x1, y1, x2, y2, rule, to_cost FROM edges
-
-
-* id: an int4 identifier of the edge
-* source: an int4 identifier of the source vertex
-* target: an int4 identifier of the target vertex
-* cost: double precision value of the edge traversal cost. (a negative cost will prevent the edge from being inserted in the graph).
-* reverse_cost (optional): the cost for the reverse traversal of the edge. This is only used when the directed and has_reverse_cost parameters are true (see the above remark about negative costs).
-* directed: true if the graph is directed
-* has_reverse_cost: if true, the reverse_cost column of the SQL generated set of rows will be used for the cost of the traversal of the edge in the opposite direction.
-* x1: double precision value of x coordinate for edge's start vertex
-* y1: double precision value of y coordinate for edge's start vertex
-* x2: double precision value of x coordinate for edge's end vertex
-* y2: double precision value of y coordinate for edge's end vertex
-* rule: a string with a comma separated list of edge ids which describes a rule for turning restriction (if you came along these edges, you can pass through the current one only with the cost stated in to_cost column)
-* to_cost: a cost of restricted passage (can be very high in a case of turn restriction or comparable with an edge cost in a case of traffic light)
-
-**source_id**: int4 id of the start point
-
-**directed**: true if the graph is directed
-
-**has_reverse_cost**: if true, the reverse_cost column of the SQL generated set of rows will be used for the cost of the traversal of the edge in the opposite direction.
-
-
-Output:
-------- 
-
-The function returns a set of rows. There is one row for each crossed edge, and 
-an additional one containing the terminal vertex. The columns of each row are:
-
-* vertex_id: the identifier of source vertex of each edge. There is one more row after the last edge, which contains the vertex identifier of the target path.
-* edge_id: the identifier of the edge crossed
-* cost: The cost associated to the current edge. It is 0 for the row after the last edge. Thus, the path total cost can be computated using a sum of all rows in the cost column.
-
-
-Examples:
----------
-
-Shooting* algorithm calculates a path from edge to edge (not from vertex to 
-vertex). Column vertex_id contains start vertex of an edge from column edge_id.
-
-To describe turn restrictions:
-
-.. code-block:: sql
-
-	 gid | source | target | cost | x1 | y1 | x2 | y2 | to_cost | rule
-	-----+--------+--------+------+----+----+----+----+---------+------
-	  12 |      3 |     10 |    2 |  4 |  3 |  4 |  5 |    1000 | 14
-
-
-means that the cost of going from edge 14 to edge 12 is 1000, and
-
-.. code-block:: sql
-
-	 gid | source | target | cost | x1 | y1 | x2 | y2 | to_cost | rule
-	-----+--------+--------+------+----+----+----+----+---------+------
-	  12 |      3 |     10 |    2 |  4 |  3 |  4 |  5 |    1000 | 14, 4
-
-
-means that the cost of going from edge 14 to edge 12 through edge 4 is 1000.
-
-If you need multiple restrictions for a given edge then you have to add multiple 
-records for that edge each with a separate restriction. For example:
-
-.. code-block:: sql
-
-	 gid | source | target | cost | x1 | y1 | x2 | y2 | to_cost | rule
-	-----+--------+--------+------+----+----+----+----+---------+------
-	  11 |      3 |     10 |    2 |  4 |  3 |  4 |  5 |    1000 | 4
-	  11 |      3 |     10 |    2 |  4 |  3 |  4 |  5 |    1000 | 12
-
-
-means that the cost of going from either edge 4 or 12 to edge 11 is 1000. And 
-then you always need to order your data by gid when you load it to a shortest 
-path function..
-
-To search a path using the Shooting* algorithm:
-
-.. code-block:: sql
-
-	SELECT * FROM shortest_path_shooting_star('SELECT id, source, target, cost, 
-		     x1, y1, x2, y2, rule, to_cost FROM edges', 17, 9, true, false);
-
-
-.. code-block:: sql
-
-	 vertex_id | edge_id | cost
-	-----------+---------+------
-		    16 |      17 |    1
-		    15 |      16 |    1
-		     2 |       5 |    1
-		     3 |       4 |    1
-		    20 |      12 |    2
-		    10 |       9 |    2
-	(6 rows)
-
-
diff --git a/src/shooting_star/sql/CMakeLists.txt b/src/shooting_star/sql/CMakeLists.txt
deleted file mode 100644
index 460761d..0000000
--- a/src/shooting_star/sql/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Append in local scope
-LIST(APPEND PACKAGE_SQL_FILES
-    ${CMAKE_CURRENT_SOURCE_DIR}/shooting_star.sql
-#    ${CMAKE_CURRENT_SOURCE_DIR}/shooting_star_wrappers.sql
-)
-
-# set in parent scope
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
diff --git a/src/shooting_star/sql/shooting_star.sql b/src/shooting_star/sql/shooting_star.sql
deleted file mode 100644
index edcbcf0..0000000
--- a/src/shooting_star/sql/shooting_star.sql
+++ /dev/null
@@ -1,51 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
---
--- Copyright (c) 2005 Sylvain Pasche,
---               2006-2007 Anton A. Patrushev, Orkney, Inc.
---
--- This program is free software; you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation; either version 2 of the License, or
--- (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program; if not, write to the Free Software
--- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
---
-
-
------------------------------------------------------------------------
--- Core function for shortest_path_astar computation
--- Simillar to shortest_path in usage but uses the Shooting* algorithm
------------------------------------------------------------------------
-CREATE OR REPLACE FUNCTION pgr_shootingStar(sql text, source_id integer, 
-        target_id integer,directed boolean, has_reverse_cost boolean)
-         RETURNS SETOF pgr_costResult
-         AS '$libdir/librouting', 'shortest_path_shooting_star'
-         LANGUAGE c IMMUTABLE STRICT; 
diff --git a/src/shooting_star/src/CMakeLists.txt b/src/shooting_star/src/CMakeLists.txt
deleted file mode 100644
index 450ae06..0000000
--- a/src/shooting_star/src/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-#SET(LIBRARY_OUTPUT_PATH ../../../lib/)
-#IF(APPLE)
-#    SET(LIBRARY_MODE_TARGET "MODULE")
-#ELSE(APPLE)
-#    SET(LIBRARY_MODE_TARGET "SHARED")
-#ENDIF(APPLE)
-#ADD_LIBRARY(routing ${LIBRARY_MODE_TARGET} shooting_star.c shooting_star_boost_wrapper.cpp)
-#INSTALL(TARGETS routing DESTINATION ${LIBRARY_INSTALL_PATH})
-#IF(APPLE)
-#    SET_TARGET_PROPERTIES(routing PROPERTIES LINK_FLAGS "-bundle_loader ${POSTGRESQL_EXECUTABLE} -bundle")
-#ENDIF(APPLE)
-
-ADD_LIBRARY(shooting_star OBJECT shooting_star.c shooting_star_boost_wrapper.cpp)
diff --git a/src/shooting_star/src/edge_visitors.hpp b/src/shooting_star/src/edge_visitors.hpp
deleted file mode 100644
index 19399cc..0000000
--- a/src/shooting_star/src/edge_visitors.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-#ifndef EDGE_VISITORS_HPP
-#define EDGE_VISITORS_HPP
-
-#include <iosfwd>
-#include <boost/config.hpp>
-#include <boost/version.hpp>
-
-#if BOOST_VERSION > 103900
-#include <boost/property_map/property_map.hpp>
-#else
-#include <boost/property_map.hpp>
-#endif
-
-#include <boost/graph/graph_traits.hpp>
-#include <boost/limits.hpp>
-
-#if BOOST_VERSION <= 14700
-#include <boost/graph/detail/is_same.hpp>
-#else
-#include <boost/type_traits/is_same.hpp>
-#endif
-
-namespace boost 
-{
-  // Event Tags
-
-  namespace detail 
-  {
-    // For partial specialization workaround
-    enum event_edge_visitor_enum
-    { 
-      on_initialize_edge_num, on_start_edge_num,
-      on_discover_edge_num, on_finish_edge_num
-    };
-  }
-							    
-  struct on_initialize_edge { enum { num = detail::on_initialize_edge_num }; };
-  struct on_start_edge { enum { num = detail::on_start_edge_num }; };
-  struct on_discover_edge { enum { num = detail::on_discover_edge_num }; };
-  struct on_finish_edge { enum { num = detail::on_finish_edge_num }; };
-
-}
-
-#endif
diff --git a/src/shooting_star/src/shooting_star.c b/src/shooting_star/src/shooting_star.c
deleted file mode 100644
index 5e1dc13..0000000
--- a/src/shooting_star/src/shooting_star.c
+++ /dev/null
@@ -1,574 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-/*
- * Shooting* Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2007 Anton A. Patrushev, Orkney, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include "postgres.h"
-#include "executor/spi.h"
-#include "funcapi.h"
-#include "catalog/pg_type.h"
-#if PGSQL_VERSION > 92
-#include "access/htup_details.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <search.h>
-
-#include <string.h>
-#include <time.h>
-
-#include "shooting_star.h"
-
-//-------------------------------------------------------------------------
-
-Datum shortest_path_shooting_star(PG_FUNCTION_ARGS);
-
-#undef DEBUG
-//#define DEBUG 1
-
-#ifdef DEBUG
-#define DBG(format, arg...)                     \
-    elog(NOTICE, format , ## arg)
-#else
-#define DBG(format, arg...) do { ; } while (0)
-#endif
-
-// The number of tuples to fetch from the SPI cursor at each iteration
-#define TUPLIMIT 1000
-
-static char *
-text2char(text *in)
-{
-  char *out = palloc(VARSIZE(in));
-
-  memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
-  out[VARSIZE(in) - VARHDRSZ] = '\0';
-  return out;
-}
-
-static int 
-finish(int code, int ret)
-{
-  code = SPI_finish();
-  if (code  != SPI_OK_FINISH )
-    {
-      elog(ERROR,"couldn't disconnect from SPI");
-      return -1 ;
-    }
-  
-  return ret;
-}
-  
-typedef struct edge_shooting_star_columns 
-{
-  int id;
-  int source;
-  int target;
-  int cost;
-  int reverse_cost;
-  int s_x;
-  int s_y;
-  int t_x;
-  int t_y;
-  int to_cost;//cost of transit to adjacent edge
-  int rule;
-} edge_shooting_star_columns_t;
-
-static int
-fetch_edge_shooting_star_columns(SPITupleTable *tuptable, 
-			 edge_shooting_star_columns_t *edge_columns, 
-			 bool has_reverse_cost)
-{
-  edge_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
-  edge_columns->source = SPI_fnumber(SPI_tuptable->tupdesc, "source");
-  edge_columns->target = SPI_fnumber(SPI_tuptable->tupdesc, "target");
-  edge_columns->cost = SPI_fnumber(SPI_tuptable->tupdesc, "cost");
-  if (edge_columns->id == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->source == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->target == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->cost == SPI_ERROR_NOATTRIBUTE) 
-    {
-      elog(ERROR, "Error, query must return columns "
-	   "'id', 'source', 'target' and 'cost'");
-      return -1;
-    }
-
-  if (SPI_gettypeid(SPI_tuptable->tupdesc, 
-		    edge_columns->source) != INT4OID ||
-      SPI_gettypeid(SPI_tuptable->tupdesc, 
-		    edge_columns->target) != INT4OID ||
-      SPI_gettypeid(SPI_tuptable->tupdesc, edge_columns->cost) != FLOAT8OID) 
-    {
-      elog(ERROR, "Error, columns 'source', 'target' must be of type int4, "
-	   "'cost' must be of type float8");
-      return -1;
-    }
-
-  DBG("columns: id %i source %i target %i cost %i", 
-      edge_columns->id, edge_columns->source, 
-      edge_columns->target, edge_columns->cost);
-
-  if (has_reverse_cost)
-    {
-      edge_columns->reverse_cost = SPI_fnumber(SPI_tuptable->tupdesc, 
-					       "reverse_cost");
-
-      if (edge_columns->reverse_cost == SPI_ERROR_NOATTRIBUTE) 
-        {
-	  elog(ERROR, "Error, reverse_cost is used, but query did't return "
-	       "'reverse_cost' column");
-	  return -1;
-        }
-
-      if (SPI_gettypeid(SPI_tuptable->tupdesc, 
-			edge_columns->reverse_cost) != FLOAT8OID) 
-        {
-	  elog(ERROR, "Error, columns 'reverse_cost' must be of type float8");
-	  return -1;
-        }
-
-      DBG("columns: reverse_cost cost %i", edge_columns->reverse_cost);
-    }
-
-  edge_columns->s_x = SPI_fnumber(SPI_tuptable->tupdesc, "x1");
-  edge_columns->s_y = SPI_fnumber(SPI_tuptable->tupdesc, "y1");
-  edge_columns->t_x = SPI_fnumber(SPI_tuptable->tupdesc, "x2");
-  edge_columns->t_y = SPI_fnumber(SPI_tuptable->tupdesc, "y2");
-
-  if (edge_columns->s_x == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->s_y == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->t_x == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->t_y == SPI_ERROR_NOATTRIBUTE) 
-    {
-      elog(ERROR, "Error, query must return columns "
-	   "'x1', 'x2', 'y1' and 'y2'");
-      return -1;
-    }
-
-  DBG("columns: x1 %i y1 %i x2 %i y2 %i", 
-      edge_columns->s_x, edge_columns->s_y,
-      edge_columns->t_x,edge_columns->t_y);
-    
-
-  edge_columns->to_cost = SPI_fnumber(SPI_tuptable->tupdesc, "to_cost");
-  edge_columns->rule = SPI_fnumber(SPI_tuptable->tupdesc, "rule");
-
-  if (edge_columns->to_cost == SPI_ERROR_NOATTRIBUTE ||
-      edge_columns->rule == SPI_ERROR_NOATTRIBUTE) 
-    {
-      elog(ERROR, "Error, query must return columns "
-	   "'to_cost' and 'rule'");
-      return -1;
-    }
-
-  return 0;
-}
-
-//edges should be ordered by id or else we have to search for 
-//existing edges every time we want to add adjacent edge
-static void
-fetch_edge_shooting_star(HeapTuple *tuple, TupleDesc *tupdesc, 
-		 edge_shooting_star_columns_t *edge_columns, 
-		 edge_shooting_star_t *target_edge)
-{
-  Datum binval;
-  bool isnull;
-  int t;
-
-  for(t=0; t<MAX_RULE_LENGTH;++t)
-    target_edge->rule[t] = -1;
-    
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->id, &isnull);
-  if (isnull)
-    elog(ERROR, "id contains a null value");
-  target_edge->id = DatumGetInt32(binval);
-  
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->source, &isnull);
-  if (isnull)
-    elog(ERROR, "source contains a null value");
-  target_edge->source = DatumGetInt32(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->target, &isnull);
-  if (isnull)
-    elog(ERROR, "target contains a null value");
-  target_edge->target = DatumGetInt32(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->cost, &isnull);
-  if (isnull)
-    elog(ERROR, "cost contains a null value");
-  target_edge->cost = DatumGetFloat8(binval);
-
-  if (edge_columns->reverse_cost != -1) 
-    {
-      binval = SPI_getbinval(*tuple, *tupdesc, 
-			     edge_columns->reverse_cost, &isnull);
-      if (isnull)
-	elog(ERROR, "reverse_cost contains a null value");
-      target_edge->reverse_cost =  DatumGetFloat8(binval);
-    }
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->s_x, &isnull);
-  if (isnull)
-    elog(ERROR, "source x contains a null value");
-  target_edge->s_x = DatumGetFloat8(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->s_y, &isnull);
-  if (isnull)
-    elog(ERROR, "source y contains a null value");
-  target_edge->s_y = DatumGetFloat8(binval);
-  
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->t_x, &isnull);
-  if (isnull)
-    elog(ERROR, "target x contains a null value");
-  target_edge->t_x = DatumGetFloat8(binval);
-  
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->t_y, &isnull);
-  if (isnull)
-    elog(ERROR, "target y contains a null value");
-  target_edge->t_y = DatumGetFloat8(binval);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, edge_columns->to_cost, &isnull);
-  if (isnull)
-    target_edge->to_cost = 0;
-    
-  else
-    target_edge->to_cost = DatumGetFloat8(binval);
-
-  char *str = DatumGetCString(SPI_getvalue(*tuple, *tupdesc, edge_columns->rule));
-
-  if(str!=NULL)
-  {
-    char* pch = NULL;
-    int ci = MAX_RULE_LENGTH;
-
-    pch = (char *)strtok (str," ,");
-  
-    while (pch != NULL)
-    {
-      --ci;
-      target_edge->rule[ci] = atoi(pch);
-      pch = (char *)strtok (NULL, " ,");
-    }
-  }
-}
-
-
-static int compute_shortest_path_shooting_star(char* sql, int source_edge_id, 
-				       int target_edge_id, bool directed, 
-				       bool has_reverse_cost, 
-				       path_element_t **path, int *path_count) 
-{
-  
-  int SPIcode;
-  void *SPIplan;
-  Portal SPIportal;
-  bool moredata = TRUE;
-  int ntuples;
-  edge_shooting_star_t *edges = NULL;
-  int total_tuples = 0;
-  
-//  int v_max_id=0;
-//  int v_min_id=INT_MAX;  
-  int e_max_id=0;
-  int e_min_id=INT_MAX;  
-    
-  edge_shooting_star_columns_t edge_columns = {id: -1, source: -1, target: -1, 
-				       cost: -1, reverse_cost: -1, 
-				       s_x: -1, s_y: -1, t_x: -1, t_y: -1,
-				       to_cost: -1, rule: -1};
-  char *err_msg;
-  int ret = -1;
-  register int z, t;
-  
-  int s_count=0;
-  int t_count=0;
-  
-  DBG("start shortest_path_shooting_star\n");
-        
-  SPIcode = SPI_connect();
-  if (SPIcode  != SPI_OK_CONNECT)
-    {
-      elog(ERROR, "shortest_path_shooting_star: couldn't open a connection to SPI");
-      return -1;
-    }
-
-  SPIplan = SPI_prepare(sql, 0, NULL);
-  if (SPIplan  == NULL)
-    {
-      elog(ERROR, "shortest_path_shooting_star: couldn't create query plan via SPI");
-      return -1;
-    }
-
-  if ((SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) 
-    {
-      elog(ERROR, "shortest_path_shooting_star: SPI_cursor_open('%s') returns NULL", 
-	   sql);
-      return -1;
-    }
-
-  while (moredata == TRUE)
-    {
-      SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
-
-      if (edge_columns.id == -1) 
-        {
-	  if (fetch_edge_shooting_star_columns(SPI_tuptable, &edge_columns, 
-				       has_reverse_cost) == -1)
-	    return finish(SPIcode, ret);
-        }
-	
-	//DBG("***%i***", ret);
-
-      ntuples = SPI_processed;
-      total_tuples += ntuples;
-
-      if (!edges)
-	edges = palloc(total_tuples * sizeof(edge_shooting_star_t));
-      else
-	edges = repalloc(edges, total_tuples * sizeof(edge_shooting_star_t));
-
-      if (edges == NULL) 
-        {
-	  elog(ERROR, "Out of memory");
-	  return finish(SPIcode, ret);
-        }
-
-      if (ntuples > 0) 
-        {
-	  int t;
-	  SPITupleTable *tuptable = SPI_tuptable;
-	  TupleDesc tupdesc = SPI_tuptable->tupdesc;
-	  
-	  for (t = 0; t < ntuples; t++) 
-            {
-	      HeapTuple tuple = tuptable->vals[t];
-	      fetch_edge_shooting_star(&tuple, &tupdesc, &edge_columns, 
-			       &edges[total_tuples - ntuples + t]);
-            }
-	  SPI_freetuptable(tuptable);
-        } 
-      else 
-        {
-	  moredata = FALSE;
-        }
-    }
-    
-      
-  DBG("Total %i tuples", total_tuples);
-
-    
-
-  for(z=0; z<total_tuples; z++)
-  {
-    if(edges[z].id<e_min_id)
-      e_min_id=edges[z].id;
-
-    if(edges[z].id>e_max_id)
-      e_max_id=edges[z].id;
-
-  }
-
-    DBG("E : %i <-> %i", e_min_id, e_max_id);
-
-  for(z=0; z<total_tuples; ++z)
-  {
-
-    //check if edges[] contains source and target
-    if(edges[z].id == source_edge_id)
-      ++s_count;
-    if(edges[z].id == target_edge_id)
-      ++t_count;
-
-
-    //edges[z].source-=v_min_id;
-    //edges[z].target-=v_min_id;
-    
-  }
-    
-  DBG("Total %i tuples", total_tuples);
-
-  if(s_count == 0)
-  {
-    elog(ERROR, "Start edge was not found.");
-    return -1;
-  }
-	      
-  if(t_count == 0)
-  {
-    elog(ERROR, "Target edge was not found.");
-    return -1;
-  }
-			    
-  DBG("Total %i tuples", total_tuples);
-
-  DBG("Calling boost_shooting_star <%i>\n", total_tuples);
-
-  //time_t stime = time(NULL);    
-
-  ret = boost_shooting_star(edges, total_tuples, source_edge_id, 
-		    target_edge_id,
-		    directed, has_reverse_cost,
-		    path, path_count, &err_msg, e_max_id);
-
-  //time_t etime = time(NULL);    
-
-  //DBG("Path was calculated in %f seconds. \n", difftime(etime, stime));
-
-  DBG("SIZE %i\n",*path_count);
-
-  DBG("ret =  %i\n",ret);
-  
-
-  if (ret < 0)
-    {
-      ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), 
-        errmsg("Error computing path: %s", err_msg)));
-    } 
-  return finish(SPIcode, ret);
-}
-
-
-PG_FUNCTION_INFO_V1(shortest_path_shooting_star);
-Datum
-shortest_path_shooting_star(PG_FUNCTION_ARGS)
-{
-  FuncCallContext     *funcctx;
-  int                  call_cntr;
-  int                  max_calls;
-  TupleDesc            tuple_desc;
-  path_element_t      *path = 0;
-  
-  /* stuff done only on the first call of the function */
-  if (SRF_IS_FIRSTCALL())
-    {
-      MemoryContext   oldcontext;
-      int path_count = 0;
-      int ret;
-
-      /* create a function context for cross-call persistence */
-      funcctx = SRF_FIRSTCALL_INIT();
-      
-      /* switch to memory context appropriate for multiple function calls */
-      oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-
-
-      ret = compute_shortest_path_shooting_star(text2char(PG_GETARG_TEXT_P(0)),
-					PG_GETARG_INT32(1),
-					PG_GETARG_INT32(2),
-					PG_GETARG_BOOL(3),
-					PG_GETARG_BOOL(4), 
-					&path, &path_count);
-
-#ifdef DEBUG
-      DBG("Ret is %i", ret);
-      if (ret >= 0) 
-        {
-	  int i;
-	  for (i = 0; i < path_count; i++) 
-            {
-	      DBG("Step # %i vertex_id  %i ", i, path[i].vertex_id);
-	      DBG("        edge_id    %i ", path[i].edge_id);
-	      DBG("        cost       %f ", path[i].cost);
-            }
-        }
-#endif
-
-      /* total number of tuples to be returned */
-      DBG("Conting tuples number\n");
-      funcctx->max_calls = path_count;
-      funcctx->user_fctx = path;
-      
-      DBG("Path count %i", path_count);
-      
-      funcctx->tuple_desc = 
-	BlessTupleDesc(RelationNameGetTupleDesc("pgr_costResult"));
-
-      MemoryContextSwitchTo(oldcontext);
-    }
-
-  /* stuff done on every call of the function */
-
-  funcctx = SRF_PERCALL_SETUP();
-  
-  call_cntr = funcctx->call_cntr;
-  max_calls = funcctx->max_calls;
-  tuple_desc = funcctx->tuple_desc;
-  path = (path_element_t*) funcctx->user_fctx;
-  
-  DBG("Trying to allocate some memory\n");
-
-  if (call_cntr < max_calls)    /* do when there is more left to send */
-    {
-      HeapTuple    tuple;
-      Datum        result;
-      Datum *values;
-      bool* nulls;
-      
-      values = palloc(4 * sizeof(Datum));
-      nulls = palloc(4 * sizeof(bool));
-  
-      values[0] = Int32GetDatum(call_cntr);
-      nulls[0] = false;
-      values[1] = Int32GetDatum(path[call_cntr].vertex_id);
-      nulls[1] = false;
-      values[2] = Int32GetDatum(path[call_cntr].edge_id);
-      nulls[2] = false;
-      values[3] = Float8GetDatum(path[call_cntr].cost);
-      nulls[3] = false;
-  
-      tuple = heap_form_tuple(tuple_desc, values, nulls);
-  
-      /* make the tuple into a datum */
-      result = HeapTupleGetDatum(tuple);
-  
-      /* clean up (this is not really necessary) */
-      pfree(values);
-      pfree(nulls);
-      
-      SRF_RETURN_NEXT(funcctx, result);
-    }
-  else    /* do when there is no more left */
-    {
-      if (path) free(path);
-      SRF_RETURN_DONE(funcctx);
-    }
-}
diff --git a/src/shooting_star/src/shooting_star.h b/src/shooting_star/src/shooting_star.h
deleted file mode 100644
index 9001593..0000000
--- a/src/shooting_star/src/shooting_star.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-/*
- * Shooting* shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2007 Anton A. Patrushev, Orkney, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#define _SHOOTING_STAR_H
-#define MAX_RULE_LENGTH 5
-
-#define MAX_NODES 1000000
-#define MAX_COST  10000000
-
-#include "postgres.h"
-
-typedef struct edge_shooting_star 
-{
-  int id;
-  int source;
-  int target;
-  float8 cost;
-  float8 reverse_cost;
-  float8 s_x;
-  float8 s_y;
-  float8 t_x;
-  float8 t_y;
-  float8 to_cost;
-  int through_id[MAX_RULE_LENGTH];
-  int rule[MAX_RULE_LENGTH];
-} edge_shooting_star_t;
-
-//I had to redeclare this. I couldn't include dijkstra.h 'cause
-//struct edge conflicts with function adjacency_list::edge()
-typedef struct path_element
-{
-  int vertex_id;
-  int edge_id;
-  float8 cost;
-} path_element_t;
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-  int boost_shooting_star(edge_shooting_star_t *edges, unsigned int count, 
-                  int source_edge_id, int target_edge_id,
-                  bool directed, bool has_reverse_cost,
-                  path_element_t **path, int *path_count, char **err_msg,
-		  int e_max_id);
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/shooting_star/src/shooting_star_boost_wrapper.cpp b/src/shooting_star/src/shooting_star_boost_wrapper.cpp
deleted file mode 100644
index 8d45a31..0000000
--- a/src/shooting_star/src/shooting_star_boost_wrapper.cpp
+++ /dev/null
@@ -1,456 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-/*
- * Shooting* Shortest path algorithm for PostgreSQL
- *
- * Copyright (c) 2007 Anton A. Patrushev, Orkney, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-// Include C header first for windows build issue
-#include "shooting_star.h"
-
-#include <boost/config.hpp>
-#include <boost/version.hpp>
-
-#include <boost/graph/graph_traits.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#if BOOST_VERSION > 103900
-#include <boost/property_map/vector_property_map.hpp>
-#else
-#include <boost/vector_property_map.hpp>
-#endif
-#include <shooting_star_search.hpp>
-
-#include <cmath>    // for sqrt
-
-using namespace std;
-using namespace boost;
-
-struct Edge
-{
-  int id;
-  int source;
-  int target;
-  float8 cost;
-  float distance;
-  float rank;
-  std::map< int, vector< std::pair<float, std::vector<int> > >, std::less<int> > adjacent_edges;
-  default_color_type color;
-  
-  std::size_t index;
-};
-	
-struct Vertex
-{
-  int id;
-  float8 x;
-  float8 y;
-};
-
-// exception for termination
-template <class Edge>
-class found_goal 
-{
-  public:
-    found_goal() {}
-    found_goal(Edge target) : target_edge(target) {}
-    found_goal(const found_goal &fg) {}
-    ~found_goal() {}
-    Edge get_target()
-    {
-      return target_edge;
-    }
-  private:
-    Edge target_edge;
-};
-
-
-// visitor that terminates when we find the goal
-template <class Edge>
-class shooting_star_goal_visitor : public boost::default_shooting_star_visitor
-{
-public:
-  shooting_star_goal_visitor(Edge goal, int max_id) : m_goal(goal){}
-  shooting_star_goal_visitor(const shooting_star_goal_visitor &gv) : m_goal(gv.m_goal){}
-  ~shooting_star_goal_visitor(){}
-
-  template <class Graph>
-  void examine_edge(Edge e, Graph& g, int e_max_id) 
-  {
-    if( g[e].id == g[m_goal].id || g[e].id == g[m_goal].id + e_max_id )
-    {
-      throw found_goal<Edge>(e);
-    }
-  }
-  template <class Graph>
-  void finish_edge(Edge e, Graph& g) {}
-private:
-  Edge m_goal;
-  int e_max_id;
-};
-
-// Heuristic function
-template <class Graph, class CostType>
-class distance_heuristic
-{
-public:
-  typedef typename graph_traits<Graph>::edge_descriptor Edge;
-  distance_heuristic(Graph& g, Edge goal):m_g(g), m_goal(goal){}
-  CostType operator()(Edge e)
-  {
-    CostType dx = m_g[source(m_goal, m_g)].x - m_g[source(e, m_g)].x;
-    CostType dxt = m_g[target(m_goal, m_g)].x - m_g[target(e, m_g)].x;
-    CostType dy = m_g[source(m_goal, m_g)].y - m_g[source(e, m_g)].y;
-    CostType dyt = m_g[target(m_goal, m_g)].y - m_g[target(e, m_g)].y;
-    //You can choose any heuristical function from below
-    //return ::max(dx, dy);
-    //return ::sqrt(dx * dx + dy * dy)/2;
-    //return 0;
-    //return (min(::fabs(dx),::fabs(dxt))+min(::fabs(dy),::fabs(dyt)))/2;
-    return sqrt(pow(min(::fabs(dx),::fabs(dxt)),2)+pow(min(::fabs(dy),::fabs(dyt)),2))/2;
-  } 
-private:
-  Graph& m_g;
-  Edge m_goal;
-};
-
-
-// Adds an edge to the graph
-// Also copies all attributes and adjacent edges
-template <class G, class E>
-static void
-graph_add_edge(G &graph, int index,
-               int id, int source, int target, 
-	       float8 cost, float8 s_x, float8 s_y, float8 t_x, float8 t_y, 
-	       std::map< int, vector< std::pair<float, vector<int> > >, std::less<int> > adjacent_edges)
-{
-
-  E e;
-  bool inserted;
-
-  if (cost < 0) // edges are inserted as unpassable if cost is negative
-    cost = MAX_COST;
-
-  tie(e, inserted) = add_edge(source, target, graph);
-
-  graph[e].cost = cost;
-  graph[e].id = id;
-  
-  graph[e].source = source;
-  graph[e].target = target;
-  
-  graph[e].adjacent_edges = adjacent_edges;
-
-  graph[e].rank = 0;
-  graph[e].distance = 0;
-  
-  graph[e].index = index;
-
-  
-  typedef typename graph_traits<G>::vertex_descriptor Vertex;
-  Vertex s = vertex(source, graph);
-  Vertex t = vertex(target, graph);
-
-  graph[s].id=source;
-  graph[t].id=target;
-
-  graph[s].x=s_x;
-  graph[s].y=s_y;
-  graph[t].x=t_x;
-  graph[t].y=t_y;
-
-}
-
-// Main Shooting* function.
-// It renumbers vertices, fills the graph with edges,
-// calculates a route and return a result.
-int 
-boost_shooting_star(edge_shooting_star_t *edges_array, unsigned int count, 
-	    int source_edge_id, int target_edge_id,
-	    bool directed, bool has_reverse_cost,
-	    path_element_t **path, int *path_count, char **err_msg, int e_max_id)
-{
-
-  typedef adjacency_list<vecS, vecS, directedS, Vertex, Edge> graph_t;
-
-  typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
-  typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
-
-  const unsigned int num_nodes = count*2;
-  
-  int z;
-  int src, trg, offset, rule_num;
-  
-  graph_t graph(num_nodes);
-
-  std::map< int, vector< std::pair<float, vector<int> > >, std::less<int> > adjacent_edges;
-
-  std::map< int, int, std::less<int> > vertices;
-  
-  vector<int> rule;
-
-  offset = 1;
-  rule_num = 0;
-
-  for (std::size_t j = 0; j < count; ++j)
-  {
-    //Vertex ids renumbering moved here
-    src = edges_array[j].source;
-    trg = edges_array[j].target;
-    
-    if(vertices[src]==0)
-    {
-      vertices[src]=j+offset;
-    }
-    edges_array[j].source=vertices[src];
-    
-    if(vertices[trg]==0)
-    {
-      offset++;      
-      vertices[trg]=j+offset;
-    }
-    edges_array[j].target=vertices[trg];
-    
-    for(z=0; z<MAX_RULE_LENGTH;++z)
-    {
-      if(edges_array[j].rule[z] > 0)
-      {
-        rule.push_back(edges_array[j].rule[z]);
-      }
-    }
-
-    if(edges_array[j].to_cost > 0)
-    {
-      adjacent_edges[edges_array[j].id].push_back(std::pair<float8, vector<int> > (edges_array[j].to_cost, rule) );
-      rule.clear();
-    }
-
-    if((j < count-1 && edges_array[j].id != edges_array[j+1].id)||(j==count-1))
-    {
-      graph_add_edge<graph_t, edge_descriptor>(graph, j,
-					       edges_array[j].id, edges_array[j].source, 
-					       edges_array[j].target, edges_array[j].cost, 
-					       edges_array[j].s_x, edges_array[j].s_y, 
-					       edges_array[j].t_x, edges_array[j].t_y, adjacent_edges);
-    
-      // if the edge is not directed or if it is directed and has reverse cost
-      if (!directed || (directed && has_reverse_cost))
-      {
-        float8 cost, reverse_cost;
-		
-        if (has_reverse_cost)
-        {
-          cost = edges_array[j].cost;
-		  reverse_cost = edges_array[j].reverse_cost;
-		  
-		  //If chosen source/target edge's cost is high, take the edge for opposite direction
-		  if(cost > reverse_cost)
-		  {
-			  if(edges_array[j].id == source_edge_id)
-				source_edge_id += e_max_id;
-			  else if(edges_array[j].id == target_edge_id)
-				target_edge_id += e_max_id;
-		  }
-        }
-        else
-        {
-          cost = edges_array[j].cost;
-        }
-
-
-      if(adjacent_edges[edges_array[j].id].size() > 0)
-      {
-	    adjacent_edges[edges_array[j].id+e_max_id].assign( adjacent_edges[edges_array[j].id].begin(), adjacent_edges[edges_array[j].id].end() );
-	    adjacent_edges.erase(edges_array[j].id);
-      }
-
-
-        graph_add_edge<graph_t, edge_descriptor>(graph, j,
-	                                       edges_array[j].id+e_max_id, edges_array[j].target, 
-					       edges_array[j].source, cost, 
-					       edges_array[j].s_x, edges_array[j].s_y, 
-					       edges_array[j].t_x, edges_array[j].t_y, adjacent_edges);
-      }
-
-    adjacent_edges.clear();
-    rule_num = 0;
-    }
-    else
-    {
-      rule_num++;
-    }
-  }
-  
-  
-  edge_descriptor source_edge;
-  edge_descriptor target_edge;
-  
-  bool source_found = false, target_found = false;
-  
-  graph_traits<graph_t>::edge_iterator ei, ei_end;
-
-  for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei) 
-  {
-    if(graph[*ei].id == source_edge_id || graph[*ei].id == source_edge_id - e_max_id)
-    {
-      source_edge = *ei;
-      source_found = true;
-      break;
-    }
-
-  }
-
-  if (!source_found) 
-  {
-    *err_msg = (char *) "Source edge not found";
-    return -2;
-  }
-
-
-  for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei) 
-  {
-    if(graph[*ei].id == target_edge_id || graph[*ei].id == target_edge_id - e_max_id)
-    {
-      target_edge = *ei;
-      target_found = true;
-      break;
-    }
-  }
-
-
-  if (!target_found)
-  {
-    *err_msg = (char *) "Target edge not found";
-    return -3;
-  }
-
-  property_map<graph_t, std::size_t Edge::*>::type edge_index = get(&Edge::index, graph);
-
-  std::map< int, edge_descriptor, std::less<int> > predecessors;
-  
-  property_map<graph_t, float Edge::*>::type rank = get(&Edge::rank, graph);
-  property_map<graph_t, float Edge::*>::type distance = get(&Edge::distance, graph);
-
-  try 
-  {
-    //calling Shooting* search
-    shooting_star_search
-      (graph, source_edge,
-       distance_heuristic<graph_t, float>(graph, target_edge),
-       weight_map(get(&Edge::cost, graph)).
-       weight_map2(get(&Edge::adjacent_edges, graph)).
-       edge_color_map(get(&Edge::color, graph)).
-       visitor(shooting_star_goal_visitor<edge_descriptor>(target_edge, e_max_id)),
-       edge_index,
-       distance, rank,
-       predecessors, e_max_id
-       );
-
-  } 
-  catch(found_goal<edge_descriptor> &fg) 
-  {
-  
-    vector<edge_descriptor> path_vect;
-    int max = MAX_NODES;
-    
-    target_edge = fg.get_target();
-
-    path_vect.push_back(target_edge);
-    
-    while (target_edge != source_edge) 
-      {
-        
-        if ((target_edge == predecessors[graph[target_edge].id]) && (predecessors[graph[target_edge].id] != source_edge))
-	{
-          *err_msg = (char *) "No path found";
-          return -1;
-	    
-	}
-  
-	target_edge = predecessors[graph[target_edge].id];
-	
-	//Check if we have u-turns within same edge at the beginning
-	if( !(abs(graph[predecessors[graph[target_edge].id]].id - graph[target_edge].id) == e_max_id && (target_edge != source_edge || predecessors[graph[target_edge].id] != source_edge)) )
-    {   
-        path_vect.push_back(target_edge);
-	}
-	
-	// This check was made to be sure that we can
-	// restore the path from the target edge within
-	// MAX_NODE iterations.
-	// Sometimes it doesn't work properly and search exits here
-	// even if the target edge was reached.
-
-        if (!max--) 
-	  {
-            *err_msg = (char *) "No path found";
-            return -1;
-	  }	  
-      }
-
-    *path = (path_element_t *) malloc(sizeof(path_element_t) * 
-				      (path_vect.size() + 1));
-    *path_count = path_vect.size();
-    
-    int start_from = path_vect.size() - 1;
-    
-    for(int i = start_from, j = 0; i >= 0; i--, j++)
-    {
-      float cost;
-	  graph_traits < graph_t >::edge_descriptor e;
-
-      e = path_vect.at(i);
-      
-      if(graph[e].id > e_max_id)
-      {
-        graph[e].id -= e_max_id;
-      }
-      
-      (*path)[j].edge_id = graph[e].id;
-      (*path)[j].cost = graph[e].cost;
-      (*path)[j].vertex_id = source(e, graph);
-    }
-
-    return EXIT_SUCCESS;
-  }
-
-  *err_msg = (char *) "Target was not reached";
-  return 0;
-
-}
-
diff --git a/src/shooting_star/src/shooting_star_relax.hpp b/src/shooting_star/src/shooting_star_relax.hpp
deleted file mode 100644
index 98f0a8c..0000000
--- a/src/shooting_star/src/shooting_star_relax.hpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-//=======================================================================
-// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
-// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek,
-//
-// Copyright 2007 Orkney, Inc.
-// Author: Anton A. Patrushev
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//=======================================================================
-#ifndef BOOST_GRAPH_SHOOTING_STAR_RELAX_HPP
-#define BOOST_GRAPH_SHOOTING_STAR_RELAX_HPP
-
-#include <boost/version.hpp>
-#include <functional>
-#include <boost/limits.hpp> // for numeric limits
-#include <boost/graph/graph_traits.hpp>
-#if BOOST_VERSION > 103900
-#include <boost/property_map/property_map.hpp>
-#else
-#include <boost/property_map.hpp>
-#endif
-
-#include <postgres.h>
-
-#define U_TURN_COST 100000
-
-bool is_equal ( int a[], int b[], int size )
-{
-  for ( int i = 0; i < size; i++ ) 
-  {
-    if ( a[i] != b[i] )
-    return false;
-  }
-	      
-  return true;
-}
-
-namespace boost {
-
-    // The following version of the plus functor prevents
-    // problems due to overflow at positive infinity.
-
-    template <class T>
-    struct closed_plus
-    {
-      // std::abs just isn't portable :(
-      template <class X>
-      inline X my_abs(const X& x) const { return x < 0 ? -x : x; }
-
-      T operator()(const T& a, const T& b) const {
-        using namespace std;
-        T inf = (numeric_limits<T>::max)();
-        if (b > 0 && my_abs(inf - a) < b)
-          return inf;
-        return a + b;
-      }
-    };
-    
-    template <class Edge, class Graph, class WeightMap, class EdgeMap,
-            class PredecessorMap, class DistanceMap, class CostMap,
-            class BinaryFunction, class BinaryPredicate>
-    bool relax(Edge e, 
-               Edge pe,
-               Edge s, 
-               const Graph& g, const WeightMap& w, const EdgeMap& em,
-               PredecessorMap& p, DistanceMap& d, CostMap& c,
-               const BinaryFunction& combine, const BinaryPredicate& compare,
-	       int e_max_id)
-    {
-      typedef typename graph_traits<Graph>::directed_category DirCat;
-      bool is_undirected = is_same<DirCat, undirected_tag>::value;
-
-      typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
-            
-      Vertex u = source(e, g), v = target(e, g), pu = source(pe, g);
-
-      typedef typename property_traits<DistanceMap>::value_type D;
-      typedef typename property_traits<WeightMap>::value_type W;
-      
-      typedef typename property_traits<EdgeMap>::value_type E;
-      
-      D d_e = get(d, e);
-      D d_pe = get(d, pe);
-      
-      W w_e = get(w, e);
-
-      //edge where we came from
-      bool edge_exists;
-      
-      W w_pe_e;
-
-      E w_pe = get(em, e);
-      
-      int contains = -1;
-	
-      Edge ce = pe;
-      int e_id;
-
-      std::vector<Edge> edge_h;
-      typedef typename std::vector<Edge>::iterator It;
-
-      for(int i=0; i< w_pe[g[e].id].size(); ++i)
-      
-      if(w_pe[g[e].id].at(i).second.size() < 1 || w_pe[g[e].id].at(i).second.back() > 0)
-      {
-      
-      for(int j=0; j<w_pe[g[e].id].at(i).second.size(); ++j)
-      {
-	e_id = g[ce].id;
-	
-        if(w_pe[g[e].id].at(i).second.at(j) == -1)
-	  continue;
-	
-	if(w_pe[g[e].id].at(i).second.at(j) == e_id || w_pe[g[e].id].at(i).second.at(j)+e_max_id == e_id||
-	   w_pe[g[e].id].at(i).second.at(j) == e_id+e_max_id || w_pe[g[e].id].at(i).second.at(j)+e_max_id == e_id+e_max_id)
-	{
-	 contains = i;
-	 edge_h.push_back(ce);
-	}
-	else if(i == contains)
-	{
-	 contains = -1;
-	}
-	
-	ce = p[g[ce].id];
-      }
-      
-      }
-      
-      //calculate w_pe_e
-      if(contains >= 0)
-      {
-        w_pe_e = w_pe[g[e].id].at(contains).first;
-      }
-      //Check if it is a u-turn not in the beginning of route 
-      else if( abs(g[e].id-g[pe].id) == e_max_id && g[e].id != g[s].id && g[pe].id != g[s].id )
-      {
-		w_pe_e = U_TURN_COST;
-      }
-      else
-      {
-        w_pe_e = 0;
-      }
-
-      //Ugly combination with w_e_pe.
-
-      if ( compare(combine(combine(d_pe, get(w, pe)), w_pe_e), d_e)) 
-      {
-	put(d, e, combine(combine(d_pe, get(w, pe)), w_pe_e));
-	p[g[e].id] = pe;
-
-        return true;
-      }
-      else
-      {
-        return false;
-      }
-    }
-
-    template <class Graph, class WeightMap, class EdgeMap,
-      class PredecessorMap, class DistanceMap>
-    bool relax(typename graph_traits<Graph>::edge_descriptor e,
-               const Graph& g, WeightMap w, EdgeMap em, PredecessorMap p, DistanceMap d)
-    {
-      typedef typename property_traits<DistanceMap>::value_type D;
-      typedef closed_plus<D> Combine;
-      typedef std::less<D> Compare;
-      return relax(e, g, w, em, p, d, Combine(), Compare());
-    }
-
-} // namespace boost
-
-#endif
diff --git a/src/shooting_star/src/shooting_star_search.hpp b/src/shooting_star/src/shooting_star_search.hpp
deleted file mode 100644
index 33a4c84..0000000
--- a/src/shooting_star/src/shooting_star_search.hpp
+++ /dev/null
@@ -1,643 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-//
-//=======================================================================
-// Copyright (c) 2004 Kristopher Beevers
-//               2007 Anton A. Patrushev, Orkney Inc.
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//=======================================================================
-//
-
-#ifndef BOOST_GRAPH_SHOOTING_STAR_SEARCH_HPP
-#define BOOST_GRAPH_SHOOTING_STAR_SEARCH_HPP
-
-#define MAX_RULE_LENGTH 5
-
-#include <functional>
-#include <boost/limits.hpp>
-#include <boost/graph/named_function_params.hpp>
-#include <boost/pending/mutable_queue.hpp>
-#include <boost/pending/relaxed_heap.hpp>
-#include <shooting_star_relax.hpp>
-#include <boost/pending/indirect_cmp.hpp>
-#include <boost/graph/exception.hpp>
-#include <boost/graph/breadth_first_search.hpp>
-
-#include <queue>
-#include "edge_visitors.hpp"
-
-template <class Edge>
-struct EdgeRankCompare 
-{
-  bool operator()(const Edge& LHS, const Edge& RHS) 
-  {
-    return (LHS.rank < RHS.rank);
-  }
-		
-};
-
-template <class Edge, class Container, class Cmp>
-class edge_queue : public std::priority_queue<Edge, Container, Cmp>
-{
-protected:
-  using std::priority_queue< Edge, Container, Cmp >::c;
-  using std::priority_queue< Edge, Container, Cmp >::comp;
-    
-public:
-  void sort()
-  {
-    sort_heap(c.begin(), c.end(), comp);
-  }   
-};
-
-namespace boost 
-{
-  
-  template <class Heuristic, class Graph>
-  struct AStarHeuristicConcept 
-  {
-    void constraints()
-    {
-      function_requires< CopyConstructibleConcept<Heuristic> >();
-      h(u);
-    }
-    Heuristic h;
-    typename graph_traits<Graph>::vertex_descriptor u;
-  };
-  
-    
-
-  template <class Graph, class CostType>
-  class astar_heuristic : public std::unary_function<
-    typename graph_traits<Graph>::vertex_descriptor, CostType>
-  {
-  public:
-    typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
-    astar_heuristic() {}
-    CostType operator()(Vertex u) { return static_cast<CostType>(0); }
-  };
-  
-  
-  template <class Visitor, class Graph>
-  struct ShootingStarVisitorConcept {
-    void constraints()
-    {
-      function_requires< CopyConstructibleConcept<Visitor> >();
-      vis.initialize_vertex(u, g);
-      vis.discover_vertex(u, g);
-      vis.examine_vertex(u, g);
-      vis.examine_edge(e, g, e_max_id);
-      vis.black_target(e, pe, s, g, e_max_id);
-      vis.gray_target(e, pe, s, g, e_max_id);
-      vis.finish_vertex(u, g);
-      
-      vis.tree_edge(e, pe, s, g, e_max_id);
-
-      vis.initialize_edge(e, g);
-      vis.discover_edge(e, g);
-      vis.finish_edge(e, g);
-
-    }
-    Visitor vis;
-    Graph g;
-    typename graph_traits<Graph>::vertex_descriptor u;
-    typename graph_traits<Graph>::edge_descriptor e, pe, s;
-    int e_max_id;
-  };
-  
-  
-  // Main visitor function.
-  // It decides what to do with an edge of certain color
-  
-  template <class IncidenceGraph, class Buffer, class BFSVisitor,
-            class ColorMap, class EdgeColorMap/*, class HistoryMap*/>
-  void shooting_star_edges_visit (const IncidenceGraph& g,
-		            typename graph_traits<IncidenceGraph>::edge_descriptor s,
-			    Buffer& Q, BFSVisitor vis, ColorMap color, EdgeColorMap edge_color, 
-			    int e_max_id)
-  {
-    function_requires< IncidenceGraphConcept<IncidenceGraph> >();
-    typedef graph_traits<IncidenceGraph> GTraits;
-    typedef typename GTraits::vertex_descriptor Vertex;
-    typedef typename GTraits::edge_descriptor Edge;
-    function_requires< ShootingStarVisitorConcept<BFSVisitor, IncidenceGraph> >();
-    function_requires< ReadWritePropertyMapConcept<EdgeColorMap, Edge> >();
-    
-    typedef typename property_traits<ColorMap>::value_type ColorValue;
-    typedef color_traits<ColorValue> Color;
-
-    typedef typename property_traits<EdgeColorMap>::value_type EdgeColorValue;
-    typedef color_traits<EdgeColorValue> EdgeColor;
-
-    typename GTraits::out_edge_iterator ei, ei_end;
-
-    // Paint source edge gray
-    put(edge_color, s, EdgeColor::gray());
-    vis.discover_edge(s, g);
-    
-    // Enqueue the source edge
-    Q.push(s);
-    
-    // While the queue is not empty
-    while (! Q.empty()) 
-    {
-      // Get an edge from the top
-      Edge e = Q.top();  Q.pop();            
-      
-      // Examine the edge
-      vis.examine_edge(e, g, e_max_id);
-      
-      // For all adjacent edges for the current one
-      for (tie(ei, ei_end) = out_edges(target(e, g), g); ei != ei_end; ++ei) 
-      {
-        // Get a color
-        EdgeColorValue e_color = get(edge_color, *ei);
-
-	// Discover the edge and paint it grey 
-	// and enqueue it if it was white
-	if (e_color == EdgeColor::white()) 
-	{         
-	  vis.tree_edge(*ei, e, s, g, e_max_id);
-	  put(edge_color, *ei, EdgeColor::gray());   
-	  vis.discover_edge(*ei, g);
-          Q.push(*ei);
-        } 
-	// or execute appropriate function 
-	// if it was grey or black
-	else 
-	{                                     
-	  vis.non_tree_edge(*ei, g);
-          if (e_color == EdgeColor::gray())
-	  {         
-	    vis.gray_target(*ei, e, s, g, e_max_id);
-          }
-	  else
-	  {                                      
-	    vis.black_target(*ei, e, s, g, e_max_id);
-	  }
-        }
-	
-      } // end for
-
-      // Finally paint the parent edge black
-      put(edge_color, e, EdgeColor::black());        
-      vis.finish_edge(e, g);
-      
-    } // end while
-  }
-																							      
-  
-  template <class Visitors = null_visitor>
-  class shooting_star_visitor : public bfs_visitor<Visitors> 
-  {
-    public:
-      shooting_star_visitor() {}
-      shooting_star_visitor(Visitors vis)
-        : bfs_visitor<Visitors>(vis) {}
-  
-      template <class Edge, class Graph>
-      void edge_relaxed(Edge e, Graph& g) 
-      {
-        invoke_visitors(this->m_vis, e, g, on_edge_relaxed());
-      }
-      template <class Edge, class Graph>
-      void edge_not_relaxed(Edge e, Graph& g) 
-      {
-        invoke_visitors(this->m_vis, e, g, on_edge_not_relaxed());      
-      }
-      template <class Edge, class Graph>
-      void initialize_edge(Edge e, Graph& g) 
-      {
-        invoke_visitors(this->m_vis, e, g, on_initialize_edge());      
-      }
-    
-    private:
-      template <class Edge, class Graph>
-      void tree_edge(Edge e, Edge pe, Edge s, Graph& g) {}
-      template <class Edge, class Graph>
-      void non_tree_edge(Edge e, Graph& g) {}
-  };
-
-  template <class Visitors>
-  shooting_star_visitor<Visitors>
-  make_shooting_star_visitor(Visitors vis) 
-  {
-    return shooting_star_visitor<Visitors>(vis);
-  }
-  
-  typedef shooting_star_visitor<> default_shooting_star_visitor;
-  
-
-  namespace detail {
-
-    // Shooting* visitor
-    // based on BFS visitor concept from BGL    
-    template <class AStarHeuristic, class UniformCostVisitor,
-              class UpdatableQueue, class PredecessorMap,
-              class CostMap, 
-	      class DistanceMap, class WeightMap,
-	      class EdgeMap,
-              class ColorMap, class EdgeColorMap,
-	      class BinaryFunction,
-              class BinaryPredicate>
-    struct shooting_star_bfs_visitor
-    {
-      
-      typedef typename property_traits<CostMap>::value_type C;
-      typedef typename property_traits<ColorMap>::value_type ColorValue;
-      typedef color_traits<ColorValue> Color;
-
-      typedef typename property_traits<EdgeColorMap>::value_type EdgeColorValue;
-      typedef color_traits<ColorValue> EdgeColor;
-
-      typedef typename property_traits<DistanceMap>::value_type distance_type;
-      
-      shooting_star_bfs_visitor(AStarHeuristic h, UniformCostVisitor vis,
-                        UpdatableQueue& Q, PredecessorMap& p,
-                        CostMap c, DistanceMap d, WeightMap w, EdgeMap em,
-                        ColorMap col, EdgeColorMap ecol, //HistoryMap his, 
-			BinaryFunction combine,
-                        BinaryPredicate compare, C zero)
-        : m_h(h), m_vis(vis), m_Q(Q), m_predecessor(p), m_cost(c),
-          m_distance(d), m_weight(w), m_edge(em), m_color(col), 
-	  m_ecolor(ecol), //m_history(his),
-          m_combine(combine), m_compare(compare), m_zero(zero) {}
-
-      shooting_star_bfs_visitor(const shooting_star_bfs_visitor &v)
-        : m_h(v.m_h), m_vis(v.m_vis), m_Q(v.m_Q), m_predecessor(v.m_predecessor), m_cost(v.m_cost),
-          m_distance(v.m_distance), m_weight(v.m_weight), m_edge(v.m_edge), m_color(v.m_color), 
-	  m_ecolor(v.m_ecolor), //m_history(his),
-          m_combine(v.m_combine), m_compare(v.m_compare), m_zero(v.m_zero) {}
-	  
-      ~shooting_star_bfs_visitor() {}
-      
-      template <class Vertex, class Graph>
-      void initialize_vertex(Vertex u, Graph& g) 
-      {
-        m_vis.initialize_vertex(u, g);
-      }
-      template <class Edge, class Graph>
-      void initialize_edge(Edge e, Graph& g) 
-      {
-        m_vis.initialize_edge(e, g);
-      }
-      template <class Vertex, class Graph>
-      void discover_vertex(Vertex u, Graph& g) 
-      {
-        m_vis.discover_vertex(u, g);
-      }
-      template <class Edge, class Graph>
-      void discover_edge(Edge e, Graph& g) 
-      {
-        m_vis.discover_vertex(e, g);
-      }
-      template <class Vertex, class Graph>
-      void examine_vertex(Vertex u, Graph& g) 
-      {
-        m_vis.examine_vertex(u, g);
-      }
-      template <class Vertex, class Graph>
-      void finish_vertex(Vertex u, Graph& g) 
-      {
-        m_vis.finish_vertex(u, g);
-      }
-      template <class Edge, class Graph>
-      void examine_edge(Edge e, Graph& g, int e_max_id) 
-      { 
-        if (m_compare(get(m_weight, e), m_zero))
-          throw negative_edge();
-        m_vis.examine_edge(e, g, e_max_id);
-      }
-      template <class Edge, class Graph>
-      void non_tree_edge(Edge, Graph&) {}
-      
-      template <class Edge, class Graph>
-      void finish_edge(Edge e, Graph& g) 
-      {
-        m_vis.finish_edge(e, g);
-      }
-      
-      
-      template <class Edge, class Graph>
-      void tree_edge(Edge e, Edge pe, Edge s, Graph& g, int e_max_id) 
-      {
-        m_decreased = relax(e, pe, s, g, m_weight, m_edge, m_predecessor, m_distance,
-                            m_cost, m_combine, m_compare, e_max_id);
-    
-        if(m_decreased) 
-	{
-          m_vis.edge_relaxed(e, g);
-          
-	  put(m_cost, e,
-              m_combine(get(m_distance, e),
-                        m_h(e)));
-
-        } 
-	else
-          m_vis.edge_not_relaxed(e, g);
-      }
-      
-      
-      template <class Edge, class Graph>
-      void gray_target(Edge e, Edge pe, Edge s, Graph& g, int e_max_id) 
-      {
-        m_decreased = relax(e, pe, s, g, m_weight, m_edge, m_predecessor, m_distance,
-                            m_cost, m_combine, m_compare, e_max_id);
-
-        if(m_decreased) 
-	{
-	  put(m_cost, e,
-              m_combine(get(m_distance, e),
-                        m_h(e)));
-			
-          m_Q.update(e);
-	  	  
-          m_vis.edge_relaxed(e, g);
-        } 
-	else
-          m_vis.edge_not_relaxed(e, g);
-      }
-      
-            
-      template <class Edge, class Graph>
-      void black_target(Edge e, Edge pe, Edge s, Graph& g, int e_max_id) 
-      {
-
-        m_decreased = relax(e, pe, s, g, m_weight, m_edge, m_predecessor, m_distance,
-                            m_cost, m_combine, m_compare, e_max_id);
-
-        if(m_decreased) 
-	{
-          m_vis.edge_relaxed(e, g);
-	  put(m_cost, e, m_combine(get(m_distance, e), m_h(e)));
-          
-          m_Q.push(e);
-          put(m_ecolor, e, EdgeColor::gray());
-          m_vis.black_target(e, g);
-        } 
-	else
-          m_vis.edge_not_relaxed(e, g);
-      }  
-
-      AStarHeuristic m_h;
-      UniformCostVisitor m_vis;
-      UpdatableQueue& m_Q;
-      PredecessorMap& m_predecessor;
-      CostMap m_cost;
-      EdgeMap m_edge;
-      DistanceMap m_distance;
-      WeightMap m_weight;
-      ColorMap m_color;
-      EdgeColorMap m_ecolor;
-      BinaryFunction m_combine;
-      BinaryPredicate m_compare;
-      bool m_decreased;
-      C m_zero;      
-    };
-    
-  } // namespace detail
-
-  template <typename VertexAndEdgeListGraph, typename AStarHeuristic,
-            typename ShootingStarVisitor, typename PredecessorMap,
-            typename CostMap, 
-	    typename DistanceMap,
-            typename WeightMap, 
-	    typename EdgeMap,
-	    typename ColorMap, typename EdgeColorMap,
-	    typename IndexMap,
-            typename CompareFunction, typename CombineFunction,
-            typename CostInf, typename CostZero>
-  inline void
-  shooting_star_search_no_init
-    (VertexAndEdgeListGraph &g,
-     typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor s,
-     AStarHeuristic h, ShootingStarVisitor vis,
-     PredecessorMap &predecessor, CostMap cost,
-     DistanceMap distance, WeightMap weight, EdgeMap edge_map,
-     ColorMap color, EdgeColorMap edge_color,
-     IndexMap index_map, CompareFunction compare, CombineFunction combine,
-     CostInf inf, CostZero zero, int e_max_id)
-  {
-    typedef indirect_cmp<CostMap, CompareFunction> IndirectCmp;
-    IndirectCmp icmp(cost, compare);
-  
-    typedef typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor
-      Edge;
-    
-    // Queue to store the list of edges to examine.
-    // I really hate this queue for what it does with the memory sometimes.
-    //
-    //And by the way...
-    //
-    //This place is for rent :)
-    //
-    typedef mutable_queue<Edge, std::vector<Edge>, IndirectCmp, IndexMap>
-      MutableQueue;
-    MutableQueue Q(num_edges(g), icmp, index_map);
-
-    detail::shooting_star_bfs_visitor<AStarHeuristic, ShootingStarVisitor,
-        MutableQueue, PredecessorMap, CostMap, DistanceMap,
-	WeightMap, EdgeMap, ColorMap, EdgeColorMap, /*HistoryMap,*/ CombineFunction, CompareFunction>
-      bfs_vis(h, vis, Q, predecessor, cost, distance, weight,
-              edge_map, color, edge_color, combine, compare, zero);
-  
-    shooting_star_edges_visit(g, s, Q, bfs_vis, color, edge_color, e_max_id);
-  }
-  
-  // Non-named parameter interface
-  template <typename VertexAndEdgeListGraph, typename AStarHeuristic,
-            typename ShootingStarVisitor, typename PredecessorMap,
-            typename CostMap, typename DistanceMap,
-            typename WeightMap, typename EdgeMap, 
-	    typename IndexMap,
-            typename ColorMap, typename EdgeColorMap,
-	    //typename HistoryMap,
-            typename CompareFunction, typename CombineFunction,
-            typename CostInf, typename CostZero>
-  inline void
-  shooting_star_search
-    (VertexAndEdgeListGraph &g,
-     typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor s,
-     AStarHeuristic h, ShootingStarVisitor vis,
-     PredecessorMap &predecessor, CostMap cost,
-     DistanceMap distance, WeightMap weight,
-     EdgeMap edge_map, IndexMap index_map, ColorMap color, EdgeColorMap edge_color,
-     CompareFunction compare, CombineFunction combine,
-     CostInf inf, CostZero zero, int e_max_id)
-  {
-    
-    typedef typename property_traits<ColorMap>::value_type ColorValue;
-    typedef color_traits<ColorValue> Color;
-    
-    typedef typename property_traits<EdgeColorMap>::value_type EdgeColorValue;
-    typedef color_traits<EdgeColorValue> EdgeColor;
-
-    typename graph_traits<VertexAndEdgeListGraph>::vertex_iterator ui, ui_end;
-    typename graph_traits<VertexAndEdgeListGraph>::edge_iterator ei, ei_end;
-
-    for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) 
-    {
-      vis.initialize_vertex(*ui, g);
-    }
-
-    for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) 
-    {
-      put(distance, *ei, inf);
-      put(edge_color, *ei, EdgeColor::white());
-      predecessor[g[*ei].id] = *ei;
-      put(cost, *ei, inf);
-    }
-
-    put(distance, s, zero);
-
-    put(cost, s, h(s));
-
-    shooting_star_search_no_init
-      (g, s, h, vis, predecessor, cost, distance, weight, edge_map,
-       color, edge_color, index_map, compare, combine, inf, zero, e_max_id);
-    
-  }
-  
-  namespace detail 
-  {
-    template <class VertexAndEdgeListGraph, class AStarHeuristic,
-              class CostMap, class DistanceMap, class WeightMap, class EdgeMap,
-              class IndexMap, 
-	      class PredecessorMap,
-	      class ColorMap, class EdgeColorMap, 
-	      class Params>
-    inline void
-    shooting_star_dispatch2
-      (VertexAndEdgeListGraph& g,
-       typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor s,
-       AStarHeuristic h, CostMap cost, DistanceMap distance,
-       WeightMap weight, EdgeMap edge_map, IndexMap index_map, 
-       PredecessorMap& predecessor, ColorMap color,
-       EdgeColorMap edge_color, const Params& params,
-       int e_max_id)
-    {
-      dummy_property_map p_map;
-      typedef typename property_traits<CostMap>::value_type C;
-      shooting_star_search
-        (g, s, h,
-         choose_param(get_param(params, graph_visitor),
-                      make_shooting_star_visitor(null_visitor())),
-	 predecessor,
-         cost, distance, weight, edge_map, index_map, color, edge_color, //history,
-         choose_param(get_param(params, distance_compare_t()),
-                      std::less<C>()),
-         choose_param(get_param(params, distance_combine_t()),
-                      closed_plus<C>()),
-         choose_param(get_param(params, distance_inf_t()),
-                      std::numeric_limits<C>::max BOOST_PREVENT_MACRO_SUBSTITUTION ()),
-         choose_param(get_param(params, distance_zero_t()),
-                      C()),
-	 e_max_id
-	);
-    }
-  
-    template <class VertexAndEdgeListGraph, class AStarHeuristic,
-              class CostMap, class DistanceMap, class WeightMap,
-              class EdgeMap, class IndexMap, 
-	      class PredecessorMap,
-	      class ColorMap, class EdgeColorMap,
-	      class Params>
-    inline void
-    shooting_star_dispatch1
-      (VertexAndEdgeListGraph& g,
-       typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor s,
-       AStarHeuristic h, CostMap cost, DistanceMap distance,
-       WeightMap weight, EdgeMap edge_map, IndexMap index_map, PredecessorMap& predecessor, 
-       ColorMap color, EdgeColorMap edge_color, const Params& params,
-       int e_max_id)
-    {
-      typedef typename property_traits<WeightMap>::value_type D;
-      typename std::vector<D>::size_type
-        n = is_default_param(distance) ? num_vertices(g) : 1;
-      std::vector<D> distance_map(n);
-      n = is_default_param(cost) ? num_vertices(g) : 1;
-      std::vector<D> cost_map(n);
-
-      std::vector<default_color_type> color_map(num_vertices(g));
-      default_color_type c = white_color;
-      
-      detail::shooting_star_dispatch2
-        (g, s, h,
-         choose_param(cost, make_iterator_property_map
-                      (cost_map.begin(), index_map,
-                       cost_map[0])),
-         choose_param(distance, make_iterator_property_map
-                      (distance_map.begin(), index_map, 
-                       distance_map[0])),
-         weight, edge_map, index_map,
-	 predecessor,
-	 choose_param(color, make_iterator_property_map
-                      (color_map.begin(), index_map, c)),
-	 edge_color, 
-         params,
-	 e_max_id);
-    }
-  } // namespace detail
-  
-  // Named parameter interface
-  template <typename VertexAndEdgeListGraph,
-            typename AStarHeuristic,
-            typename P, typename T, typename R, 
-	    typename IndexMap,
-	    typename DistanceMap,
-	    typename CostMap,
-	    typename PredecessorMap>
-  void
-  shooting_star_search
-    (VertexAndEdgeListGraph &g,
-     typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor s,
-     AStarHeuristic h, const bgl_named_params<P, T, R>& params, 
-     IndexMap edge_index,
-     DistanceMap distance, 
-     CostMap cost,
-     PredecessorMap &pre_map,
-     int e_max_id)
-  {
-    typedef typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor tEdge;
-
-    detail::shooting_star_dispatch1
-      (g, s, h,
-       cost,
-       distance,
-       choose_const_pmap(get_param(params, edge_weight), g, edge_weight), //weight
-       choose_const_pmap(get_param(params, edge_weight2), g, edge_weight2), //adjacent edges cost
-       edge_index,
-       pre_map, //predecessors
-       get_param(params, vertex_color), //vertex color (deprecated)
-       get_param(params, edge_color), //edge color
-       params,
-       e_max_id
-       );    
-  }
-  
-} // namespace boost
-
-#endif // BOOST_GRAPH_SHOOTING_STAR_SEARCH_HPP
diff --git a/src/shooting_star/test/CMakeLists.txt b/src/shooting_star/test/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/shooting_star/test/spss-any-00.data b/src/shooting_star/test/spss-any-00.data
deleted file mode 100644
index 0b883d6..0000000
--- a/src/shooting_star/test/spss-any-00.data
+++ /dev/null
@@ -1,212 +0,0 @@
-BEGIN;
---
--- PostgreSQL database dump
---
-
-SET client_encoding = 'UTF8';
-SET standard_conforming_strings = off;
-SET check_function_bodies = false;
-SET client_min_messages = warning;
-SET escape_string_warning = off;
-
-SET search_path = public, pg_catalog;
-
-SET default_tablespace = '';
-
-SET default_with_oids = false;
-
---
--- Name: edges1; Type: TABLE; Schema: public; Owner: -; Tablespace: 
---
-
-DROP TABLE IF EXISTS edges1 CASCADE;
-
-CREATE TABLE edges1 (
-    eid integer NOT NULL,
-    dir character varying,
-    source integer,
-    target integer,
-    cost double precision,
-    reverse_cost double precision,
-    x1 double precision,
-    y1 double precision,
-    x2 double precision,
-    y2 double precision,
-    to_cost double precision,
-    rule text,
-    the_geom geometry,
-    CONSTRAINT enforce_dims_the_geom CHECK ((st_ndims(the_geom) = 2)),
-    CONSTRAINT enforce_geotype_the_geom CHECK (((geometrytype(the_geom) = 'LINESTRING'::text) OR (the_geom IS NULL)))
---    , CONSTRAINT enforce_srid_the_geom CHECK ((st_srid(the_geom) = (0)))
-);
-
-
---
--- Name: restrictions1; Type: TABLE; Schema: public; Owner: -; Tablespace: 
---
-
-DROP TABLE IF EXISTS restrictions1 CASCADE;
-
-CREATE TABLE restrictions1 (
-    rid integer NOT NULL,
-    to_cost double precision,
-    teid integer,
-    feid integer,
-    via text
-);
-
-
---
--- Name: restrictions1_rid_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE restrictions1_rid_seq
-    INCREMENT BY 1
-    NO MAXVALUE
-    NO MINVALUE
-    CACHE 1;
-
-
---
--- Name: restrictions1_rid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE restrictions1_rid_seq OWNED BY restrictions1.rid;
-
-
---
--- Name: restrictions1_rid_seq; Type: SEQUENCE SET; Schema: public; Owner: -
---
-
-SELECT pg_catalog.setval('restrictions1_rid_seq', 1, true);
-
-
---
--- Name: restrictions1a; Type: TABLE; Schema: public; Owner: -; Tablespace: 
---
-
-DROP TABLE IF EXISTS restrictions1a CASCADE;
-
-CREATE TABLE restrictions1a (
-    rid integer,
-    to_cost double precision,
-    teid integer,
-    feid integer,
-    via text
-);
-
-
---
--- Name: rid; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE restrictions1 ALTER COLUMN rid SET DEFAULT nextval('restrictions1_rid_seq'::regclass);
-
-
---
--- Data for Name: edges1; Type: TABLE DATA; Schema: public; Owner: -
---
-
-COPY edges1 (eid, dir, source, target, cost, reverse_cost, x1, y1, x2, y2, to_cost, rule, the_geom) FROM stdin WITH NULL '__NULL__';
-1	B	1	2	1	1	2	0	2	1	__NULL__	__NULL__	010200000002000000000000000000004000000000000000000000000000000040000000000000F03F
-2	TF	2	3	-1	1	2	1	3	1	__NULL__	__NULL__	0102000000020000000000000000000040000000000000F03F0000000000000840000000000000F03F
-3	TF	3	4	-1	1	3	1	4	1	__NULL__	__NULL__	0102000000020000000000000000000840000000000000F03F0000000000001040000000000000F03F
-4	B	2	7	1	1	2	1	2	2	__NULL__	__NULL__	0102000000020000000000000000000040000000000000F03F00000000000000400000000000000040
-5	FT	3	8	1	-1	3	1	3	2	__NULL__	__NULL__	0102000000020000000000000000000840000000000000F03F00000000000008400000000000000040
-6	B	5	6	1	1	0	2	1	2	__NULL__	__NULL__	01020000000200000000000000000000000000000000000040000000000000F03F0000000000000040
-7	B	6	7	1	1	1	2	2	2	__NULL__	__NULL__	010200000002000000000000000000F03F000000000000004000000000000000400000000000000040
-8	B	7	8	1	1	2	2	3	2	__NULL__	__NULL__	0102000000020000000000000000000040000000000000004000000000000008400000000000000040
-9	B	8	9	1	1	3	2	4	2	__NULL__	__NULL__	0102000000020000000000000000000840000000000000004000000000000010400000000000000040
-10	B	7	10	1	1	2	2	2	3	__NULL__	__NULL__	0102000000020000000000000000000040000000000000004000000000000000400000000000000840
-11	FT	8	11	1	-1	3	2	3	3	__NULL__	__NULL__	0102000000020000000000000000000840000000000000004000000000000008400000000000000840
-12	FT	10	11	1	-1	2	3	3	3	__NULL__	__NULL__	0102000000020000000000000000000040000000000000084000000000000008400000000000000840
-13	FT	11	12	1	-1	3	3	4	3	__NULL__	__NULL__	0102000000020000000000000000000840000000000000084000000000000010400000000000000840
-14	B	10	13	1	1	2	3	2	4	__NULL__	__NULL__	0102000000020000000000000000000040000000000000084000000000000000400000000000001040
-15	B	9	12	1	1	4	2	4	3	__NULL__	__NULL__	0102000000020000000000000000001040000000000000004000000000000010400000000000000840
-16	B	4	9	1	1	4	1	4	2	__NULL__	__NULL__	0102000000020000000000000000001040000000000000F03F00000000000010400000000000000040
-\.
-
-
---
--- Data for Name: restrictions1; Type: TABLE DATA; Schema: public; Owner: -
---
-
-COPY restrictions1 (rid, to_cost, teid, feid, via) FROM stdin WITH NULL '__NULL__';
-1	100	7	4	__NULL__
-2	4	8	3	5
-3	100	9	16	__NULL__
-\.
-
-
---
--- Data for Name: restrictions1a; Type: TABLE DATA; Schema: public; Owner: -
---
-
-COPY restrictions1a (rid, to_cost, teid, feid, via) FROM stdin WITH NULL '__NULL__';
-1	100	7	4	__NULL__
-\.
-
-
---
--- Name: edges1_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
---
-
-ALTER TABLE ONLY edges1
-    ADD CONSTRAINT edges1_pkey PRIMARY KEY (eid);
-
-
---
--- Name: restrictions1_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
---
-
-ALTER TABLE ONLY restrictions1
-    ADD CONSTRAINT restrictions1_pkey PRIMARY KEY (rid);
-
-
---
--- PostgreSQL database dump complete
---
-COMMIT;
-
-/*
-
-select * from turn_restrict_shortest_path(
-    'select eid as id, source::integer, target::integer,cost, reverse_cost from edges1',
-    1,     -- edge_id for start
-    0.5,   -- midpoint of edge
-    6,     -- edge_id of route end
-    0.5,   -- midpoint of edge
-    true,  -- directed graph?
-    true,  -- has_reverse_cost?
-    null); -- no turn restrictions
-
-select * from turn_restrict_shortest_path(
-    'select eid as id, source::integer, target::integer,cost, reverse_cost from edges1',
-    1,     -- node_id of start
-    5,     -- node_id of end
-    true,  -- directed graph?
-    true,  -- has_reverse_cost?
-    null); -- no turn restrictions
-
-select * from turn_restrict_shortest_path(
-    'select eid as id, source::integer, target::integer,cost, reverse_cost from edges1',
-    1,    -- edge_id for start
-    0.5,  -- midpoint of edge
-    6,    -- edge_id of route end
-    0.5,  -- midpoint of edge
-    true, -- directed graph?
-    true, -- has_reverse_cost?
-              -- include the turn restrictions
-    'select to_cost, teid as target_id, feid||coalesce('',''||via,'''') as via_path from restrictions1');
-
-select * from turn_restrict_shortest_path(
-    'select eid as id, source::integer, target::integer,cost, reverse_cost from edges1',
-    1,     -- node_id of start
-    5,     -- node_id of end
-    true,  -- directed graph?
-    true,  -- has_reverse_cost?
-               -- include the turn restrictions
-    'select to_cost, teid as target_id, feid||coalesce('',''||via,'''') as via_path from restrictions1');
-
-*/
-
diff --git a/src/topology/doc/doc-pgr_analyzeGraph.queries b/src/topology/doc/doc-pgr_analyzeGraph.queries
index 25e304c..ca91813 100644
--- a/src/topology/doc/doc-pgr_analyzeGraph.queries
+++ b/src/topology/doc/doc-pgr_analyzeGraph.queries
@@ -1,5 +1,7 @@
 BEGIN;
 BEGIN
+SET client_min_messages TO NOTICE;
+SET
 SELECT  pgr_createTopology('edge_table',0.001, clean := true);
 NOTICE:  PROCESSING:
 NOTICE:  pgr_createTopology('edge_table', 0.001, 'the_geom', 'id', 'source', 'target', rows_where := 'true', clean := t)
diff --git a/src/topology/doc/doc-pgr_createTopology.queries b/src/topology/doc/doc-pgr_createTopology.queries
index 8353024..04a87d7 100644
--- a/src/topology/doc/doc-pgr_createTopology.queries
+++ b/src/topology/doc/doc-pgr_createTopology.queries
@@ -256,5 +256,7 @@ NOTICE:  ----------------------------------------------
 (1 row)
 
 --q17.1
+SET client_min_messages TO NOTICE;
+SET
 ROLLBACK;
 ROLLBACK
diff --git a/src/topology/doc/pgr_analyzeGraph.rst b/src/topology/doc/pgr_analyzeGraph.rst
index d626064..9b8ae88 100644
--- a/src/topology/doc/pgr_analyzeGraph.rst
+++ b/src/topology/doc/pgr_analyzeGraph.rst
@@ -12,9 +12,6 @@
 pgr_analyzeGraph
 ===============================================================================
 
-.. index:: 
-	single: pgr_analyzeGraph(text,double precision,text,text,text,text,text)
-	module: common
 
 Name
 -------------------------------------------------------------------------------
@@ -30,6 +27,9 @@ The function returns:
   - ``OK`` after the analysis has finished.
   - ``FAIL`` when the analysis was not completed due to an error. 
 
+.. index:: 
+	single: analyzeGraph(Complete Signature)
+
 .. code-block:: sql
 
 	varchar pgr_analyzeGraph(text edge_table, double precision tolerance, 
@@ -63,7 +63,7 @@ The function returns:
   - ``OK`` after the analysis has finished.
 
     * Uses the vertices table: <edge_table>_vertices_pgr.
-    * Fills completly the ``cnt`` and ``chk`` columns of the vertices table.
+    * Fills completely the ``cnt`` and ``chk`` columns of the vertices table.
     * Returns the analysis of the section of the network defined by  ``rows_where``
 
   - ``FAIL`` when the analysis was not completed due to an error. 
@@ -126,7 +126,7 @@ The order of the parameters do not matter:
 
 	 SELECT  pgr_analyzeGraph('edge_table',0.001,source:='source',id:='id',target:='target',the_geom:='the_geom');
 
-Parameters defined with a default value can be ommited, as long as the value matches the default:
+Parameters defined with a default value can be omitted, as long as the value matches the default:
 
 .. code-block:: sql
 
diff --git a/src/topology/doc/pgr_analyzeOneWay.rst b/src/topology/doc/pgr_analyzeOneWay.rst
index 37b0787..8e344f7 100644
--- a/src/topology/doc/pgr_analyzeOneWay.rst
+++ b/src/topology/doc/pgr_analyzeOneWay.rst
@@ -12,9 +12,6 @@
 pgr_analyzeOneway
 ===============================================================================
 
-.. index:: 
-	single: pgr_analyzeOneway(text,text[],text[],text[],text[],text,text,text,boolean)
-	module: common
 
 Name
 -------------------------------------------------------------------------------
@@ -27,6 +24,9 @@ Synopsis
 
 This function analyzes oneway streets in a graph and identifies any flipped segments. 
 
+.. index:: 
+	single: analyzeOneway(Complete Signature)
+
 .. code-block:: sql
 
 	text pgr_analyzeOneway(geom_table text, 
diff --git a/src/topology/doc/pgr_createTopology.rst b/src/topology/doc/pgr_createTopology.rst
index fc28baf..7f2c4c5 100644
--- a/src/topology/doc/pgr_createTopology.rst
+++ b/src/topology/doc/pgr_createTopology.rst
@@ -12,10 +12,6 @@
 pgr_createTopology
 ===============================================================================
 
-.. index:: 
-	single: pgr_createTopology(text,double precision,text,text,text,text,text)
-	module: common
-
 Name
 -------------------------------------------------------------------------------
 
@@ -30,6 +26,9 @@ The function returns:
   - ``OK`` after the network topology has been built and the vertices table created.
   - ``FAIL`` when the network topology was not built due to an error. 
 
+.. index:: 
+	single: createTopology(Complete Signature)
+
 .. code-block:: none
 
 	varchar pgr_createTopology(text edge_table, double precision tolerance, 
@@ -88,7 +87,7 @@ The function returns:
 
 .. rubric:: The Vertices Table
 
-The vertices table is a requirment of the :ref:`pgr_analyzeGraph <pgr_analyze_graph>` and the :ref:`pgr_analyzeOneway <pgr_analyze_oneway>` functions.
+The vertices table is a requirement of the :ref:`pgr_analyzeGraph <pgr_analyze_graph>` and the :ref:`pgr_analyzeOneway <pgr_analyze_oneway>` functions.
 
 The structure of the vertices table is:
 
@@ -134,7 +133,7 @@ We get the same result AS the simplest way to use the function.
 
 .. rubric:: When using the named notation
 
-Parameters defined with a default value can be omited, as long as the value matches the default
+Parameters defined with a default value can be omitted, as long as the value matches the default
 And The order of the parameters would not matter.
 
 .. literalinclude:: doc-pgr_createTopology.queries
diff --git a/src/topology/doc/pgr_createVerticesTable.rst b/src/topology/doc/pgr_createVerticesTable.rst
index 745389f..8872b01 100644
--- a/src/topology/doc/pgr_createVerticesTable.rst
+++ b/src/topology/doc/pgr_createVerticesTable.rst
@@ -12,10 +12,6 @@
 pgr_createVerticesTable 
 ===============================================================================
 
-.. index:: 
-	single: pgr_createVerticesTable(text,text,text,text,text)
-	module: common
-
 Name
 -------------------------------------------------------------------------------
 
@@ -30,10 +26,13 @@ The function returns:
   - ``OK`` after the vertices table has been reconstructed.
   - ``FAIL`` when the vertices table was not reconstructed due to an error. 
 
+.. index:: 
+	single: createVerticesTable(Complete Signature)
+
 .. code-block:: sql
 
-	varchar pgr_createVerticesTable(text edge_table,  text the_geom:='the_geom'
-                           text source:='source',text target:='target',text rows_where:='true')
+	pgr_createVerticesTable(edge_table, the_geom, source, target, rows_where)
+    RETURNS VARCHAR
 
 
 
@@ -125,7 +124,7 @@ The order of the parameters do not matter:
 
 	 SELECT  pgr_createVerticesTable('edge_table',source:='source',target:='target',the_geom:='the_geom');
 
-Parameters defined with a default value can be omited, as long as the value matches the default:
+Parameters defined with a default value can be omitted, as long as the value matches the default:
 
 .. code-block:: sql
 
diff --git a/src/topology/doc/pgr_nodeNetwork.rst b/src/topology/doc/pgr_nodeNetwork.rst
index 6aa8cdc..918608c 100644
--- a/src/topology/doc/pgr_nodeNetwork.rst
+++ b/src/topology/doc/pgr_nodeNetwork.rst
@@ -12,10 +12,6 @@
 pgr_nodeNetwork
 ===============================================================================
 
-.. index:: 
-	single: pgr_NodeNetwork(text,float8,text,text,text)
-	module: common
-
 Name
 -------------------------------------------------------------------------------
 
@@ -30,11 +26,13 @@ Synopsis
 
 The function reads edges from a not "noded" network table and writes the "noded" edges into a new table.
 
+.. index:: 
+	single: pgr_NodeNetwork(Complete Signature)
+
 .. code-block:: sql
 
-    text pgr_nodenetwork(text edge_table, float8, tolerance,
-			 text  id='id', text the_geom='the_geom',text table_ending='noded'
-             text rows_where ='', boolean outall=false)
+    pgr_nodenetwork(edge_table, tolerance, id, text the_geom, table_ending, rows_where, outall)
+    RETURNS TEXT
   
 
 Description
@@ -122,7 +120,7 @@ The analysis tell us that the network has a gap and and an intersection. We try
 	NOTICE:  pgr_nodeNetwork('edge_table',0.001,'the_geom','id','noded')
 	NOTICE:  Performing checks, pelase wait .....
 	NOTICE:  Processing, pelase wait .....
-	NOTICE:    Splitted Edges: 3
+	NOTICE:    Split Edges: 3
 	NOTICE:   Untouched Edges: 15
 	NOTICE:       Total original Edges: 18
 	NOTICE:   Edges generated: 6
diff --git a/src/topology/sql/create_vertices_table.sql b/src/topology/sql/create_vertices_table.sql
index 69c4c00..e6b0acf 100644
--- a/src/topology/sql/create_vertices_table.sql
+++ b/src/topology/sql/create_vertices_table.sql
@@ -160,15 +160,15 @@ BEGIN
   raise debug 'Checking Condition';
     -- issue #193 & issue #210 & #213
     -- this sql is for trying out the where clause
-    -- the select * is to avoid any colum name conflicts
+    -- the select * is to avoid any column name conflicts
     -- limit 1, just try on first record
-    -- if the where clasuse is ill formed it will be catched in the exception
+    -- if the where clasuse is ill formed it will be caught in the exception
     sql = 'select * from '||_pgr_quote_ident(tabname)||' WHERE true'||rows_where ||' limit 1';
     EXECUTE sql into dummyRec;
     -- end 
 
     -- if above where clasue works this one should work
-    -- any error will be catched by the exception also
+    -- any error will be caught by the exception also
     sql = 'select count(*) from '||_pgr_quote_ident(tabname)||' WHERE (' || gname || ' IS NULL or '||
 		sourcename||' is null or '||targetname||' is null)=true '||rows_where;
     raise debug '%',sql;
diff --git a/src/topology/sql/nodeNetwork.sql b/src/topology/sql/nodeNetwork.sql
index 9718814..43bd16d 100644
--- a/src/topology/sql/nodeNetwork.sql
+++ b/src/topology/sql/nodeNetwork.sql
@@ -202,7 +202,7 @@ BEGIN
 
     -- second temp table with locus (index of intersection point on the line)
     -- to avoid updating the previous table
-    -- we keep only intersection points occuring onto the line, not at one of its ends
+    -- we keep only intersection points occurring onto the line, not at one of its ends
 --    drop table if exists inter_loc;
 
 --HAD TO CHANGE THIS QUERY
@@ -267,7 +267,7 @@ BEGIN
 		' from '|| _pgr_quote_ident(intab) ||' where  '||quote_ident(n_pkey)||' not in (select * from used)' || rows_where || ')';
 	GET DIAGNOSTICS untouched = ROW_COUNT;
 
-	raise NOTICE '  Splitted Edges: %', touched;
+	raise NOTICE '  Split Edges: %', touched;
 	raise NOTICE ' Untouched Edges: %', untouched;
 	raise NOTICE '     Total original Edges: %', touched+untouched;
         RAISE NOTICE ' Edges generated: %', splits;
diff --git a/src/topology/sql/pgrouting_analytics.sql b/src/topology/sql/pgrouting_analytics.sql
index 355e703..ef72052 100644
--- a/src/topology/sql/pgrouting_analytics.sql
+++ b/src/topology/sql/pgrouting_analytics.sql
@@ -48,7 +48,7 @@ THE SOFTWARE.
 
        select pgr_analyzeGraph('mytab', 0.000002);
 
-   After the analyzing the graph, deadends are indentified by *cnt=1*
+   After the analyzing the graph, deadends are identified by *cnt=1*
    in the "vertices_tmp" table and potential problems are identified
    with *chk=1*.  (Using 'source' and 'target' columns for analysis)
 
@@ -64,7 +64,7 @@ Makes more checks:
    checks table edge_tab exists in the schema
    checks source and target columns exist in edge_tab
    checks that source and target are completely populated i.e. do not have NULL values
-   checks table edge_tabVertices exist in the appropiate schema
+   checks table edge_tabVertices exist in the appropriate schema
        if not, it creates it and populates it
    checks 'cnt','chk' columns exist in  edge_tabVertices
        if not, it creates them
diff --git a/src/topology/sql/pgrouting_topology.sql b/src/topology/sql/pgrouting_topology.sql
index e241b1b..af9ccfc 100644
--- a/src/topology/sql/pgrouting_topology.sql
+++ b/src/topology/sql/pgrouting_topology.sql
@@ -171,15 +171,15 @@ BEGIN
     BEGIN 
         -- issue #193 & issue #210 & #213
         -- this sql is for trying out the where clause
-        -- the select * is to avoid any colum name conflicts
+        -- the select * is to avoid any column name conflicts
         -- limit 1, just try on first record
-        -- if the where clasuse is ill formed it will be catched in the exception
+        -- if the where clasuse is ill formed it will be caught in the exception
         sql = 'select * from '||_pgr_quote_ident(tabname)||' WHERE true'||rows_where ||' limit 1';
         EXECUTE sql into dummyRec;
         -- end 
 
         -- if above where clasue works this one should work
-        -- any error will be catched by the exception also
+        -- any error will be caught by the exception also
         sql = 'select count(*) from '||_pgr_quote_ident(tabname)||' WHERE (' || gname || ' IS NOT NULL AND '||
 	    idname||' IS NOT NULL)=false '||rows_where;
         EXECUTE SQL  into notincluded;
@@ -194,7 +194,7 @@ BEGIN
                 rows_where=  ' and ('||quote_ident(sourcename)||' is null or '||quote_ident(targetname)||' is  null)'; 
             end if;
         end if;
-        -- my thoery is that the select Count(*) will never go thru here
+        -- my thoery is that the select Count(*) will never go through here
         EXCEPTION WHEN OTHERS THEN  
              RAISE NOTICE 'Got %', SQLERRM; -- issue 210,211
              RAISE NOTICE 'ERROR: Condition is not correct, please execute the following query to test your condition'; 
@@ -214,7 +214,7 @@ BEGIN
                 execute 'SELECT DROPGEOMETRYCOLUMN('||quote_literal(sname)||','||quote_literal(vname)||','||quote_literal('the_geom')||')';
                 emptied = true;
             end if;
-         ELSE -- table doesnt exist
+         ELSE -- table doesn't exist
             execute 'CREATE TABLE '||_pgr_quote_ident(vertname)||' (id bigserial PRIMARY KEY,cnt integer,chk integer,ein integer,eout integer)';
             emptied = true;
          END IF;
diff --git a/src/topology/test/analyzeOneway-any.test.sql b/src/topology/test/analyzeOneway-any.test.sql
index 75f67ae..3c08288 100644
--- a/src/topology/test/analyzeOneway-any.test.sql
+++ b/src/topology/test/analyzeOneway-any.test.sql
@@ -2,6 +2,9 @@ BEGIN;
 ---------------------------------------------------------------------------------------
 --            pgr_analyzeOneway
 ---------------------------------------------------------------------------------------
+
+SET client_min_messages TO NOTICE;
+
 SELECT pgr_analyzeOneway('edge_table',
 ARRAY['', 'B', 'TF'],
 ARRAY['', 'B', 'FT'],
diff --git a/src/topology/test/createVertTab-any.test.sql b/src/topology/test/createVertTab-any.test.sql
index 7a14412..8fa90c7 100644
--- a/src/topology/test/createVertTab-any.test.sql
+++ b/src/topology/test/createVertTab-any.test.sql
@@ -4,6 +4,7 @@ BEGIN;
 --                  PGR_createVerticesTable
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
+SET client_min_messages TO NOTICE;
 
 --    SELECT pgr_createTopology('edge_table',0.001);
 	 SELECT  pgr_createVerticesTable('edge_table');
diff --git a/src/topology/test/doc-pgr_analyzeGraph.test.sql b/src/topology/test/doc-pgr_analyzeGraph.test.sql
index 92f54dd..21514cc 100644
--- a/src/topology/test/doc-pgr_analyzeGraph.test.sql
+++ b/src/topology/test/doc-pgr_analyzeGraph.test.sql
@@ -7,6 +7,7 @@ BEGIN;
     --              PGR_analyzegraph
     ------------------------------------------------------------------------------------------------------
     ------------------------------------------------------------------------------------------------------
+    SET client_min_messages TO NOTICE;
 
     SELECT  pgr_createTopology('edge_table',0.001, clean := true);
     SELECT  pgr_analyzeGraph('edge_table',0.001);
diff --git a/src/topology/test/doc-pgr_createTopology.test.sql b/src/topology/test/doc-pgr_createTopology.test.sql
index 4f3660c..4fb8fd2 100644
--- a/src/topology/test/doc-pgr_createTopology.test.sql
+++ b/src/topology/test/doc-pgr_createTopology.test.sql
@@ -114,4 +114,6 @@ BEGIN;
     SELECT pgr_createTopology('edge_table',  0.001, rows_where:='id < 6', clean := true);
     SELECT pgr_createTopology('edge_table',  0.001);
     \echo --q17.1
+
+    SET client_min_messages TO NOTICE;
     ROLLBACK;	
diff --git a/src/topology/test/nodeNetwork-any.result b/src/topology/test/nodeNetwork-any.result
index 588b79a..8250259 100644
--- a/src/topology/test/nodeNetwork-any.result
+++ b/src/topology/test/nodeNetwork-any.result
@@ -26,7 +26,7 @@ NOTICE:  PROCESSING:
 NOTICE:  pgr_nodeNetwork('edge_table', 0.001, 'id', 'the_geom', 'noded', '<NULL>',  f)
 NOTICE:  Performing checks, please wait .....
 NOTICE:  Processing, please wait .....
-NOTICE:    Splitted Edges: 3
+NOTICE:    Split Edges: 3
 NOTICE:   Untouched Edges: 15
 NOTICE:       Total original Edges: 18
 NOTICE:   Edges generated: 6
diff --git a/src/topology/test/nodeNetwork-any.test.sql b/src/topology/test/nodeNetwork-any.test.sql
index 883c960..ec894d2 100644
--- a/src/topology/test/nodeNetwork-any.test.sql
+++ b/src/topology/test/nodeNetwork-any.test.sql
@@ -2,6 +2,8 @@ BEGIN;
 --                pgr_nodeNetwork
 --------------------------------------------------------------------------------
 
+SET client_min_messages TO NOTICE;
+
 SELECT pgr_createTopology('edge_table', 0.001, clean := TRUE);
 SELECT pgr_analyzegraph('edge_table', 0.001);
 SELECT pgr_nodeNetwork('edge_table', 0.001);
diff --git a/src/trsp/CMakeLists.txt b/src/trsp/CMakeLists.txt
deleted file mode 100644
index fe4fdcf..0000000
--- a/src/trsp/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-set(PACKAGE_SQL_FILES "")
-add_subdirectory(sql)
-set(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-subdirs(doc src test)
diff --git a/src/trsp/doc/CMakeLists.txt b/src/trsp/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/trsp/doc/pgr_trsp.rst b/src/trsp/doc/pgr_trsp.rst
index e878509..c3a3798 100644
--- a/src/trsp/doc/pgr_trsp.rst
+++ b/src/trsp/doc/pgr_trsp.rst
@@ -13,11 +13,10 @@ pgr_trsp - Turn Restriction Shortest Path (TRSP)
 ===============================================================================
 
 .. index:: 
-	single: pgr_trsp(text,integer,integer,boolean,boolean)
-	single: pgr_trsp(text,integer,integer,boolean,boolean,text)
-	single: pgr_trspViaVertices(text,integer,double precision,integer,double precision,boolean,boolean)
-	single: pgr_trspViaEdges(text,integer,double precision,integer,double precision,boolean,boolean,text)
-	module: trsp
+	single: trsp(text,integer,integer,boolean,boolean)
+	single: trsp(text,integer,integer,boolean,boolean,text)
+	single: trspViaVertices(text,integer,double precision,integer,double precision,boolean,boolean)
+	single: trspViaEdges(text,integer,double precision,integer,double precision,boolean,boolean,text)
 
 Name
 -------------------------------------------------------------------------------
@@ -88,7 +87,7 @@ The TRSP setup is mostly the same as :ref:`Dijkstra shortest path <pgr_dijkstra>
 
 	:to_cost: ``float8`` turn restriction cost
 	:target_id: ``int4`` target id
-	:via_path: ``text`` commar seperated list of edges in the reverse order of ``rule``
+	:via_path: ``text`` comma separated list of edges in the reverse order of ``rule``
 
 Another variant of TRSP allows to specify **EDGE id** of source and target together with a fraction to interpolate the position:
 
@@ -143,7 +142,7 @@ We also have support for vias where you can say generate a from A to B to C, etc
 
 	:to_cost: ``float8`` turn restriction cost
 	:target_id: ``int4`` target id
-	:via_path: ``text`` commar seperated list of edges in the reverse order of ``rule``
+	:via_path: ``text`` commar separated list of edges in the reverse order of ``rule``
 
 Another variant of TRSP allows to specify **EDGE id** together with a fraction to interpolate the position:
 
diff --git a/src/trsp/sql/trsp_V2.2.sql b/src/trsp/sql/trsp_V2.2.sql
index 8b5b9b9..0ff2500 100644
--- a/src/trsp/sql/trsp_V2.2.sql
+++ b/src/trsp/sql/trsp_V2.2.sql
@@ -86,7 +86,7 @@ BEGIN
             new_sql := 
             'WITH old_sql AS (' || edges_sql || ')' ||
             '   SELECT id, source, target, cost FROM old_sql';
-        ELSE -- it does not have reverse_cost but user want's it
+        ELSE -- it does not have reverse_cost but user wants it
             RAISE EXCEPTION 'Error, reverse_cost is used, but query did''t return ''reverse_cost'' column'
             USING ERRCODE := 'XX000';
         END IF;
@@ -139,7 +139,7 @@ BEGIN
             new_sql := 
                'WITH old_sql AS (' || edges_sql || ')' ||
                 '   SELECT id, source, target, cost FROM old_sql';
-        ELSE -- it does not have reverse_cost but user want's it
+        ELSE -- it does not have reverse_cost but user wants it
             RAISE EXCEPTION 'Error, reverse_cost is used, but query did''t return ''reverse_cost'' column'
             USING ERRCODE := 'XX000';
         END IF;
diff --git a/src/trsp/src/CMakeLists.txt b/src/trsp/src/CMakeLists.txt
index 316f6a1..bbb9409 100644
--- a/src/trsp/src/CMakeLists.txt
+++ b/src/trsp/src/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_library(trsp OBJECT 
     trsp.c
-    trsp_core.cpp
+    trsp_driver.cpp
     GraphDefinition.cpp)
 
diff --git a/src/trsp/src/GraphDefinition.cpp b/src/trsp/src/GraphDefinition.cpp
index 3b95141..2d58e0c 100644
--- a/src/trsp/src/GraphDefinition.cpp
+++ b/src/trsp/src/GraphDefinition.cpp
@@ -21,9 +21,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#undef min
+#undef max
 #endif
 
 
@@ -641,11 +643,11 @@ bool GraphDefinition::addEdge(edge_t edgeIn)
     {
         //Connect current edge with existing edge with start node
         //connectEdge(
-        long lEdgeCount = itNodeMap->second.size();
-        long lEdgeIndex;
+        int64_t lEdgeCount = itNodeMap->second.size();
+        int64_t lEdgeIndex;
         for(lEdgeIndex = 0; lEdgeIndex < lEdgeCount; lEdgeIndex++)
         {
-            long lEdge = itNodeMap->second.at(lEdgeIndex);    
+            int64_t lEdge = itNodeMap->second.at(lEdgeIndex);    
             connectEdge(newEdge, m_vecEdgeVector[lEdge], true);
         }
     }
@@ -657,11 +659,11 @@ bool GraphDefinition::addEdge(edge_t edgeIn)
     {
         //Connect current edge with existing edge with end node
         //connectEdge(
-        long lEdgeCount = itNodeMap->second.size();
-        long lEdgeIndex;
+        int64_t lEdgeCount = itNodeMap->second.size();
+        int64_t lEdgeIndex;
         for(lEdgeIndex = 0; lEdgeIndex < lEdgeCount; lEdgeIndex++)
         {
-            long lEdge = itNodeMap->second.at(lEdgeIndex);    
+            int64_t lEdge = itNodeMap->second.at(lEdgeIndex);    
             connectEdge(newEdge, m_vecEdgeVector[lEdge], false);
         }
     }
diff --git a/src/trsp/src/GraphDefinition.h b/src/trsp/src/GraphDefinition.h
index 3aad411..85c4733 100644
--- a/src/trsp/src/GraphDefinition.h
+++ b/src/trsp/src/GraphDefinition.h
@@ -26,16 +26,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <vector>
 #include <map>
 #include <queue>
-
+#if defined(_MSC_VER) && _MSC_VER >= 1700
+#include <functional>
+#endif
 #include <sstream>
-#include "trsp.h"
+#include "trsp_driver.h"
 
 
 typedef std::pair<double, std::vector<int64_t> > PDVI;
 
 
 class GraphDefinition {
-    typedef std::vector<long> LongVector;
+    typedef std::vector<int64_t> LongVector;
     typedef std::vector<LongVector> VectorOfLongVector;
     typedef std::pair<int, bool> PIB;
     typedef std::pair<double, PIB> PDP;
@@ -70,10 +72,10 @@ class GraphDefinition {
 
 
      public:
-         long m_lEdgeID;
-         long m_lEdgeIndex;
-         long m_lStartNode;
-         long m_lEndNode;
+         int64_t m_lEdgeID;
+         int64_t m_lEdgeIndex;
+         int64_t m_lStartNode;
+         int64_t m_lEndNode;
          double m_dCost;
          double m_dReverseCost;
          short m_sDirection;
@@ -87,8 +89,8 @@ class GraphDefinition {
 
 
     typedef std::vector<GraphEdgeInfo> GraphEdgeVector;
-    typedef std::map<long,LongVector> Long2LongVectorMap;
-    typedef std::map<long,long> Long2LongMap;
+    typedef std::map<int64_t,LongVector> Long2LongVectorMap;
+    typedef std::map<int64_t,int64_t> Long2LongMap;
 
 
 
diff --git a/src/trsp/src/trsp.c b/src/trsp/src/trsp.c
index 2e127ed..40be22a 100644
--- a/src/trsp/src/trsp.c
+++ b/src/trsp/src/trsp.c
@@ -29,10 +29,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #endif
 
 #include "fmgr.h"
-#include "trsp.h"
+#include "trsp_driver.h"
 
-Datum turn_restrict_shortest_path_vertex(PG_FUNCTION_ARGS);
-Datum turn_restrict_shortest_path_edge(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum turn_restrict_shortest_path_vertex(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum turn_restrict_shortest_path_edge(PG_FUNCTION_ARGS);
 
 // #define DEBUG 
 #include "../../common/src/debug_macro.h"
@@ -59,7 +59,7 @@ static int compute_trsp(
     PGR_DBG("Load edges");
     pgr_edge_t *edges = NULL;
     size_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    pgr_get_edges(edges_sql, &edges, &total_tuples);
     PGR_DBG("Total %ld edges", total_tuples);
 
     PGR_DBG("Load restrictions");
@@ -80,7 +80,6 @@ static int compute_trsp(
     PGR_DBG("Total %ld restriction", total_restrict_tuples);
 
 
-
     int v_max_id=0;
     int v_min_id=INT_MAX;
 
@@ -103,7 +102,7 @@ static int compute_trsp(
 
     //defining min and max vertex id
 
-    PGR_DBG("Total %i edge tuples", total_tuples);
+    PGR_DBG("Total %ld edge tuples", total_tuples);
 
     for(z=0; z<total_tuples; z++) {
         if(edges[z].source<v_min_id)
@@ -117,11 +116,11 @@ static int compute_trsp(
 
         if(edges[z].target>v_max_id)
             v_max_id=(int)edges[z].target;      
-
         //PGR_DBG("%i <-> %i", v_min_id, v_max_id);
 
     }
 
+//<<<<<<< HEAD
     //::::::::::::::::::::::::::::::::::::  
     //:: reducing vertex id (renumbering)
     //::::::::::::::::::::::::::::::::::::
@@ -165,7 +164,6 @@ static int compute_trsp(
         end_id   -= v_min_id;
     }
 
-
     if (dovertex) {
         PGR_DBG("Calling trsp_node_wrapper\n");
         ret = trsp_node_wrapper(edges, total_tuples, 
@@ -199,7 +197,7 @@ static int compute_trsp(
 
     PGR_DBG("ret = %i\n", ret);
 
-    PGR_DBG("*path_count = %i\n", *path_count);
+    PGR_DBG("*path_count = %ld\n", *path_count);
 
     if (ret < 0)
     {
@@ -215,7 +213,7 @@ static int compute_trsp(
 
 
 PG_FUNCTION_INFO_V1(turn_restrict_shortest_path_vertex);
-    Datum
+PGDLLEXPORT Datum
 turn_restrict_shortest_path_vertex(PG_FUNCTION_ARGS)
 {
 
@@ -346,7 +344,7 @@ turn_restrict_shortest_path_vertex(PG_FUNCTION_ARGS)
 }
 
 PG_FUNCTION_INFO_V1(turn_restrict_shortest_path_edge);
-    Datum
+PGDLLEXPORT Datum
 turn_restrict_shortest_path_edge(PG_FUNCTION_ARGS)
 {
 
diff --git a/src/trsp/src/trsp_core.cpp b/src/trsp/src/trsp_driver.cpp
similarity index 98%
rename from src/trsp/src/trsp_core.cpp
rename to src/trsp/src/trsp_driver.cpp
index 5677706..b7db59b 100644
--- a/src/trsp/src/trsp_core.cpp
+++ b/src/trsp/src/trsp_driver.cpp
@@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <string.h>
 #include <sstream>
 #include "GraphDefinition.h"
+#include "trsp_driver.h"
 
 
 int trsp_node_wrapper(
diff --git a/src/trsp/src/trsp.h b/src/trsp/src/trsp_driver.h
similarity index 93%
rename from src/trsp/src/trsp.h
rename to src/trsp/src/trsp_driver.h
index 775c8e2..22f1505 100644
--- a/src/trsp/src/trsp.h
+++ b/src/trsp/src/trsp_driver.h
@@ -29,16 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 typedef pgr_edge_t edge_t;
 typedef Restrict_t restrict_t;
 
-#if 0
-typedef struct restrict_struct
-{
-		int target_id;
-		float8 to_cost;
-        int via[MAX_RULE_LENGTH];
-} 
-restrict_t;
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/tsp/CMakeLists.txt b/src/tsp/CMakeLists.txt
deleted file mode 100644
index fe4fdcf..0000000
--- a/src/tsp/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-set(PACKAGE_SQL_FILES "")
-add_subdirectory(sql)
-set(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-subdirs(doc src test)
diff --git a/src/tsp/doc/CMakeLists.txt b/src/tsp/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/tsp/doc/doc-pgr_TSP.queries b/src/tsp/doc/doc-pgr_TSP.queries
new file mode 100644
index 0000000..abd0633
--- /dev/null
+++ b/src/tsp/doc/doc-pgr_TSP.queries
@@ -0,0 +1,73 @@
+SET client_min_messages TO WARNING;
+SET
+-- q1
+WITH
+query AS (
+    SELECT * FROM pgr_TSP(
+        $$
+        SELECT * FROM pgr_dijkstraCostMatrix(
+            'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+            directed := false
+        )
+        $$
+    )
+)
+SELECT agg_cost < 20 AS under_20 FROM query WHERE seq = 14;
+ under_20 
+----------
+ t
+(1 row)
+
+-- q2
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+        directed := false
+    )
+    $$,
+    start_id := 7,
+    randomize := false
+);
+ seq | node | cost | agg_cost 
+-----+------+------+----------
+   1 |    7 |    1 |        0
+   2 |    8 |    1 |        1
+   3 |    5 |    1 |        2
+   4 |    2 |    1 |        3
+   5 |    1 |    2 |        4
+   6 |    3 |    1 |        6
+   7 |    4 |    1 |        7
+   8 |    9 |    1 |        8
+   9 |   12 |    1 |        9
+  10 |   11 |    1 |       10
+  11 |   10 |    1 |       11
+  12 |   13 |    3 |       12
+  13 |    6 |    3 |       15
+  14 |    7 |    0 |       18
+(14 rows)
+
+-- q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 5, 6, -6], directed := false);
+    $$,
+    start_id := 5,
+    randomize := false
+);
+ seq | node | cost | agg_cost 
+-----+------+------+----------
+   1 |    5 |    1 |        0
+   2 |    6 |    1 |        1
+   3 |    3 |  1.6 |        2
+   4 |   -1 |  1.3 |      3.6
+   5 |   -6 |  0.3 |      4.9
+   6 |    5 |    0 |      5.2
+(6 rows)
+
+-- q4
diff --git a/src/tsp/doc/doc-pgr_eucledianTSP.queries b/src/tsp/doc/doc-pgr_eucledianTSP.queries
new file mode 100644
index 0000000..3fa21f4
--- /dev/null
+++ b/src/tsp/doc/doc-pgr_eucledianTSP.queries
@@ -0,0 +1,94 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO WARNING;
+SET
+-- q1
+WITH
+query AS (
+    SELECT * FROM pgr_eucledianTSP(
+        $$
+        SELECT id, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+        $$
+    )
+)
+SELECT agg_cost < 20 AS under_20 FROM query WHERE seq = 18;
+ under_20 
+----------
+ t
+(1 row)
+
+-- q2
+SELECT* from pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom) AS y FROM edge_table_vertices_pgr
+    $$,
+    tries_per_temperature := 3,
+    cooling_factor := 0.5,
+    randomize := false
+);
+ seq | node |       cost       |     agg_cost     
+-----+------+------------------+------------------
+   1 |    1 |  1.4142135623731 |                0
+   2 |    3 |                1 |  1.4142135623731
+   3 |    4 |                1 | 2.41421356237309
+   4 |    9 | 0.58309518948453 | 3.41421356237309
+   5 |   16 | 0.58309518948453 | 3.99730875185762
+   6 |    6 |                1 | 4.58040394134215
+   7 |    5 |                1 | 5.58040394134215
+   8 |    8 |                1 | 6.58040394134215
+   9 |    7 | 1.58113883008419 | 7.58040394134215
+  10 |   14 |   1.499999999999 | 9.16154277142634
+  11 |   15 |              0.5 | 10.6615427714253
+  12 |   13 |              1.5 | 11.1615427714253
+  13 |   17 | 1.11803398874989 | 12.6615427714253
+  14 |   12 |                1 | 13.7795767601752
+  15 |   11 |                1 | 14.7795767601752
+  16 |   10 |                2 | 15.7795767601752
+  17 |    2 |                1 | 17.7795767601752
+  18 |    1 |                0 | 18.7795767601752
+(18 rows)
+
+-- q3
+SET client_min_messages TO NOTICE;
+SET
+SELECT* from pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom) AS y FROM edge_table_vertices_pgr
+    $$,
+    tries_per_temperature := 0,
+    randomize := false
+);
+NOTICE:  pgr_eucledianTSP Processing Information 
+Initializing tsp class ---> tsp.greedyInitial ---> tsp.annealing ---> OK
+
+Cycle(100) 	total changes =0	0 were because  delta energy < 0
+Total swaps: 3
+Total slides: 0
+Total reverses: 0
+Times best tour changed: 4
+Best cost reached = 18.7796
+ seq | node |       cost       |     agg_cost     
+-----+------+------------------+------------------
+   1 |    1 |  1.4142135623731 |                0
+   2 |    3 |                1 |  1.4142135623731
+   3 |    4 |                1 | 2.41421356237309
+   4 |    9 | 0.58309518948453 | 3.41421356237309
+   5 |   16 | 0.58309518948453 | 3.99730875185762
+   6 |    6 |                1 | 4.58040394134215
+   7 |    5 |                1 | 5.58040394134215
+   8 |    8 |                1 | 6.58040394134215
+   9 |    7 | 1.58113883008419 | 7.58040394134215
+  10 |   14 |   1.499999999999 | 9.16154277142634
+  11 |   15 |              0.5 | 10.6615427714253
+  12 |   13 |              1.5 | 11.1615427714253
+  13 |   17 | 1.11803398874989 | 12.6615427714253
+  14 |   12 |                1 | 13.7795767601752
+  15 |   11 |                1 | 14.7795767601752
+  16 |   10 |                2 | 15.7795767601752
+  17 |    2 |                1 | 17.7795767601752
+  18 |    1 |                0 | 18.7795767601752
+(18 rows)
+
+-- q4
+ROLLBACK;
+ROLLBACK
diff --git a/src/tsp/doc/doc-tsp.queries b/src/tsp/doc/doc-tsp.queries
new file mode 100644
index 0000000..84d11b5
--- /dev/null
+++ b/src/tsp/doc/doc-tsp.queries
@@ -0,0 +1,118 @@
+BEGIN;
+BEGIN
+SET client_min_messages TO WARNING;
+SET
+-- q1
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT id::INTEGER, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$
+    , 1);
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+ seq | id1 | id2 |       cost        
+-----+-----+-----+-------------------
+   0 |   1 |   1 |                 1
+   1 |   2 |   2 |                 1
+   2 |   5 |   5 |                 1
+   3 |   8 |   8 |                 1
+   4 |   7 |   7 |  1.58113883008419
+   5 |  14 |  14 |  1.58113883008419
+   6 |  13 |  13 |               0.5
+   7 |  15 |  15 |               0.5
+   8 |  10 |  10 |                 1
+   9 |  11 |  11 |  1.11803398874989
+  10 |  17 |  17 |  1.11803398874989
+  11 |  12 |  12 | 0.860232526704263
+  12 |  16 |  16 |  0.58309518948453
+  13 |   6 |   6 |                 1
+  14 |   9 |   9 |                 1
+  15 |   4 |   4 |                 1
+  16 |   3 |   3 |   1.4142135623731
+(17 rows)
+
+-- q2
+SELECT * FROM pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$,
+    1,
+    randomize := false
+);
+ seq | node |       cost        |     agg_cost     
+-----+------+-------------------+------------------
+   1 |    1 |   1.4142135623731 |                0
+   2 |    3 |                 1 |  1.4142135623731
+   3 |    4 |                 1 | 2.41421356237309
+   4 |    9 |                 1 | 3.41421356237309
+   5 |    6 |  0.58309518948453 | 4.41421356237309
+   6 |   16 | 0.860232526704263 | 4.99730875185763
+   7 |   12 |  1.11803398874989 | 5.85754127856189
+   8 |   17 |  1.11803398874989 | 6.97557526731178
+   9 |   11 |                 1 | 8.09360925606168
+  10 |   10 |               0.5 | 9.09360925606168
+  11 |   15 |               0.5 | 9.59360925606168
+  12 |   13 |  1.58113883008419 | 10.0936092560617
+  13 |   14 |  1.58113883008419 | 11.6747480861459
+  14 |    7 |                 1 | 13.2558869162301
+  15 |    8 |                 1 | 14.2558869162301
+  16 |    5 |                 1 | 15.2558869162301
+  17 |    2 |                 1 | 16.2558869162301
+  18 |    1 |                 0 | 17.2558869162301
+(18 rows)
+
+-- q3
+SELECT * FROM pgr_TSP(
+    (SELECT * FROM pgr_vidsToDMatrix(
+            'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14)::INTEGER[], false , true, true)
+    ),
+    1
+);
+ seq | id 
+-----+----
+   0 |  1
+   1 |  2
+   2 |  3
+   3 |  8
+   4 | 11
+   5 |  5
+   6 | 10
+   7 | 12
+   8 |  9
+   9 |  6
+  10 |  7
+  11 |  4
+  12 |  0
+(13 rows)
+
+-- q4
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14), false)
+    $$,
+    1,
+    randomize := false
+);
+ seq | node | cost | agg_cost 
+-----+------+------+----------
+   1 |    1 |    3 |        0
+   2 |    4 |    1 |        3
+   3 |    9 |    1 |        4
+   4 |   12 |    1 |        5
+   5 |   11 |    2 |        6
+   6 |   13 |    1 |        8
+   7 |   10 |    1 |        9
+   8 |    5 |    2 |       10
+   9 |    7 |    1 |       12
+  10 |    8 |    2 |       13
+  11 |    6 |    1 |       15
+  12 |    3 |    1 |       16
+  13 |    2 |    1 |       17
+  14 |    1 |    0 |       18
+(14 rows)
+
+-- q5
+ROLLBACK;
+ROLLBACK
diff --git a/src/tsp/doc/pgr_eucledianTSP.rst b/src/tsp/doc/pgr_eucledianTSP.rst
new file mode 100644
index 0000000..1cabd1d
--- /dev/null
+++ b/src/tsp/doc/pgr_eucledianTSP.rst
@@ -0,0 +1,148 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _pgr_eucledianTSP:
+
+pgr_eucledianTSP
+=============================================================================
+
+Name
+-------------------------------------------------------------------------------
+
+* ``pgr_eucledianTSP`` - Returns a route that visits all the coordinates pairs exactly once.
+
+
+Synopsis
+-------------------------------------------------------------------------------
+
+The travelling salesman problem (TSP) or travelling salesperson problem asks the following question:
+
+  - Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?
+   
+This implementation uses simulated annealing to return the approximate solution when the input is given in the form of coordinates.
+
+Signature Summary
+-------------------------------------------------------------------------------
+
+.. code-block:: none
+
+    pgr_eucledianTSP(coordinates_sql)
+    pgr_eucledianTSP(coordinates_sql,
+        start_id, end_id,
+        max_processing_time,
+        tries_per_temperature, max_changes_per_temperature, max_consecutive_non_changes,
+        initial_temperature, final_temperature, cooling_factor,
+        randomize,
+    RETURNS SETOF (seq, node, cost, agg_cost)
+
+
+Signatures
+-------------------------------------------------------------------------------
+
+.. index::
+    single: eucledianTSP(Basic Use)
+
+Minimal Signature
+...............................................................................
+
+.. code-block:: none
+
+    pgr_eucledianTSP(coordinates_sql)
+    RETURNS SETOF (seq, node, cost, agg_cost)
+
+:Example: 
+
+Because the documentation examples are auto generated and tested for non changing results,
+and the default is to have random execution, the example is wrapping the actual call.
+
+.. literalinclude:: doc-pgr_eucledianTSP.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+
+.. index::
+    single: eucledianTSP(Complete Signature)
+
+Complete Signature
+...............................................................................
+
+.. code-block:: none
+
+
+    pgr_eucledianTSP(coordinates_sql,
+        start_id, end_id,
+        max_processing_time,
+        tries_per_temperature, max_changes_per_temperature, max_consecutive_non_changes,
+        initial_temperature, final_temperature, cooling_factor,
+        randomize,
+    RETURNS SETOF (seq, node, cost, agg_cost)
+
+
+.. rubric:: Example:
+
+.. literalinclude:: doc-pgr_eucledianTSP.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+Description of the Signatures
+-------------------------------------------------------------------------------
+
+Description of the coordinates SQL query
+...............................................................................
+
+======= =========== =================================================
+Column  Type              Description
+======= =========== =================================================
+**id**  ``BIGINT``  Identifier of the coordinate. (optional)
+**x**   ``FLOAT``   X value of the coordinate.
+**y**   ``FLOAT``   Y value of the coordinate.
+======= =========== =================================================
+
+
+When the value of **id** is not given then the coordinates will receive an **id** starting from 1, in the order given.
+
+..
+    description of the configuration parameters
+
+.. include:: tsp_parameters.txt
+
+
+..
+    description of the return values
+
+.. include:: tsp_return_values.txt
+
+
+
+Examples
+-------------------------------------------------------------------------------
+
+:Example: Skipping the Simulated Annealing & showing some process information
+
+.. literalinclude:: doc-pgr_eucledianTSP.queries
+   :start-after: -- q3
+   :end-before: -- q4
+
+
+
+The queries use the :ref:`sampledata` network.
+
+
+.. rubric:: History
+
+* New in version 2.3.0
+
+
+
+See Also
+-------------------------------------------------------------------------------
+
+* :ref:`tsp`
+* http://en.wikipedia.org/wiki/Traveling_salesman_problem
+* http://en.wikipedia.org/wiki/Simulated_annealing
diff --git a/src/tsp/doc/pgr_tsp.rst b/src/tsp/doc/pgr_tsp-V2.0.rst
similarity index 92%
copy from src/tsp/doc/pgr_tsp.rst
copy to src/tsp/doc/pgr_tsp-V2.0.rst
index 6c9008a..d27df47 100644
--- a/src/tsp/doc/pgr_tsp.rst
+++ b/src/tsp/doc/pgr_tsp-V2.0.rst
@@ -7,30 +7,37 @@
     Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
    ****************************************************************************
 
-.. _pgr_tsp:
+.. _pgr_tsp-V2.0:
 
-pgr_tsp - Traveling Sales Person
+pgr_tsp -Deprecated Signatures
 ===============================================================================
 
-.. index:: 
-	single: pgr_tsp(sql text, start_id integer)
-    single: pgr_tsp(sql text, start_id integer, end_id integer)
-    single: pgr_tsp(matrix float[][], start integer)
-    single: pgr_tsp(matrix float[][], start integer, end integer)
-    single: _pgr_makeDistanceMatrix(sqlin text)
+.. warning:: These functions signatures are deprecated!!!
+
+    * That means they has been replaced by new signatures.
+    * These signatures are no longer supported, and may be removed from future versions.
+    * All code that use these functions signatures should be converted to use its replacement.
 
 Name
 -------------------------------------------------------------------------------
 
 * ``pgr_tsp`` - Returns the best route from a start node via a list of nodes.
+
+.. warning:: Use :ref:`pgr_eucledianTSP` instead.  
+
 * ``pgr_tsp`` - Returns the best route order when passed a disance matrix.
+
+.. warning:: Use :ref:`pgr_TSP` instead.  
+
 * ``_pgr_makeDistanceMatrix`` - Returns a Eucleadian distance Matrix from the points provided in the sql result.
 
+.. warning:: There is no replacement.
+
 
 Synopsis
 -------------------------------------------------------------------------------
 
-The travelling salesman problem (TSP) or travelling salesperson problem asks the following question: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? This algoritm uses simulated annealing to return a high quality approximate solution. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
+The travelling salesman problem (TSP) or travelling salesperson problem asks the following question: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? This algorithm uses simulated annealing to return a high quality approximate solution. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
 
 .. code-block:: sql
 
@@ -241,6 +248,8 @@ The queries use the :ref:`sampledata` network.
 See Also
 -------------------------------------------------------------------------------
 
+* :ref:`tsp`, :ref:`pgr_TSP`, :ref:`pgr_eucledianTSP`
+
 * :ref:`type_cost_result`
 * http://en.wikipedia.org/wiki/Traveling_salesman_problem
 * http://en.wikipedia.org/wiki/Simulated_annealing
diff --git a/src/tsp/doc/pgr_tsp.rst b/src/tsp/doc/pgr_tsp.rst
index 6c9008a..60a139c 100644
--- a/src/tsp/doc/pgr_tsp.rst
+++ b/src/tsp/doc/pgr_tsp.rst
@@ -7,240 +7,166 @@
     Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
    ****************************************************************************
 
-.. _pgr_tsp:
+.. _pgr_TSP:
 
-pgr_tsp - Traveling Sales Person
-===============================================================================
-
-.. index:: 
-	single: pgr_tsp(sql text, start_id integer)
-    single: pgr_tsp(sql text, start_id integer, end_id integer)
-    single: pgr_tsp(matrix float[][], start integer)
-    single: pgr_tsp(matrix float[][], start integer, end integer)
-    single: _pgr_makeDistanceMatrix(sqlin text)
+pgr_TSP
+=============================================================================
 
 Name
 -------------------------------------------------------------------------------
 
-* ``pgr_tsp`` - Returns the best route from a start node via a list of nodes.
-* ``pgr_tsp`` - Returns the best route order when passed a disance matrix.
-* ``_pgr_makeDistanceMatrix`` - Returns a Eucleadian distance Matrix from the points provided in the sql result.
+* ``pgr_TSP`` - Returns a route that visits all the nodes exactly once.
 
 
 Synopsis
 -------------------------------------------------------------------------------
 
-The travelling salesman problem (TSP) or travelling salesperson problem asks the following question: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? This algoritm uses simulated annealing to return a high quality approximate solution. Returns a set of :ref:`pgr_costResult <type_cost_result>` (seq, id1, id2, cost) rows, that make up a path.
-
-.. code-block:: sql
-
-	pgr_costResult[] pgr_tsp(sql text, start_id integer);
-	pgr_costResult[] pgr_tsp(sql text, start_id integer, end_id integer);
-
-
-Returns a set of (seq integer, id1 integer, id2 integer, cost float8) that is the best order to visit the nodes in the matrix. ``id1`` is the index into the distance matrix. ``id2`` is the point id from the sql.
-
-If no ``end_id`` is supplied or it is -1 or equal to the start_id then the TSP result is assumed to be a circluar loop returning back to the start. If ``end_id`` is supplied then the route is assumed to start and end the the designated ids. 
-
-.. code-block:: sql
+The travelling salesman problem (TSP) or travelling salesperson problem asks the following question:
 
-    record[] pgr_tsp(matrix float[][], start integer)
-    record[] pgr_tsp(matrix float[][], start integer, end integer)
+  - Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?
+   
+This implementation uses simulated annealing to return the approximate solution when the input is given in the form of matrix cell contents.
+The matrix informetion must be symmetrical.
 
 
-Description
+Signature Summary
 -------------------------------------------------------------------------------
 
-.. rubric:: With Euclidean distances
-
-The TSP solver is based on ordering the points using straight line (euclidean) distance [#f0]_ between nodes. The implementation is using an approximation algorithm that is very fast. It is not an exact solution, but it is guaranteed that a solution is returned after certain number of iterations.
-
-:sql: a SQL query, which should return a set of rows with the following columns:
-
-	.. code-block:: sql
-
-		SELECT id, x, y FROM vertex_table
-
-	:id: ``int4`` identifier of the vertex
-	:x: ``float8`` x-coordinate
-	:y: ``float8`` y-coordinate
-
-:start_id: ``int4`` id of the start point
-:end_id: ``int4`` id of the end point, This is *OPTIONAL*, if include the route is optimized from start to end, otherwise it is assumed that the start and the end are the same point.
-
+.. code-block:: none
 
-The function returns set of :ref:`type_cost_result`:
+    pgr_TSP(matrix_cell_sql)
+    pgr_TSP(matrix_cell_sql,
+        start_id, end_id,
+        max_processing_time,
+        tries_per_temperature, max_changes_per_temperature, max_consecutive_non_changes,
+        initial_temperature, final_temperature, cooling_factor,
+        randomize,
+    RETURNS SETOF (seq, node, cost, agg_cost)
 
-:seq:   row sequence
-:id1:   internal index to the distance matric
-:id2:   ``id`` of the node
-:cost:  cost to traverse from the current node to the next node.
+Signatures
+-------------------------------------------------------------------------------
 
-.. rubric:: Create a distance matrix
+.. NOTE:: The following only aplies to the new signature(s)
 
-For users that need a distance matrix we have a simple function that takes SQL in ``sql`` as described above and returns a record with ``dmatrix`` and ``ids``.
 
-    .. code-block:: sql
-    
-        SELECT dmatrix, ids from _pgr_makeDistanceMatrix('SELECT id, x, y FROM vertex_table');
+.. index::
+    single: TSP(Basic Use) -- New Signature
 
-The function returns a record of ``dmatrix``, ``ids``:
+Basic Use
+...............................................................................
 
-:dmatrix: ``float8[][]`` a symeteric Euclidean distance matrix based on ``sql``.
-:ids: ``integer[]`` an array of ids as they are ordered in the distance matrix.
+.. code-block:: none
 
+    pgr_TSP(matrix_cell_sql)
+    RETURNS SETOF (seq, node, cost, agg_cost)
 
-.. rubric:: With distance matrix
+:Example: 
 
-For users, that do not want to use Euclidean distances, we also provode the ability to pass a distance matrix that we will solve and return an ordered list of nodes for the best order to visit each. It is up to the user to fully populate the distance matrix. 
+Because the documentation examples are auto generated and tested for non changing results,
+and the default is to have random execution, the example is wrapping the actual call.
 
-:matrix: ``float[][]`` distance matrix of points
-:start: ``int4`` index of the start point
-:end: ``int4`` (optional) index of the end node
+.. literalinclude:: doc-pgr_TSP.queries
+   :start-after: -- q1
+   :end-before: -- q2
 
-The ``end`` node is an optional parameter, you can just leave it out if you want a loop where the ``start`` is the depot and the route returns back to the depot. If you include the ``end`` parameter, we optimize the path from ``start`` to ``end`` and minimize the distance of the route while include the remaining points.
+..
+    TODO Intermediate Use
 
-The distance matrix is a multidimensional `PostgreSQL array type <http://www.postgresql.org/docs/9.1/static/arrays.html>`_ that must be ``N x N`` in size. 
+.. index::
+    single: TSP(Complete Signature) -- New Signature
 
-The result will be N records of ``[ seq, id ]``:
+Complete Signature
+...............................................................................
 
-:seq: row sequence
-:id: index into the matrix
+.. code-block:: none
 
 
-.. rubric:: Footnotes
+    pgr_TSP(matrix_cell_sql,
+        start_id, end_id,
+        max_processing_time,
+        tries_per_temperature, max_changes_per_temperature, max_consecutive_non_changes,
+        initial_temperature, final_temperature, cooling_factor,
+        randomize,
+    RETURNS SETOF (seq, node, cost, agg_cost)
 
-.. [#f0] There was some thought given to pre-calculating the driving distances between the nodes using Dijkstra, but then I read a paper (unfortunately I don't remember who wrote it), where it was proved that the quality of TSP with euclidean distance is only slightly worse than one with real distance in case of normal city layout. In case of very sparse network or rivers and bridges it becomes more inaccurate, but still wholly satisfactory. Of course it is nice to have exact solution, b [...]
 
+.. rubric:: Example:
 
-.. rubric:: History
+.. literalinclude:: doc-pgr_TSP.queries
+   :start-after: -- q2
+   :end-before: -- q3
 
-* Renamed in version 2.0.0
-* GAUL dependency removed in version 2.0.0
 
-
-Examples
+Description of the Signatures
 -------------------------------------------------------------------------------
 
-* Using SQL parameter (all points from the table, atarting from 6 and ending at 5). We have listed two queries in this example, the first might vary from system to system because there are multiple equivalent answers. The second query should be stable in that the length optimal route should be the same regardless of order.
-
-
+Description of the Matrix Cell SQL query
+...............................................................................
 
-.. code-block:: sql
+============= =========== =================================================
+Column        Type              Description
+============= =========== =================================================
+**start_vid** ``BIGINT``  Identifier of the starting vertex.
+**end_vid**   ``BIGINT``  Identifier of the ending vertex.
+**agg_cost**  ``FLOAT``   Cost for going from start_vid to end_vid
+============= =========== =================================================
 
-    CREATE TABLE vertex_table (
-        id serial,
-        x double precision,
-        y double precision
-    );
+Can be Used with:
 
-    INSERT INTO vertex_table VALUES
-    (1,2,0), (2,2,1), (3,3,1), (4,4,1), (5,0,2), (6,1,2), (7,2,2),
-    (8,3,2), (9,4,2), (10,2,3), (11,3,3), (12,4,3), (13,2,4);
+* :ref:`pgr_dijkstraCostmatrix`
+* :ref:`pgr_withPointsCostmatrix`
+* :ref:`pgr_floydWarshall`
+* :ref:`pgr_johnson`
 
-    SELECT seq, id1, id2, round(cost::numeric, 2) AS cost
-      FROM pgr_tsp('SELECT id, x, y FROM vertex_table ORDER BY id', 6, 5);
+To generate a symmetric matrix
 
-     seq | id1 | id2 | cost
-    -----+-----+-----+------
-       0 |   5 |   6 | 1.00
-       1 |   6 |   7 | 1.00
-       2 |   7 |   8 | 1.41
-       3 |   1 |   2 | 1.00
-       4 |   0 |   1 | 1.41
-       5 |   2 |   3 | 1.00
-       6 |   3 |   4 | 1.00
-       7 |   8 |   9 | 1.00
-       8 |  11 |  12 | 1.00
-       9 |  10 |  11 | 1.41
-      10 |  12 |  13 | 1.00
-      11 |   9 |  10 | 2.24
-      12 |   4 |   5 | 1.00
-    (13 rows)
+* directed := false.
 
-    SELECT round(sum(cost)::numeric, 4) as cost
-   FROM pgr_tsp('SELECT id, x, y FROM vertex_table ORDER BY id', 6, 5);
+If using directed := true, the resulting non symmetric matrix must be converted to
+symmetric by fixing the non symmetric values according to your application needs.
 
-      cost
-    ---------
-     15.4787
-    (1 row)
+..
+    description of the configuration parameters
 
+.. include:: tsp_parameters.txt
 
 
-* Using distance matrix (A loop starting from 1)
+..
+    description of the return values
 
-When using just the start node you are getting a loop that starts with 1, in this case, and travels through the other nodes and is implied to return to the start node from the last one in the list. Since this is a circle there are at least two possible paths, one clockwise and one counter-clockwise that will have the same length and be equall valid. So in the following example it is also possible to get back a sequence of ids = {1,0,3,2} instead of the {1,2,3,0} sequence listed below.
+.. include:: tsp_return_values.txt
 
-.. code-block:: sql
 
-	SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1);
 
-	 seq | id 
-	-----+----
-	   0 |  1
-	   1 |  2
-	   2 |  3
-	   3 |  0
-	(4 rows)
+Examples
+-------------------------------------------------------------------------------
 
-* Using distance matrix (Starting from 1, ending at 2)
+:Example: Using with points of interest.
 
-.. code-block:: sql
+To generate a symmetric matrix:
 
-	SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1,2);
+* the **side** information of pointsOfInterset is ignored by not including it in the query
+* and **directed := false**
 
-	 seq | id 
-	-----+----
-	   0 |  1
-	   1 |  0
-	   2 |  3
-	   3 |  2
-	(4 rows)
+.. literalinclude:: doc-pgr_TSP.queries
+   :start-after: -- q3
+   :end-before: -- q4
 
-* Using the vertices table edge_table_vertices_pgr generated by :ref:`pgr_create_topology`. Again we have two queries where the first might vary and the second is based on the overal path length.
+The queries use the :ref:`sampledata` network.
 
-.. code-block:: sql
 
-	SELECT seq, id1, id2, round(cost::numeric, 2) AS cost
-   FROM pgr_tsp('SELECT id::integer, st_x(the_geom) as x,st_x(the_geom) as y FROM edge_table_vertices_pgr  ORDER BY id', 6, 5);
 
-     seq | id1 | id2 | cost
-    -----+-----+-----+------
-       0 |   5 |   6 | 0.00
-       1 |  10 |  11 | 0.00
-       2 |   2 |   3 | 1.41
-       3 |   3 |   4 | 0.00
-       4 |  11 |  12 | 0.00
-       5 |   8 |   9 | 0.71
-       6 |  15 |  16 | 0.00
-       7 |  16 |  17 | 2.12
-       8 |   1 |   2 | 0.00
-       9 |  14 |  15 | 1.41
-      10 |   7 |   8 | 1.41
-      11 |   6 |   7 | 0.71
-      12 |  13 |  14 | 2.12
-      13 |   0 |   1 | 0.00
-      14 |   9 |  10 | 0.00
-      15 |  12 |  13 | 0.00
-      16 |   4 |   5 | 1.41
-    (17 rows)
-
-    SELECT round(sum(cost)::numeric, 4) as cost
-       FROM pgr_tsp('SELECT id::integer, st_x(the_geom) as x,st_x(the_geom) as y FROM edge_table_vertices_pgr  ORDER BY id', 6, 5);
-
-      cost
-    ---------
-     11.3137
-    (1 row)
+.. rubric:: History
 
+* Rewritten in version 2.3.0
+* Renamed in version 2.0.0
+* GAUL dependency removed in version 2.0.0
 
-The queries use the :ref:`sampledata` network.
 
 
 See Also
 -------------------------------------------------------------------------------
 
-* :ref:`type_cost_result`
+* :ref:`tsp`
 * http://en.wikipedia.org/wiki/Traveling_salesman_problem
 * http://en.wikipedia.org/wiki/Simulated_annealing
diff --git a/src/tsp/doc/tsp.rst b/src/tsp/doc/tsp.rst
new file mode 100644
index 0000000..f10faf5
--- /dev/null
+++ b/src/tsp/doc/tsp.rst
@@ -0,0 +1,277 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _tsp:
+
+Traveling Sales Person
+===============================================================================
+
+- :ref:`pgr_TSP` - When input is given as matrix cell information.
+- :ref:`pgr_eucledianTSP` - When input are coordinates.
+
+.. toctree::
+    :hidden:
+
+    ./pgr_tsp
+    ./pgr_eucledianTSP
+
+.. NOTE:: These signatures are being deprecated
+
+    .. code-block:: sql
+
+       -- (1)
+       pgr_costResult[] pgr_tsp(sql text, start_id integer) 
+       pgr_costResult[] pgr_tsp(sql text, start_id integer, end_id integer)
+
+       -- (2)
+       record[] pgr_tsp(matrix float[][], start integer)
+       record[] pgr_tsp(matrix float[][], start integer, end integer)
+
+    - See http://docs.pgrouting.org/2.2/en/src/common/doc/types/cost_result.html 
+    - See http://docs.pgrouting.org/2.2/en/src/tsp/doc/pgr_tsp.html
+    - For more details, see tsp_deprecated_.
+
+    Use :ref:`pgr_eucledianTSP` insteadi of (1).
+    Use :ref:`pgr_TSP` instead of (2).
+
+General Information 
+------------------------------------
+
+Origin 
+..........
+
+The traveling sales person problem was studied in the 18th century by mathematicians
+ **Sir William Rowam Hamilton** and **Thomas Penyngton  Kirkman**.
+
+A discussion about the work of Hamilton & Kirkman
+can be found in the book **Graph Theory (Biggs et  al. 1976)**.
+
+* ISBN-13: 978-0198539162
+* ISBN-10: 0198539169 
+
+It is believed that the general form of the TSP have been first studied by Kalr Menger in Vienna and Harvard.
+The problem  was  later promoted by Hassler, Whitney  &  Merrill at Princeton.
+A detailed  description about the connection between Menger & Whitney, and the development of the  
+TSP can be found in  `On the history of combinatorial optimization (till 1960) <http://www.cwi.nl/~lex/files/histco.ps>`_
+
+Problem Definition 
+...................
+
+Given a collection of cities and travel cost between each pair,
+find the cheapest way for visiting all of the cities and returning to the starting point.
+
+Characteristics 
+................
+
+- The travel costs are symmetric:
+
+  - traveling costs from city A to city B are just as much as traveling from B to A.
+
+- This problem is an NP-hard optimization problem.
+
+- To calculate the number of different tours through :math:`n` cities:
+
+  - Given a starting city,
+  - There are :math:`n-1` choices for the second city,
+  - And  :math:`n-2` choices for the third city, etc.
+  - Multiplying these together we get :math:`(n-1)!  = (n-1) (n-2) . .  1`.
+  - Now since our travel costs do not depend on the direction we take around the tour:
+
+    - this number by 2
+    -  :math:`(n-1)!/2`.
+
+TSP & Simulated Annealing
+.........................
+
+The simulated annealing algorithm was originally inspired from the process of
+annealing in metal work.
+
+    Annealing involves heating and cooling a material to
+    alter its physical properties due to the changes in its internal structure.
+    As the metal cools its new structure becomes fixed,
+    consequently causing the metal to retain its newly obtained properties.
+
+
+.. rubric:: Pseudocode
+
+Given an initial solution, the simulated annealing process, will start with a high temperature
+and gradually cool down until the desired temperature is reached.
+
+For each temperature, a neighbouring new solution **snew** is calculated. The higher the temperature
+the higher the probability of accepting the new solution as a possible bester solution.
+
+Once the desired temperature is reached, the best solution found is returned
+
+.. code-block:: none
+
+    Solution ← initial_solution;
+
+    temperature ← initial_temperature;
+    while (temperature > final_temperature) {
+
+        do tries_per_temperature times {
+            snew ← neighbour(solution);
+            If P(E(solution), E(snew), T) ≥ random(0, 1)
+                solution ← snew;
+        }
+
+        temperature ← temperature * cooling factor;
+    }
+
+    Output: the best solution
+
+
+
+pgRouting Implementation
+.........................
+
+pgRouting's implementation adds some extra parameters to allow some exit controls within the
+simulated annealing process.
+
+To cool down faster to the next temperature:
+
+    - max_changes_per_temperature: limits the number of changes in the solution per temperature 
+    - max_consecutive_non_changes: limits the number of consecutive non changes per temperature
+
+This is done by doing some book keeping on the times **solution ← snew;** is executed.
+
+    - max_changes_per_temperature: Increases by one when **solution** changes
+    - max_consecutive_non_changes: Reset to 0 when **solution** changes, and increased each **try**
+
+Additionally to stop the algorithm at a higher temperature than the desired one:
+
+    - max_processing_time: limits the time the simulated annealing is performed.
+    - book keeping is done to see if there was a change in **solution** on the last temperature
+
+Note that, if no change was found in the first **max_consecutive_non_changes** tries, then the
+simulated annealing will stop.
+
+.. code-block:: none
+
+    Solution ← initial_solution;
+
+    temperature ← initial_temperature;
+    while (temperature > final_temperature) {
+
+        do tries_per_temperature times {
+            snew ← neighbour(solution);
+            If P(E(solution), E(snew), T) ≥ random(0, 1)
+                solution ← snew;
+
+            when max_changes_per_temperature is reached
+                or max_consecutive_non_changes is reached
+                BREAK;
+        }
+
+        temperature ← temperature * cooling factor;
+        when no changes were done in the current temperature
+            or max_processing_time has being reached
+            BREAK;
+    }
+
+    Output: the best solution
+
+
+Choosing parameters
+.........................
+
+There is no exact rule on how the parameters have to be chose, it will depend on the
+special characteristics of the problem.
+
+- Your computational time is crucial, then put your time limit to **max_processing_time**.
+- Make the **tries_per_temperture** depending on the number of cities, for example:
+
+  - Useful to estimate the time it takes to do one cycle: use `1`
+
+    - this will help to set a reasonable **max_processing_time**
+
+  - :math:`n * (n-1)`
+  - :math:`500 * n`
+
+- For a faster decreasing the temperature set **cooling_factor** to a smaller number,
+  and set to a higher number for a slower decrease.
+
+- When for the same given data the same results are needed, set **randomize** to `false`.
+
+  - When estimating how long it takes to do one cycle: use `false`
+
+
+A recommendation is to play with the values and see what fits to the particular data.
+
+
+..
+    description of control parameters
+
+
+.. include:: tsp_parameters.txt 
+
+
+.. _tsp_deprecated:
+
+Deprecated functionality
+.........................
+
+The old functionality is deprecated:
+
+* User can not control the execution.
+* Not all valuable information is returned.
+* Some returned column don not have meaningful names.
+
+
+:Example:
+
+Using the old functionality, for example
+
+* `id` can not be of type `BIGINT`.
+* `id1` and `id2` are meningless column names.
+* Needs an index as parameter for the starting node.
+
+.. literalinclude:: doc-tsp.queries
+   :start-after: -- q1
+   :end-before: -- q2
+
+With the new functionality:
+
+* `id` can be of type `BIGINT` .
+* There is an aggregate cost column.
+* Instead of an index it uses the node identifier for the starting node.
+
+.. literalinclude:: doc-tsp.queries
+   :start-after: -- q2
+   :end-before: -- q3
+
+:Example:
+
+Using the old functionality, for example
+
+* `id`, `source`, `target` can not be of type `BIGINT`.
+* It does not return the `cost` column.
+* Needs an index as parameter for the starting node.
+* The identifiers in the result does not correspond to the indentifiers given as input.
+
+.. literalinclude:: doc-tsp.queries
+   :start-after: -- q3
+   :end-before: -- q4
+
+With the new functionality:
+
+* `id`, `source`, `target` can be of type `BIGINT`, 
+* There is an aggregate cost column and a cost column in the results.
+* Instead of an index it uses the node identifier for the starting node.
+
+.. literalinclude:: doc-tsp.queries
+   :start-after: -- q4
+   :end-before: -- q5
+
+
+See Also
+.........................
+
+  * http://en.wikipedia.org/wiki/Traveling_salesman_problem
+  * http://en.wikipedia.org/wiki/Simulated_annealing
diff --git a/src/tsp/doc/tsp_parameters.txt b/src/tsp/doc/tsp_parameters.txt
new file mode 100644
index 0000000..9b5ebb1
--- /dev/null
+++ b/src/tsp/doc/tsp_parameters.txt
@@ -0,0 +1,34 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+
+Description Of the Control parameters
+.....................................
+
+The control parameters are optional, and have a default value.
+
+=============================== ===========  ============  =================================================
+Parameter                       Type         Default       Description
+=============================== ===========  ============  =================================================
+**start_vid**                   ``BIGINT``    `0`          The greedy part of the implementation will use this identifier.
+**end_vid**                     ``BIGINT``    `0`          Last visiting vertex before returning to start_vid.
+**max_processing_time**         ``FLOAT``    `+infinity`   Stop the annealing processing when the value is reached.
+**tries_per_temperature**       ``INTEGER``  `500`         Maximum number of times a neighbor(s) is searched in each temperature.
+**max_changes_per_temperature** ``INTEGER``  `60`          Maximum number of times the solution is changed in each temperature.
+**max_consecutive_non_changes** ``INTEGER``  `100`         Maximum number of consecutive times the solution is not changed in each temperature.
+**initial_temperature**         ``FLOAT``    `100`         Starting temperature.
+**final_temperature**           ``FLOAT``    `0.1`         Ending temperature.
+**cooling_factor**              ``FLOAT``    `0.9`         Value between between 0 and 1 (not including) used to calculate the next temperature.
+**randomize**                   ``BOOLEAN``  `true`        Choose the random seed
+
+                                                             - true: Use current time as seed
+                                                             - false: Use `1` as seed. Using this value will get the same results with the same data in each execution.
+
+=============================== ===========  ============  =================================================
+
diff --git a/src/tsp/doc/tsp_return_values.txt b/src/tsp/doc/tsp_return_values.txt
new file mode 100644
index 0000000..c66108b
--- /dev/null
+++ b/src/tsp/doc/tsp_return_values.txt
@@ -0,0 +1,27 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+Description of the return values
+.................................
+
+Returns set of ``(seq, node, cost, agg_cost)``
+
+============= =========== =================================================
+Column           Type              Description
+============= =========== =================================================
+**seq**       ``INTEGER`` Row sequence.
+**node**      ``BIGINT``  Identifier of the node/coordinate/point.
+**cost**      ``FLOAT``   Cost to traverse from the current ``node`` ito the next ``node`` in the path sequence.
+                            - ``0`` for the last row in the path sequence.
+
+**agg_cost**  ``FLOAT``   Aggregate cost from the ``node`` at ``seq = 1`` to the current node.
+                            - ``0`` for the first row in the path sequence.
+
+============= =========== =================================================
+
diff --git a/src/tsp/sql/CMakeLists.txt b/src/tsp/sql/CMakeLists.txt
index 6264c92..7f647e9 100644
--- a/src/tsp/sql/CMakeLists.txt
+++ b/src/tsp/sql/CMakeLists.txt
@@ -1,7 +1,18 @@
 # Append in local scope
 LIST(APPEND PACKAGE_SQL_FILES
+    #This are the old signature
     ${CMAKE_CURRENT_SOURCE_DIR}/routing_tsp.sql
     ${CMAKE_CURRENT_SOURCE_DIR}/routing_tsp_wrappers.sql
+
+    #this one implements the new tsp
+    ${CMAKE_CURRENT_SOURCE_DIR}/TSP.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/eucledianTSP.sql
+
+    #this file wrap pgr_tsp with pgr_eucledianTSP
+    ${CMAKE_CURRENT_SOURCE_DIR}/tsp_v2.0_coordinates.sql
+
+    
+    #${CMAKE_CURRENT_SOURCE_DIR}/_makeMatrix.sql
 )
 
 # set in parent scope
diff --git a/src/tsp/sql/TSP.sql b/src/tsp/sql/TSP.sql
new file mode 100644
index 0000000..610d62c
--- /dev/null
+++ b/src/tsp/sql/TSP.sql
@@ -0,0 +1,26 @@
+
+CREATE OR REPLACE FUNCTION pgr_TSP(
+    matrix_row_sql TEXT,
+    start_id BIGINT DEFAULT 0,
+    end_id BIGINT DEFAULT 0,
+
+    max_processing_time FLOAT DEFAULT '+infinity'::FLOAT,
+
+    tries_per_temperature INTEGER DEFAULT 500,
+    max_changes_per_temperature INTEGER DEFAULT 60,
+    max_consecutive_non_changes INTEGER DEFAULT 100,
+
+    initial_temperature FLOAT DEFAULT 100,
+    final_temperature FLOAT DEFAULT 0.1,
+    cooling_factor FLOAT DEFAULT 0.9,
+
+    randomize BOOLEAN DEFAULT true,
+
+    OUT seq INTEGER,
+    OUT node BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+RETURNS SETOF record
+AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'newTSP'
+LANGUAGE c VOLATILE STRICT;
+
diff --git a/src/tsp/sql/_makeMatrix.sql b/src/tsp/sql/_makeMatrix.sql
new file mode 100644
index 0000000..7d50069
--- /dev/null
+++ b/src/tsp/sql/_makeMatrix.sql
@@ -0,0 +1,69 @@
+/*
+UNUSED CODE
+*/
+-- vertices_sql has the form
+-- SELECT id, the_geom FROM .....
+
+CREATE OR REPLACE FUNCTION _pgr_makeMatrix(
+    matrix_sql regclass,
+    OUT dmatrix double precision[],
+    OUT ids BIGINT[]
+)
+AS
+$BODY$
+DECLARE
+    sql text;
+    count_sql text;
+    ids_sql text;
+    rec record;
+    dummy_row double precision[];
+    n INTEGER; -- size of matrix
+    has_the_geom BOOLEAN DEFAULT false;
+    
+BEGIN
+    dmatrix := array[]::double precision[];
+    ids := array[]::integer[];
+    sql = format('SELECT start_vid, end_vid, agg_cost FROM %I ', matrix_sql);
+    BEGIN
+        EXECUTE sql || 'LIMIT 1';
+        EXCEPTION WHEN OTHERS THEN
+            RAISE EXCEPTION 'An expected column was not found in the query 1'
+            USING HINT = 'Please verify columns: (start_vid, end_vid, agg_cost)';
+    END;
+
+    count_sql = format('SELECT count(DISTINCT start_vid) AS count FROM %I', matrix_sql);
+    EXECUTE count_sql INTO rec;
+    n := rec.count;
+
+    ids_sql = format('SELECT DISTINCT start_vid FROM %I ORDER BY start_vid', matrix_sql);
+    FOR rec IN EXECUTE ids_sql LOOP
+        ids := ids || rec.start_vid;
+    END LOOP;
+
+    FOR i in 1 .. n LOOP
+        dummy_row := dummy_row || '+Infinity'::float8;
+    END LOOP;
+
+    FOR i in 1 .. n LOOP
+        dmatrix := dmatrix || ARRAY[dummy_row];
+    END LOOP;
+
+    FOR i IN 1 .. n LOOP
+        dmatrix[i][i] :=  0.0;
+    END LOOP;
+
+    sql = format('
+    WITH 
+      ids AS (SELECT DISTINCT start_vid FROM %I ORDER by start_vid),
+      distinct_ids AS (SELECT DISTINCT row_number() over () AS id, start_vid FROM ids),
+      renumbered1 AS (SELECT id AS new_start_vid,  end_vid, agg_cost FROM distinct_ids JOIN %I USING (start_vid) ORDER BY new_start_vid, end_vid),
+      renumbered2 AS (SELECT new_start_vid,  id AS new_end_vid, agg_cost FROM distinct_ids JOIN renumbered1 ON (start_vid = end_vid))
+      SELECT new_start_vid AS start_vid, new_end_vid AS end_vid, agg_cost from renumbered2 ORDER BY new_start_vid', matrix_sql,matrix_sql);
+
+    FOR rec IN EXECUTE sql LOOP
+        dmatrix[rec.start_vid][rec.end_vid] := rec.agg_cost;
+    END LOOP;
+
+END
+$BODY$
+language plpgsql stable cost 10;
diff --git a/src/tsp/sql/eucledianTSP.sql b/src/tsp/sql/eucledianTSP.sql
new file mode 100644
index 0000000..7d6ceac
--- /dev/null
+++ b/src/tsp/sql/eucledianTSP.sql
@@ -0,0 +1,27 @@
+
+CREATE OR REPLACE FUNCTION pgr_eucledianTSP(
+    coordinates_sql TEXT,
+    start_id BIGINT DEFAULT 0,
+    end_id BIGINT DEFAULT 0,
+
+    max_processing_time FLOAT DEFAULT '+infinity'::FLOAT,
+
+    tries_per_temperature INTEGER DEFAULT 500,
+    max_changes_per_temperature INTEGER DEFAULT 60,
+    max_consecutive_non_changes INTEGER DEFAULT 100,
+
+    initial_temperature FLOAT DEFAULT 100,
+    final_temperature FLOAT DEFAULT 0.1,
+    cooling_factor FLOAT DEFAULT 0.9,
+
+    randomize BOOLEAN DEFAULT true,
+
+    OUT seq integer,
+    OUT node BIGINT,
+    OUT cost FLOAT,
+    OUT agg_cost FLOAT)
+RETURNS SETOF record
+AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'eucledianTSP'
+LANGUAGE c VOLATILE STRICT;
+
+
diff --git a/src/tsp/sql/routing_tsp_wrappers.sql b/src/tsp/sql/routing_tsp_wrappers.sql
index b21025b..9e242f5 100644
--- a/src/tsp/sql/routing_tsp_wrappers.sql
+++ b/src/tsp/sql/routing_tsp_wrappers.sql
@@ -61,7 +61,7 @@ end;
 $body$
 language plpgsql stable cost 10;
 
-
+/*
 
 create or replace function pgr_tsp(sql text, start_id integer, end_id integer default (-1))
     returns setof pgr_costResult as
@@ -104,4 +104,4 @@ end;
 $body$
 language plpgsql volatile cost 50 rows 50;
 
-
+*/
diff --git a/src/tsp/sql/tsp_v2.0_coordinates.sql b/src/tsp/sql/tsp_v2.0_coordinates.sql
new file mode 100644
index 0000000..047cae1
--- /dev/null
+++ b/src/tsp/sql/tsp_v2.0_coordinates.sql
@@ -0,0 +1,72 @@
+
+/*
+    Old signature has:
+    sql: id INTEGER, x FLOAT, y FLOAT
+*/
+
+
+
+
+CREATE OR  REPLACE FUNCTION pgr_tsp(sql text, start_id INTEGER, end_id INTEGER default (-1))
+returns setof pgr_costResult as
+$body$
+DECLARE
+table_sql TEXT;
+rec RECORD;
+debuglevel TEXT;
+n BIGINT;
+
+BEGIN
+    -- checking the fixed columns and data types of the integers
+    EXECUTE 'SHOW client_min_messages' INTO debuglevel;
+
+    EXECUTE 'SET client_min_messages TO NOTICE';
+    RAISE NOTICE 'Deprecated Signature pgr_tsp(sql, integer, integer)';
+    EXECUTE 'set client_min_messages  to '|| debuglevel;
+
+    table_sql := 'CREATE TABLE ___tmp  AS ' || sql ;
+    EXECUTE table_sql;
+
+
+    BEGIN
+        EXECUTE 'SELECT id, x, y FROM ___tmp' INTO rec;
+        EXCEPTION
+            WHEN OTHERS THEN
+                RAISE EXCEPTION 'An expected column was not found in the query'
+                USING ERRCODE = 'XX000',
+                HINT = 'Please verify the column names: id, x, y';
+    END;
+
+    EXECUTE
+    'SELECT
+        pg_typeof(id)::text as id_type,
+        pg_typeof(x)::text as x_type,
+        pg_typeof(y)::text as y_type FROM ___tmp' INTO rec;
+
+
+    IF NOT((rec.id_type in ('integer'::text))
+        AND (rec.x_type = 'double precision'::text)
+        AND (rec.y_type = 'double precision'::text)) THEN
+            RAISE EXCEPTION '''id'' must be of type INTEGER, ''x'' ad ''y'' must be of type FLOAT'
+            USING ERRCODE = 'XX000';
+    END IF;
+
+    EXECUTE 'SELECT count(*) AS n FROM (' || sql || ') AS __a__' INTO rec;
+    n = rec.n;
+
+    EXECUTE 'SET client_min_messages TO ERROR';
+    RETURN query
+        SELECT (seq - 1)::INTEGER AS seq, node::INTEGER AS id1, node::INTEGER AS id2, cost
+        FROM pgr_eucledianTSP(sql, start_id, end_id,
+
+            tries_per_temperature :=  500 * n :: INTEGER,
+            max_changes_per_temperature := 60 * n :: INTEGER,
+            max_consecutive_non_changes := 500 * n :: INTEGER,
+
+            randomize := false) WHERE seq <= n;
+    DROP TABLE ___tmp;
+    EXECUTE 'set client_min_messages  to '|| debuglevel;
+
+END;
+$body$
+language plpgsql volatile cost 500 ROWS 50;
diff --git a/src/tsp/sql/xyd_tsp.sql b/src/tsp/sql/xyd_tsp.sql
deleted file mode 100644
index 475deb4..0000000
--- a/src/tsp/sql/xyd_tsp.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-
-CREATE OR REPLACE FUNCTION pgr_tsp(distance_sql TEXT, start_id BIGINT,
-    end_id BIGINT DEFAULT -1,
-    OUT seq integer,
-    OUT node integer,
-    OUT cost FLOAT,
-    OUT agg_cost FLOAT)
-
-    RETURNS SETOF record
-    AS '$libdir/${PGROUTING_LIBRARY_NAME}', 'xyd_tsp'
-    LANGUAGE c IMMUTABLE VOLATILE;
diff --git a/src/tsp/src/CMakeLists.txt b/src/tsp/src/CMakeLists.txt
index 44d037b..fe87114 100644
--- a/src/tsp/src/CMakeLists.txt
+++ b/src/tsp/src/CMakeLists.txt
@@ -1,12 +1,15 @@
 ADD_LIBRARY(tsp OBJECT
-    tsp2.c 
-    tsplib.c
+    eucledianTSP.c
+    newTSP.c
 
-    #distances_input.c
-    #xyd_tsp.c
+    newTSP_driver.cpp
+    eucledianTSP_driver.cpp
 
-    #tsp_driver.cpp
-    #pgr_tsp.cpp
-    #Dmatrix.cpp
-    )
+    Dmatrix.cpp
+    eucledianDmatrix.cpp
+    tour.cpp
 
+    #Code for the old signature
+    tsp2.c
+    tsplib.c
+    )
diff --git a/src/tsp/src/Dmatrix.cpp b/src/tsp/src/Dmatrix.cpp
index 35e8416..5c242a2 100644
--- a/src/tsp/src/Dmatrix.cpp
+++ b/src/tsp/src/Dmatrix.cpp
@@ -1,43 +1,70 @@
-#ifdef __MINGW32__
+/*PGR-GNU*****************************************************************
+
+FILE: Dmatrix.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#undef min
+#undef max
 #endif
 
+#include "./Dmatrix.h"
 
+#include <string.h>
+#include <sstream>
 #include <algorithm>
+#include <limits>
 #include <vector>
-#include "./Dmatrix.hpp"
+#include <cmath>
 
+#include "../../common/src/pgr_assert.h"
 
+#include "./tour.h"
+
+namespace pgrouting {
+namespace tsp {
 
 double
-Dmatrix::pathCost(const Ids &path) const {
-    double len = 0;
-    if (path.empty()) return len;
-    auto prev_id = path.front();
-    for (const auto &id : path) {
-        if (id == path.front()) continue;
-        if (costs[prev_id][id] == std::numeric_limits<double>::max())
-            return std::numeric_limits<double>::max();
-        len += costs[prev_id][id];
-        prev_id = id;
-    }
-    len += costs[prev_id][ids.front()];
-    return len;
-}
+Dmatrix::tourCost(const Tour &tour) const {
+    double total_cost(0);
+    if (tour.cities.empty()) return total_cost;
 
+    auto prev_id = tour.cities.front();
+    for (const auto &id : tour.cities) {
+        if (id == tour.cities.front()) continue;
 
+        pgassert(distance(prev_id, id) != std::numeric_limits<double>::max());
 
-double
-Dmatrix::max() const {
-    double maxd(0);
-    for (const auto &row : costs) {
-        auto row_max = std::max_element(row.begin(),row.end());
-        maxd = maxd < *row_max? *row_max : maxd;
+        total_cost += costs[prev_id][id];
+        prev_id = id;
     }
-    return maxd;
+    total_cost += costs[prev_id][tour.cities.front()];
+    return total_cost;
 }
 
+
+
 void
 Dmatrix::set_ids(const std::vector < Matrix_cell_t > &data_costs) {
     ids.reserve(data_costs.size() * 2);
@@ -46,14 +73,20 @@ Dmatrix::set_ids(const std::vector < Matrix_cell_t > &data_costs) {
         ids.push_back(cost.to_vid);
     }
     std::sort(ids.begin(), ids.end());
-    auto last = std::unique(ids.begin(), ids.end());
-    ids.erase(last, ids.end());
+    ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
     /*
      * freeing up unused space
      */
     ids.shrink_to_fit();
 }
 
+bool
+Dmatrix::has_id(int64_t id) const {
+    auto pos = std::lower_bound(ids.begin(), ids.end(), id);
+    return *pos == id;
+}
+
+
 size_t
 Dmatrix::get_index(int64_t id) const {
     auto pos = std::lower_bound(ids.begin(), ids.end(), id);
@@ -61,7 +94,7 @@ Dmatrix::get_index(int64_t id) const {
 }
 
 int64_t
-Dmatrix::get_id(size_t id) const{
+Dmatrix::get_id(size_t id) const {
     return ids[id];
 }
 
@@ -109,7 +142,7 @@ Dmatrix::obeys_triangle_inequality() const {
     for (size_t i = 0; i < costs.size(); ++i) {
         for (size_t j = 0; j < costs.size(); ++j) {
             for (size_t k = 0; k < costs.size(); ++k) {
-                if (costs[i][k] <= (costs[i][j] + costs[j][k])) return false;
+                if (!(costs[i][k] <= (costs[i][j] + costs[j][k]))) return false;
             }
         }
     }
@@ -117,65 +150,60 @@ Dmatrix::obeys_triangle_inequality() const {
 }
 
 bool
-Dmatrix::is_symetric() const{
+Dmatrix::is_symmetric() const {
     for (size_t i = 0; i < costs.size(); ++i) {
         for (size_t j = 0; j < costs.size(); ++j) {
-            if (costs[i][j] != costs[j][i]) return false;
+            if (0.000001 < std::fabs(costs[i][j] - costs[j][i])) {
+                std::ostringstream log;
+                log << "i \t" << i
+                    << "j \t" << j
+                    << "costs[i][j] \t" << costs[i][j]
+                    << "costs[j][i] \t" << costs[j][i]
+                    << "\n";
+                log << (*this);
+                pgassertwm(false, log.str());
+                return false;
+            }
         }
     }
     return true;
 }
 
 
-Dmatrix
-Dmatrix::get_symetric() const {
-    double sum(0);
-    for (const auto &row : costs) {
-        for (const auto &cell : row) {
-            sum += cell;
-        }
+std::ostream& operator<<(std::ostream &log, const Dmatrix &matrix) {
+    for (const auto id : matrix.ids) {
+        log << "\t" << id;
     }
-    if (is_symetric()) return *this; 
-    Dmatrix new_costs;
-    new_costs.costs.resize(costs.size() * 2);
-    for (auto &row : new_costs.costs) {
-        row.resize(costs.size() * 2);
-        for (auto &cell : row) {
-            cell = std::numeric_limits<double>::max();
+    log << "\n";
+    size_t i = 0;
+    for (const auto row : matrix.costs) {
+        size_t j = 0;
+        for (const auto cost : row) {
+            log << "(" << i << "," << j << ")"
+                << "\t(" << matrix.ids[i] << "," << matrix.ids[j] << ")"
+                << "\t(" << matrix.get_index(matrix.ids[i])
+                << "," << matrix.get_index(matrix.ids[j]) << ")"
+                << "\t = " << cost
+                << "\t = " << matrix.costs[i][j]
+                << "\t = " << matrix.costs[j][i] << "\n";
+            ++j;
         }
+        ++i;
     }
-
-    /*
-     * Matrix cuadrants
-     *   A= inf           B= transposed original
-     *   C=original       D= inf
-     *
-     *   B & C "semi" diagonals are 0
-     */
-    for (size_t i = 0; i < costs.size(); ++i) {
-        for (size_t j = 0; j < costs.size(); ++j) {
-            /*
-             *  A & D
-             */
-            new_costs[i][j] = 
-                new_costs[i + costs.size()][j + costs.size()] = 
-                std::numeric_limits<double>::max();
-
-            /*
-             * B
-             */
-            new_costs[i + costs.size()][j] =
-                i == j? costs[i][j] : 0;
-
-            /*
-             * C
-             */
-            new_costs[i][j + costs.size()] =
-                i == j? costs[j][i] : 0;
+    for (size_t i = 0; i < matrix.costs.size(); ++i) {
+        for (size_t j = 0; j < matrix.costs.size(); ++j) {
+            for (size_t k = 0; k < matrix.costs.size(); ++k) {
+                log << matrix.costs[i][k] << " <= ("
+                    << matrix.costs[i][j] << " + "  << matrix.costs[j][k] << ")"
+                    << (matrix.costs[i][k] <= (matrix.costs[i][j] + matrix.costs[j][k]))
+                    << "\n";
+            }
         }
     }
-    new_costs.ids = ids;
-    new_costs.ids.insert(new_costs.ids.end(), ids.begin(), ids.end());
 
-    return new_costs;
+    return log;
 }
+
+
+}  // namespace tsp
+}  // namespace pgrouting
diff --git a/src/tsp/src/Dmatrix.h b/src/tsp/src/Dmatrix.h
new file mode 100644
index 0000000..2bc23e5
--- /dev/null
+++ b/src/tsp/src/Dmatrix.h
@@ -0,0 +1,125 @@
+/*PGR-GNU*****************************************************************
+
+FILE: Dmatrix.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#ifndef SRC_TSP_SRC_DMATRIX_H_
+#define SRC_TSP_SRC_DMATRIX_H_
+#pragma once
+
+#include <iostream>
+#include <vector>
+
+#include "../../common/src/pgr_types.h"
+
+namespace pgrouting {
+namespace tsp {
+
+class Tour;  // for tourCost
+
+class Dmatrix {
+ public:
+    Dmatrix() = default;
+    explicit Dmatrix(const std::vector < Matrix_cell_t > &data_costs);
+
+    bool has_no_infinity() const;
+    bool obeys_triangle_inequality() const;
+    bool is_symmetric() const;
+
+    /*! @brief sets a special value for the distance(i,j)
+     *
+     * @param [in] i - index in matrix
+     * @param [in] j - index in matrix
+     * @param [in] dist - distance from i to j & from j to i
+     *
+     */
+    void set(size_t i, size_t j, double dist) {
+        costs[i][j] = costs[j][i] = dist;}
+
+    /*! @brief original id -> true
+     *
+     * @param [in] id - original id
+     * @returns true if id is in the distance table
+     */
+    bool has_id(int64_t id) const;
+
+    /*! @brief original id -> idx
+     *
+     * @param [in] id - original id
+     * @returns idx index of the id in the distance table
+     */
+    size_t get_index(int64_t id) const;
+
+    /*! @brief idx -> original id
+     *
+     * @param [in] idx - index (i-th coordinate)
+     * @returns the original id corresponding to idx
+     */
+    int64_t get_id(size_t idx) const;
+
+    /*! @brief |idx|
+     *
+     * @returns the total number of coordinates
+     */
+    size_t size() const {return ids.size();}
+
+    /*! @brief tour evaluation
+     *
+     * @param [in] tour
+     * @returns total cost of traversing the tour
+     */
+    double tourCost(const Tour &tour) const;
+
+    /*! @brief returns a row of distances
+     *
+     * @param [in] idx - row index
+     * @returns distances from idx to all other coordinates
+     */
+    const std::vector<double>& get_row(size_t idx) const {
+        return costs[idx];}
+
+    double comparable_distance(size_t i, size_t j) const {
+        return distance(i, j);}
+
+    double distance(size_t i, size_t j) const {
+        return costs[i][j];}
+
+    friend std::ostream& operator<<(
+            std::ostream &log,
+            const Dmatrix &matrix);
+
+ protected:
+    void set_ids(const std::vector<matrix_cell> &data_costs);
+    std::vector<int64_t> ids;
+
+ private:
+    typedef std::vector < std::vector < double > > Costs;
+    Costs costs;
+    std::vector< double >& operator[] (size_t i) {return costs[i];}
+    const std::vector< double >& operator[] (size_t i) const {return costs[i];}
+};
+
+}  // namespace tsp
+}  // namespace pgrouting
+
+#endif  // SRC_TSP_SRC_DMATRIX_H_
diff --git a/src/tsp/src/Dmatrix.hpp b/src/tsp/src/Dmatrix.hpp
deleted file mode 100644
index 1dccc0c..0000000
--- a/src/tsp/src/Dmatrix.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#pragma once
-
-
-#include "../../common/src/pgr_types.h"
-
-
-#include <vector>
-
-
-
-class Dmatrix {
- public:
-    typedef std::vector < std::vector < double > > Costs;
-    typedef std::vector < int64_t > Ids;
-
-    Dmatrix() = default;
-    Dmatrix(const std::vector < Matrix_cell_t > &data_costs);
-
-    bool has_no_infinity() const;
-
-    bool obeys_triangle_inequality() const;
-    bool is_symetric() const;
-
-    Dmatrix get_symetric() const; 
-
-    void set_ids(const std::vector<matrix_cell> &data_costs);
-
-    size_t get_index(int64_t id) const;
-    int64_t get_id (size_t id) const;
-    size_t size() const {return ids.size();};
-    double max() const;
-    double pathCost(const Ids &path) const;
-    std::vector< double >& operator[] (size_t i) {return costs[i];}
-
-    Costs costs;
-    Ids ids;
-};
-
diff --git a/src/tsp/src/OBSOLETE/tsp.c b/src/tsp/src/OBSOLETE/tsp.c
deleted file mode 100644
index 8422861..0000000
--- a/src/tsp/src/OBSOLETE/tsp.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-/*
- * Traveling Salesman Problem solution algorithm for PostgreSQL
- *
- * Copyright (c) 2006 Anton A. Patrushev, Orkney, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include "tsp.h"
-
-#include "postgres.h"
-#include "executor/spi.h"
-#include "funcapi.h"
-#include "catalog/pg_type.h"
-#if PGSQL_VERSION > 92
-#include "access/htup_details.h"
-#endif
-
-#include "string.h"
-#include "math.h"
-
-#include "fmgr.h"
-
-#ifdef PG_MODULE_MAGIC
-PG_MODULE_MAGIC;
-#endif
-
-
-// ------------------------------------------------------------------------
-
-/*
- * Define this to have profiling enabled
- */
-//#define PROFILE
-
-#ifdef PROFILE
-#include <sys/time.h>
-
-struct timeval prof_tsp, prof_store, prof_extract, prof_total;
-long proftime[5];
-long profipts1, profipts2, profopts;
-#define profstart(x) do { gettimeofday(&x, NULL); } while (0);
-#define profstop(n, x) do { struct timeval _profstop;   \
-        long _proftime;                         \
-        gettimeofday(&_profstop, NULL);                         \
-        _proftime = ( _profstop.tv_sec*1000000+_profstop.tv_usec) -     \
-                ( x.tv_sec*1000000+x.tv_usec); \
-        elog(NOTICE, \
-                "PRF(%s) %lu (%f ms)", \
-                (n), \
-             _proftime, _proftime / 1000.0);    \
-        } while (0);
-
-#else
-
-#define profstart(x) do { } while (0);
-#define profstop(n, x) do { } while (0);
-
-#endif // PROFILE
-
-// ------------------------------------------------------------------------
-
-Datum tsp(PG_FUNCTION_ARGS);
-
-#undef DEBUG
-//#define DEBUG 1
-
-#ifdef DEBUG
-#define DBG(format, arg...)                     \
-    elog(NOTICE, format , ## arg)
-#else
-#define DBG(format, arg...) do { ; } while (0)
-#endif
-
-// The number of tuples to fetch from the SPI cursor at each iteration
-#define TUPLIMIT 1000
-
-// macro to store distance values as DISTANCE[MAX_TOWNS][MAX_TOWNS]
-#define D(i,j) DISTANCE[(i)*MAX_TOWNS + j]
-
-DTYPE *DISTANCE;
-float *x;
-float *y;
-int MAX_TOWNS;
-int total_tuples;
-
-
-static char *
-text2char(text *in)
-{
-  char *out = (char*)palloc(VARSIZE(in));
-
-  memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
-  out[VARSIZE(in) - VARHDRSZ] = '\0';
-  return out;
-}
-
-static int
-finish(int code, int ret)
-{
-  code = SPI_finish();
-  if (code  != SPI_OK_FINISH )
-  {
-    elog(ERROR,"couldn't disconnect from SPI");
-    return -1 ;
-  }
-  return ret;
-}
-		  
-
-typedef struct point_columns
-{
-  int id;
-  float8 x;
-  float8 y;
-} point_columns_t;
-
-
-static int
-fetch_point_columns(SPITupleTable *tuptable, point_columns_t *point_columns)
-{
-  //DBG("Fetching point");
-
-  point_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "source_id");
-  point_columns->x = SPI_fnumber(SPI_tuptable->tupdesc, "x");
-  point_columns->y = SPI_fnumber(SPI_tuptable->tupdesc, "y");
-  if (point_columns->id == SPI_ERROR_NOATTRIBUTE ||
-      point_columns->x == SPI_ERROR_NOATTRIBUTE ||
-      point_columns->y == SPI_ERROR_NOATTRIBUTE) 
-    {
-      elog(ERROR, "Error, query must return columns "
-           "'source_id', 'x' and 'y'");
-      return -1;
-    }
-    
-  //DBG("* Point %i [%f, %f]", point_columns->id, point_columns->x, point_columns->y);
-
-  return 0;
-}
-
-static void
-fetch_point(HeapTuple *tuple, TupleDesc *tupdesc, 
-            point_columns_t *point_columns, point_t *point)
-{
-  Datum binval;
-  bool isnull;
-
-  //DBG("inside fetch_point");
-
-  binval = SPI_getbinval(*tuple, *tupdesc, point_columns->id, &isnull);
-  //DBG("Got id");
-
-  if (isnull)
-    elog(ERROR, "id contains a null value");
-
-  point->id = DatumGetInt32(binval);
-
-  //DBG("id = %i", point->id);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, point_columns->x, &isnull);
-  if (isnull)
-    elog(ERROR, "x contains a null value");
-
-  point->x = DatumGetFloat8(binval);
-
-  //DBG("x = %f", point->x);
-
-  binval = SPI_getbinval(*tuple, *tupdesc, point_columns->y, &isnull);
-
-  if (isnull)
-    elog(ERROR, "y contains a null value");
-
-  point->y = DatumGetFloat8(binval);
-
-  //DBG("y = %f", point->y);
-}
-
-
-static int findid(point_t *points, int n, int id)
-{
-    int i;
-
-    if (!points || n==0) return 0;
-
-    for (i=0; i<n; i++) {
-        if (points[i].id == id) return i;
-    }
-
-    return 0;
-}
-
-
-static int solve_tsp(char* sql, char* p_ids, 
-                     int source, path_element_t** path) 
-{
-  int SPIcode;
-  void *SPIplan;
-  Portal SPIportal;
-  bool moredata = TRUE;
-  int ntuples;
-
-  //todo replace path (vector of path_element_t) with this array
-  int *ids;
-
-  point_t *points=NULL;
-  point_columns_t point_columns = {.id= -1, .x= -1, .y=-1};
-
-  char *err_msg = NULL;
-  int ret = -1;
-    
-  char *p;
-  int   z = 0;
-  int   i;
-  
-  int    tt, cc;
-  double dx, dy;
-  float  fit=0.0;
-  int got_source = 0;
-
-  DBG("inside tsp");
-
-  //int total_tuples = 0;
-  total_tuples = 0;
-
-  /* count the number of towns and allocate memory */
-  for (i=0, MAX_TOWNS=1; i<strlen(p_ids); i++)
-    if (p_ids[i] == ',') MAX_TOWNS++;
-
-  DBG("MAX_TOWNS=%d", MAX_TOWNS);
-
-  if (MAX_TOWNS < 4) {
-    elog(ERROR, "Error: TSP requires 4 or more locations. Only %d were supplied.", MAX_TOWNS);
-    return -1;
-  }
-
-  *path = (path_element_t *) palloc( MAX_TOWNS * sizeof(path_element_t) );
-  if (! *path) {
-    elog(ERROR, "Failed to alloc memory!");
-    return -1;
-  }
-
-  ids = (int *)palloc( MAX_TOWNS * sizeof(int) );
-  if (!ids) {
-    elog(ERROR, "Failed to alloc memory!");
-    return -1;
-  }
-
-  DISTANCE = (DTYPE *) palloc(MAX_TOWNS * MAX_TOWNS * sizeof(DTYPE));
-  if (!DISTANCE) {
-    elog(ERROR, "Failed to alloc memory!");
-    return -1;
-  }
-
-  x = (float *) palloc(MAX_TOWNS * sizeof(float));
-  y = (float *) palloc(MAX_TOWNS * sizeof(float));
-  if (!x || !y) {
-    elog(ERROR, "Failed to alloc memory!");
-    return -1;
-  }
-
-  p = strtok(p_ids, ",");
-  while(p != NULL) {
-      ids[z]=atoi(p);
-      if (ids[z] == source) got_source = 1;
-      p = strtok(NULL, ",");
-      z++;
-      if(z > MAX_TOWNS)
-      {
-        elog(ERROR, "Number of points exeeds max number.");
-        break;
-      }
-  }
-
-  if (!got_source) {
-    elog(ERROR, "tsp: source id not included in list of ids!");
-    return -1;
-  }
-    
-  DBG("start tsp");
-        
-  SPIcode = SPI_connect();
-
-  if (SPIcode  != SPI_OK_CONNECT) {
-      elog(ERROR, "tsp: couldn't open a connection to SPI");
-      return -1;
-  }
-
-  SPIplan = SPI_prepare(sql, 0, NULL);
-
-  if (SPIplan  == NULL) {
-      elog(ERROR, "tsp: couldn't create query plan via SPI");
-      return finish(SPIcode, -1);
-  }
-
-  if ((SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) {
-      elog(ERROR, "tsp: SPI_cursor_open('%s') returns NULL", sql);
-      return finish(SPIcode, -1);
-  }
-    
-  DBG("Query: %s",sql);
-
-  while (moredata == TRUE) {
-      SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
-
-      if (point_columns.id == -1) {
-          if (fetch_point_columns(SPI_tuptable, &point_columns) == -1)
-	      return finish(SPIcode, ret);
-      }
-
-      ntuples = SPI_processed;
-
-      total_tuples += ntuples;
-
-      //DBG("Tuples: %i", total_tuples);
-
-      if (!points)
-        points = palloc(total_tuples * sizeof(point_t));
-      else
-        points = repalloc(points, total_tuples * sizeof(point_t));
-                                        
-      if (points == NULL) {
-          elog(ERROR, "Out of memory");
-	      return finish(SPIcode, ret);
-      }
-
-      if (ntuples > 0) {
-          int t;
-          SPITupleTable *tuptable = SPI_tuptable;
-          TupleDesc tupdesc = SPI_tuptable->tupdesc;
-
-          //DBG("Got tuple desc");
-                
-          for (t = 0; t < ntuples; t++) {
-              HeapTuple tuple = tuptable->vals[t];
-              fetch_point(&tuple, &tupdesc, &point_columns, 
-                          &points[total_tuples - ntuples + t]);
-          }
-
-          SPI_freetuptable(tuptable);
-      }
-      else {
-          moredata = FALSE;
-      }                                       
-  }
-
-  
-  DBG("Calling TSP");
-        
-  profstop("extract", prof_extract);
-  profstart(prof_tsp);
-
-  DBG("Total tuples: %i", total_tuples);
-
-  for(tt=0; tt < total_tuples; tt++) {
-      ids[tt] = points[tt].id;
-      x[tt] = points[tt].x;
-      y[tt] = points[tt].y;
-  
-      //DBG("Point at %i: %i [%f, %f]",  tt, ids[tt], x[tt], y[tt]);
-            
-      for(cc=0; cc < total_tuples; cc++) {
-          dx = x[tt] - x[cc];
-          dy = y[tt] - y[cc];
-          D(tt, cc) = D(cc, tt) = sqrt(dx*dx + dy*dy);
-      }
-  }
-
-  DBG("DISTANCE matrix computed");
-    
-  ret = find_tsp_solution(total_tuples, DISTANCE, ids, 
-                          source, -1, &fit, err_msg);
-
-  DBG("TSP solved!");
-  DBG("Score: %f", fit);
-
-  if (ret < 0) {
-      elog(ERROR, "Error computing path: %s", err_msg);
-      return finish(SPIcode, ret);
-  }
-
-  for(tt=0; tt < total_tuples; tt++) {
-      ((path_element_t*)(*path))[tt].vertex_id = ids[tt];
-      ((path_element_t*)(*path))[tt].edge_id   = tt + 1;
-      if (tt == total_tuples-1)
-        ((path_element_t*)(*path))[tt].cost = D(findid(points, total_tuples, ids[tt]), findid(points, total_tuples, ids[0]));
-      else
-        ((path_element_t*)(*path))[tt].cost = D(findid(points, total_tuples, ids[tt]), findid(points, total_tuples, ids[tt+1]));
-  }
-    
-  pfree(points);
-
-  profstop("tsp", prof_tsp);
-  profstart(prof_store);
-
-  DBG("Profile changed and ret is %i", ret);
-
-  if (ret < 0) {
-      //elog(ERROR, "Error computing path: %s", err_msg);
-      ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), errmsg("Error computing path: %s", err_msg)));
-  } 
-
-  return finish(SPIcode, ret);    
-}
-
-PG_FUNCTION_INFO_V1(tsp);
-Datum
-tsp(PG_FUNCTION_ARGS)
-{
-  FuncCallContext     *funcctx;
-  int                  call_cntr;
-  int                  max_calls;
-  TupleDesc            tuple_desc;
-  path_element_t      *path;
-    
-  /* stuff done only on the first call of the function */
-  if (SRF_IS_FIRSTCALL())
-    {
-      MemoryContext   oldcontext;
-      //int path_count;
-      int ret=-1;
-
-      // XXX profiling messages are not thread safe
-      profstart(prof_total);
-      profstart(prof_extract);
-
-      /* create a function context for cross-call persistence */
-      funcctx = SRF_FIRSTCALL_INIT();
-
-      /* switch to memory context appropriate for multiple function calls */
-      oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-        
-
-
-      ret = solve_tsp(text2char(PG_GETARG_TEXT_P(0)),
-                      text2char(PG_GETARG_TEXT_P(1)),
-                      PG_GETARG_INT32(2),
-                      &path);
-
-      /* total number of tuples to be returned */
-      DBG("Counting tuples number");
-
-      funcctx->max_calls = total_tuples;
-
-      funcctx->user_fctx = path;
-
-      funcctx->tuple_desc = BlessTupleDesc(
-                              RelationNameGetTupleDesc("pgr_costResult"));
-      MemoryContextSwitchTo(oldcontext);
-    }
-
-  /* stuff done on every call of the function */
-  funcctx = SRF_PERCALL_SETUP();
-
-  call_cntr = funcctx->call_cntr;
-  max_calls = funcctx->max_calls;
-  tuple_desc = funcctx->tuple_desc;
-
-  path = (path_element_t *)funcctx->user_fctx;
-
-  DBG("Trying to allocate some memory");
-  DBG("call_cntr = %i, max_calls = %i", call_cntr, max_calls);
-
-  if (call_cntr < max_calls)    /* do when there is more left to send */
-    {
-      HeapTuple    tuple;
-      Datum        result;
-      Datum *values;
-      char* nulls;
-
-      values = palloc(4 * sizeof(Datum));
-      nulls = palloc(4 * sizeof(char));
-
-      values[0] = Int32GetDatum(call_cntr);
-      nulls[0] = ' ';
-      values[1] = Int32GetDatum(path[call_cntr].vertex_id);
-      nulls[1] = ' ';
-      values[2] = Int32GetDatum(path[call_cntr].edge_id);
-      nulls[2] = ' ';
-      values[3] = Float8GetDatum(path[call_cntr].cost);
-      nulls[3] = ' ';
-
-      DBG("Heap making");
-
-      tuple = heap_formtuple(tuple_desc, values, nulls);
-
-      DBG("Datum making");
-
-      /* make the tuple into a datum */
-      result = HeapTupleGetDatum(tuple);
-
-      DBG("VAL: %i, %i", values[0], result);
-      DBG("Trying to free some memory");
-    
-      /* clean up (this is not really necessary) */
-      pfree(values);
-      pfree(nulls);
-        
-
-      SRF_RETURN_NEXT(funcctx, result);
-    }
-  else    /* do when there is no more left */
-    {
-      DBG("Ending function");
-      profstop("store", prof_store);
-      profstop("total", prof_total);
-      DBG("Profiles stopped");
-
-      SRF_RETURN_DONE(funcctx);
-    }
-}
diff --git a/src/tsp/src/eucledianDmatrix.cpp b/src/tsp/src/eucledianDmatrix.cpp
new file mode 100644
index 0000000..3e10097
--- /dev/null
+++ b/src/tsp/src/eucledianDmatrix.cpp
@@ -0,0 +1,169 @@
+/*PGR-GNU*****************************************************************
+
+FILE: eucledianDmatrix.cpp
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <algorithm>
+#include <vector>
+#include <cmath>
+#include "../../common/src/pgr_assert.h"
+
+#include "./eucledianDmatrix.h"
+#include "./tour.h"
+
+namespace pgrouting {
+namespace tsp {
+
+
+const std::vector<double>
+eucledianDmatrix::get_row(size_t i) const {
+    std::vector<double> result;
+
+    for (size_t j = 0; j < ids.size(); ++j) {
+        result.push_back(distance(i, j));
+    }
+
+    pgassert(result.size() == ids.size());
+    return result;
+}
+
+
+double
+eucledianDmatrix::comparable_distance(size_t i, size_t j) const {
+    if (special_distance >= 0 &&
+            ((row == i && column == j)
+             ||(row == j && column == i))) {
+        return special_distance * special_distance;
+    }
+    auto dx = coordinates[i].x - coordinates[j].x;
+    auto dy = coordinates[i].y - coordinates[j].y;
+    return dx * dx + dy * dy;
+}
+
+double
+eucledianDmatrix::distance(size_t i, size_t j) const {
+    if (special_distance >= 0 &&
+            ((row == i && column == j)
+             ||(row == j && column == i))) {
+        return special_distance;
+    }
+    if (i == j) return 0;
+    return std::sqrt(comparable_distance(i, j));
+}
+
+double
+eucledianDmatrix::tourCost(const Tour &tour) const {
+    double total_cost(0);
+    if (tour.cities.empty()) return total_cost;
+
+    auto prev_id = tour.cities.front();
+    for (const auto &id : tour.cities) {
+        if (id == tour.cities.front()) continue;
+
+        total_cost += distance(prev_id, id);
+        prev_id = id;
+    }
+    total_cost += distance(prev_id, tour.cities.front());
+    return total_cost;
+}
+
+
+
+bool
+eucledianDmatrix::has_id(int64_t id) const {
+    auto pos = std::lower_bound(ids.begin(), ids.end(), id);
+    return *pos == id;
+}
+
+size_t
+eucledianDmatrix::get_index(int64_t id) const {
+    auto pos = std::lower_bound(ids.begin(), ids.end(), id);
+    return pos - ids.begin();
+}
+
+int64_t
+eucledianDmatrix::get_id(size_t id) const {
+    return ids[id];
+}
+
+/*
+ * constructor
+ */
+eucledianDmatrix::eucledianDmatrix(
+        const std::vector < Coordinate_t > &data_coordinates)
+    : coordinates(data_coordinates) {
+        set_ids();
+        std::sort(coordinates.begin(), coordinates.end(),
+                [](const Coordinate_t &lhs, const Coordinate_t &rhs)
+                {return lhs.id < rhs.id;});
+    }
+
+void
+eucledianDmatrix::set_ids() {
+    ids.reserve(coordinates.size());
+    for (const auto &data : coordinates) {
+        ids.push_back(data.id);
+    }
+    std::sort(ids.begin(), ids.end());
+#ifndef NDEBUG
+    auto total = ids.size();
+#endif
+    ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
+    pgassertwm(total == ids.size(), "Duplicated id found");
+}
+
+bool
+eucledianDmatrix::has_no_infinity() const {
+    return true;
+}
+
+bool
+eucledianDmatrix::obeys_triangle_inequality() const {
+    return true;
+}
+
+bool
+eucledianDmatrix::is_symmetric() const {
+    return true;
+}
+
+std::ostream& operator<<(std::ostream &log, const eucledianDmatrix &matrix) {
+    for (const auto id : matrix.ids) {
+        log << "\t" << id;
+    }
+    log << "\n";
+    for (const auto row : matrix.coordinates) {
+        log << row.id << "(" << row.x << "," << row.y << ")\n";
+    }
+    return log;
+}
+
+
+}  // namespace tsp
+}  // namespace pgrouting
diff --git a/src/tsp/src/eucledianDmatrix.h b/src/tsp/src/eucledianDmatrix.h
new file mode 100644
index 0000000..580aab5
--- /dev/null
+++ b/src/tsp/src/eucledianDmatrix.h
@@ -0,0 +1,124 @@
+/*PGR-GNU*****************************************************************
+
+FILE: eucledianDmatrix.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#ifndef SRC_TSP_SRC_EUCLEDIANDMATRIX_H_
+#define SRC_TSP_SRC_EUCLEDIANDMATRIX_H_
+#pragma once
+
+#include <iostream>
+#include <vector>
+
+#include "../../common/src/pgr_types.h"
+
+namespace pgrouting {
+namespace tsp {
+
+class Tour;  // for tourCost
+
+class eucledianDmatrix {
+ public:
+    eucledianDmatrix() = default;
+    explicit eucledianDmatrix(
+            const std::vector< Coordinate_t > &data_coordinates);
+
+    bool has_no_infinity() const;
+    bool obeys_triangle_inequality() const;
+    bool is_symmetric() const;
+
+    /*! @brief sets a special value for the distance(i,j)
+     *
+     * @param[in] i - index in matrix
+     * @param[in] j - index in matrix
+     * @param[in] dist - distance from i to j & from j to i
+     *
+     */
+    void set(size_t i, size_t j, double dist) {
+        row = i; column = j; special_distance = dist;}
+
+    /*! @brief original id -> true
+     *
+     * @param[in] id  original id
+     *
+     * @returns true if id is in the distance table
+     */
+    bool has_id(int64_t id) const;
+
+    /*! @brief original id -> idx
+     *
+     * @param[in] id - original id
+     * @returns idx index of the id in the distance table
+     */
+    size_t get_index(int64_t id) const;
+
+    /*! @brief idx -> original id
+     *
+     * @param[in] idx - index (i-th coordinate)
+     * @returns the original id corresponding to idx
+     */
+    int64_t get_id(size_t idx) const;
+
+    /*! @brief |idx|
+     *
+     * @returns the total number of coordinates
+     */
+    size_t size() const {return ids.size();}
+
+    /*! @brief tour evaluation
+     *
+     * @param[in] tour
+     * @returns total cost of traversing the tour
+     */
+    double tourCost(const Tour &tour) const;
+
+    /*! @brief returns a row of distances
+     *
+     * @param[in] idx  row index
+     *
+     * @returns distances from idx to all other coordinates
+     */
+    const std::vector<double> get_row(size_t idx) const;
+
+    double comparable_distance(size_t i, size_t j) const;
+    double distance(size_t i, size_t j) const;
+
+    friend std::ostream& operator<<(
+            std::ostream &log,
+            const eucledianDmatrix &matrix);
+
+ protected:
+    void set_ids();
+    std::vector<int64_t> ids;
+
+ private:
+    std::vector < Coordinate_t >  coordinates;
+    size_t row;
+    size_t column;
+    double special_distance;
+};
+
+}  // namespace tsp
+}  // namespace pgrouting
+
+#endif  // SRC_TSP_SRC_EUCLEDIANDMATRIX_H_
diff --git a/src/tsp/src/xyd_tsp.c b/src/tsp/src/eucledianTSP.c
similarity index 61%
copy from src/tsp/src/xyd_tsp.c
copy to src/tsp/src/eucledianTSP.c
index 9ba3641..434f49f 100644
--- a/src/tsp/src/xyd_tsp.c
+++ b/src/tsp/src/eucledianTSP.c
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: xyz_tsp.c
+File: eucledianTSP.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
@@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-********************************************************************PGR-GNU*/
+ ********************************************************************PGR-GNU*/
 
 #include "postgres.h"
 #include "executor/spi.h"
@@ -35,79 +35,124 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
+#include "fmgr.h"
 
-// #define DEBUG
+#define DEBUG
 
-#include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
+#include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
-#include "./distances_input.h"
-#include "./tsp_driver.h"
+#include "./../../common/src/coordinates_input.h"
+#include "./eucledianTSP_driver.h"
 
-// #include "./one_to_one_dijkstra_driver.h"
 
 
-PG_FUNCTION_INFO_V1(xyd_tsp);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum eucledianTSP(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
 static
 void
 process(
-        char* distances_sql,
+        char* coordinates_sql,
         int64_t start_vid,
         int64_t end_vid,
+
+        double time_limit,
+
+        int64_t tries_per_temperature,
+        int64_t max_changes_per_temperature,
+        int64_t max_consecutive_non_changes,
+
+        double initial_temperature,
+        double final_temperature,
+        double cooling_factor,
+
+        bool randomize,
+
         General_path_element_t **result_tuples,
         size_t *result_count) {
     pgr_SPI_connect();
 
-    PGR_DBG("Load data");
-    Matrix_cell_t *distances = NULL;
-    size_t total_distances = 0;
-    pgr_get_distances(distances_sql, &distances, &total_distances);
+    /*
+     * errors in parameters
+     */
+    if (initial_temperature < final_temperature) {
+        elog(ERROR, "Condition not met: initial_temperature > final_temperature");
+    }
+    if (final_temperature <= 0) {
+        elog(ERROR, "Condition not met: final_temperature > 0");
+    }
+    if (cooling_factor <=0 || cooling_factor >=1) {
+        elog(ERROR, "Condition not met: 0 < cooling_factor < 1");
+    }
+    if (tries_per_temperature < 0) {
+        elog(ERROR, "Condition not met: tries_per_temperature >= 0");
+    }
+    if (max_changes_per_temperature  < 1) {
+        elog(ERROR, "Condition not met: max_changes_per_temperature > 0");
+    }
+    if (max_consecutive_non_changes < 1) {
+        elog(ERROR, "Condition not met: max_consecutive_non_changes > 0");
+    }
+    if (time_limit < 0) {
+        elog(ERROR, "Condition not met: max_processing_time >= 0");
+    }
 
-    if (total_distances == 0) {
-        PGR_DBG("No distances found");
+
+    Coordinate_t *coordinates = NULL;
+    size_t total_coordinates = 0;
+    pgr_get_coordinates(coordinates_sql, &coordinates, &total_coordinates);
+
+    if (total_coordinates == 0) {
+        PGR_DBG("No coordinates found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_distances);
 
-    PGR_DBG("Starting processing");
     char *err_msg = NULL;
-    do_pgr_tsp(
-            distances,
-            total_distances,
+    char *log_msg = NULL;
+    clock_t start_t = clock();
+    do_pgr_eucledianTSP(
+            coordinates,
+            total_coordinates,
             start_vid,
             end_vid,
+            initial_temperature,
+            final_temperature,
+            cooling_factor,
+            tries_per_temperature,
+            max_changes_per_temperature,
+            max_consecutive_non_changes,
+            randomize,
+            time_limit,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
-    PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    time_msg(" processing eucledianTSP", start_t, clock());
+    if (log_msg) {
+        elog(NOTICE, "%s", log_msg);
+        free(log_msg);
+    }
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
 
-    free(err_msg);
-    pfree(distances);
+    pfree(coordinates);
     pgr_SPI_finish();
 }
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(eucledianTSP);
 PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS) {
+eucledianTSP(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
     uint32_t               max_calls;
@@ -116,7 +161,7 @@ xyd_tsp(PG_FUNCTION_ARGS) {
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t  *result_tuples = NULL;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
@@ -129,20 +174,44 @@ xyd_tsp(PG_FUNCTION_ARGS) {
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text,
-        // start_vid BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+        /*
+
+           CREATE OR REPLACE FUNCTION pgr_eucledianTSP(
+           coordinates_sql TEXT,
+           start_id BIGINT DEFAULT 0,
+           end_id BIGINT DEFAULT 0,
+
+           max_processing_time FLOAT DEFAULT '+infinity'::FLOAT,
+
+           tries_per_temperature INTEGER DEFAULT 500,
+           max_changes_per_temperature INTEGER DEFAULT 60,
+           max_consecutive_non_changes INTEGER DEFAULT 200,
+
+           initial_temperature FLOAT DEFAULT 100,
+           final_temperature FLOAT DEFAULT 0.1,
+           cooling_factor FLOAT DEFAULT 0.9,
+
+           randomize BOOLEAN DEFAULT true,
+           */
 
-        PGR_DBG("Calling process");
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
                 PG_GETARG_INT64(1),
                 PG_GETARG_INT64(2),
+
+                PG_GETARG_FLOAT8(3),
+
+                PG_GETARG_INT32(4),
+                PG_GETARG_INT32(5),
+                PG_GETARG_INT32(6),
+
+                PG_GETARG_FLOAT8(7),
+                PG_GETARG_FLOAT8(8),
+                PG_GETARG_FLOAT8(9),
+
+                PG_GETARG_BOOL(10),
                 &result_tuples,
                 &result_count);
-
         /*                                                                    */
         /**********************************************************************/
 
diff --git a/src/tsp/src/eucledianTSP_driver.cpp b/src/tsp/src/eucledianTSP_driver.cpp
new file mode 100644
index 0000000..e118e5c
--- /dev/null
+++ b/src/tsp/src/eucledianTSP_driver.cpp
@@ -0,0 +1,207 @@
+/* PGR-GNU*****************************************************************
+ * File: eucledianTSP_driver.cpp
+ *
+ * Generated with Template by:
+ * Copyright (c) 2015 pgRouting developers
+ * Mail: project at pgrouting.org
+ *
+ * Function's developer:
+ * Copyright (c) 2015 Celia Virginia Vergara Castillo
+ * Mail: vicky_vergara at hotmail.com
+ *
+ * ------
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *  ******************************************************************** PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <string.h>
+#include <sstream>
+#include <vector>
+#include <algorithm>
+
+#include "./eucledianTSP_driver.h"
+#include "./eucledianDmatrix.h"
+
+#include "./pgr_tsp.hpp"
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_alloc.hpp"
+
+void
+do_pgr_eucledianTSP(
+        Coordinate_t *coordinates_data,
+        size_t total_coordinates,
+        int64_t start_vid,
+        int64_t end_vid,
+
+        double initial_temperature,
+        double final_temperature,
+        double cooling_factor,
+        int64_t tries_per_temperature,
+        int64_t max_changes_per_temperature,
+        int64_t max_consecutive_non_changes,
+        bool randomize,
+        double time_limit,
+
+        General_path_element_t **return_tuples,
+        size_t *return_count,
+        char **log_msg,
+        char **err_msg) {
+    std::ostringstream err;
+    std::ostringstream log;
+
+    try {
+        std::vector< Coordinate_t > coordinates(
+                coordinates_data,
+                coordinates_data + total_coordinates);
+
+        pgrouting::tsp::eucledianDmatrix costs(coordinates);
+
+        double real_cost = -1;
+
+        size_t idx_start = costs.has_id(start_vid) ?
+            costs.get_index(start_vid) : 0;
+
+        size_t idx_end = costs.has_id(end_vid) ?
+            costs.get_index(end_vid) : 0;
+
+        if (costs.has_id(start_vid) && costs.has_id(end_vid) && start_vid != end_vid) {
+            /* An ending vertex needs to be by the starting vertex */
+            real_cost = costs.distance(idx_start, idx_end);
+            costs.set(idx_start, idx_end, 0);
+        }
+
+
+        log << "pgr_eucledianTSP Processing Information \nInitializing tsp class --->";
+        pgrouting::tsp::TSP<pgrouting::tsp::eucledianDmatrix> tsp(costs);
+
+
+        log << " tsp.greedyInitial --->";
+        tsp.greedyInitial(idx_start);
+
+
+
+        log << " tsp.annealing --->";
+        tsp.annealing(
+                initial_temperature,
+                final_temperature,
+                cooling_factor,
+                tries_per_temperature,
+                max_changes_per_temperature,
+                max_consecutive_non_changes,
+                randomize,
+                time_limit);
+        log << " OK\n";
+        log << tsp.get_log();
+        log << tsp.get_stats();
+
+        auto bestTour(tsp.get_tour());
+
+        if (costs.has_id(start_vid) && costs.has_id(end_vid) && start_vid != end_vid) {
+            costs.set(idx_start, idx_end, real_cost);
+        }
+
+        log << "\nBest cost reached = " << costs.tourCost(bestTour);
+
+        auto start_ptr = std::find(
+                bestTour.cities.begin(),
+                bestTour.cities.end(),
+                idx_start);
+
+        std::rotate(
+                bestTour.cities.begin(),
+                start_ptr,
+                bestTour.cities.end());
+
+        if (costs.has_id(start_vid) && costs.has_id(end_vid) && start_vid != end_vid) {
+            if (*(bestTour.cities.begin() + 1) == idx_end) {
+                std::reverse(
+                        bestTour.cities.begin() + 1,
+                        bestTour.cities.end());
+            }
+        }
+
+
+        std::vector< General_path_element_t > result;
+        result.reserve(bestTour.cities.size() + 1);
+        pgassert(bestTour.cities.size() == costs.size());
+
+        bestTour.cities.push_back(bestTour.cities.front());
+
+        auto prev_id = bestTour.cities.front();
+        double agg_cost = 0;
+        for (const auto &id : bestTour.cities) {
+            if (id == prev_id) continue;
+            General_path_element_t data;
+            data.node = costs.get_id(prev_id);
+            data.edge = prev_id;
+            data.cost = costs.distance(prev_id, id);
+            data.agg_cost = agg_cost;
+            result.push_back(data);
+            agg_cost += data.cost;
+            prev_id = id;
+        }
+
+        /* inserting the returning to starting point */
+        {
+            General_path_element_t data;
+            data.node = costs.get_id(bestTour.cities.front());
+            data.edge = bestTour.cities.front();
+            data.cost = costs.distance(prev_id, bestTour.cities.front());
+            agg_cost += data.cost;
+            data.agg_cost = agg_cost;
+            result.push_back(data);
+        }
+
+        pgassert(result.size() == bestTour.cities.size());
+        *return_count = bestTour.size();
+        (*return_tuples) = pgr_alloc(result.size(), (*return_tuples));
+
+        /* store the results */
+        int seq = 0;
+        for (const auto &row : result) {
+            (*return_tuples)[seq] = row;
+            ++seq;
+        }
+
+        *log_msg = strdup(log.str().c_str());
+        (*err_msg) = NULL;
+        return;
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    }
+}
diff --git a/src/tsp/src/tsp_driver.h b/src/tsp/src/eucledianTSP_driver.h
similarity index 73%
copy from src/tsp/src/tsp_driver.h
copy to src/tsp/src/eucledianTSP_driver.h
index 4ce69ff..a97abb0 100644
--- a/src/tsp/src/tsp_driver.h
+++ b/src/tsp/src/eucledianTSP_driver.h
@@ -27,25 +27,39 @@
  *
  *  ********************************************************************PGR-GNU*/
 
+#ifndef SRC_TSP_SRC_EUCLEDIANTSP_DRIVER_H_
+#define SRC_TSP_SRC_EUCLEDIANTSP_DRIVER_H_
+
 #pragma once
 
+#include "../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "../../common/src/pgr_types.h"
-
-int 
-do_pgr_tsp(
-        Matrix_cell_t *distances, size_t total_distances,
+void
+do_pgr_eucledianTSP(
+        Coordinate_t *coordinates, size_t total_coordinates,
         int64_t start_vid,
         int64_t end_vid,
+
+        double initial_temperature,
+        double final_temperature,
+        double cooling_factor,
+        int64_t tries_per_temperature,
+        int64_t max_changes_per_temperature,
+        int64_t max_consecutive_non_changes,
+        bool randomize,
+        double time_limit,
+
         General_path_element_t **results,
         size_t *total_results,
+        char **log_msg,
         char **err_msg);
 
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_TSP_SRC_EUCLEDIANTSP_DRIVER_H_
diff --git a/src/tsp/src/xyd_tsp.c b/src/tsp/src/newTSP.c
similarity index 64%
rename from src/tsp/src/xyd_tsp.c
rename to src/tsp/src/newTSP.c
index 9ba3641..072b501 100644
--- a/src/tsp/src/xyd_tsp.c
+++ b/src/tsp/src/newTSP.c
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
-File: xyz_tsp.c
+File: newTSP.c
 
 Generated with Template by:
 Copyright (c) 2015 pgRouting developers
@@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-********************************************************************PGR-GNU*/
+ ********************************************************************PGR-GNU*/
 
 #include "postgres.h"
 #include "executor/spi.h"
@@ -35,26 +35,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
+#include "fmgr.h"
 
-// #define DEBUG
+#define DEBUG
 
-#include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
+#include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
-#include "./distances_input.h"
-#include "./tsp_driver.h"
+#include "./../../common/src/matrixRows_input.h"
+#include "./newTSP_driver.h"
 
-// #include "./one_to_one_dijkstra_driver.h"
 
 
-PG_FUNCTION_INFO_V1(xyd_tsp);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum newTSP(PG_FUNCTION_ARGS);
 
 /******************************************************************************/
 /*                          MODIFY AS NEEDED                                  */
@@ -64,14 +58,53 @@ process(
         char* distances_sql,
         int64_t start_vid,
         int64_t end_vid,
+
+        double time_limit,
+
+        int64_t tries_per_temperature,
+        int64_t max_changes_per_temperature,
+        int64_t max_consecutive_non_changes,
+
+        double initial_temperature,
+        double final_temperature,
+        double cooling_factor,
+
+        bool randomize,
+
         General_path_element_t **result_tuples,
         size_t *result_count) {
     pgr_SPI_connect();
 
-    PGR_DBG("Load data");
+    /*
+     * errors in parameters
+     */
+
+    if (initial_temperature < final_temperature) {
+        elog(ERROR, "Condition not met: initial_temperature > final_temperature");
+    }
+    if (final_temperature <= 0) {
+        elog(ERROR, "Condition not met: final_temperature > 0");
+    }
+    if (cooling_factor <=0 || cooling_factor >=1) {
+        elog(ERROR, "Condition not met: 0 < cooling_factor < 1");
+    }
+    if (tries_per_temperature < 0) {
+        elog(ERROR, "Condition not met: tries_per_temperature >= 0");
+    }
+    if (max_changes_per_temperature  < 1) {
+        elog(ERROR, "Condition not met: max_changes_per_temperature > 0");
+    }
+    if (max_consecutive_non_changes < 1) {
+        elog(ERROR, "Condition not met: max_consecutive_non_changes > 0");
+    }
+    if (time_limit < 0) {
+        elog(ERROR, "Condition not met: max_processing_time >= 0");
+    }
+
+
     Matrix_cell_t *distances = NULL;
     size_t total_distances = 0;
-    pgr_get_distances(distances_sql, &distances, &total_distances);
+    pgr_get_matrixRows(distances_sql, &distances, &total_distances);
 
     if (total_distances == 0) {
         PGR_DBG("No distances found");
@@ -80,34 +113,47 @@ process(
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_distances);
 
-    PGR_DBG("Starting processing");
     char *err_msg = NULL;
+    char *log_msg = NULL;
+    clock_t start_t = clock();
     do_pgr_tsp(
             distances,
             total_distances,
             start_vid,
             end_vid,
+            initial_temperature,
+            final_temperature,
+            cooling_factor,
+            tries_per_temperature,
+            max_changes_per_temperature,
+            max_consecutive_non_changes,
+            randomize,
+            time_limit,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
-    PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    time_msg(" processing eucledianTSP", start_t, clock());
+    if (log_msg) {
+        elog(NOTICE, "%s", log_msg);
+        free(log_msg);
+    }
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
 
-    free(err_msg);
     pfree(distances);
     pgr_SPI_finish();
 }
 /*                                                                            */
 /******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(newTSP);
 PGDLLEXPORT Datum
-#endif
-xyd_tsp(PG_FUNCTION_ARGS) {
+newTSP(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
     uint32_t               max_calls;
@@ -116,7 +162,7 @@ xyd_tsp(PG_FUNCTION_ARGS) {
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
     /*                                                                        */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t  *result_tuples = NULL;
     size_t result_count = 0;
     /*                                                                        */
     /**************************************************************************/
@@ -129,20 +175,44 @@ xyd_tsp(PG_FUNCTION_ARGS) {
 
         /**********************************************************************/
         /*                          MODIFY AS NEEDED                          */
-        // CREATE OR REPLACE FUNCTION pgr_dijkstra(
-        // sql text,
-        // start_vid BIGINT,
-        // end_vid BIGINT,
-        // directed BOOLEAN default true,
+        /*
+
+           CREATE OR REPLACE FUNCTION pgr_newTSP(
+           matrix_row_sql TEXT,
+           start_id BIGINT DEFAULT 0,
+           end_id BIGINT DEFAULT 0,
+
+           max_processing_time FLOAT DEFAULT '+infinity'::FLOAT,
+
+           tries_per_temperature INTEGER DEFAULT 500,
+           max_changes_per_temperature INTEGER DEFAULT 60,
+           max_consecutive_non_changes INTEGER DEFAULT 200,
+
+           initial_temperature FLOAT DEFAULT 100,
+           final_temperature FLOAT DEFAULT 0.1,
+           cooling_factor FLOAT DEFAULT 0.9,
+
+           randomize BOOLEAN DEFAULT true,
+           */
 
-        PGR_DBG("Calling process");
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
                 PG_GETARG_INT64(1),
                 PG_GETARG_INT64(2),
+
+                PG_GETARG_FLOAT8(3),
+
+                PG_GETARG_INT32(4),
+                PG_GETARG_INT32(5),
+                PG_GETARG_INT32(6),
+
+                PG_GETARG_FLOAT8(7),
+                PG_GETARG_FLOAT8(8),
+                PG_GETARG_FLOAT8(9),
+
+                PG_GETARG_BOOL(10),
                 &result_tuples,
                 &result_count);
-
         /*                                                                    */
         /**********************************************************************/
 
diff --git a/src/tsp/src/newTSP_driver.cpp b/src/tsp/src/newTSP_driver.cpp
new file mode 100644
index 0000000..239baa6
--- /dev/null
+++ b/src/tsp/src/newTSP_driver.cpp
@@ -0,0 +1,223 @@
+/* PGR-GNU*****************************************************************
+ * File: newTSP_driver.cpp
+ *
+ * Generated with Template by:
+ * Copyright (c) 2015 pgRouting developers
+ * Mail: project at pgrouting.org
+ *
+ * Function's developer:
+ * Copyright (c) 2015 Celia Virginia Vergara Castillo
+ * Mail: vicky_vergara at hotmail.com
+ *
+ * ------
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *  ******************************************************************** PGR-GNU*/
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+
+#include <string.h>
+#include <sstream>
+#include <vector>
+#include <algorithm>
+
+#include "./newTSP_driver.h"
+#include "./Dmatrix.h"
+
+#include "./pgr_tsp.hpp"
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_alloc.hpp"
+
+void
+do_pgr_tsp(
+        Matrix_cell_t *distances,
+        size_t total_distances,
+        int64_t start_vid,
+        int64_t end_vid,
+
+        double initial_temperature,
+        double final_temperature,
+        double cooling_factor,
+        int64_t tries_per_temperature,
+        int64_t max_changes_per_temperature,
+        int64_t max_consecutive_non_changes,
+        bool randomize,
+        double time_limit,
+
+        General_path_element_t **return_tuples,
+        size_t *return_count,
+        char **log_msg,
+        char **err_msg) {
+    std::ostringstream err;
+    std::ostringstream log;
+
+    try {
+        std::vector < Matrix_cell_t > data_costs(
+                distances,
+                distances + total_distances);
+
+        pgrouting::tsp::Dmatrix costs(data_costs);
+
+        if (!costs.has_no_infinity()) {
+            err << "An Infinity value was found on the Matrix";
+            *err_msg = strdup(err.str().c_str());
+            *log_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        if (!costs.is_symmetric()) {
+            err << "A Non symmetric Matrix was given as input";
+            *err_msg = strdup(err.str().c_str());
+            *log_msg = strdup(log.str().c_str());
+            return;
+        }
+
+        double real_cost = -1;
+
+        size_t idx_start = costs.has_id(start_vid) ?
+            costs.get_index(start_vid) : 0;
+
+        size_t idx_end = costs.has_id(end_vid) ?
+            costs.get_index(end_vid) : 0;
+
+        if (costs.has_id(start_vid) && costs.has_id(end_vid) && start_vid != end_vid) {
+            /* An ending vertex needs to be by the starting vertex */
+            real_cost = costs.distance(idx_start, idx_end);
+            costs.set(idx_start, idx_end, 0);
+        }
+
+
+        log << "pgr_eucledianTSP Processing Information \nInitializing tsp class --->";
+        pgrouting::tsp::TSP<pgrouting::tsp::Dmatrix> tsp(costs);
+
+
+        log << " tsp.greedyInitial --->";
+        tsp.greedyInitial(idx_start);
+
+
+
+        log << " tsp.annealing --->";
+        tsp.annealing(
+                initial_temperature,
+                final_temperature,
+                cooling_factor,
+                tries_per_temperature,
+                max_changes_per_temperature,
+                max_consecutive_non_changes,
+                randomize,
+                time_limit);
+        log << " OK\n";
+        log << tsp.get_log();
+        log << tsp.get_stats();
+
+        auto bestTour(tsp.get_tour());
+
+        if (costs.has_id(start_vid) && costs.has_id(end_vid) && start_vid != end_vid) {
+            costs.set(idx_start, idx_end, real_cost);
+        }
+
+
+        log << "\nBest cost reached = " << costs.tourCost(bestTour);
+
+        auto start_ptr = std::find(
+                bestTour.cities.begin(),
+                bestTour.cities.end(),
+                idx_start);
+
+
+        std::rotate(
+                bestTour.cities.begin(),
+                start_ptr,
+                bestTour.cities.end());
+
+        if (costs.has_id(start_vid) && costs.has_id(end_vid) && start_vid != end_vid) {
+            if (*(bestTour.cities.begin() + 1) == idx_end) {
+                std::reverse(
+                        bestTour.cities.begin() + 1,
+                        bestTour.cities.end());
+            }
+        }
+
+
+        std::vector< General_path_element_t > result;
+        result.reserve(bestTour.cities.size() + 1);
+        pgassert(bestTour.cities.size() == costs.size());
+
+        bestTour.cities.push_back(bestTour.cities.front());
+
+        auto prev_id = bestTour.cities.front();
+        double agg_cost = 0;
+        for (const auto &id : bestTour.cities) {
+            if (id == prev_id) continue;
+            General_path_element_t data;
+            data.node = costs.get_id(prev_id);
+            data.edge = prev_id;
+            data.cost = costs.distance(prev_id, id);
+            data.agg_cost = agg_cost;
+            result.push_back(data);
+            agg_cost += data.cost;
+            prev_id = id;
+        }
+
+        /* inserting the returning to starting point */
+        {
+            General_path_element_t data;
+            data.node = costs.get_id(bestTour.cities.front());
+            data.edge = bestTour.cities.front();
+            data.cost = costs.distance(prev_id, bestTour.cities.front());
+            agg_cost += data.cost;
+            data.agg_cost = agg_cost;
+            result.push_back(data);
+        }
+
+        pgassert(result.size() == bestTour.cities.size());
+        *return_count = bestTour.size();
+        (*return_tuples) = pgr_alloc(result.size(), (*return_tuples));
+
+        /* store the results */
+        int seq = 0;
+        for (const auto &row : result) {
+            (*return_tuples)[seq] = row;
+            ++seq;
+        }
+
+        *log_msg = strdup(log.str().c_str());
+        (*err_msg) = NULL;
+        return;
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(err.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    }
+}
diff --git a/src/tsp/src/tsp_driver.h b/src/tsp/src/newTSP_driver.h
similarity index 77%
rename from src/tsp/src/tsp_driver.h
rename to src/tsp/src/newTSP_driver.h
index 4ce69ff..82c6180 100644
--- a/src/tsp/src/tsp_driver.h
+++ b/src/tsp/src/newTSP_driver.h
@@ -27,25 +27,38 @@
  *
  *  ********************************************************************PGR-GNU*/
 
+#ifndef SRC_TSP_SRC_NEWTSP_DRIVER_H_
+#define SRC_TSP_SRC_NEWTSP_DRIVER_H_
 #pragma once
 
+#include "../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "../../common/src/pgr_types.h"
-
-int 
+void
 do_pgr_tsp(
         Matrix_cell_t *distances, size_t total_distances,
         int64_t start_vid,
         int64_t end_vid,
+
+        double initial_temperature,
+        double final_temperature,
+        double cooling_factor,
+        int64_t tries_per_temperature,
+        int64_t max_changes_per_temperature,
+        int64_t max_consecutive_non_changes,
+        bool randomize,
+        double time_limit,
+
         General_path_element_t **results,
         size_t *total_results,
+        char **log_msg,
         char **err_msg);
 
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_TSP_SRC_NEWTSP_DRIVER_H_
diff --git a/src/tsp/src/pgr_tsp.cpp b/src/tsp/src/pgr_tsp.cpp
index 204e0f8..f696a5f 100644
--- a/src/tsp/src/pgr_tsp.cpp
+++ b/src/tsp/src/pgr_tsp.cpp
@@ -1,5 +1,5 @@
 /*PGR-GNU*****************************************************************
- * File: tsp_driver.cpp
+ * File: pgr_tsp.cpp
  *
  * Generated with Template by:
  * Copyright (c) 2015 pgRouting developers
@@ -27,355 +27,535 @@
  *
  *  ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
+#undef min
+#undef max
 #endif
 
+#include "./pgr_tsp.hpp"
 
+#include <time.h>
 
+#include <iomanip>
+#include <limits>
 #include <vector>
+#include <set>
 #include <algorithm>
+#include <cmath>
 
 #include "../../common/src/pgr_types.h"
-#include "./pgr_tsp.hpp"
+#include "../../common/src/pgr_assert.h"
 
 
 
 static
 size_t
 rand(size_t n) {
-    return static_cast< size_t >(std::rand() * n);
+    pgassert(n > 0);
+    return static_cast< size_t >(std::rand() % n);
 }
 
 
 static
 size_t
 succ(size_t i, size_t n) {
+    pgassert(n > 0);
     return static_cast<size_t>((i + 1) % n);
 }
 
 static
 size_t
-MOD(size_t i, size_t n) {
-#if 1
-return succ(i, n);
-#else
-return  ((i) % (n) > 0 ? (i) % (n) : (i) % (n) + (n));
-#endif
+pred(size_t i, size_t n) {
+    return  i == 0? n - 1: i -1;
 }
 
-double
-TSP::D(size_t i, size_t j) {
-    return dist[i][j];
+
+namespace pgrouting {
+namespace tsp {
+
+template < typename MATRIX >
+void TSP<MATRIX>::invariant() const {
+    /* the calculated value & the actual value are the same */
+    pgassert(std::fabs(tourCost(current_tour) - current_cost) < epsilon);
+    pgassert(std::fabs(tourCost(best_tour) - bestCost) < epsilon);
+    pgassert(n == MATRIX::ids.size());
+    pgassert(n == current_tour.size());
+    pgassert(n == best_tour.size());
 }
 
+template < typename MATRIX >
 void
-TSP::update(Ids new_order) {
-    auto blength = dist.pathCost(new_order);
-    if (bestCost < blength) {
-        border = new_order;
-        bestCost = blength;
+TSP<MATRIX>::update_if_best() {
+    invariant();
+    ++updatecalls;
+
+    if (current_cost < bestCost) {
+        ++improve_count;
+        best_tour = current_tour;
+        bestCost = current_cost;
     }
+
+    invariant();
 }
 
-/*
- * Prim's approximated TSP tour
- * See also [Cristophides'92]
- */
-bool
-TSP::findEulerianPath() {
-    Ids iorder(n);
-    Ids mst(n);
-    Ids arc(n);
-    std::vector < double > dis(n);
-    double d;
-#if 0
-    int n, *iorder, *jorder;
-    DTYPE d;
-    DTYPE maxd;
-    DTYPE *dist;
-    DTYPE *dis;
-
-    jorder = tsp->jorder;
-    iorder = tsp->iorder;
-    dist   = tsp->dist;
-    maxd   = tsp->maxd;
-    n      = tsp->n;
-
-    if (!(mst = (int*) palloc(n * sizeof(int))) ||
-            !(arc = (int*) palloc(n * sizeof(int))) ||
-            !(dis = (DTYPE*) palloc(n * sizeof(DTYPE))) )
-    {
-        elog(ERROR, "Failed to allocate memory!");
-        return -1;
+
+
+template < typename MATRIX >
+size_t
+TSP<MATRIX>::find_closest_city(
+        size_t current_city,
+        const std::set<size_t> inserted) const {
+    invariant();
+
+    auto distance_row(get_row(current_city));
+    pgassert(distance_row.size() == n);
+
+#ifndef NDEBUG
+    std::ostringstream err;
+    for (const auto &d : distance_row) {
+        err  << d << ", ";
     }
 #endif
-    // PGR_DBG("findEulerianPath: 1");
-
-    size_t j(0);
-    double curr_maxd = maxd;
-    dis[0] = -1;
-
-    for (size_t i = 1; i < n; ++i) {
-        dis[i] = dist[i][0];
-        arc[i] = 0;
-        if (curr_maxd > dis[i]) {
-            curr_maxd = dis[i];
-            j = i;
-        }
-    }
-    //PGR_DBG("findEulerianPath: j=%d", j);
 
-    if (curr_maxd == maxd) {
-        // PGR_DBG("Error TSP fail to findEulerianPath, check your distance matrix is valid.");
-        return false;
-    }
+    size_t best_city = 0;
+    auto best_distance = std::numeric_limits<double>::max();
+#ifndef NDEBUG
+    bool found(false);
+#endif
 
-    /*
-     * O(n^2) Minimum Spanning Trees by Prim and Jarnick 
-     * for graphs with adjacency matrix. 
-     */
-    for (size_t a = 0; a < n - 1; a++) {
-        size_t k(0);
-        mst[a] = j * n + arc[j]; /* join fragment j with MST */
-        dis[j] = -1; 
-        d = maxd;
-        for (size_t i = 0; i < n; i++)
-        {
-            if (dis[i] >= 0) /* not connected yet */
-            {
-                if (dis[i] > dist[i][j])
-                {
-                    dis[i] = dist[i][j];
-                    arc[i] = j;
-                }
-                if (d > dis[i])
-                {
-                    d = dis[i];
-                    k = i;
-                }
-            }
+    for (size_t i = 0; i < distance_row.size(); ++i) {
+        if (i == current_city) continue;
+        if (inserted.find(i) != inserted.end()) continue;
+        if (distance_row[i] <  best_distance) {
+            best_city = i;
+            best_distance = distance_row[i];
+#ifndef NDEBUG
+            found = true;
+#endif
         }
-        j = k;
     }
-    //PGR_DBG("findEulerianPath: 3");
+    pgassertwm(found, err.str());
 
-    /*
-     * Preorder Tour of MST
-     */
-#if 0
-#define VISITED(x) jorder[x]
-#define NQ(x) arc[l++] = x
-#define DQ()  arc[--l]
-#define EMPTY (l==0)
+    invariant();
+    return best_city;
+}
+
+
+
+template < typename MATRIX >
+void
+TSP<MATRIX>::greedyInitial(size_t idx_start) {
+    invariant();
+
+    std::set<size_t> pending(best_tour.cities.begin(), best_tour.cities.end());
+    std::set<size_t> inserted;
+    std::vector<size_t> tour_to_be;
+
+    auto current_city = idx_start;
+
+#ifndef NDEBUG
+    std::ostringstream err;
+    auto ps(pending.size());
 #endif
-    for (auto &val : jorder) {
-        val = 0;
-    }
 
-#if 0
-    for (i = 0; i < n; i++) VISITED(i) = 0;
+    pending.erase(idx_start);
+
+#ifndef NDEBUG
+    pgassert(pending.size() == (ps - 1));
 #endif
 
-    size_t l = 0;
-    size_t k = 0;
-    d = 0;
-    arc[l++] = 0;
-    while (!(l == 0)) {
-        size_t i = arc[--l];
-
-        if (!jorder[i]) {
-            iorder[k++] = i;
-            jorder[i]  = 1;            
-            /* push all kids of i */
-            for (size_t j = 0; j < n - 1; j++) {
-                if (i == mst[j] % n)
-                    arc[l++] = mst[j] % n; 
-            }
+    tour_to_be.push_back(current_city);
+    inserted.insert(current_city);
+
+    while (!pending.empty()) {
+        auto next_city = find_closest_city(current_city, inserted);
+        tour_to_be.push_back(next_city);
+        inserted.insert(next_city);
+
+#ifndef NDEBUG
+        auto ps(pending.size());
+        err << "before";
+        for (const auto p : pending) {
+            err << p << ",";
         }
-    }
+#endif
+
+        pending.erase(next_city);
 
-#if 0
-    k = 0; l = 0; d = 0; NQ(0);
-    while (!EMPTY)
-    {
-        i = DQ();
-        if (!VISITED(i))
-        {
-            iorder[k++] = i;
-            VISITED(i)  = 1;            
-            for (j = 0; j < n - 1; j++) /* push all kids of i */
-            {
-                if (i == mst[j]%n) NQ(mst[j]/n); 
-            }    
+#ifndef NDEBUG
+        err << "\nafter deleting" << next_city << ":\t";
+        for (const auto p : pending) {
+            err << p << ",";
         }
-    }
+        pgassertwm(pending.size() == (ps - 1), err.str());
 #endif
-    //PGR_DBG("findEulerianPath: 4");
 
-    update(iorder);
-    return true;
+        current_city = next_city;
+    }
+
+    pgassert(tour_to_be.size() == n);
+    current_tour = Tour(tour_to_be);
+    current_cost = tourCost(current_tour);
+    update_if_best();
+    swapClimb();
+
+    invariant();
+    return;
 }
 
+
+
 /*
- * Local Search Heuristics
- *  b-------a        b       a
- *  .       .   =>   .\     /.
- *  . d...e .        . e...d .  
- *  ./     \.        .       .
- *  c       f        c-------f
+ *
+ * 0 1 2 3 4 5 6 7 8 9
+ *     p   f     l
+ * slides [4,5,6] to position p
+ *
+ * 0 1 4 5 6 2 3 7 8 9
+ *
+ *
+ * 0 1 2 3 4 5 6 7 8 9
+ *     f     l     p
+ * slides [2,3,4] to position p
+ *
+ * 0 1 6 7 2 3 4 5 8 9
+ *
+ *
  */
 
+template < typename MATRIX >
 double
-TSP::getThreeWayCost(Path p) {
-    size_t a, b, c, d, e, f;
-
-    a = iorder[MOD(p[0] - 1, n)];
-    b = iorder[p[0]];
-    c = iorder[p[1]];
-    d = iorder[MOD(p[1] + 1, n)];
-    e = iorder[p[2]];
-    f = iorder[MOD(p[2] + 1, n)];
-
-    return (D(a,d) + D(e,b) + D(c,f) - D(a,b) - D(c,d) - D(e,f)); 
-    /* add cost between d and e if non symetric TSP */ 
-}
+TSP<MATRIX>::getDeltaSlide(size_t place, size_t first, size_t last) const {
+    invariant();
+#ifndef NDEBUG
+    std::ostringstream err;
+    err  << "\tplace" << place
+        << "\tfirst" << first
+        << "\tlast" << last
+        << "\tn" << n;
+#endif
 
-void
-TSP::doThreeWay(Path p) {
-    size_t count, m1, m2, m3, a, b, c, d, e, f;
-
-    a = MOD(p[0]-1,n);
-    b = p[0];
-    c = p[1];
-    d = MOD(p[1]+1,n);
-    e = p[2];
-    f = MOD(p[2]+1,n);    
-
-    m1 = MOD(n + c - b, n) + 1;  /* num cities from b to c */
-    m2 = MOD(n + a - f, n) + 1;  /* num cities from f to a */
-    m3 = MOD(n + e - d, n) + 1;  /* num cities from d to e */
-
-    count = 0;
-    /* [b..c] */
-    for (size_t i = 0; i < m1; i++)
-        jorder[count++] = iorder[MOD(i + b, n)];
-
-    /* [f..a] */
-    for (size_t i = 0; i < m2; i++)
-        jorder[count++] = iorder[MOD(i+f,n)];
-
-    /* [d..e] */
-    for (size_t i = 0; i < m3; i++)
-        jorder[count++] = iorder[MOD(i+d,n)];
-
-    /* copy segment back into iorder */
-    for (size_t i = 0; i < n; i++) iorder[i] = jorder[i];
+    pgassertwm(place < first || place > last, err.str());
+    pgassertwm(first < last, err.str());
+    pgassertwm(last < n, err.str());
+    pgassertwm(place < n, err.str());
+    pgassertwm(first < n, err.str());
+
+    /*
+     * Initial state
+     * [...f] [f+1 ... l] [l+1 ...p] [p+1 ...]
+     *
+     * final state
+     * [...f] [l+1 ... p] [f+1 ...l] [p+1 ...]
+     *
+     *
+     * Initial state
+     *   [f+1 ... l]
+     *     :      :
+     * [...f]   [l+1 ...p] [p+1 ...]
+     *
+     * final state
+     *               [f+1 ... l]
+     *                :       :
+     * [...f] [l+1 ...p]   [p+1 ...]
+     *
+     */
+
+    auto cityP = current_tour.cities[place];
+    auto cityF = current_tour.cities[first];
+    auto cityL = current_tour.cities[last];
+    auto cityP1 = current_tour.cities[succ(place, n)];
+    auto cityF1 = current_tour.cities[succ(first, n)];
+    auto cityL1 = current_tour.cities[succ(last, n)];
+
+    auto delta(
+            distance(cityF, cityL1)
+            + distance(cityP, cityF1)
+            + distance(cityL, cityP1)
+            - distance(cityF, cityF1)
+            - distance(cityL, cityL1)
+            - distance(cityP, cityP1));
+
+#ifndef NDEBUG
+    Tour new_tour(current_tour);
+    new_tour.slide(place, first, last);
+
+    err << "\ncurrent_tour:";
+    for (const auto id : current_tour.cities) {
+        err << id << ", ";
+    }
+
+    err << "\nnew_tour:";
+    for (const auto id : new_tour.cities) {
+        err << id << ", ";
+    }
+
+    auto exactDelta = tourCost(new_tour) - tourCost(current_tour);
+    err << "\n"
+        << exactDelta
+        << " - " <<  delta
+        << " = "
+        << exactDelta - delta
+        << " = "
+        << std::fabs(exactDelta - delta);
+    pgassertwm(std::fabs((exactDelta - delta)) < epsilon, err.str());
+#endif
+
+    invariant();
+    return delta;
 }
 
 
 /*
- *   c..b       c..b
- *    \/    =>  |  |
- *    /\        |  |
- *   a  d       a  d
+ *       c..d            c..d
+ *       |  |     =>     |  |
+ *       |  |            |  |
+ *  b -- a  e --f   b -- e  a -- f
  *
  *   a b 1  2   .. n-1 n c d
  *   a c n n-1  ..  2  1 c d
  */
+template < typename MATRIX >
 double
-TSP::getReverseCost(Path p) {
+TSP<MATRIX>::getDeltaSwap(size_t posA, size_t posE) const {
+    invariant();
+
+    if (succ(posE, n ) == posA) std::swap(posA, posE);
+    if (succ(posA, n) == posE) {
+        auto b = current_tour.cities[pred(posA, n)];
+        auto a = current_tour.cities[posA];
+
+        auto e = current_tour.cities[posE];
+        auto f = current_tour.cities[succ(posE, n)];
+        return distance(b, e) + distance(e, a) + distance(a, f)
+            - distance(b, a) - distance(a, e)  - distance(e, f);
+    }
 
-    auto a = iorder[MOD(p[0] - 1, n)];
-    auto b = iorder[p[0]];
-    auto c = iorder[p[1]];
-    auto d = iorder[MOD(p[1] + 1, n)];
+    auto b = current_tour.cities[pred(posA, n)];
+    auto a = current_tour.cities[posA];
+    auto c = current_tour.cities[succ(posA, n)];
+
+    auto d = current_tour.cities[pred(posE, n)];
+    auto e = current_tour.cities[posE];
+    auto f = current_tour.cities[succ(posE, n)];
+
+#ifndef NDEBUG
+    auto delta = distance(b, e) + distance(e, c) + distance(d, a) + distance(a, f)
+        - distance(b, a) - distance(a, c)  - distance(d, e) - distance(e, f);
+    auto new_tour(current_tour);
+    new_tour.swap(posA, posE);
+    auto exactDelta = tourCost(new_tour) - tourCost(current_tour);
+    std::ostringstream log;
+    log << exactDelta
+        << " - " <<  delta
+        << " = "
+        << exactDelta - delta
+        << " = "
+        << std::fabs(exactDelta - delta);
+
+    pgassertwm(std::fabs((exactDelta - delta)) < epsilon, log.str());
+#endif
 
-    return (D(d,b) + D(c,a) - D(a,b) - D(c,d));
-    /* add cost between c and b if non symetric TSP */ 
+    invariant();
+    return  distance(b, e) + distance(e, c) + distance(d, a) + distance(a, f)
+        - distance(b, a) - distance(a, c)  - distance(d, e) - distance(e, f);
 }
 
-void
-TSP::doReverse(Path p) {
-
-    /* reverse path b...c */
-    size_t nswaps = (MOD(p[1] - p[0], n) + 1) / 2;
-    for (size_t i = 0; i < nswaps; i++) {
-        size_t first = MOD(p[0]+i, n);
-        size_t last  = MOD(p[1]-i, n);
-        std::swap(iorder[first], iorder[last]);
-#if 0
-        tmp   = iorder[first];
-        iorder[first] = iorder[last];
-        iorder[last]  = tmp;
+/*
+ *   ..A                    C
+ *       [                    )
+ *   ..a  b 1  2   .. n-1 n c d ..
+ *   ..a  c n n-1  ..  2  1 b d ..
+ */
+template < typename MATRIX >
+double
+TSP<MATRIX>::getDeltaReverse(size_t posA, size_t posC) const {
+    invariant();
+
+    if (posA == (posC - 1)) return 0;
+    auto a = current_tour.cities[posA];
+    auto b = current_tour.cities[succ(posA, n)];
+
+    auto c = current_tour.cities[posC];
+    auto d = current_tour.cities[succ(posC, n)];
+
+
+#ifndef NDEBUG
+    auto delta = distance(a, c) + distance(b, d) - distance(a, b) - distance(c, d);
+    auto new_tour(current_tour);
+    new_tour.reverse(posA, posC);
+    auto exactDelta = tourCost(new_tour) - tourCost(current_tour);
+
+    std::ostringstream log;
+    log << "exactDelta(" << exactDelta
+        << ") - delta(" <<  delta
+        << ") = "
+        << exactDelta - delta
+        << " = "
+        << (exactDelta - delta)
+        << " epsilon = " << epsilon;
+    pgassertwm(std::fabs((exactDelta - delta)) < epsilon, log.str());
 #endif
-    }
+
+    invariant();
+    return  distance(a, c) + distance(b, d) - distance(a, b) - distance(c, d);
 }
 
+template < typename MATRIX >
+void
+TSP<MATRIX>::swapClimb() {
+    invariant();
+    pgassert(n > 2);
+
+    //    auto first = std::rand() % n;
+    //    for (size_t first = std::rand() % n; first < n; first++) {
+    for (size_t first = 0; first < n; first++) {
+        for (size_t last = first + 1; last < n; last++) {
+            pgassert(first < last);
+
+            auto energyChange = getDeltaSwap(first, last);
+
+            if (energyChange < 0 && epsilon < std::fabs(energyChange)) {
+                ++swap_count;
+                current_cost += energyChange;
+                current_tour.swap(first, last);
+                update_if_best();
+            }
+        }
+    }
+    invariant();
+}
 
+template < typename MATRIX >
 void
-TSP::annealing() {
-    Path   p;
-    size_t    numOnPath, numNotOnPath;
+TSP<MATRIX>::annealing(
+        double temperature,
+        double final_temperature,
+        double cooling_factor,
+        int64_t tries_per_temperature,
+        int64_t max_changes_per_temperature,
+        int64_t max_consecutive_non_changes,
+        bool randomize,
+        double time_limit) {
+    invariant();
+    clock_t start_time(clock());
+
+    if (randomize) {
+        std::srand(static_cast<unsigned int>(time(NULL)));
+    } else {
+        std::srand(1);
+    }
+
+
 
-    double pathCost(dist.pathCost(iorder));
-    const double T_INIT = 100.0;
-    const double FINAL_T = 0.1;
-    const double COOLING = 0.9; /* to lower down T (< 1) */
-    const size_t TRIES_PER_T(500 * n);
-    const size_t IMPROVED_PATH_PER_T = 60 * n;
 
     /* annealing schedule */
-    for (double T = T_INIT; FINAL_T < T; T *= COOLING) {
-        size_t pathchg = 0;
-        for (size_t j = 0; j < TRIES_PER_T; j++) {
-            do {
-                p[0] = rand(n);
-                p[1] = rand(n);
-                /* non-empty path */
-                if (p[0] == p[1]) 
-                    p[1] = MOD(p[0] + 1, n);
-
-                numOnPath = MOD(p[1] - p[0], n) + 1;
-                numNotOnPath = n - numOnPath;
-            } while (numOnPath < 2 || numNotOnPath < 2); /* non-empty path */
-
-            if (rand(2)) {
-                /*  threeWay */
-                do {
-                    p[2] = MOD(rand(numNotOnPath) + p[1] + 1, n);
-                } while (p[0] == MOD(p[2] + 1, n)); /* avoids a non-change */
-
-                auto energyChange = getThreeWayCost(p);
-                // if (energyChange < 0 || RREAL < exp(-energyChange / T) )
-                if (energyChange < 0 || std::rand() < exp(-energyChange / static_cast<double>(T)) ) {
-                    pathchg++;
-                    pathCost += energyChange;
-                    doThreeWay(p);
-                }
-
-            } else {
-                /* path Reverse */
-                auto energyChange = getReverseCost(p);
-                if (energyChange < 0 || std::rand() < exp(-energyChange / static_cast<double>(T)) ) {
-                    pathchg++;
-                    pathCost += energyChange;
-                    doReverse(p); 
-                }
-            }
-            // if the new length is better than best then save it as best
-            update(iorder);
-#if 0
-            if (pathlen < tsp->bestlen) {
-                tsp->bestlen = pathlen;
-                for (i=0; i<tsp->n; i++) tsp->border[i] = tsp->iorder[i];
+    for (; final_temperature < temperature; temperature *= cooling_factor) {
+        invariant();
+
+        log << "\nCycle(" << temperature <<") ";
+
+        /*
+           how many times the tour changed in current temperature
+           */
+        int64_t pathchg = 0;
+        size_t enchg = 0;
+        int64_t non_change = 0;
+        for (int64_t j = 0; j < tries_per_temperature; j++) {
+            ++non_change;
+
+            auto which = rand(2);
+            // which = 1;
+            switch (which) {
+                case 0: {
+                            /* reverse */
+                            pgassert(n > 2);
+
+                            auto c1 = std::rand() % n;
+                            auto c2 = std::rand() % n;
+
+                            if (c1 == c2) c2 = succ(c2, n);
+                            if (c1 == (c2 - 1)) c2 = succ(c2, n);
+                            if (c1 > c2) std::swap(c1, c2);
+
+                            pgassert(c1 != c2);
+                            pgassert(c1 < n && c2 < n);
+                            pgassert(c1 < c2);
+
+                            auto energyChange = getDeltaReverse(c1, c2);
+
+                            if ( (energyChange < 0 && epsilon < std::fabs(energyChange))
+                                    || (0 < energyChange
+                                        &&  (static_cast<double>(std::rand()) / static_cast<double>(RAND_MAX))  < exp(-energyChange / temperature))) {
+                                if (energyChange < 0) ++enchg;
+                                ++reverse_count;
+                                ++pathchg;
+                                non_change = 0;
+                                current_cost += energyChange;
+                                current_tour.reverse(c1, c2);
+                                update_if_best();
+                            }
+                        }
+                        break;
+                case 1: {
+                            /* slide */
+                            pgassert(n > 3);
+
+                            auto first = std::rand() % n;
+                            auto last = std::rand() % n;
+
+                            if (first == last) last = succ(last, n);
+                            if (first > last) std::swap(first, last);
+                            if (first == 0 && last == (n - 1)) {
+                                first = succ(first, n);
+                            }
+
+                            pgassert((n - (last - first) - 1) > 0);
+                            auto place = std::rand() % (n - (last - first) - 1);
+                            place = place < first?  place :
+                                last + (place - first) + 1;
+
+
+                            pgassert((place < first || place > last) && (first < last));
+
+                            auto energyChange = getDeltaSlide(place, first, last);
+
+                            if ((energyChange < 0 && epsilon < std::fabs(energyChange))
+                                    || (0 < energyChange
+                                        &&  (static_cast<double>(std::rand()) / static_cast<double>(RAND_MAX))  < exp(-energyChange / temperature))) {
+                                if (energyChange < 0) ++enchg;
+                                ++slide_count;
+                                ++pathchg;
+                                non_change = 0;
+                                current_cost += energyChange;
+                                current_tour.slide(place, first, last);
+                                update_if_best();
+                            }
+                        }
+                        break;
+            }  // switch
+
+
+            if (max_changes_per_temperature < pathchg
+                    && max_consecutive_non_changes < non_change ) {
+                break;
             }
-#endif
-            if (pathchg > IMPROVED_PATH_PER_T) break; /* finish early */
-        }   
-        // PGR_DBG("T:%f L:%f B:%f C:%d", T, pathlen, tsp->bestlen, pathchg);
+        }  // for tries per temperature
+
+        swapClimb();
+        clock_t current_time(clock());
+        double elapsed_time = static_cast<double>(current_time - start_time) / CLOCKS_PER_SEC;
+        if (time_limit < elapsed_time) {
+            break;
+        }
+        log << "\ttotal changes =" << pathchg
+            << "\t" << enchg << " were because  delta energy < 0";
         if (pathchg == 0) break;   /* if no change then quit */
-    }
+    }  // for temperatures
 }
 
+}  // namespace tsp
+}  // namespace pgrouting
+
diff --git a/src/tsp/src/pgr_tsp.hpp b/src/tsp/src/pgr_tsp.hpp
index 3697ee2..37cf422 100644
--- a/src/tsp/src/pgr_tsp.hpp
+++ b/src/tsp/src/pgr_tsp.hpp
@@ -26,68 +26,119 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  *  ********************************************************************PGR-GNU*/
+#pragma once
 
+#include <sstream>
 #include <vector>
+#include <set>
+#include <string>
 
 #include "../../common/src/pgr_types.h"
-#include "./Dmatrix.hpp"
+#include "../../common/src/pgr_assert.h"
+#include "./Dmatrix.h"
+#include "./eucledianDmatrix.h"
+#include "./tour.h"
 
-class TSP {
- public:
-/*
- * Defs
- */
-typedef size_t Path[3];      /* specify how to change path */
 
-typedef std::vector< std::vector < double > > Costs;
-typedef std::vector< int64_t > Ids;
-
-     Dmatrix dist;
-     size_t n;
-     double maxd;
-     size_t bestlen;
-     double bestCost;
-     Ids iorder;
-     /*
-      * std::vector< bool > visited;
-      */
-     Ids jorder;
-     Ids border;
-     double b[4];
+namespace pgrouting {
+namespace tsp {
 
+template < typename MATRIX >
+class TSP: public MATRIX {
+ public:
+     using MATRIX::distance;
+     using MATRIX::tourCost;
+     using MATRIX::get_row;
 
      /*
       * function members
       */
-     TSP(Dmatrix  _costs)
-         : dist(_costs),
-         n(_costs.size()) {
-             iorder.resize(n);
-             jorder.resize(n);
-             maxd = dist.max();
-
-             /*
-              * identity_permutations
-              */
-             std::iota(std::begin(iorder), std::end(iorder), 0);
-#if 0
-             for (auto &e : iorder) {
-                  e = i;
-             }
-#endif
-             /*
-              * best order
-              */
-             border = iorder;
-             bestCost = dist.pathCost(border);
+     explicit TSP(const MATRIX &_costs)
+         : MATRIX(_costs),
+         current_tour(_costs.size()),
+         best_tour(_costs.size()),
+         epsilon(0.000001),
+         n(_costs.size()),
+         updatecalls(0),
+         swap_count(0),
+         slide_count(0),
+         reverse_count(0),
+         improve_count(0) {
+             pgassert(n == MATRIX::size());
+             bestCost = MATRIX::tourCost(best_tour);
+             current_cost = MATRIX::tourCost(current_tour);
+             pgassert(bestCost == current_cost);
          }
-     void update(Ids new_order);
-     bool findEulerianPath();
-     void annealing();
-     void doThreeWay(Path p);
-     double getThreeWayCost (Path p);
-     double getReverseCost(Path p);
-     void doReverse(Path p);
-     double D(size_t, size_t);
+
+
+     Tour get_tour() const {return best_tour;}
+
+     std::string get_stats() const {
+         std::ostringstream log1;
+         log1
+             << "\nTotal swaps: " << swap_count
+             << "\nTotal slides: " << slide_count
+             << "\nTotal reverses: " << reverse_count
+             << "\nTimes best tour changed: " << improve_count;
+         return log1.str();}
+
+     std::string get_log() const {
+         return log.str();}
+
+     void greedyInitial(size_t idx_start = 0);
+     void annealing(
+             double initial_temperature,
+             double final_temperature,
+             double cooling_factor,
+             int64_t tries_per_temperature,
+             int64_t max_changes_per_temperature,
+             int64_t max_consecutive_non_changes,
+             bool randomize,
+             double time_limit);
+
+
+ private:
+     Tour current_tour;
+     Tour best_tour;
+     double bestCost;
+     double current_cost;
+     double epsilon;
+     size_t n;
+
+     int updatecalls;
+
+     std::ostringstream log;
+     size_t swap_count;
+     size_t slide_count;
+     size_t reverse_count;
+     size_t improve_count;
+
+ private:
+     void invariant() const;
+
+     size_t find_closest_city(
+             size_t current_city,
+             const std::set<size_t> inserted) const;
+
+     double getDeltaSlide(
+             size_t posP,
+             size_t posF,
+             size_t posL) const;
+
+     void swapClimb();
+
+     double getDeltaSwap(
+             size_t posA,
+             size_t posC) const;
+
+     double getDeltaReverse(
+             size_t posA,
+             size_t posC) const;
+
+     void update_if_best();
 };
 
+}  // namespace tsp
+}  // namespace pgrouting
+
+#include "pgr_tsp.cpp"
diff --git a/src/tsp/src/tour.cpp b/src/tsp/src/tour.cpp
new file mode 100644
index 0000000..b815203
--- /dev/null
+++ b/src/tsp/src/tour.cpp
@@ -0,0 +1,100 @@
+/*PGR-GNU*****************************************************************
+
+FILE:
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#include "./tour.h"
+
+#include <algorithm>
+
+#include "../../common/src/pgr_assert.h"
+
+
+namespace pgrouting {
+namespace tsp {
+
+std::ostream& operator<<(
+        std::ostream &log,
+        const Tour &tour) {
+    for (const auto &city : tour.cities) {
+        log << city << ", ";
+    }
+    return log;
+}
+
+
+
+void Tour::reverse(
+        size_t c1,
+        size_t c2) {
+    pgassert(c1 < c2 && c2 < cities.size());
+    std::reverse(
+            cities.begin() + (c1 + 1),
+            cities.begin() + (c2 + 1));
+}
+
+void Tour::slide(
+        size_t place,
+        size_t first,
+        size_t last) {
+    pgassert(first < cities.size());
+    pgassert(last  < cities.size());
+    pgassert(place < cities.size());
+
+    if (place < first) {
+        std::rotate(
+                cities.begin() + (place + 1),
+                cities.begin() + (first + 1),
+                cities.begin() + (last + 1));
+    } else {
+        std::rotate(
+                cities.begin() + (first + 1),
+                cities.begin() + (last + 1),
+                cities.begin() + (place + 1));
+    }
+}
+
+void Tour::rotate(
+        size_t c1,
+        size_t c2,
+        size_t c3) {
+    pgassert(c1 < c2 && c2 < c3 && c3 < cities.size());
+
+    std::rotate(
+            cities.begin() + (c1 + 1),
+            cities.begin() + (c2 + 1),
+            cities.begin() + (c3 + 1));
+}
+
+
+void Tour::swap(
+        size_t c1,
+        size_t c2 ) {
+    pgassert(c1 < c2);
+
+    std::iter_swap(cities.begin() + c1, cities.begin() + c2);
+}
+
+
+}  // namespace tsp
+}  // namespace pgrouting
diff --git a/src/tsp/src/tour.h b/src/tsp/src/tour.h
new file mode 100644
index 0000000..9b0e8a6
--- /dev/null
+++ b/src/tsp/src/tour.h
@@ -0,0 +1,160 @@
+/*PGR-GNU*****************************************************************
+
+FILE: tour.h
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+#ifndef SRC_TSP_SRC_TOUR_H_
+#define SRC_TSP_SRC_TOUR_H_
+#pragma once
+
+#include <stdlib.h>
+#include <algorithm>
+#include <numeric>
+#include <vector>
+
+#include "./Dmatrix.h"
+
+
+namespace pgrouting {
+namespace tsp {
+
+
+class Tour {
+ public:
+     Tour(const Tour &) = default;
+
+     explicit Tour(const std::vector<size_t> &cities_order) :
+         cities(cities_order) {
+     }
+
+     explicit Tour(size_t n) {
+         cities.resize(n);
+         std::iota(std::begin(cities), std::end(cities), 0);
+     }
+
+     inline size_t size() const {return cities.size();}
+
+     friend std::ostream& operator<<(
+             std::ostream &log,
+             const Tour &tour);
+
+
+     friend double Dmatrix::tourCost(const Tour &tour) const;
+
+
+     /* @brief slides range [first + 1, last + 1) into place + 1
+      *
+      * 0 1 2 3 4 5 6 7 8 9
+      *     p   f     l
+      * slides [4,5,6] to position p
+      *
+      * 0 1 4 5 6 2 3 7 8 9
+      *
+      *
+      * 0 1 2 3 4 5 6 7 8 9
+      *     f     l     p
+      * slides [2,3,4] to position p
+      *
+      * 0 1 6 7 2 3 4 5 8 9
+      *
+      * uses std::reverse
+      *
+      * http://en.cppreference.com/w/cpp/algorithm/rotate
+      *
+      * first    -   the beginning of the original range
+      * last     -   the end of the original range
+      * place    -   location where to slide
+      *
+      *
+      *
+      * @params[IN] place index of place
+      * @params[IN] first - index of first
+      * @params[IN] last - index of last
+      *
+      * precondition:
+      * pgassert(first < cities.size();
+      * pgassert(last  < cities.size();
+      * pgassert(place < cities.size();
+      *
+      */
+
+     void slide(
+             size_t place,
+             size_t first,
+             size_t last);
+
+
+     /* @brief std::reverse on the cities
+      *
+      * http://en.cppreference.com/w/cpp/algorithm/reverse
+      *
+      * first    -   the beginning of the original range
+      * last     -   the end of the original range
+      *
+      * @params[IN] c1 - index of first
+      * @params[IN] c2 - index of lasst
+      *
+      * precondition:
+      * pgassert(c1 < c2);
+      *
+      */
+
+     void reverse(
+             size_t c1,
+             size_t c2);
+
+
+     /* @brief std::rotate on the cities
+      *
+      * http://en.cppreference.com/w/cpp/algorithm/rotate
+      *
+      * first    -   the beginning of the original range
+      * n_first  -   the element that should appear at the beginning of the rotated range
+      * last     -   the end of the original range
+      *
+      * @params[IN] c1 - index of first
+      * @params[IN] c2 - index of n_first
+      * @params[IN] c3 - index of last
+      *
+      * precondition:
+      * pgassert(c2 && c2 < c3 && c3 < n);
+      *
+      */
+     void rotate(
+             size_t c1,
+             size_t c2,
+             size_t c3);
+
+
+     void swap(
+             size_t c1,
+             size_t c2);
+
+ public:
+     std::vector<size_t> cities;
+};
+
+}  // namespace tsp
+}  // namespace pgrouting
+
+#endif  // SRC_TSP_SRC_TOUR_H_
diff --git a/src/tsp/src/tsp.h b/src/tsp/src/tsp.h
index ec83eb2..5cb4481 100644
--- a/src/tsp/src/tsp.h
+++ b/src/tsp/src/tsp.h
@@ -22,27 +22,31 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
- 
-#define _TSP_H
+/*
+ * This code is deprecated
+ */
+
+#ifndef SRC_TSP_SRC_TSP_H_
+#define SRC_TSP_SRC_TSP_H_
 
 // define the type of object for the distance matrix
 #define DTYPE double
 
 #include "postgres.h"
-#include "../../common/src/pgr_types.h" 
+#include "../../common/src/pgr_types.h"
 
-typedef struct point
-{
+typedef struct point {
   int id;
   float8 x;
   float8 y;
 } point_t;
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
   int find_tsp_solution(int num, DTYPE *dist, int *p_ids, int source, int end, DTYPE *fit, char* err_msg);
 #ifdef __cplusplus
 }
 #endif
+
+#endif  // SRC_TSP_SRC_TSP_H_
diff --git a/src/tsp/src/tsp2.c b/src/tsp/src/tsp2.c
index e230956..188f99d 100644
--- a/src/tsp/src/tsp2.c
+++ b/src/tsp/src/tsp2.c
@@ -31,7 +31,11 @@ THE SOFTWARE.
 
 ********************************************************************PGR-MIT*/
 
-#include "tsp.h"
+/*
+ * This code is deprecated
+ */
+
+#include "./tsp.h"
 #include <math.h>
 
 #include "postgres.h"
@@ -45,28 +49,27 @@ THE SOFTWARE.
 
 #include "fmgr.h"
 
-#ifndef PG_MODULE_MAGIC
-PG_MODULE_MAGIC;
-#endif
+PGDLLEXPORT Datum tsp_matrix(PG_FUNCTION_ARGS);
 
 #undef DEBUG
-//#define DEBUG 1
 #include "../../common/src/debug_macro.h"
 
+#if 0
 #ifndef INFINITY
+#ifndef _MSC_VER
 #define INFINITY (1.0/0.0)
+#else  // _MSC_VER
+#define INFINITY (DBL_MAX + DBL_MAX);
+#endif  // _MSC_VER
+#endif
 #endif
 
 // The number of tuples to fetch from the SPI cursor at each iteration
 #define TUPLIMIT 1000
 
-PG_FUNCTION_INFO_V1(tsp_matrix);
-Datum
-tsp_matrix(PG_FUNCTION_ARGS);
 
-static DTYPE *get_pgarray(int *num, ArrayType *input)
-{
-    int         ndims, *dims; // , *lbs;
+static DTYPE *get_pgarray(int *num, ArrayType *input) {
+    int         ndims, *dims;  // , *lbs;
     bool       *nulls;
     Oid         i_eltype;
     int16       i_typlen;
@@ -82,7 +85,7 @@ static DTYPE *get_pgarray(int *num, ArrayType *input)
 
 
     /* validate input data type */
-    switch(i_eltype){
+    switch (i_eltype) {
     case INT2OID:
     case INT4OID:
     case FLOAT4OID:
@@ -109,8 +112,9 @@ static DTYPE *get_pgarray(int *num, ArrayType *input)
     PGR_DBG("get_pgarray: ndims=%d, n=%d", ndims, n);
 
 #ifdef DEBUG
-    for (i=0; i<ndims; i++) {
-        PGR_DBG("   dims[%d]=%d, lbs[%d]=%d", i, dims[i], i, lbs[i]);
+    for (i = 0; i < ndims; i++) {
+        // PGR_DBG("   dims[%d]=%d, lbs[%d]=%d", i, dims[i], i, lbs[i]);
+        PGR_DBG("   dims[%d]=%d", i, dims[i]);
     }
 #endif
 
@@ -120,12 +124,11 @@ static DTYPE *get_pgarray(int *num, ArrayType *input)
         elog(ERROR, "Error: Out of memory!");
     }
 
-    for (i=0; i<n; i++) {
+    for (i = 0; i < n; i++) {
         if (nulls[i]) {
-            data[i] = INFINITY;
-        }
-        else {
-            switch(i_eltype){
+            data[i] = (DTYPE) 0;
+        } else {
+            switch (i_eltype) {
                 case INT2OID:
                     data[i] = (DTYPE) DatumGetInt16(i_data[i]);
                     break;
@@ -145,8 +148,10 @@ static DTYPE *get_pgarray(int *num, ArrayType *input)
                that this will not work and you will get and error in
                findEulerianPath
             **********************************************************/
-            if (data[i] < 0)
-                data[i] = INFINITY;
+            if (data[i] < 0) {
+                data[i] = (DTYPE) 0;
+                nulls[i] = true;
+            }
         }
         PGR_DBG("    data[%d]=%.4f", i, data[i]);
     }
@@ -161,10 +166,9 @@ static DTYPE *get_pgarray(int *num, ArrayType *input)
 
 
 // macro to store distance values as matrix[num][num]
-#define D(i,j) matrix[(i)*num + j]
+#define D(i, j) matrix[(i) * num + j]
 
-static int solve_tsp(DTYPE *matrix, int num, int start, int end, int **results)
-{
+static int solve_tsp(DTYPE *matrix, int num, int start, int end, int **results) {
     int ret;
     int i;
     int *ids;
@@ -192,8 +196,8 @@ static int solve_tsp(DTYPE *matrix, int num, int start, int end, int **results)
     */
     if (end >= 0) {
         PGR_DBG("Updating start end costs");
-        D(start,end)=0.0;
-        D(end,start)=0.0;
+        D(start, end) = 0.0;
+        D(end, start) = 0.0;
     }
 
     PGR_DBG("Alloc ids");
@@ -203,7 +207,7 @@ static int solve_tsp(DTYPE *matrix, int num, int start, int end, int **results)
         elog(ERROR, "Error: Out of memory (solve_tsp)");
     }
 
-    for(i=0; i<num; i++) {
+    for (i = 0; i < num; i++) {
         ids[i] = i;
     }
 
@@ -226,9 +230,9 @@ static int solve_tsp(DTYPE *matrix, int num, int start, int end, int **results)
  *                             OUT seq int, OUT id int);
 */
 
-Datum
-tsp_matrix(PG_FUNCTION_ARGS)
-{
+PG_FUNCTION_INFO_V1(tsp_matrix);
+PGDLLEXPORT Datum
+tsp_matrix(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t                  call_cntr;
     uint32_t                  max_calls;
@@ -242,8 +246,8 @@ tsp_matrix(PG_FUNCTION_ARGS)
     /* stuff done only on the first call of the function */
     if (SRF_IS_FIRSTCALL()) {
         MemoryContext   oldcontext;
-        //int path_count;
-        int ret=-1;
+        // int path_count;
+        int ret = -1;
 
         /* create a function context for cross-call persistence */
         funcctx = SRF_FIRSTCALL_INIT();
@@ -254,8 +258,8 @@ tsp_matrix(PG_FUNCTION_ARGS)
         matrix = get_pgarray(&num, PG_GETARG_ARRAYTYPE_P(0));
 
         ret = solve_tsp(matrix, num,
-                        PG_GETARG_INT32(1), // start index
-                        PG_GETARG_INT32(2), // end  index 
+                        PG_GETARG_INT32(1),  // start index
+                        PG_GETARG_INT32(2),  // end  index
                         &tsp_res);
 
         pfree(matrix);
@@ -279,8 +283,8 @@ tsp_matrix(PG_FUNCTION_ARGS)
          * generate attribute metadata needed later to produce tuples from raw
          * C strings
          */
-        //attinmeta = TupleDescGetAttInMetadata(tuple_desc);
-        //funcctx->attinmeta = attinmeta;
+        // attinmeta = TupleDescGetAttInMetadata(tuple_desc);
+        // funcctx->attinmeta = attinmeta;
 
         MemoryContextSwitchTo(oldcontext);
     }
@@ -330,8 +334,7 @@ tsp_matrix(PG_FUNCTION_ARGS)
 
 
         SRF_RETURN_NEXT(funcctx, result);
-    }
-    else {   /* do when there is no more left */
+    } else {   /* do when there is no more left */
         PGR_DBG("Freeing tsp_res");
         free(tsp_res);
 
diff --git a/src/tsp/src/tsp_driver.cpp b/src/tsp/src/tsp_driver.cpp
deleted file mode 100644
index 8c8b422..0000000
--- a/src/tsp/src/tsp_driver.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*// PGR-GNU*****************************************************************
- * File: tspi_driver.cpp
- *
- * Generated with Template by:
- * Copyright (c) 2015 pgRouting developers
- * Mail: project at pgrouting.org
- *
- * Function's developer:
- * Copyright (c) 2015 Celia Virginia Vergara Castillo
- * Mail: vicky_vergara at hotmail.com
- *
- * ------
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *  ******************************************************************** PGR-GNU*/
-
-#ifdef __MINGW32__
-#include <winsock2.h>
-#include <windows.h>
-#endif
-
-
-#include <vector>
-#include <algorithm>
-
-#include "./tsp_driver.h"
-
-#include "./Dmatrix.hpp"
-#include "./pgr_tsp.hpp"
-/*
- * Defs
- */
-
-typedef std::vector< int64_t > Ids;
-
-int
-do_pgr_tsp(
-        Matrix_cell_t *distances,
-        size_t total_distances,
-        int64_t start_vid,
-        int64_t end_vid,
-        General_path_element_t **path,
-        size_t *total_results,
-        char **err_msg) {
-
-    std::vector < Matrix_cell_t > data_costs(distances, distances + total_distances);
-    Dmatrix costs(data_costs);
-
-    if (!costs.has_no_infinity()) {
-        return 5;
-    }
-    if (!costs.obeys_triangle_inequality()) {
-        return 6;
-    }
-    costs = costs.get_symetric();
-
-
-#if 0
-    int   i, j;
-    int   istart = 0;
-    int   jstart = 0;
-    int   iend = -1;
-    int   jend = -1;
-    int   rev = 0;
-    long  seed = -314159L;
-    size_t blength;
-#endif
-
-    // PGR_DBG("sizeof(long)=%d", (int)sizeof(long));
-
-#if 0
-    // moving forward
-    initRand(seed);
-#endif 
-
-    /* initialize tsp struct */
-    TSP tsp(costs);
-#if 0
-    tsp.n = num;
-    tsp.dist   = NULL;
-    tsp.iorder = NULL;
-    tsp.jorder = NULL;
-    tsp.border = NULL;
-
-
-    if (!(tsp.iorder = (int*) palloc (tsp.n * sizeof(int)))   ||
-            !(tsp.jorder = (int*) palloc (tsp.n * sizeof(int)))   ||
-            !(tsp.border = (int*) palloc (tsp.n * sizeof(int)))   ) {
-        elog(FATAL, "Memory allocation failed!");
-        return -1;
-    }
-
-    tsp.maxd = 0;
-    for (i=0; i<tsp.n*tsp.n; i++) {
-        tsp.maxd = MAX(tsp.maxd, cost[i]);
-    }
-
-    /* identity permutation */
-    for (i = 0; i < tsp.n; i++) tsp.iorder[i] = i;
-
-    tsp.bestlen = pathLength(&tsp);
-    for (i = 0; i < tsp.n; i++) tsp.border[i] = tsp.iorder[i];
-#endif
-
-    // PGR_DBG("Initial Path Length: %.4f", tsp.bestlen);
-
-    /*
-     * Set up first eulerian path iorder to be improved by
-     * simulated annealing.
-     */
-    if (!tsp.findEulerianPath())
-        return 8;
-
-#if 0
-    // this is done automatically in tsp.findEulerianPath call
-    blength = pathLength(&tsp);
-    if (blength < tsp.bestlen) {
-        tsp.bestlen = blength;
-        for (i = 0; i < tsp.n; i++) tsp.border[i] = tsp.iorder[i];
-    }
-#endif
-
-    // PGR_DBG("Approximated Path Length: %.4f", tsp.bestlen);
-
-    tsp.annealing();
-
-    *total_results = tsp.bestlen;
-    // PGR_DBG("Final Path Length: %.4f", tsp.bestlen);
-
-    tsp.iorder = tsp.border;
-#if 0
-    for (i=0; i<tsp.n; i++) tsp.iorder[i] = tsp.border[i];
-    // PGR_DBG("Best Path Length: %.4f", *total_len);
-#endif
-
-    // reorder ids[] with start as first
-
-#ifdef DEBUG
-    for (i=0; i<tsp.n; i++) {
-        // PGR_DBG("i: %d, ids[i]: %d, io[i]: %d, jo[i]: %d, jo[io[i]]: %d",
-        i, ids[i], tsp.iorder[i], tsp.jorder[i], tsp.jorder[tsp.iorder[i]]);
-    }
-#endif
-
-    size_t istart = costs.get_index(start_vid);
-    auto start_ptr = std::find(tsp.iorder.begin(), tsp.iorder.end(), istart);
-
-    /*
-     *  1 2 3 4 5 6 e s 7 8 9 
-     *  =>
-     *  s 7 8 9 1 2 3 4 5 6 e
-     */
-    Ids results(start_ptr, tsp.iorder.end());
-    std::copy(tsp.iorder.begin(), start_ptr, results.end());
-
-    std::vector< General_path_element_t > result;
-    result.reserve(tsp.iorder.size());
-    auto prev_id = tsp.iorder.front();
-    double agg_cost = 0;
-    for (const auto &id : tsp.iorder) {
-        General_path_element_t data;
-        data.node = costs.get_id(id);
-        data.cost   = id == prev_id? 0: costs[prev_id][id];
-        agg_cost += data.cost;
-        data.agg_cost = agg_cost;
-        result.push_back(data);
-    }
-
-    *path = static_cast<General_path_element_t *>(malloc(sizeof(General_path_element_t) * (result.size())));
-
-    //store the results
-    int seq = 0;
-    if (end_vid == -1) {};
-    for (const auto &row : result) {
-        (*path)[seq] = row;
-        ++seq;
-    }
-
-    *total_results = result.size();
-
-    (*err_msg) = NULL;
-    return 0;
-
-#if 0
-/*
- * If the end is specified and the end point and it follow start
- * then we swap start and end and extract the list backwards
- * and later we reverse the list for the desired order.
- */
-if ((jend > 0 && jend == jstart + 1)
-        || (jend == 0 && jstart == tsp.n-1)) {
-    int tmp = jend;
-    jend = jstart;
-    jstart = tmp;
-    rev = 1;
-    // PGR_DBG("reversed start and end: jstart: %d, jend: %d", jstart, jend);
-}
-
-// copy ids to tsp.jorder so we can rewrite ids
-memcpy(tsp.jorder, ids, tsp.n * sizeof(int));
-
-// write reordered ids into ids[]
-// remember at this point jorder is our list if ids
-for (i=jstart, j=0; i < tsp.n; i++, j++)
-ids[j] = tsp.jorder[tsp.iorder[i]];
-
-for (i=0; i < jstart; i++, j++)
-ids[j] =tsp.jorder[tsp.iorder[i]];
-
-// if we reversed the order above, now put it correct.
-if (rev) {
-    int tmp = jend;
-    jend = jstart;
-    jstart = tmp;
-    reverse(tsp.n, ids);
-}
-#endif
-
-}
-
-
diff --git a/src/tsp/src/tsplib.c b/src/tsp/src/tsplib.c
index 3aeef9c..bb9b523 100644
--- a/src/tsp/src/tsplib.c
+++ b/src/tsp/src/tsplib.c
@@ -1,16 +1,20 @@
+/*
+ * THIS CODE IS DEPRECATED
+ */
+
 /*PGR-MIT*****************************************************************
 
-*  $Id: tsplib.c,v 1.1 2006/05/13 23:39:56 woodbri Exp $
+*  $Id: tsplib.c, v 1.1 2006/05/13 23:39:56 woodbri Exp $
 *
 *  tsplib
-*  Copyright 2005,2013, Stephen Woodbridge, All rights Reserved
+*  Copyright 2005, 2013, Stephen Woodbridge, All rights Reserved
 *  This file is released under MIT-X license as part of pgRouting.
 
 ------
 MIT/X license
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
+of this software and associated documentation files(the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
@@ -39,7 +43,7 @@ THE SOFTWARE.
 *  Routine to calculate the node order for a Traveling Salesman Problem
 *  from a distance matrix.
 *
-*  $Log: tsplib.c,v $
+*  $Log: tsplib.c, v $
 *  Revision 1.1  2006/05/13 23:39:56  woodbri
 *  Initial checkin of IMT::TSP module.
 *
@@ -47,17 +51,17 @@ THE SOFTWARE.
 *
 **********************************************************************
 *
-* Simulated annealing and a non symetric
+* Simulated annealing and a non symmetric
 * Euclidian Traveling Salesman Problem.
 *
 * Solution based on local search heuristics for
-* non-crossing paths and nearest neighbors 
+* non-crossing paths and nearest neighbors
 *
 * Storage Requirements: 4n ints
 *
-* Problem: given an nXn matrix of costs for n cities in the plane, 
-* find a permutation pi_1, pi_2, ..., pi_n of 1, 2, ..., n that 
-* minimizes sum for 1<=i<n D(pi_i,pi_i+1), where D(i,j) is the 
+* Problem: given an nXn matrix of costs for n cities in the plane,
+* find a permutation pi_1, pi_2, ..., pi_n of 1, 2, ..., n that
+* minimizes sum for 1<=i<n D(pi_i, pi_i+1), where D(i, j) is the
 * euclidian distance between cities i and j from the matrix
 *
 * This means that the ith row is the "from" city and the jth column
@@ -66,45 +70,44 @@ THE SOFTWARE.
 * NOTE: costs are assumed to be ints, so scaling them to meters or
 * some other int would be advisable.
 *
-* NOTE: the internal cost calculations ASSUME a symetric matrix. There
-* are notes of what needs to be updated, but all D(i,j)s need to be
+* NOTE: the internal cost calculations ASSUME a symmetric matrix. There
+* are notes of what needs to be updated, but all D(i, j)s need to be
 * reviewed because order is important for asymetric cases.
 *
-* Note: with n cities, there is (n-1)!/2 possible tours.
+* Note: with n cities, there is(n-1)!/2 possible tours.
 * factorial(10)=3628800  factorial(50)=3E+64  factorial(150)=5.7E+262
 * If we could check one tour per clock cycle on a 100 MHZ computer, we
 * would still need to wait approximately 10^236 times the age of the
-* universe to explore all tours for 150 cities. 
+* universe to explore all tours for 150 cities.
 *
-* Derivied from code 1995 by Maugis Lionel (Sofreavia) on sid1
+* Derivied from code 1995 by Maugis Lionel(Sofreavia) on sid1
 * that was placed in the public domain.
 *************************************************************************/
 
-//#ifdef __MINGW64__
-//#define ELOG_H
-//#include <winsock2.h>
-//#endif
+// #ifdef __MINGW64__
+// #define ELOG_H
+// #include <winsock2.h>
+// #endif
 #include <postgres.h>
 #include <string.h>    /* memcpy */
 #include <math.h>      /* exp    */
 
-#include "tsp.h"
+#include "./tsp.h"
 
 #undef DEBUG
-//#define DEBUG 1
+// #define DEBUG 1
 #include "../../common/src/debug_macro.h"
 
 
-
 #define T_INIT                        100
 #define FINAL_T                       0.1
-#define COOLING                       0.9 /* to lower down T (< 1) */
-#define TRIES_PER_T                   500*n  
-#define IMPROVED_PATH_PER_T           60*n   
+#define COOLING                       0.9 /* to lower down T(< 1) */
+#define TRIES_PER_T                   500*n
+#define IMPROVED_PATH_PER_T           60*n
 
 /*
  *   MACHINE INDEPENDENT RANDOM NUMBER GENERATOR
- *   Written by:  DIMACS  (modified for TSP)
+ *   Written by:  DIMACS (modified for TSP)
 */
 
 #define PRANDMAX 1000000000
@@ -116,8 +119,7 @@ static
 int Rand(void);
 
 static
-void initRand (int seed)
-{
+void initRand(int seed) {
     int i, ii;
     int last, next;
 
@@ -127,7 +129,7 @@ void initRand (int seed)
     arr[0] = last = seed;
     next = 1;
     for (i = 1; i < 55; i++) {
-        ii = (21 * i) % 55;
+        ii =(21 * i) % 55;
         arr[ii] = next;
         next = last - next;
         if (next < 0)
@@ -137,12 +139,11 @@ void initRand (int seed)
     a = 0;
     b = 24;
     for (i = 0; i < 165; i++)
-        last = Rand ();
+        last = Rand();
 }
 
 static
-int Rand (void)
-{
+int Rand(void) {
     int t;
 
     if (a-- == 0)
@@ -178,25 +179,24 @@ typedef struct tspstruct {
     DTYPE bestlen;
     int *iorder;
     int *jorder;
-    int *border;  // best order we find
+    int *border;  //  best order we find
     float b[4];
 } TSP;
 
-#define MOD(i,n)    ((i) % (n) >= 0 ? (i) % (n) : (i) % (n) + (n))
-#define D(x,y) dist[(x)*n+y]        
+#define MOD(i, n)   ((i) %(n) >= 0 ?(i) %(n) :(i) %(n) +(n))
+#define D(x, y) dist[(x)*n+y]
 
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#define MAX(a,b) ((a)>(b)?(a):(b))
-#define sqr(x)   ((x)*(x))
+#define MIN(a, b)((a) < (b)?(a) : (b))
+#define MAX(a, b)((a) > (b)?(a) : (b))
+#define sqr(x)  ((x)*(x))
 
 /*
  * Prim's approximated TSP tour
  * See also [Cristophides'92]
  */
 static
-int findEulerianPath(TSP *tsp)
-{
-    int *mst, *arc;    
+int findEulerianPath(TSP *tsp) {
+    int *mst, *arc;
     int i, j, k, l, a;
     int n, *iorder, *jorder;
     DTYPE d;
@@ -210,54 +210,47 @@ int findEulerianPath(TSP *tsp)
     maxd   = tsp->maxd;
     n      = tsp->n;
 
-    if (!(mst = (int*) palloc((size_t) n * sizeof(int))) ||
-        !(arc = (int*) palloc((size_t) n * sizeof(int))) ||
-        !(dis = (DTYPE*) palloc((size_t) n * sizeof(DTYPE))) )
-    {
+    if (!(mst =(int*) palloc((size_t) n * sizeof(int))) ||
+        !(arc =(int*) palloc((size_t) n * sizeof(int))) ||
+        !(dis =(DTYPE*) palloc((size_t) n * sizeof(DTYPE))) ) {
         elog(ERROR, "Failed to allocate memory!");
         return -1;
     }
-    //PGR_DBG("findEulerianPath: 1");
+    // PGR_DBG("findEulerianPath: 1");
 
     k = -1;
     j = -1;
     d = maxd;
     dis[0] = -1;
-    for (i = 1; i < n; i++)
-    {
-        dis[i] = D(i,0);
+    for (i = 1; i < n; i++) {
+        dis[i] = D(i, 0);
         arc[i] = 0;
-        if (d > dis[i])
-        {
+        if (d > dis[i]) {
             d = dis[i];
             j = i;
         }
     }
-    //PGR_DBG("findEulerianPath: j=%d", j);
+    // PGR_DBG("findEulerianPath: j=%d", j);
 
     if (j == -1)
         elog(ERROR, "Error TSP fail to findEulerianPath, check your distance matrix is valid.");
 
     /*
-     * O(n^2) Minimum Spanning Trees by Prim and Jarnick 
-     * for graphs with adjacency matrix. 
+     * O(n^2) Minimum Spanning Trees by Prim and Jarnick
+     * for graphs with adjacency matrix.
      */
-    for (a = 0; a < n - 1; a++)
-    {
+    for (a = 0; a < n - 1; a++) {
         mst[a] = j * n + arc[j]; /* join fragment j with MST */
-        dis[j] = -1; 
+        dis[j] = -1;
         d = maxd;
-        for (i = 0; i < n; i++)
-        {
-            if (dis[i] >= 0) /* not connected yet */
-            {
-                if (dis[i] > D(i,j))
-                {
-                    dis[i] = D(i,j);
+        for (i = 0; i < n; i++) {
+            if (dis[i] >= 0) {
+                /* not connected yet */
+                if (dis[i] > D(i, j)) {
+                    dis[i] = D(i, j);
                     arc[i] = j;
                 }
-                if (d > dis[i])
-                {
+                if (d > dis[i]) {
                     d = dis[i];
                     k = i;
                 }
@@ -265,7 +258,7 @@ int findEulerianPath(TSP *tsp)
         }
         j = k;
     }
-    //PGR_DBG("findEulerianPath: 3");
+    // PGR_DBG("findEulerianPath: 3");
 
     /*
      * Preorder Tour of MST
@@ -273,101 +266,94 @@ int findEulerianPath(TSP *tsp)
 #define VISITED(x) jorder[x]
 #define NQ(x) arc[l++] = x
 #define DQ()  arc[--l]
-#define EMPTY (l==0)
-        
+#define EMPTY (l == 0)
+
     for (i = 0; i < n; i++) VISITED(i) = 0;
     k = 0; l = 0; d = 0; NQ(0);
-    while (!EMPTY)
-    {
+    while (!EMPTY) {
         i = DQ();
-        if (!VISITED(i))
-        {
+        if (!VISITED(i)) {
             iorder[k++] = i;
-            VISITED(i)  = 1;            
-            for (j = 0; j < n - 1; j++) /* push all kids of i */
-            {
-                if (i == mst[j]%n) NQ(mst[j]/n); 
-            }    
+            VISITED(i)  = 1;
+            for (j = 0; j < n - 1; j++) /* push all kids of i */ {
+                if (i == mst[j]%n) NQ(mst[j]/n);
+            }
         }
     }
-    //PGR_DBG("findEulerianPath: 4");
+    // PGR_DBG("findEulerianPath: 4");
 
     return 0;
 }
 
 static
-DTYPE pathLength (TSP *tsp)
-{
+DTYPE pathLength(TSP *tsp) {
     unsigned int i;
     DTYPE len = 0;
 
     int *iorder = tsp->iorder;
     DTYPE *dist   = tsp->dist;
-    int  n      = tsp->n;
-    
-    for (i = 0; i < n-1; i++)
-    {
+    int  n = tsp->n;
+
+    for (i = 0; i < n-1; i++) {
         len += D(iorder[i], iorder[i+1]);
     }
     len += D(iorder[n-1], iorder[0]); /* close path */
-    return (len);
+    return(len);
 }
 
 /*
  * Local Search Heuristics
  *  b-------a        b       a
  *  .       .   =>   .\     /.
- *  . d...e .        . e...d .  
+ *  . d...e .        . e...d .
  *  ./     \.        .       .
  *  c       f        c-------f
  */
 static
-DTYPE getThreeWayCost (TSP *tsp, Path p)
-{
+DTYPE getThreeWayCost(TSP *tsp, Path p) {
     int a, b, c, d, e, f;
     int *iorder = tsp->iorder;
     DTYPE *dist   = tsp->dist;
     int n       = tsp->n;
 
-    a = iorder[MOD(p[0]-1,n)];
+    a = iorder[MOD(p[0]-1, n)];
     b = iorder[p[0]];
     c = iorder[p[1]];
-    d = iorder[MOD(p[1]+1,n)];
+    d = iorder[MOD(p[1]+1, n)];
     e = iorder[p[2]];
-    f = iorder[MOD(p[2]+1,n)];
+    f = iorder[MOD(p[2]+1, n)];
 
-    return (D(a,d) + D(e,b) + D(c,f) - D(a,b) - D(c,d) - D(e,f)); 
-        /* add cost between d and e if non symetric TSP */ 
+    return(D(a, d) + D(e, b) + D(c, f) - D(a, b) - D(c, d) - D(e, f));
+        /* add cost between d and e if non symmetric TSP */
 }
 
 static
-void doThreeWay (TSP *tsp, Path p)
-{
+void doThreeWay(TSP *tsp, Path p) {
     int i, count, m1, m2, m3, a, b, c, d, e, f;
     int *iorder = tsp->iorder;
     int *jorder = tsp->jorder;
     int n       = tsp->n;
-    
-    a = MOD(p[0]-1,n);
+
+    a = MOD(p[0]-1, n);
     b = p[0];
     c = p[1];
-    d = MOD(p[1]+1,n);
+    d = MOD(p[1]+1, n);
     e = p[2];
-    f = MOD(p[2]+1,n);    
-    
-    m1 = MOD(n+c-b,n)+1;  /* num cities from b to c */
-    m2 = MOD(n+a-f,n)+1;  /* num cities from f to a */
-    m3 = MOD(n+e-d,n)+1;  /* num cities from d to e */
+    f = MOD(p[2]+1, n);
+
+    m1 = MOD(n+c-b, n)+1;  /* num cities from b to c */
+    m2 = MOD(n+a-f, n)+1;  /* num cities from f to a */
+    m3 = MOD(n+e-d, n)+1;  /* num cities from d to e */
 
     count = 0;
     /* [b..c] */
-    for (i = 0; i < m1; i++) jorder[count++] = iorder[MOD(i+b,n)];
+    for (i = 0; i < m1; i++) jorder[count++] = iorder[MOD(i+b, n)];
 
     /* [f..a] */
-    for (i = 0; i < m2; i++) jorder[count++] = iorder[MOD(i+f,n)];
+    for (i = 0; i < m2; i++) jorder[count++] = iorder[MOD(i+f, n)];
 
     /* [d..e] */
-    for (i = 0; i < m3; i++) jorder[count++] = iorder[MOD(i+d,n)];
+    for (i = 0; i < m3; i++) jorder[count++] = iorder[MOD(i+d, n)];
 
     /* copy segment back into iorder */
     for (i = 0; i < n; i++) iorder[i] = jorder[i];
@@ -380,33 +366,29 @@ void doThreeWay (TSP *tsp, Path p)
  *   a  d       a  d
  */
 static
-DTYPE getReverseCost (TSP *tsp, Path p)
-{
+DTYPE getReverseCost(TSP *tsp, Path p) {
     int a, b, c, d;
     int *iorder = tsp->iorder;
     DTYPE *dist   = tsp->dist;
     int n       = tsp->n;
-    
-    a = iorder[MOD(p[0]-1,n)];
+
+    a = iorder[MOD(p[0]-1, n)];
     b = iorder[p[0]];
     c = iorder[p[1]];
-    d = iorder[MOD(p[1]+1,n)];
-    
-    return (D(d,b) + D(c,a) - D(a,b) - D(c,d));
-    /* add cost between c and b if non symetric TSP */ 
+    d = iorder[MOD(p[1]+1, n)];
+
+    return(D(d, b) + D(c, a) - D(a, b) - D(c, d));
+    /* add cost between c and b if non symmetric TSP */
 }
-static
-void doReverse(TSP *tsp, Path p)
-{
+static void doReverse(TSP *tsp, Path p) {
     int i, nswaps, first, last, tmp;
     int *iorder = tsp->iorder;
     int n       = tsp->n;
-    
+
 
     /* reverse path b...c */
-    nswaps = (MOD(p[1]-p[0],n)+1)/2;
-    for (i = 0; i < nswaps; i++)
-    {
+    nswaps =(MOD(p[1]-p[0], n)+1)/2;
+    for (i = 0; i < nswaps; i++) {
         first = MOD(p[0]+i, n);
         last  = MOD(p[1]-i, n);
         tmp   = iorder[first];
@@ -416,8 +398,7 @@ void doReverse(TSP *tsp, Path p)
 }
 
 static
-void annealing(TSP *tsp)
-{
+void annealing(TSP *tsp) {
     Path   p;
     int    i, j, pathchg;
     int    numOnPath, numNotOnPath;
@@ -425,53 +406,47 @@ void annealing(TSP *tsp)
     int    n = tsp->n;
     double energyChange, T;
 
-    pathlen = pathLength (tsp); 
+    pathlen = pathLength(tsp);
 
-    for (T = T_INIT; T > FINAL_T; T *= COOLING)  /* annealing schedule */
-    {
+    for (T = T_INIT; T > FINAL_T; T *= COOLING)  /* annealing schedule */ {
         pathchg = 0;
-        for (j = 0; j < TRIES_PER_T; j++)
-        {
+        for (j = 0; j < TRIES_PER_T; j++) {
             do {
-                p[0] = unifRand (n);
-                p[1] = unifRand (n);
+                p[0] = unifRand(n);
+                p[1] = unifRand(n);
                 /* non-empty path */
-                if (p[0] == p[1]) p[1] = MOD(p[0]+1,n);
-                numOnPath = MOD(p[1]-p[0],n) + 1;
+                if (p[0] == p[1]) p[1] = MOD(p[0]+1, n);
+                numOnPath = MOD(p[1]-p[0], n) + 1;
                 numNotOnPath = n - numOnPath;
             } while (numOnPath < 2 || numNotOnPath < 2); /* non-empty path */
-            
-            if (RANDOM() % 2) /*  threeWay */
-            {
+
+            if (RANDOM() % 2) /*  threeWay */ {
                 do {
-                    p[2] = MOD(unifRand (numNotOnPath)+p[1]+1,n);
-                } while (p[0] == MOD(p[2]+1,n)); /* avoids a non-change */
+                    p[2] = MOD(unifRand(numNotOnPath)+p[1]+1, n);
+                } while (p[0] == MOD(p[2]+1, n)); /* avoids a non-change */
 
-                energyChange = getThreeWayCost (tsp, p);
-                if (energyChange < 0 || RREAL < exp(-energyChange/T) )
-                {
+                energyChange = getThreeWayCost(tsp, p);
+                if (energyChange < 0 || RREAL < exp(-energyChange/T)) {
                     pathchg++;
                     pathlen += energyChange;
-                    doThreeWay (tsp, p);
+                    doThreeWay(tsp, p);
                 }
-            }
-            else            /* path Reverse */
-            {
-                energyChange = getReverseCost (tsp, p);
-                if (energyChange < 0 || RREAL < exp(-energyChange/T))
-                {
+            } else {
+                /* path Reverse */
+                energyChange = getReverseCost(tsp, p);
+                if (energyChange < 0 || RREAL < exp(-energyChange/T)) {
                     pathchg++;
                     pathlen += energyChange;
-                    doReverse(tsp, p); 
+                    doReverse(tsp, p);
                 }
             }
-            // if the new length is better than best then save it as best
+            //  if the new length is better than best then save it as best
             if (pathlen < tsp->bestlen) {
                 tsp->bestlen = pathlen;
-                for (i=0; i<tsp->n; i++) tsp->border[i] = tsp->iorder[i];
+                for (i = 0; i < tsp->n; i++) tsp->border[i] = tsp->iorder[i];
             }
             if (pathchg > IMPROVED_PATH_PER_T) break; /* finish early */
-        }   
+        }
         PGR_DBG("T:%f L:%f B:%f C:%d", T, pathlen, tsp->bestlen, pathchg);
         if (pathchg == 0) break;   /* if no change then quit */
     }
@@ -479,10 +454,9 @@ void annealing(TSP *tsp)
 
 
 static
-void reverse(int num, int *ids)
-{
+void reverse(int num, int *ids) {
     int i, j, t;
-    for (i=0, j=num-1; i<j; i++, j--) {
+    for (i = 0, j = num - 1; i < j; i++, j--) {
         t = ids[j];
         ids[j] = ids[i];
         ids[i] = t;
@@ -490,8 +464,7 @@ void reverse(int num, int *ids)
 }
 
 
-int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE *total_len, char *err_msg)
-{
+int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE *total_len, char *err_msg) {
     int   i, j;
     int   istart = 0;
     int   jstart = 0;
@@ -499,10 +472,10 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
     int   jend = -1;
     int   rev = 0;
     TSP   tsp;
-    long  seed = -314159L;
+    int64_t  seed = -314159L;
     DTYPE blength;
 
-    PGR_DBG("sizeof(long)=%d", (int)sizeof(long));
+    PGR_DBG("sizeof(int64_t)=%d", (int)sizeof(int64_t));
 
     initRand((int) seed);
 
@@ -510,11 +483,11 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
     char bufff[2048];
     int nnn;
     PGR_DBG("---------- Matrix[%d][%d] ---------------------\n", num, num);
-    for (i=0; i<num; i++) {
+    for (i = 0; i < num; i++) {
         sprintf(bufff, "%d:", i);
         nnn = 0;
-        for (j=0; j<num; j++) {
-            nnn += sprintf(bufff+nnn, "\t%.4f", cost[i*num+j]);
+        for (j = 0; j < num; j++) {
+            nnn += sprintf(bufff + nnn, "\t%.4f", cost[i * num + j]);
         }
         PGR_DBG("%s", bufff);
     }
@@ -527,16 +500,16 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
     tsp.jorder = NULL;
     tsp.border = NULL;
 
-    if (!(tsp.iorder = (int*) palloc ((size_t) tsp.n * sizeof(int)))   ||
-        !(tsp.jorder = (int*) palloc ((size_t) tsp.n * sizeof(int)))   ||
-        !(tsp.border = (int*) palloc ((size_t) tsp.n * sizeof(int)))   ) {
+    if (!(tsp.iorder =(int*) palloc((size_t) tsp.n * sizeof(int)))   ||
+        !(tsp.jorder =(int*) palloc((size_t) tsp.n * sizeof(int)))   ||
+        !(tsp.border =(int*) palloc((size_t) tsp.n * sizeof(int)))   ) {
             elog(FATAL, "Memory allocation failed!");
             return -1;
         }
 
     tsp.dist = cost;
     tsp.maxd = 0;
-    for (i=0; i<tsp.n*tsp.n; i++) {
+    for (i=0; i < tsp.n * tsp.n; i++) {
         tsp.maxd = MAX(tsp.maxd, cost[i]);
     }
 
@@ -552,7 +525,7 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
      * Set up first eulerian path iorder to be improved by
      * simulated annealing.
      */
-    if(findEulerianPath(&tsp))
+    if (findEulerianPath(&tsp))
         return -1;
 
     blength = pathLength(&tsp);
@@ -569,26 +542,26 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
     PGR_DBG("Final Path Length: %.4f", *total_len);
 
     *total_len = tsp.bestlen;
-    for (i=0; i<tsp.n; i++) tsp.iorder[i] = tsp.border[i];
+    for (i = 0; i < tsp.n; i++) tsp.iorder[i] = tsp.border[i];
     PGR_DBG("Best Path Length: %.4f", *total_len);
 
-    // reorder ids[] with start as first
+    //  reorder ids[] with start as first
 
 #ifdef DEBUG
-    for (i=0; i<tsp.n; i++) {
+    for (i = 0; i < tsp.n; i++) {
         PGR_DBG("i: %d, ids[i]: %d, io[i]: %d, jo[i]: %d, jo[io[i]]: %d",
             i, ids[i], tsp.iorder[i], tsp.jorder[i], tsp.jorder[tsp.iorder[i]]);
     }
 #endif
 
-    // get index of start node in ids
+    //  get index of start node in ids
     for (i=0; i < tsp.n; i++) {
         if (ids[i] == start) istart = i;
         if (ids[i] == end)   iend = i;
     }
     PGR_DBG("istart: %d, iend: %d", istart, iend);
 
-    // get the idex of start in iorder
+    //  get the idex of start in iorder
     for (i=0; i < tsp.n; i++) {
         if (tsp.iorder[i] == istart) jstart = i;
         if (tsp.iorder[i] == iend)   jend = i;
@@ -600,7 +573,7 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
      * then we swap start and end and extract the list backwards
      * and later we reverse the list for the desired order.
     */
-    if ((jend > 0 && jend == jstart+1) || (jend == 0 && jstart == tsp.n-1)) {
+    if ((jend > 0 && jend == jstart+1) ||(jend == 0 && jstart == tsp.n-1)) {
         int tmp = jend;
         jend = jstart;
         jstart = tmp;
@@ -608,18 +581,18 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
         PGR_DBG("reversed start and end: jstart: %d, jend: %d", jstart, jend);
     }
 
-    // copy ids to tsp.jorder so we can rewrite ids
+    //  copy ids to tsp.jorder so we can rewrite ids
     memcpy(tsp.jorder, ids, (size_t) tsp.n * sizeof(int));
 
-    // write reordered ids into ids[]
-    // remember at this point jorder is our list if ids
-    for (i=jstart, j=0; i < tsp.n; i++, j++)
+    //  write reordered ids into ids[]
+    //  remember at this point jorder is our list if ids
+    for (i=jstart, j = 0; i < tsp.n; i++, j++)
         ids[j] = tsp.jorder[tsp.iorder[i]];
 
     for (i=0; i < jstart; i++, j++)
-        ids[j] =tsp.jorder[tsp.iorder[i]];
+        ids[j] = tsp.jorder[tsp.iorder[i]];
 
-    // if we reversed the order above, now put it correct.
+    //  if we reversed the order above, now put it correct.
     if (rev) {
         int tmp = jend;
         jend = jstart;
@@ -629,7 +602,7 @@ int find_tsp_solution(int num, DTYPE *cost, int *ids, int start, int end, DTYPE
 
 #ifdef DEBUG
     PGR_DBG("ids getting returned!");
-    for (i=0; i<tsp.n; i++) {
+    for (i=0; i < tsp.n; i++) {
         PGR_DBG("i: %d, ids[i]: %d, io[i]: %d, jo[i]: %d",
             i, ids[i], tsp.iorder[i], tsp.jorder[i]);
     }
diff --git a/src/tsp/test/CMakeLists.txt b/src/tsp/test/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/tsp/test/development/gr9882-tsp.test.sql b/src/tsp/test/development/gr9882-tsp.test.sql
new file mode 100644
index 0000000..5e69d87
--- /dev/null
+++ b/src/tsp/test/development/gr9882-tsp.test.sql
@@ -0,0 +1,9903 @@
+-- http://www.math.uwaterloo.ca/tsp/world/countries.html#GR
+
+-- NAME : gr9882
+-- COMMENT : 9882 locations in Greece
+-- COMMENT : Derived from National Imagery and Mapping Agency data
+-- TYPE : TSP
+-- DIMENSION : 9882
+-- EDGE_WEIGHT_TYPE : EUC_2D
+-- NODE_COORD_SECTION
+
+DROP TABLE IF EXISTS gr9882;
+CREATE TABLE gr9882 (id BIGINT, x FLOAT, y FLOAT, the_geom geometry);
+COPY gr9882 (id, x, y) FROM stdin WITH DELIMITER ' ';
+1 34816.6667 24100.0000
+2 34833.3333 24083.3333
+3 34850.0000 24050.0000
+4 34850.0000 24083.3333
+5 34850.0000 24116.6667
+6 34866.6667 24083.3333
+7 34933.3333 24800.0000
+8 34933.3333 24916.6667
+9 34966.6667 24883.3333
+10 34966.6667 24933.3333
+11 34966.6667 24950.0000
+12 34966.6667 25033.3333
+13 34966.6667 25133.3333
+14 34966.6667 25250.0000
+15 34983.3333 24750.0000
+16 34983.3333 24850.0000
+17 34983.3333 24916.6667
+18 34983.3333 24983.3333
+19 34983.3333 25000.0000
+20 34983.3333 25016.6667
+21 34983.3333 25150.0000
+22 34983.3333 25166.6667
+23 34983.3333 25200.0000
+24 34983.3333 25216.6667
+25 34983.3333 25266.6667
+26 34983.3333 25283.3333
+27 34983.3333 25316.6667
+28 34983.3333 25333.3333
+29 35000.0000 24816.6667
+30 35000.0000 24900.0000
+31 35000.0000 24933.3333
+32 35000.0000 25033.3333
+33 35000.0000 25066.6667
+34 35000.0000 25133.3333
+35 35000.0000 25150.0000
+36 35000.0000 25366.6667
+37 35000.0000 25383.3333
+38 35000.0000 25483.3333
+39 35000.0000 25516.6667
+40 35000.0000 25533.3333
+41 35000.0000 25583.3333
+42 35000.0000 25633.3333
+43 35016.6667 24783.3333
+44 35016.6667 24800.0000
+45 35016.6667 24833.3333
+46 35016.6667 24866.6667
+47 35016.6667 24883.3333
+48 35016.6667 24900.0000
+49 35016.6667 24916.6667
+50 35016.6667 24950.0000
+51 35016.6667 24966.6667
+52 35016.6667 25000.0000
+53 35016.6667 25066.6667
+54 35016.6667 25083.3333
+55 35016.6667 25116.6667
+56 35016.6667 25166.6667
+57 35016.6667 25200.0000
+58 35016.6667 25416.6667
+59 35016.6667 25516.6667
+60 35016.6667 25533.3333
+61 35016.6667 25550.0000
+62 35016.6667 25583.3333
+63 35016.6667 25683.3333
+64 35016.6667 25750.0000
+65 35016.6667 25833.3333
+66 35016.6667 26100.0000
+67 35016.6667 26116.6667
+68 35033.3333 24783.3333
+69 35033.3333 24833.3333
+70 35033.3333 24933.3333
+71 35033.3333 25150.0000
+72 35033.3333 25233.3333
+73 35033.3333 25250.0000
+74 35033.3333 25266.6667
+75 35033.3333 25283.3333
+76 35033.3333 25383.3333
+77 35033.3333 25433.3333
+78 35033.3333 25450.0000
+79 35033.3333 25483.3333
+80 35033.3333 25500.0000
+81 35033.3333 25550.0000
+82 35033.3333 25566.6667
+83 35033.3333 25600.0000
+84 35033.3333 25666.6667
+85 35033.3333 25750.0000
+86 35033.3333 25766.6667
+87 35033.3333 25900.0000
+88 35033.3333 25950.0000
+89 35033.3333 25966.6667
+90 35033.3333 25983.3333
+91 35033.3333 26150.0000
+92 35050.0000 24816.6667
+93 35050.0000 24833.3333
+94 35050.0000 24866.6667
+95 35050.0000 24900.0000
+96 35050.0000 24950.0000
+97 35050.0000 25050.0000
+98 35050.0000 25066.6667
+99 35050.0000 25100.0000
+100 35050.0000 25116.6667
+101 35050.0000 25183.3333
+102 35050.0000 25300.0000
+103 35050.0000 25333.3333
+104 35050.0000 25383.3333
+105 35050.0000 25416.6667
+106 35050.0000 25450.0000
+107 35050.0000 25500.0000
+108 35050.0000 25550.0000
+109 35050.0000 25633.3333
+110 35050.0000 25666.6667
+111 35050.0000 25783.3333
+112 35050.0000 25800.0000
+113 35050.0000 25833.3333
+114 35050.0000 25883.3333
+115 35050.0000 25950.0000
+116 35050.0000 26050.0000
+117 35050.0000 26066.6667
+118 35050.0000 26100.0000
+119 35050.0000 26116.6667
+120 35050.0000 26150.0000
+121 35050.0000 26183.3333
+122 35066.6667 24766.6667
+123 35066.6667 24816.6667
+124 35066.6667 24866.6667
+125 35066.6667 24883.3333
+126 35066.6667 24916.6667
+127 35066.6667 24933.3333
+128 35066.6667 24966.6667
+129 35066.6667 25016.6667
+130 35066.6667 25033.3333
+131 35066.6667 25083.3333
+132 35066.6667 25100.0000
+133 35066.6667 25116.6667
+134 35066.6667 25133.3333
+135 35066.6667 25200.0000
+136 35066.6667 25216.6667
+137 35066.6667 25233.3333
+138 35066.6667 25300.0000
+139 35066.6667 25566.6667
+140 35066.6667 25716.6667
+141 35066.6667 25750.0000
+142 35066.6667 25816.6667
+143 35066.6667 25866.6667
+144 35066.6667 25966.6667
+145 35066.6667 26016.6667
+146 35066.6667 26083.3333
+147 35066.6667 26116.6667
+148 35083.3333 24733.3333
+149 35083.3333 24833.3333
+150 35083.3333 24866.6667
+151 35083.3333 24883.3333
+152 35083.3333 24916.6667
+153 35083.3333 24933.3333
+154 35083.3333 24950.0000
+155 35083.3333 24966.6667
+156 35083.3333 25033.3333
+157 35083.3333 25050.0000
+158 35083.3333 25083.3333
+159 35083.3333 25100.0000
+160 35083.3333 25183.3333
+161 35083.3333 25216.6667
+162 35083.3333 25233.3333
+163 35083.3333 25250.0000
+164 35083.3333 25266.6667
+165 35083.3333 25283.3333
+166 35083.3333 25333.3333
+167 35083.3333 25366.6667
+168 35083.3333 25400.0000
+169 35083.3333 25566.6667
+170 35083.3333 25583.3333
+171 35083.3333 25650.0000
+172 35083.3333 25716.6667
+173 35083.3333 25766.6667
+174 35083.3333 25816.6667
+175 35083.3333 25833.3333
+176 35083.3333 25916.6667
+177 35083.3333 25933.3333
+178 35083.3333 25950.0000
+179 35083.3333 25966.6667
+180 35083.3333 25983.3333
+181 35083.3333 26033.3333
+182 35083.3333 26050.0000
+183 35083.3333 26066.6667
+184 35083.3333 26083.3333
+185 35083.3333 26100.0000
+186 35083.3333 26133.3333
+187 35083.3333 26166.6667
+188 35100.0000 24683.3333
+189 35100.0000 24783.3333
+190 35100.0000 24833.3333
+191 35100.0000 24850.0000
+192 35100.0000 24916.6667
+193 35100.0000 24966.6667
+194 35100.0000 25000.0000
+195 35100.0000 25066.6667
+196 35100.0000 25083.3333
+197 35100.0000 25166.6667
+198 35100.0000 25183.3333
+199 35100.0000 25216.6667
+200 35100.0000 25250.0000
+201 35100.0000 25283.3333
+202 35100.0000 25300.0000
+203 35100.0000 25350.0000
+204 35100.0000 25366.6667
+205 35100.0000 25383.3333
+206 35100.0000 25400.0000
+207 35100.0000 25416.6667
+208 35100.0000 25683.3333
+209 35100.0000 25800.0000
+210 35100.0000 25866.6667
+211 35100.0000 25950.0000
+212 35100.0000 26066.6667
+213 35100.0000 26083.3333
+214 35100.0000 26133.3333
+215 35100.0000 26266.6667
+216 35116.6667 24616.6667
+217 35116.6667 24750.0000
+218 35116.6667 24766.6667
+219 35116.6667 24816.6667
+220 35116.6667 24866.6667
+221 35116.6667 24900.0000
+222 35116.6667 24916.6667
+223 35116.6667 24933.3333
+224 35116.6667 24950.0000
+225 35116.6667 25000.0000
+226 35116.6667 25116.6667
+227 35116.6667 25133.3333
+228 35116.6667 25216.6667
+229 35116.6667 25233.3333
+230 35116.6667 25250.0000
+231 35116.6667 25266.6667
+232 35116.6667 25283.3333
+233 35116.6667 25300.0000
+234 35116.6667 25333.3333
+235 35116.6667 25716.6667
+236 35116.6667 25733.3333
+237 35116.6667 25800.0000
+238 35116.6667 25850.0000
+239 35116.6667 25883.3333
+240 35116.6667 25983.3333
+241 35116.6667 26016.6667
+242 35116.6667 26066.6667
+243 35116.6667 26083.3333
+244 35116.6667 26100.0000
+245 35116.6667 26150.0000
+246 35116.6667 26216.6667
+247 35116.6667 26233.3333
+248 35133.3333 24600.0000
+249 35133.3333 24650.0000
+250 35133.3333 24733.3333
+251 35133.3333 24816.6667
+252 35133.3333 24900.0000
+253 35133.3333 24916.6667
+254 35133.3333 24950.0000
+255 35133.3333 24983.3333
+256 35133.3333 25000.0000
+257 35133.3333 25016.6667
+258 35133.3333 25033.3333
+259 35133.3333 25066.6667
+260 35133.3333 25083.3333
+261 35133.3333 25116.6667
+262 35133.3333 25150.0000
+263 35133.3333 25166.6667
+264 35133.3333 25183.3333
+265 35133.3333 25216.6667
+266 35133.3333 25233.3333
+267 35133.3333 25266.6667
+268 35133.3333 25333.3333
+269 35133.3333 25533.3333
+270 35133.3333 25666.6667
+271 35133.3333 25900.0000
+272 35133.3333 25950.0000
+273 35133.3333 26016.6667
+274 35133.3333 26033.3333
+275 35133.3333 26066.6667
+276 35133.3333 26100.0000
+277 35133.3333 26116.6667
+278 35133.3333 26166.6667
+279 35133.3333 26216.6667
+280 35133.3333 26250.0000
+281 35150.0000 24633.3333
+282 35150.0000 24666.6667
+283 35150.0000 24716.6667
+284 35150.0000 24733.3333
+285 35150.0000 24750.0000
+286 35150.0000 24766.6667
+287 35150.0000 24783.3333
+288 35150.0000 24816.6667
+289 35150.0000 24833.3333
+290 35150.0000 25033.3333
+291 35150.0000 25200.0000
+292 35150.0000 25233.3333
+293 35150.0000 25266.6667
+294 35150.0000 25300.0000
+295 35150.0000 25350.0000
+296 35150.0000 25466.6667
+297 35150.0000 25533.3333
+298 35150.0000 25550.0000
+299 35150.0000 25566.6667
+300 35150.0000 25583.3333
+301 35150.0000 25633.3333
+302 35150.0000 25866.6667
+303 35150.0000 25916.6667
+304 35150.0000 25966.6667
+305 35150.0000 26016.6667
+306 35150.0000 26083.3333
+307 35150.0000 26100.0000
+308 35150.0000 26166.6667
+309 35150.0000 26183.3333
+310 35150.0000 26250.0000
+311 35166.6667 24450.0000
+312 35166.6667 24483.3333
+313 35166.6667 24516.6667
+314 35166.6667 24533.3333
+315 35166.6667 24583.3333
+316 35166.6667 24716.6667
+317 35166.6667 24733.3333
+318 35166.6667 24783.3333
+319 35166.6667 25000.0000
+320 35166.6667 25066.6667
+321 35166.6667 25100.0000
+322 35166.6667 25116.6667
+323 35166.6667 25200.0000
+324 35166.6667 25250.0000
+325 35166.6667 25333.3333
+326 35166.6667 25350.0000
+327 35166.6667 25366.6667
+328 35166.6667 25433.3333
+329 35166.6667 25450.0000
+330 35166.6667 25483.3333
+331 35166.6667 25650.0000
+332 35166.6667 25700.0000
+333 35166.6667 25933.3333
+334 35166.6667 25950.0000
+335 35166.6667 25983.3333
+336 35166.6667 26016.6667
+337 35166.6667 26033.3333
+338 35166.6667 26050.0000
+339 35166.6667 26100.0000
+340 35166.6667 26116.6667
+341 35166.6667 26166.6667
+342 35166.6667 26183.3333
+343 35166.6667 26250.0000
+344 35183.3333 24233.3333
+345 35183.3333 24416.6667
+346 35183.3333 24450.0000
+347 35183.3333 24516.6667
+348 35183.3333 24533.3333
+349 35183.3333 24550.0000
+350 35183.3333 24583.3333
+351 35183.3333 24666.6667
+352 35183.3333 24683.3333
+353 35183.3333 24733.3333
+354 35183.3333 25016.6667
+355 35183.3333 25033.3333
+356 35183.3333 25066.6667
+357 35183.3333 25216.6667
+358 35183.3333 25250.0000
+359 35183.3333 25283.3333
+360 35183.3333 25316.6667
+361 35183.3333 25333.3333
+362 35183.3333 25366.6667
+363 35183.3333 25433.3333
+364 35183.3333 25500.0000
+365 35183.3333 25516.6667
+366 35183.3333 25600.0000
+367 35183.3333 25616.6667
+368 35183.3333 25666.6667
+369 35183.3333 25683.3333
+370 35183.3333 25716.6667
+371 35183.3333 25900.0000
+372 35183.3333 25966.6667
+373 35183.3333 26033.3333
+374 35183.3333 26050.0000
+375 35183.3333 26066.6667
+376 35183.3333 26100.0000
+377 35183.3333 26116.6667
+378 35183.3333 26150.0000
+379 35183.3333 26183.3333
+380 35200.0000 24066.6667
+381 35200.0000 24083.3333
+382 35200.0000 24150.0000
+383 35200.0000 24166.6667
+384 35200.0000 24233.3333
+385 35200.0000 24266.6667
+386 35200.0000 24283.3333
+387 35200.0000 24316.6667
+388 35200.0000 24383.3333
+389 35200.0000 24400.0000
+390 35200.0000 24416.6667
+391 35200.0000 24450.0000
+392 35200.0000 24483.3333
+393 35200.0000 24500.0000
+394 35200.0000 24566.6667
+395 35200.0000 24633.3333
+396 35200.0000 24650.0000
+397 35200.0000 24683.3333
+398 35200.0000 25000.0000
+399 35200.0000 25033.3333
+400 35200.0000 25083.3333
+401 35200.0000 25100.0000
+402 35200.0000 25166.6667
+403 35200.0000 25183.3333
+404 35200.0000 25200.0000
+405 35200.0000 25216.6667
+406 35200.0000 25250.0000
+407 35200.0000 25266.6667
+408 35200.0000 25316.6667
+409 35200.0000 25333.3333
+410 35200.0000 25350.0000
+411 35200.0000 25366.6667
+412 35200.0000 25383.3333
+413 35200.0000 25466.6667
+414 35200.0000 25483.3333
+415 35200.0000 25583.3333
+416 35200.0000 25616.6667
+417 35200.0000 25650.0000
+418 35200.0000 25666.6667
+419 35200.0000 25683.3333
+420 35200.0000 25700.0000
+421 35200.0000 26116.6667
+422 35200.0000 26250.0000
+423 35200.0000 26266.6667
+424 35216.6667 24066.6667
+425 35216.6667 24083.3333
+426 35216.6667 24100.0000
+427 35216.6667 24183.3333
+428 35216.6667 24200.0000
+429 35216.6667 24216.6667
+430 35216.6667 24266.6667
+431 35216.6667 24500.0000
+432 35216.6667 24516.6667
+433 35216.6667 24533.3333
+434 35216.6667 24600.0000
+435 35216.6667 24616.6667
+436 35216.6667 24683.3333
+437 35216.6667 24700.0000
+438 35216.6667 24716.6667
+439 35216.6667 25000.0000
+440 35216.6667 25033.3333
+441 35216.6667 25050.0000
+442 35216.6667 25200.0000
+443 35216.6667 25216.6667
+444 35216.6667 25266.6667
+445 35216.6667 25300.0000
+446 35216.6667 25333.3333
+447 35216.6667 25350.0000
+448 35216.6667 25383.3333
+449 35216.6667 25466.6667
+450 35216.6667 25516.6667
+451 35216.6667 25533.3333
+452 35216.6667 25550.0000
+453 35216.6667 25600.0000
+454 35216.6667 25650.0000
+455 35216.6667 25683.3333
+456 35216.6667 25700.0000
+457 35216.6667 26033.3333
+458 35216.6667 26216.6667
+459 35216.6667 26266.6667
+460 35233.3333 23633.3333
+461 35233.3333 23683.3333
+462 35233.3333 23966.6667
+463 35233.3333 24016.6667
+464 35233.3333 24083.3333
+465 35233.3333 24116.6667
+466 35233.3333 24133.3333
+467 35233.3333 24216.6667
+468 35233.3333 24350.0000
+469 35233.3333 24383.3333
+470 35233.3333 24400.0000
+471 35233.3333 24450.0000
+472 35233.3333 24466.6667
+473 35233.3333 24516.6667
+474 35233.3333 24633.3333
+475 35233.3333 24650.0000
+476 35233.3333 24666.6667
+477 35233.3333 24700.0000
+478 35233.3333 24983.3333
+479 35233.3333 25000.0000
+480 35233.3333 25016.6667
+481 35233.3333 25033.3333
+482 35233.3333 25166.6667
+483 35233.3333 25183.3333
+484 35233.3333 25216.6667
+485 35233.3333 25233.3333
+486 35233.3333 25350.0000
+487 35233.3333 25366.6667
+488 35233.3333 25433.3333
+489 35233.3333 25450.0000
+490 35233.3333 25466.6667
+491 35233.3333 25616.6667
+492 35233.3333 25683.3333
+493 35233.3333 25700.0000
+494 35233.3333 25716.6667
+495 35250.0000 23550.0000
+496 35250.0000 23583.3333
+497 35250.0000 23666.6667
+498 35250.0000 23683.3333
+499 35250.0000 23716.6667
+500 35250.0000 23783.3333
+501 35250.0000 23816.6667
+502 35250.0000 24150.0000
+503 35250.0000 24166.6667
+504 35250.0000 24183.3333
+505 35250.0000 24216.6667
+506 35250.0000 24250.0000
+507 35250.0000 24300.0000
+508 35250.0000 24316.6667
+509 35250.0000 24333.3333
+510 35250.0000 24433.3333
+511 35250.0000 24450.0000
+512 35250.0000 24500.0000
+513 35250.0000 24533.3333
+514 35250.0000 24566.6667
+515 35250.0000 24600.0000
+516 35250.0000 24633.3333
+517 35250.0000 24650.0000
+518 35250.0000 24683.3333
+519 35250.0000 24983.3333
+520 35250.0000 25033.3333
+521 35250.0000 25066.6667
+522 35250.0000 25116.6667
+523 35250.0000 25166.6667
+524 35250.0000 25233.3333
+525 35250.0000 25250.0000
+526 35250.0000 25300.0000
+527 35250.0000 25333.3333
+528 35250.0000 25350.0000
+529 35250.0000 25383.3333
+530 35250.0000 25416.6667
+531 35250.0000 25550.0000
+532 35250.0000 25616.6667
+533 35250.0000 25633.3333
+534 35250.0000 25650.0000
+535 35250.0000 25666.6667
+536 35250.0000 25683.3333
+537 35250.0000 26250.0000
+538 35266.6667 23616.6667
+539 35266.6667 23650.0000
+540 35266.6667 23683.3333
+541 35266.6667 23700.0000
+542 35266.6667 23716.6667
+543 35266.6667 23733.3333
+544 35266.6667 23750.0000
+545 35266.6667 23816.6667
+546 35266.6667 24133.3333
+547 35266.6667 24283.3333
+548 35266.6667 24300.0000
+549 35266.6667 24333.3333
+550 35266.6667 24350.0000
+551 35266.6667 24433.3333
+552 35266.6667 24516.6667
+553 35266.6667 24583.3333
+554 35266.6667 24650.0000
+555 35266.6667 25000.0000
+556 35266.6667 25016.6667
+557 35266.6667 25050.0000
+558 35266.6667 25116.6667
+559 35266.6667 25133.3333
+560 35266.6667 25183.3333
+561 35266.6667 25216.6667
+562 35266.6667 25233.3333
+563 35266.6667 25250.0000
+564 35266.6667 25283.3333
+565 35266.6667 25300.0000
+566 35266.6667 25366.6667
+567 35266.6667 25416.6667
+568 35266.6667 25566.6667
+569 35266.6667 25583.3333
+570 35266.6667 25650.0000
+571 35266.6667 25666.6667
+572 35266.6667 25716.6667
+573 35266.6667 26266.6667
+574 35283.3333 23616.6667
+575 35283.3333 23633.3333
+576 35283.3333 23650.0000
+577 35283.3333 23666.6667
+578 35283.3333 23683.3333
+579 35283.3333 23700.0000
+580 35283.3333 23733.3333
+581 35283.3333 23750.0000
+582 35283.3333 23766.6667
+583 35283.3333 23783.3333
+584 35283.3333 23816.6667
+585 35283.3333 23833.3333
+586 35283.3333 23966.6667
+587 35283.3333 24183.3333
+588 35283.3333 24200.0000
+589 35283.3333 24333.3333
+590 35283.3333 24350.0000
+591 35283.3333 24366.6667
+592 35283.3333 24383.3333
+593 35283.3333 24416.6667
+594 35283.3333 24466.6667
+595 35283.3333 24483.3333
+596 35283.3333 24500.0000
+597 35283.3333 24516.6667
+598 35283.3333 24883.3333
+599 35283.3333 25033.3333
+600 35283.3333 25050.0000
+601 35283.3333 25066.6667
+602 35283.3333 25083.3333
+603 35283.3333 25100.0000
+604 35283.3333 25133.3333
+605 35283.3333 25183.3333
+606 35283.3333 25233.3333
+607 35283.3333 25266.6667
+608 35283.3333 25300.0000
+609 35283.3333 25316.6667
+610 35283.3333 25333.3333
+611 35283.3333 25466.6667
+612 35283.3333 25500.0000
+613 35283.3333 25616.6667
+614 35283.3333 25633.3333
+615 35283.3333 25666.6667
+616 35283.3333 25700.0000
+617 35300.0000 23516.6667
+618 35300.0000 23583.3333
+619 35300.0000 23600.0000
+620 35300.0000 23616.6667
+621 35300.0000 23633.3333
+622 35300.0000 23650.0000
+623 35300.0000 23683.3333
+624 35300.0000 23700.0000
+625 35300.0000 23716.6667
+626 35300.0000 23783.3333
+627 35300.0000 23800.0000
+628 35300.0000 24183.3333
+629 35300.0000 24316.6667
+630 35300.0000 24350.0000
+631 35300.0000 24366.6667
+632 35300.0000 24383.3333
+633 35300.0000 24400.0000
+634 35300.0000 24416.6667
+635 35300.0000 24450.0000
+636 35300.0000 24466.6667
+637 35300.0000 24500.0000
+638 35300.0000 24533.3333
+639 35300.0000 24583.3333
+640 35300.0000 24800.0000
+641 35300.0000 24816.6667
+642 35300.0000 24833.3333
+643 35300.0000 24900.0000
+644 35300.0000 24916.6667
+645 35300.0000 24933.3333
+646 35300.0000 25016.6667
+647 35300.0000 25083.3333
+648 35300.0000 25100.0000
+649 35300.0000 25150.0000
+650 35300.0000 25166.6667
+651 35300.0000 25233.3333
+652 35300.0000 25250.0000
+653 35300.0000 25300.0000
+654 35300.0000 25366.6667
+655 35300.0000 25383.3333
+656 35300.0000 25433.3333
+657 35300.0000 25516.6667
+658 35300.0000 25566.6667
+659 35300.0000 25583.3333
+660 35300.0000 25600.0000
+661 35300.0000 25616.6667
+662 35300.0000 25650.0000
+663 35300.0000 25666.6667
+664 35300.0000 25733.3333
+665 35316.6667 23533.3333
+666 35316.6667 23616.6667
+667 35316.6667 23650.0000
+668 35316.6667 23666.6667
+669 35316.6667 23683.3333
+670 35316.6667 23700.0000
+671 35316.6667 23716.6667
+672 35316.6667 23733.3333
+673 35316.6667 23750.0000
+674 35316.6667 23783.3333
+675 35316.6667 23800.0000
+676 35316.6667 23816.6667
+677 35316.6667 24200.0000
+678 35316.6667 24300.0000
+679 35316.6667 24316.6667
+680 35316.6667 24333.3333
+681 35316.6667 24350.0000
+682 35316.6667 24416.6667
+683 35316.6667 24450.0000
+684 35316.6667 24533.3333
+685 35316.6667 24616.6667
+686 35316.6667 24683.3333
+687 35316.6667 24800.0000
+688 35316.6667 24833.3333
+689 35316.6667 24850.0000
+690 35316.6667 24916.6667
+691 35316.6667 24950.0000
+692 35316.6667 25050.0000
+693 35316.6667 25133.3333
+694 35316.6667 25166.6667
+695 35316.6667 25183.3333
+696 35316.6667 25283.3333
+697 35316.6667 25316.6667
+698 35316.6667 25366.6667
+699 35316.6667 25383.3333
+700 35316.6667 25566.6667
+701 35316.6667 25600.0000
+702 35316.6667 25616.6667
+703 35316.6667 25650.0000
+704 35316.6667 25666.6667
+705 35316.6667 25683.3333
+706 35316.6667 25716.6667
+707 35316.6667 25733.3333
+708 35333.3333 23550.0000
+709 35333.3333 23600.0000
+710 35333.3333 23650.0000
+711 35333.3333 23700.0000
+712 35333.3333 23716.6667
+713 35333.3333 23733.3333
+714 35333.3333 23750.0000
+715 35333.3333 23766.6667
+716 35333.3333 23783.3333
+717 35333.3333 23800.0000
+718 35333.3333 23816.6667
+719 35333.3333 23833.3333
+720 35333.3333 23900.0000
+721 35333.3333 24183.3333
+722 35333.3333 24283.3333
+723 35333.3333 24300.0000
+724 35333.3333 24333.3333
+725 35333.3333 24350.0000
+726 35333.3333 24383.3333
+727 35333.3333 24400.0000
+728 35333.3333 24416.6667
+729 35333.3333 24466.6667
+730 35333.3333 24483.3333
+731 35333.3333 24500.0000
+732 35333.3333 24516.6667
+733 35333.3333 24616.6667
+734 35333.3333 24666.6667
+735 35333.3333 24683.3333
+736 35333.3333 24700.0000
+737 35333.3333 24716.6667
+738 35333.3333 24733.3333
+739 35333.3333 24750.0000
+740 35333.3333 24766.6667
+741 35333.3333 24783.3333
+742 35333.3333 24800.0000
+743 35333.3333 24816.6667
+744 35333.3333 24833.3333
+745 35333.3333 24850.0000
+746 35333.3333 24866.6667
+747 35333.3333 24883.3333
+748 35333.3333 25066.6667
+749 35333.3333 25083.3333
+750 35333.3333 25116.6667
+751 35333.3333 25133.3333
+752 35333.3333 25150.0000
+753 35333.3333 25166.6667
+754 35333.3333 25250.0000
+755 35333.3333 25350.0000
+756 35333.3333 25616.6667
+757 35333.3333 25633.3333
+758 35333.3333 25666.6667
+759 35333.3333 25700.0000
+760 35333.3333 25733.3333
+761 35333.3333 25750.0000
+762 35350.0000 23583.3333
+763 35350.0000 23600.0000
+764 35350.0000 23633.3333
+765 35350.0000 23666.6667
+766 35350.0000 23683.3333
+767 35350.0000 23700.0000
+768 35350.0000 23833.3333
+769 35350.0000 24166.6667
+770 35350.0000 24183.3333
+771 35350.0000 24200.0000
+772 35350.0000 24216.6667
+773 35350.0000 24233.3333
+774 35350.0000 24250.0000
+775 35350.0000 24266.6667
+776 35350.0000 24283.3333
+777 35350.0000 24316.6667
+778 35350.0000 24400.0000
+779 35350.0000 24416.6667
+780 35350.0000 24433.3333
+781 35350.0000 24450.0000
+782 35350.0000 24516.6667
+783 35350.0000 24533.3333
+784 35350.0000 24550.0000
+785 35350.0000 24566.6667
+786 35350.0000 24583.3333
+787 35350.0000 24600.0000
+788 35350.0000 24633.3333
+789 35350.0000 24666.6667
+790 35350.0000 24683.3333
+791 35350.0000 24716.6667
+792 35350.0000 24733.3333
+793 35350.0000 24750.0000
+794 35350.0000 24766.6667
+795 35350.0000 24783.3333
+796 35350.0000 24816.6667
+797 35350.0000 24833.3333
+798 35350.0000 24850.0000
+799 35350.0000 24866.6667
+800 35350.0000 24916.6667
+801 35350.0000 24966.6667
+802 35366.6667 23550.0000
+803 35366.6667 23566.6667
+804 35366.6667 23583.3333
+805 35366.6667 23600.0000
+806 35366.6667 23616.6667
+807 35366.6667 23633.3333
+808 35366.6667 23650.0000
+809 35366.6667 23666.6667
+810 35366.6667 23700.0000
+811 35366.6667 23733.3333
+812 35366.6667 23783.3333
+813 35366.6667 23850.0000
+814 35366.6667 23866.6667
+815 35366.6667 24150.0000
+816 35366.6667 24166.6667
+817 35366.6667 24250.0000
+818 35366.6667 24266.6667
+819 35366.6667 24466.6667
+820 35366.6667 24483.3333
+821 35366.6667 24500.0000
+822 35366.6667 24533.3333
+823 35366.6667 24566.6667
+824 35366.6667 24583.3333
+825 35366.6667 24600.0000
+826 35366.6667 24616.6667
+827 35366.6667 24633.3333
+828 35366.6667 24666.6667
+829 35366.6667 24700.0000
+830 35366.6667 24716.6667
+831 35366.6667 24766.6667
+832 35366.6667 24883.3333
+833 35366.6667 25016.6667
+834 35383.3333 23633.3333
+835 35383.3333 23666.6667
+836 35383.3333 23733.3333
+837 35383.3333 23766.6667
+838 35383.3333 23816.6667
+839 35383.3333 23850.0000
+840 35383.3333 23866.6667
+841 35383.3333 23900.0000
+842 35383.3333 23966.6667
+843 35383.3333 24100.0000
+844 35383.3333 24116.6667
+845 35383.3333 24133.3333
+846 35383.3333 24150.0000
+847 35383.3333 24166.6667
+848 35383.3333 24183.3333
+849 35383.3333 24200.0000
+850 35383.3333 24216.6667
+851 35383.3333 24233.3333
+852 35383.3333 24250.0000
+853 35383.3333 24600.0000
+854 35383.3333 24616.6667
+855 35383.3333 24683.3333
+856 35383.3333 24733.3333
+857 35383.3333 24950.0000
+858 35383.3333 24966.6667
+859 35400.0000 23550.0000
+860 35400.0000 23566.6667
+861 35400.0000 23600.0000
+862 35400.0000 23616.6667
+863 35400.0000 23633.3333
+864 35400.0000 23666.6667
+865 35400.0000 23683.3333
+866 35400.0000 23716.6667
+867 35400.0000 23733.3333
+868 35400.0000 23766.6667
+869 35400.0000 23783.3333
+870 35400.0000 23850.0000
+871 35400.0000 23900.0000
+872 35400.0000 23916.6667
+873 35400.0000 23933.3333
+874 35400.0000 23950.0000
+875 35400.0000 23983.3333
+876 35400.0000 24066.6667
+877 35400.0000 24083.3333
+878 35400.0000 24100.0000
+879 35400.0000 24133.3333
+880 35400.0000 24150.0000
+881 35400.0000 24166.6667
+882 35400.0000 24183.3333
+883 35400.0000 24200.0000
+884 35400.0000 24216.6667
+885 35400.0000 24233.3333
+886 35400.0000 24250.0000
+887 35400.0000 24700.0000
+888 35400.0000 24716.6667
+889 35400.0000 24733.3333
+890 35400.0000 24750.0000
+891 35400.0000 24783.3333
+892 35400.0000 24883.3333
+893 35400.0000 24983.3333
+894 35400.0000 26916.6667
+895 35400.0000 26933.3333
+896 35400.0000 26950.0000
+897 35416.6667 23566.6667
+898 35416.6667 23583.3333
+899 35416.6667 23633.3333
+900 35416.6667 23650.0000
+901 35416.6667 23683.3333
+902 35416.6667 23700.0000
+903 35416.6667 23750.0000
+904 35416.6667 23783.3333
+905 35416.6667 23850.0000
+906 35416.6667 23933.3333
+907 35416.6667 24016.6667
+908 35416.6667 24033.3333
+909 35416.6667 24050.0000
+910 35416.6667 24066.6667
+911 35416.6667 24083.3333
+912 35416.6667 24100.0000
+913 35416.6667 24116.6667
+914 35416.6667 24133.3333
+915 35416.6667 24150.0000
+916 35416.6667 24183.3333
+917 35416.6667 24200.0000
+918 35416.6667 24216.6667
+919 35416.6667 24233.3333
+920 35416.6667 24250.0000
+921 35416.6667 24700.0000
+922 35416.6667 24716.6667
+923 35416.6667 24783.3333
+924 35416.6667 26933.3333
+925 35433.3333 23583.3333
+926 35433.3333 23633.3333
+927 35433.3333 23666.6667
+928 35433.3333 23683.3333
+929 35433.3333 23700.0000
+930 35433.3333 23716.6667
+931 35433.3333 23750.0000
+932 35433.3333 23766.6667
+933 35433.3333 23783.3333
+934 35433.3333 23833.3333
+935 35433.3333 23850.0000
+936 35433.3333 23916.6667
+937 35433.3333 23933.3333
+938 35433.3333 24033.3333
+939 35433.3333 24050.0000
+940 35433.3333 24066.6667
+941 35433.3333 24116.6667
+942 35433.3333 24166.6667
+943 35433.3333 24183.3333
+944 35433.3333 24200.0000
+945 35433.3333 24233.3333
+946 35450.0000 23583.3333
+947 35450.0000 23600.0000
+948 35450.0000 23616.6667
+949 35450.0000 23633.3333
+950 35450.0000 23650.0000
+951 35450.0000 23666.6667
+952 35450.0000 23683.3333
+953 35450.0000 23700.0000
+954 35450.0000 23716.6667
+955 35450.0000 23733.3333
+956 35450.0000 23750.0000
+957 35450.0000 23766.6667
+958 35450.0000 23783.3333
+959 35450.0000 23800.0000
+960 35450.0000 23833.3333
+961 35450.0000 23866.6667
+962 35450.0000 23900.0000
+963 35450.0000 23916.6667
+964 35450.0000 24016.6667
+965 35450.0000 24033.3333
+966 35450.0000 24050.0000
+967 35450.0000 24116.6667
+968 35450.0000 24166.6667
+969 35450.0000 24200.0000
+970 35450.0000 24216.6667
+971 35450.0000 24233.3333
+972 35466.6667 23566.6667
+973 35466.6667 23600.0000
+974 35466.6667 23616.6667
+975 35466.6667 23633.3333
+976 35466.6667 23650.0000
+977 35466.6667 23666.6667
+978 35466.6667 23683.3333
+979 35466.6667 23700.0000
+980 35466.6667 23716.6667
+981 35466.6667 23733.3333
+982 35466.6667 23750.0000
+983 35466.6667 23766.6667
+984 35466.6667 23783.3333
+985 35466.6667 23800.0000
+986 35466.6667 23816.6667
+987 35466.6667 23833.3333
+988 35466.6667 23850.0000
+989 35466.6667 23866.6667
+990 35466.6667 23883.3333
+991 35466.6667 23900.0000
+992 35466.6667 23916.6667
+993 35466.6667 23933.3333
+994 35466.6667 23950.0000
+995 35466.6667 23966.6667
+996 35466.6667 23983.3333
+997 35466.6667 24066.6667
+998 35466.6667 24100.0000
+999 35466.6667 24116.6667
+1000 35466.6667 24133.3333
+1001 35466.6667 24150.0000
+1002 35466.6667 27133.3333
+1003 35483.3333 23583.3333
+1004 35483.3333 23600.0000
+1005 35483.3333 23650.0000
+1006 35483.3333 23666.6667
+1007 35483.3333 23683.3333
+1008 35483.3333 23700.0000
+1009 35483.3333 23716.6667
+1010 35483.3333 23733.3333
+1011 35483.3333 23750.0000
+1012 35483.3333 23766.6667
+1013 35483.3333 23783.3333
+1014 35483.3333 23800.0000
+1015 35483.3333 23816.6667
+1016 35483.3333 23833.3333
+1017 35483.3333 23850.0000
+1018 35483.3333 23866.6667
+1019 35483.3333 23900.0000
+1020 35483.3333 23916.6667
+1021 35483.3333 23950.0000
+1022 35483.3333 23966.6667
+1023 35483.3333 23983.3333
+1024 35483.3333 24000.0000
+1025 35483.3333 24016.6667
+1026 35483.3333 24033.3333
+1027 35483.3333 24066.6667
+1028 35483.3333 27116.6667
+1029 35483.3333 27183.3333
+1030 35500.0000 23600.0000
+1031 35500.0000 23616.6667
+1032 35500.0000 23633.3333
+1033 35500.0000 23650.0000
+1034 35500.0000 23666.6667
+1035 35500.0000 23683.3333
+1036 35500.0000 23700.0000
+1037 35500.0000 23716.6667
+1038 35500.0000 23733.3333
+1039 35500.0000 23750.0000
+1040 35500.0000 23766.6667
+1041 35500.0000 23783.3333
+1042 35500.0000 23800.0000
+1043 35500.0000 23816.6667
+1044 35500.0000 23833.3333
+1045 35500.0000 23850.0000
+1046 35500.0000 23866.6667
+1047 35500.0000 23883.3333
+1048 35500.0000 23900.0000
+1049 35500.0000 23933.3333
+1050 35500.0000 23966.6667
+1051 35500.0000 23983.3333
+1052 35500.0000 24000.0000
+1053 35500.0000 24016.6667
+1054 35500.0000 24033.3333
+1055 35500.0000 27233.3333
+1056 35516.6667 23600.0000
+1057 35516.6667 23616.6667
+1058 35516.6667 23633.3333
+1059 35516.6667 23750.0000
+1060 35516.6667 23783.3333
+1061 35516.6667 23816.6667
+1062 35516.6667 23850.0000
+1063 35516.6667 23866.6667
+1064 35516.6667 23883.3333
+1065 35516.6667 23916.6667
+1066 35516.6667 23933.3333
+1067 35516.6667 23966.6667
+1068 35516.6667 23983.3333
+1069 35516.6667 24000.0000
+1070 35516.6667 24033.3333
+1071 35516.6667 24050.0000
+1072 35516.6667 24083.3333
+1073 35516.6667 24100.0000
+1074 35516.6667 24116.6667
+1075 35516.6667 24133.3333
+1076 35516.6667 24150.0000
+1077 35516.6667 27133.3333
+1078 35533.3333 23733.3333
+1079 35533.3333 23750.0000
+1080 35533.3333 23766.6667
+1081 35533.3333 23783.3333
+1082 35533.3333 23800.0000
+1083 35533.3333 24083.3333
+1084 35533.3333 24100.0000
+1085 35533.3333 24116.6667
+1086 35533.3333 24150.0000
+1087 35533.3333 24183.3333
+1088 35533.3333 27150.0000
+1089 35550.0000 23750.0000
+1090 35550.0000 23766.6667
+1091 35550.0000 23783.3333
+1092 35550.0000 24150.0000
+1093 35550.0000 24166.6667
+1094 35550.0000 27166.6667
+1095 35550.0000 27183.3333
+1096 35566.6667 23600.0000
+1097 35566.6667 23750.0000
+1098 35566.6667 23766.6667
+1099 35566.6667 24100.0000
+1100 35566.6667 24133.3333
+1101 35600.0000 23716.6667
+1102 35616.6667 27116.6667
+1103 35633.3333 27150.0000
+1104 35666.6667 23733.3333
+1105 35683.3333 27150.0000
+1106 35733.3333 27183.3333
+1107 35750.0000 27216.6667
+1108 35766.6667 27183.3333
+1109 35800.0000 27216.6667
+1110 35866.6667 23300.0000
+1111 35883.3333 23283.3333
+1112 35900.0000 27216.6667
+1113 35900.0000 27250.0000
+1114 35950.0000 27766.6667
+1115 35966.6667 27866.6667
+1116 36000.0000 27816.6667
+1117 36016.6667 27933.3333
+1118 36050.0000 27816.6667
+1119 36050.0000 27883.3333
+1120 36066.6667 27933.3333
+1121 36083.3333 27800.0000
+1122 36083.3333 27850.0000
+1123 36083.3333 28083.3333
+1124 36100.0000 27833.3333
+1125 36100.0000 28016.6667
+1126 36116.6667 27750.0000
+1127 36133.3333 29583.3333
+1128 36150.0000 22983.3333
+1129 36150.0000 23016.6667
+1130 36150.0000 23033.3333
+1131 36150.0000 27783.3333
+1132 36150.0000 27850.0000
+1133 36150.0000 27950.0000
+1134 36166.6667 22966.6667
+1135 36166.6667 22983.3333
+1136 36166.6667 23000.0000
+1137 36183.3333 22950.0000
+1138 36183.3333 22966.6667
+1139 36183.3333 22983.3333
+1140 36183.3333 23000.0000
+1141 36183.3333 28133.3333
+1142 36200.0000 22950.0000
+1143 36200.0000 22966.6667
+1144 36200.0000 22983.3333
+1145 36200.0000 23000.0000
+1146 36216.6667 22916.6667
+1147 36216.6667 22950.0000
+1148 36216.6667 22966.6667
+1149 36216.6667 22983.3333
+1150 36216.6667 27600.0000
+1151 36216.6667 27616.6667
+1152 36216.6667 27866.6667
+1153 36233.3333 22950.0000
+1154 36233.3333 22966.6667
+1155 36233.3333 22983.3333
+1156 36233.3333 23000.0000
+1157 36233.3333 23083.3333
+1158 36233.3333 27850.0000
+1159 36250.0000 22933.3333
+1160 36250.0000 22950.0000
+1161 36250.0000 22983.3333
+1162 36250.0000 23000.0000
+1163 36250.0000 27716.6667
+1164 36250.0000 27966.6667
+1165 36250.0000 28016.6667
+1166 36250.0000 28166.6667
+1167 36266.6667 22950.0000
+1168 36266.6667 22966.6667
+1169 36266.6667 22983.3333
+1170 36266.6667 23083.3333
+1171 36266.6667 27900.0000
+1172 36266.6667 27916.6667
+1173 36283.3333 22950.0000
+1174 36283.3333 22966.6667
+1175 36283.3333 27866.6667
+1176 36283.3333 27950.0000
+1177 36300.0000 22966.6667
+1178 36300.0000 22983.3333
+1179 36300.0000 28150.0000
+1180 36316.6667 22933.3333
+1181 36316.6667 22950.0000
+1182 36316.6667 28050.0000
+1183 36333.3333 22950.0000
+1184 36333.3333 22966.6667
+1185 36333.3333 22983.3333
+1186 36333.3333 27950.0000
+1187 36350.0000 22950.0000
+1188 36350.0000 25400.0000
+1189 36350.0000 25450.0000
+1190 36350.0000 25766.6667
+1191 36350.0000 27983.3333
+1192 36366.6667 22950.0000
+1193 36383.3333 25433.3333
+1194 36383.3333 25450.0000
+1195 36383.3333 25466.6667
+1196 36399.1667 27423.6111
+1197 36400.0000 22483.3333
+1198 36400.0000 25450.0000
+1199 36400.0000 25483.3333
+1200 36400.0000 28083.3333
+1201 36400.0000 28116.6667
+1202 36400.0000 28166.6667
+1203 36415.8333 27385.0000
+1204 36416.6667 22483.3333
+1205 36416.6667 25433.3333
+1206 36416.6667 25450.0000
+1207 36416.6667 28183.3333
+1208 36420.8333 27371.3889
+1209 36433.3333 22466.6667
+1210 36433.3333 22483.3333
+1211 36433.3333 25333.3333
+1212 36433.3333 25350.0000
+1213 36433.3333 25416.6667
+1214 36433.3333 25433.3333
+1215 36433.3333 28216.6667
+1216 36449.1667 27348.3333
+1217 36450.0000 22466.6667
+1218 36450.0000 22483.3333
+1219 36450.0000 28250.0000
+1220 36458.6111 27318.6111
+1221 36466.6667 22433.3333
+1222 36466.6667 22450.0000
+1223 36466.6667 22466.6667
+1224 36466.6667 23166.6667
+1225 36466.6667 25366.6667
+1226 36466.6667 25383.3333
+1227 36466.6667 25400.0000
+1228 36483.3333 22366.6667
+1229 36483.3333 22383.3333
+1230 36483.3333 22400.0000
+1231 36483.3333 22416.6667
+1232 36483.3333 22450.0000
+1233 36483.3333 22483.3333
+1234 36483.3333 22500.0000
+1235 36483.3333 22950.0000
+1236 36483.3333 23100.0000
+1237 36483.3333 23150.0000
+1238 36500.0000 22366.6667
+1239 36500.0000 22383.3333
+1240 36500.0000 22400.0000
+1241 36500.0000 22416.6667
+1242 36500.0000 22433.3333
+1243 36500.0000 22466.6667
+1244 36500.0000 22483.3333
+1245 36500.0000 23083.3333
+1246 36516.6667 22366.6667
+1247 36516.6667 22383.3333
+1248 36516.6667 22400.0000
+1249 36516.6667 22416.6667
+1250 36516.6667 22466.6667
+1251 36516.6667 22483.3333
+1252 36516.6667 22983.3333
+1253 36516.6667 23050.0000
+1254 36516.6667 23066.6667
+1255 36516.6667 23083.3333
+1256 36533.3333 22366.6667
+1257 36533.3333 22383.3333
+1258 36533.3333 22400.0000
+1259 36533.3333 22416.6667
+1260 36533.3333 22433.3333
+1261 36533.3333 22450.0000
+1262 36533.3333 22466.6667
+1263 36533.3333 22983.3333
+1264 36533.3333 23083.3333
+1265 36533.3333 23116.6667
+1266 36533.3333 27850.0000
+1267 36550.0000 22400.0000
+1268 36550.0000 22416.6667
+1269 36550.0000 22450.0000
+1270 36550.0000 22983.3333
+1271 36550.0000 23000.0000
+1272 36550.0000 23016.6667
+1273 36550.0000 23033.3333
+1274 36550.0000 23050.0000
+1275 36550.0000 23100.0000
+1276 36550.0000 26350.0000
+1277 36558.6111 27175.5556
+1278 36566.6667 22400.0000
+1279 36566.6667 22416.6667
+1280 36566.6667 22466.6667
+1281 36566.6667 22483.3333
+1282 36566.6667 22966.6667
+1283 36566.6667 22983.3333
+1284 36566.6667 23000.0000
+1285 36566.6667 23016.6667
+1286 36566.6667 23033.3333
+1287 36566.6667 23050.0000
+1288 36574.1667 27177.7778
+1289 36583.3333 22400.0000
+1290 36583.3333 22416.6667
+1291 36583.3333 22466.6667
+1292 36583.3333 23033.3333
+1293 36600.0000 22366.6667
+1294 36600.0000 22383.3333
+1295 36600.0000 22400.0000
+1296 36600.0000 22416.6667
+1297 36600.0000 22966.6667
+1298 36600.0000 23050.0000
+1299 36600.0000 24916.6667
+1300 36600.0000 24933.3333
+1301 36600.0000 27833.3333
+1302 36603.3333 27177.7778
+1303 36611.3889 27133.3333
+1304 36616.6667 22383.3333
+1305 36616.6667 22400.0000
+1306 36616.6667 22466.6667
+1307 36616.6667 22483.3333
+1308 36616.6667 22500.0000
+1309 36616.6667 22916.6667
+1310 36616.6667 22983.3333
+1311 36616.6667 23000.0000
+1312 36616.6667 24950.0000
+1313 36617.7778 27170.8333
+1314 36633.3333 22383.3333
+1315 36633.3333 22400.0000
+1316 36633.3333 22466.6667
+1317 36633.3333 22483.3333
+1318 36633.3333 22500.0000
+1319 36633.3333 22883.3333
+1320 36633.3333 22950.0000
+1321 36633.3333 23000.0000
+1322 36633.3333 23016.6667
+1323 36633.3333 23033.3333
+1324 36633.3333 24900.0000
+1325 36633.3333 24916.6667
+1326 36650.0000 22383.3333
+1327 36650.0000 22400.0000
+1328 36650.0000 22416.6667
+1329 36650.0000 22433.3333
+1330 36650.0000 22466.6667
+1331 36650.0000 22500.0000
+1332 36650.0000 22900.0000
+1333 36650.0000 22966.6667
+1334 36650.0000 23016.6667
+1335 36650.0000 24883.3333
+1336 36662.7778 27119.4444
+1337 36666.6667 22366.6667
+1338 36666.6667 22383.3333
+1339 36666.6667 22433.3333
+1340 36666.6667 22450.0000
+1341 36666.6667 22466.6667
+1342 36666.6667 22483.3333
+1343 36666.6667 22500.0000
+1344 36666.6667 22533.3333
+1345 36666.6667 22550.0000
+1346 36666.6667 22933.3333
+1347 36666.6667 22983.3333
+1348 36666.6667 23016.6667
+1349 36683.3333 22383.3333
+1350 36683.3333 22416.6667
+1351 36683.3333 22433.3333
+1352 36683.3333 22450.0000
+1353 36683.3333 22466.6667
+1354 36683.3333 22483.3333
+1355 36683.3333 22516.6667
+1356 36683.3333 22833.3333
+1357 36683.3333 22916.6667
+1358 36683.3333 22933.3333
+1359 36683.3333 22966.6667
+1360 36683.3333 23033.3333
+1361 36683.3333 23050.0000
+1362 36683.3333 25333.3333
+1363 36700.0000 22383.3333
+1364 36700.0000 22466.6667
+1365 36700.0000 22483.3333
+1366 36700.0000 22533.3333
+1367 36700.0000 22900.0000
+1368 36700.0000 22916.6667
+1369 36700.0000 22933.3333
+1370 36700.0000 22950.0000
+1371 36700.0000 23033.3333
+1372 36700.0000 24483.3333
+1373 36700.0000 24533.3333
+1374 36700.0000 25116.6667
+1375 36716.6667 22350.0000
+1376 36716.6667 22366.6667
+1377 36716.6667 22383.3333
+1378 36716.6667 22400.0000
+1379 36716.6667 22416.6667
+1380 36716.6667 22433.3333
+1381 36716.6667 22466.6667
+1382 36716.6667 22500.0000
+1383 36716.6667 22866.6667
+1384 36716.6667 22950.0000
+1385 36716.6667 22983.3333
+1386 36733.3333 22333.3333
+1387 36733.3333 22350.0000
+1388 36733.3333 22416.6667
+1389 36733.3333 22433.3333
+1390 36733.3333 22450.0000
+1391 36733.3333 22466.6667
+1392 36733.3333 22483.3333
+1393 36733.3333 22500.0000
+1394 36733.3333 22550.0000
+1395 36733.3333 22566.6667
+1396 36733.3333 22866.6667
+1397 36733.3333 22900.0000
+1398 36733.3333 23033.3333
+1399 36733.3333 24433.3333
+1400 36733.3333 25283.3333
+1401 36750.0000 22333.3333
+1402 36750.0000 22450.0000
+1403 36750.0000 22466.6667
+1404 36750.0000 22500.0000
+1405 36750.0000 22516.6667
+1406 36750.0000 22533.3333
+1407 36750.0000 22566.6667
+1408 36750.0000 22800.0000
+1409 36750.0000 22933.3333
+1410 36750.0000 22966.6667
+1411 36750.0000 23000.0000
+1412 36750.0000 23016.6667
+1413 36750.0000 23066.6667
+1414 36750.0000 24416.6667
+1415 36750.0000 24433.3333
+1416 36750.0000 24533.3333
+1417 36766.6667 21900.0000
+1418 36766.6667 22316.6667
+1419 36766.6667 22416.6667
+1420 36766.6667 22433.3333
+1421 36766.6667 22466.6667
+1422 36766.6667 22500.0000
+1423 36766.6667 22933.3333
+1424 36766.6667 23083.3333
+1425 36766.6667 24516.6667
+1426 36766.6667 27083.3333
+1427 36783.3333 21883.3333
+1428 36783.3333 21916.6667
+1429 36783.3333 22333.3333
+1430 36783.3333 22416.6667
+1431 36783.3333 22450.0000
+1432 36783.3333 22466.6667
+1433 36783.3333 22483.3333
+1434 36783.3333 22516.6667
+1435 36783.3333 22533.3333
+1436 36783.3333 22550.0000
+1437 36783.3333 22900.0000
+1438 36783.3333 23050.0000
+1439 36783.3333 23083.3333
+1440 36783.3333 25800.0000
+1441 36783.3333 27150.0000
+1442 36800.0000 21766.6667
+1443 36800.0000 21800.0000
+1444 36800.0000 21833.3333
+1445 36800.0000 21866.6667
+1446 36800.0000 21916.6667
+1447 36800.0000 21950.0000
+1448 36800.0000 22316.6667
+1449 36800.0000 22333.3333
+1450 36800.0000 22416.6667
+1451 36800.0000 22450.0000
+1452 36800.0000 22466.6667
+1453 36800.0000 22483.3333
+1454 36800.0000 22500.0000
+1455 36800.0000 22516.6667
+1456 36800.0000 22533.3333
+1457 36800.0000 22783.3333
+1458 36800.0000 22850.0000
+1459 36800.0000 22916.6667
+1460 36800.0000 23050.0000
+1461 36800.0000 24583.3333
+1462 36800.0000 25783.3333
+1463 36800.0000 25816.6667
+1464 36800.0000 27116.6667
+1465 36816.6667 21700.0000
+1466 36816.6667 21750.0000
+1467 36816.6667 21800.0000
+1468 36816.6667 21833.3333
+1469 36816.6667 21850.0000
+1470 36816.6667 21883.3333
+1471 36816.6667 21900.0000
+1472 36816.6667 21916.6667
+1473 36816.6667 21933.3333
+1474 36816.6667 22283.3333
+1475 36816.6667 22300.0000
+1476 36816.6667 22316.6667
+1477 36816.6667 22416.6667
+1478 36816.6667 22433.3333
+1479 36816.6667 22450.0000
+1480 36816.6667 22550.0000
+1481 36816.6667 23033.3333
+1482 36816.6667 26966.6667
+1483 36833.3333 21766.6667
+1484 36833.3333 21800.0000
+1485 36833.3333 21833.3333
+1486 36833.3333 21866.6667
+1487 36833.3333 21883.3333
+1488 36833.3333 21916.6667
+1489 36833.3333 22300.0000
+1490 36833.3333 22316.6667
+1491 36833.3333 22333.3333
+1492 36833.3333 22350.0000
+1493 36833.3333 22400.0000
+1494 36833.3333 22433.3333
+1495 36833.3333 22483.3333
+1496 36833.3333 22550.0000
+1497 36833.3333 22583.3333
+1498 36833.3333 22616.6667
+1499 36833.3333 22683.3333
+1500 36833.3333 22700.0000
+1501 36833.3333 22733.3333
+1502 36833.3333 22783.3333
+1503 36833.3333 22800.0000
+1504 36833.3333 22850.0000
+1505 36833.3333 23000.0000
+1506 36833.3333 25450.0000
+1507 36833.3333 25866.6667
+1508 36833.3333 25900.0000
+1509 36850.0000 21733.3333
+1510 36850.0000 21750.0000
+1511 36850.0000 21766.6667
+1512 36850.0000 21816.6667
+1513 36850.0000 21833.3333
+1514 36850.0000 21866.6667
+1515 36850.0000 21916.6667
+1516 36850.0000 22266.6667
+1517 36850.0000 22283.3333
+1518 36850.0000 22316.6667
+1519 36850.0000 22350.0000
+1520 36850.0000 22416.6667
+1521 36850.0000 22450.0000
+1522 36850.0000 22466.6667
+1523 36850.0000 22500.0000
+1524 36850.0000 22600.0000
+1525 36850.0000 22666.6667
+1526 36850.0000 22683.3333
+1527 36850.0000 22733.3333
+1528 36850.0000 23000.0000
+1529 36850.0000 27083.3333
+1530 36850.0000 27166.6667
+1531 36850.0000 27216.6667
+1532 36866.6667 21700.0000
+1533 36866.6667 21716.6667
+1534 36866.6667 21750.0000
+1535 36866.6667 21766.6667
+1536 36866.6667 21783.3333
+1537 36866.6667 21816.6667
+1538 36866.6667 21833.3333
+1539 36866.6667 21866.6667
+1540 36866.6667 21900.0000
+1541 36866.6667 22316.6667
+1542 36866.6667 22466.6667
+1543 36866.6667 22500.0000
+1544 36866.6667 22683.3333
+1545 36866.6667 22700.0000
+1546 36866.6667 22900.0000
+1547 36866.6667 23016.6667
+1548 36866.6667 25466.6667
+1549 36866.6667 25516.6667
+1550 36883.3333 21716.6667
+1551 36883.3333 21866.6667
+1552 36883.3333 21900.0000
+1553 36883.3333 22233.3333
+1554 36883.3333 22250.0000
+1555 36883.3333 22283.3333
+1556 36883.3333 22400.0000
+1557 36883.3333 22416.6667
+1558 36883.3333 22483.3333
+1559 36883.3333 22516.6667
+1560 36883.3333 22550.0000
+1561 36883.3333 22566.6667
+1562 36883.3333 22666.6667
+1563 36883.3333 22700.0000
+1564 36883.3333 22800.0000
+1565 36883.3333 22983.3333
+1566 36883.3333 25516.6667
+1567 36883.3333 27150.0000
+1568 36883.3333 27283.3333
+1569 36883.3333 27300.0000
+1570 36900.0000 21750.0000
+1571 36900.0000 21766.6667
+1572 36900.0000 21816.6667
+1573 36900.0000 21850.0000
+1574 36900.0000 21866.6667
+1575 36900.0000 21900.0000
+1576 36900.0000 21916.6667
+1577 36900.0000 22250.0000
+1578 36900.0000 22266.6667
+1579 36900.0000 22450.0000
+1580 36900.0000 22650.0000
+1581 36900.0000 22716.6667
+1582 36900.0000 22850.0000
+1583 36900.0000 22966.6667
+1584 36900.0000 23000.0000
+1585 36900.0000 25566.6667
+1586 36900.0000 25983.3333
+1587 36900.0000 26000.0000
+1588 36916.6667 21700.0000
+1589 36916.6667 21833.3333
+1590 36916.6667 21850.0000
+1591 36916.6667 21866.6667
+1592 36916.6667 21900.0000
+1593 36916.6667 21916.6667
+1594 36916.6667 22150.0000
+1595 36916.6667 22233.3333
+1596 36916.6667 22250.0000
+1597 36916.6667 22266.6667
+1598 36916.6667 22433.3333
+1599 36916.6667 22450.0000
+1600 36916.6667 22750.0000
+1601 36916.6667 23000.0000
+1602 36916.6667 25983.3333
+1603 36933.3333 21833.3333
+1604 36933.3333 21883.3333
+1605 36933.3333 22150.0000
+1606 36933.3333 22166.6667
+1607 36933.3333 22183.3333
+1608 36933.3333 22200.0000
+1609 36933.3333 22466.6667
+1610 36933.3333 22483.3333
+1611 36933.3333 22533.3333
+1612 36933.3333 22816.6667
+1613 36933.3333 24683.3333
+1614 36933.3333 24733.3333
+1615 36933.3333 27150.0000
+1616 36950.0000 21700.0000
+1617 36950.0000 21733.3333
+1618 36950.0000 21750.0000
+1619 36950.0000 21783.3333
+1620 36950.0000 21816.6667
+1621 36950.0000 21850.0000
+1622 36950.0000 21866.6667
+1623 36950.0000 21883.3333
+1624 36950.0000 21933.3333
+1625 36950.0000 22166.6667
+1626 36950.0000 22183.3333
+1627 36950.0000 22216.6667
+1628 36950.0000 22233.3333
+1629 36950.0000 22250.0000
+1630 36950.0000 22416.6667
+1631 36950.0000 22450.0000
+1632 36950.0000 22466.6667
+1633 36950.0000 22766.6667
+1634 36950.0000 24750.0000
+1635 36950.0000 26983.3333
+1636 36966.6667 21700.0000
+1637 36966.6667 21733.3333
+1638 36966.6667 21750.0000
+1639 36966.6667 21816.6667
+1640 36966.6667 21850.0000
+1641 36966.6667 21866.6667
+1642 36966.6667 21900.0000
+1643 36966.6667 22150.0000
+1644 36966.6667 22166.6667
+1645 36966.6667 22200.0000
+1646 36966.6667 22233.3333
+1647 36966.6667 22400.0000
+1648 36966.6667 22416.6667
+1649 36966.6667 22450.0000
+1650 36966.6667 22466.6667
+1651 36966.6667 22650.0000
+1652 36966.6667 22983.3333
+1653 36966.6667 24716.6667
+1654 36966.6667 24733.3333
+1655 36966.6667 24750.0000
+1656 36966.6667 26966.6667
+1657 36966.6667 27016.6667
+1658 36983.3333 21666.6667
+1659 36983.3333 21716.6667
+1660 36983.3333 21766.6667
+1661 36983.3333 21783.3333
+1662 36983.3333 21800.0000
+1663 36983.3333 21833.3333
+1664 36983.3333 21850.0000
+1665 36983.3333 21883.3333
+1666 36983.3333 22150.0000
+1667 36983.3333 22183.3333
+1668 36983.3333 22316.6667
+1669 36983.3333 22400.0000
+1670 36983.3333 22433.3333
+1671 36983.3333 22466.6667
+1672 36983.3333 22500.0000
+1673 36983.3333 22516.6667
+1674 36983.3333 22533.3333
+1675 36983.3333 22566.6667
+1676 36983.3333 22850.0000
+1677 36983.3333 22883.3333
+1678 36983.3333 22983.3333
+1679 36983.3333 24683.3333
+1680 36983.3333 24716.6667
+1681 36983.3333 24733.3333
+1682 36983.3333 25066.6667
+1683 36983.3333 26933.3333
+1684 36983.3333 26950.0000
+1685 36983.3333 27000.0000
+1686 37000.0000 21666.6667
+1687 37000.0000 21683.3333
+1688 37000.0000 21716.6667
+1689 37000.0000 21750.0000
+1690 37000.0000 21850.0000
+1691 37000.0000 21883.3333
+1692 37000.0000 21916.6667
+1693 37000.0000 21933.3333
+1694 37000.0000 22150.0000
+1695 37000.0000 22166.6667
+1696 37000.0000 22183.3333
+1697 37000.0000 22250.0000
+1698 37000.0000 22300.0000
+1699 37000.0000 22383.3333
+1700 37000.0000 22500.0000
+1701 37000.0000 22700.0000
+1702 37000.0000 25166.6667
+1703 37016.6667 21633.3333
+1704 37016.6667 21733.3333
+1705 37016.6667 21750.0000
+1706 37016.6667 21800.0000
+1707 37016.6667 21833.3333
+1708 37016.6667 21883.3333
+1709 37016.6667 21900.0000
+1710 37016.6667 21933.3333
+1711 37016.6667 21950.0000
+1712 37016.6667 21966.6667
+1713 37016.6667 22266.6667
+1714 37016.6667 22416.6667
+1715 37016.6667 22450.0000
+1716 37016.6667 22466.6667
+1717 37016.6667 22483.3333
+1718 37016.6667 22783.3333
+1719 37016.6667 25183.3333
+1720 37016.6667 26983.3333
+1721 37033.3333 21783.3333
+1722 37033.3333 21800.0000
+1723 37033.3333 21866.6667
+1724 37033.3333 21883.3333
+1725 37033.3333 21916.6667
+1726 37033.3333 21933.3333
+1727 37033.3333 21966.6667
+1728 37033.3333 22083.3333
+1729 37033.3333 22116.6667
+1730 37033.3333 22133.3333
+1731 37033.3333 22183.3333
+1732 37033.3333 22216.6667
+1733 37033.3333 22233.3333
+1734 37033.3333 22366.6667
+1735 37033.3333 22416.6667
+1736 37033.3333 22433.3333
+1737 37033.3333 22450.0000
+1738 37033.3333 22466.6667
+1739 37033.3333 22483.3333
+1740 37033.3333 22516.6667
+1741 37033.3333 22566.6667
+1742 37033.3333 22616.6667
+1743 37033.3333 22833.3333
+1744 37033.3333 22983.3333
+1745 37033.3333 25083.3333
+1746 37033.3333 25433.3333
+1747 37033.3333 26966.6667
+1748 37050.0000 21600.0000
+1749 37050.0000 21666.6667
+1750 37050.0000 21700.0000
+1751 37050.0000 21716.6667
+1752 37050.0000 21766.6667
+1753 37050.0000 21800.0000
+1754 37050.0000 21816.6667
+1755 37050.0000 21850.0000
+1756 37050.0000 21883.3333
+1757 37050.0000 21933.3333
+1758 37050.0000 21950.0000
+1759 37050.0000 22016.6667
+1760 37050.0000 22083.3333
+1761 37050.0000 22100.0000
+1762 37050.0000 22166.6667
+1763 37050.0000 22183.3333
+1764 37050.0000 22366.6667
+1765 37050.0000 22400.0000
+1766 37050.0000 22416.6667
+1767 37050.0000 22433.3333
+1768 37050.0000 22450.0000
+1769 37050.0000 22783.3333
+1770 37050.0000 22900.0000
+1771 37050.0000 25133.3333
+1772 37050.0000 25200.0000
+1773 37050.0000 25233.3333
+1774 37050.0000 25250.0000
+1775 37050.0000 25400.0000
+1776 37050.0000 25483.3333
+1777 37050.0000 25500.0000
+1778 37050.0000 25533.3333
+1779 37050.0000 26933.3333
+1780 37066.6667 21583.3333
+1781 37066.6667 21600.0000
+1782 37066.6667 21633.3333
+1783 37066.6667 21700.0000
+1784 37066.6667 21750.0000
+1785 37066.6667 21783.3333
+1786 37066.6667 21816.6667
+1787 37066.6667 21883.3333
+1788 37066.6667 21933.3333
+1789 37066.6667 21966.6667
+1790 37066.6667 21983.3333
+1791 37066.6667 22000.0000
+1792 37066.6667 22066.6667
+1793 37066.6667 22083.3333
+1794 37066.6667 22100.0000
+1795 37066.6667 22166.6667
+1796 37066.6667 22216.6667
+1797 37066.6667 22350.0000
+1798 37066.6667 22366.6667
+1799 37066.6667 22383.3333
+1800 37066.6667 22416.6667
+1801 37066.6667 22433.3333
+1802 37066.6667 22450.0000
+1803 37066.6667 22583.3333
+1804 37066.6667 22783.3333
+1805 37066.6667 22800.0000
+1806 37066.6667 22816.6667
+1807 37066.6667 22850.0000
+1808 37066.6667 22916.6667
+1809 37066.6667 22933.3333
+1810 37066.6667 25116.6667
+1811 37066.6667 25133.3333
+1812 37066.6667 25400.0000
+1813 37066.6667 25433.3333
+1814 37066.6667 25450.0000
+1815 37066.6667 25466.6667
+1816 37066.6667 25483.3333
+1817 37066.6667 25500.0000
+1818 37066.6667 25516.6667
+1819 37083.3333 21666.6667
+1820 37083.3333 21766.6667
+1821 37083.3333 21783.3333
+1822 37083.3333 21800.0000
+1823 37083.3333 21833.3333
+1824 37083.3333 21866.6667
+1825 37083.3333 21900.0000
+1826 37083.3333 21916.6667
+1827 37083.3333 21933.3333
+1828 37083.3333 21950.0000
+1829 37083.3333 21966.6667
+1830 37083.3333 21983.3333
+1831 37083.3333 22000.0000
+1832 37083.3333 22033.3333
+1833 37083.3333 22050.0000
+1834 37083.3333 22100.0000
+1835 37083.3333 22216.6667
+1836 37083.3333 22350.0000
+1837 37083.3333 22366.6667
+1838 37083.3333 22416.6667
+1839 37083.3333 22433.3333
+1840 37083.3333 22566.6667
+1841 37083.3333 22650.0000
+1842 37083.3333 22800.0000
+1843 37083.3333 22833.3333
+1844 37083.3333 22900.0000
+1845 37083.3333 25150.0000
+1846 37083.3333 25166.6667
+1847 37083.3333 25200.0000
+1848 37083.3333 25216.6667
+1849 37083.3333 25416.6667
+1850 37083.3333 25500.0000
+1851 37083.3333 25533.3333
+1852 37083.3333 25583.3333
+1853 37100.0000 21633.3333
+1854 37100.0000 21716.6667
+1855 37100.0000 21750.0000
+1856 37100.0000 21766.6667
+1857 37100.0000 21816.6667
+1858 37100.0000 21833.3333
+1859 37100.0000 21850.0000
+1860 37100.0000 21966.6667
+1861 37100.0000 21983.3333
+1862 37100.0000 22000.0000
+1863 37100.0000 22033.3333
+1864 37100.0000 22050.0000
+1865 37100.0000 22066.6667
+1866 37100.0000 22233.3333
+1867 37100.0000 22250.0000
+1868 37100.0000 22366.6667
+1869 37100.0000 22433.3333
+1870 37100.0000 22450.0000
+1871 37100.0000 22533.3333
+1872 37100.0000 22733.3333
+1873 37100.0000 22800.0000
+1874 37100.0000 22866.6667
+1875 37100.0000 22883.3333
+1876 37100.0000 25383.3333
+1877 37100.0000 25400.0000
+1878 37100.0000 25433.3333
+1879 37100.0000 25483.3333
+1880 37100.0000 26866.6667
+1881 37116.6667 21583.3333
+1882 37116.6667 21733.3333
+1883 37116.6667 21766.6667
+1884 37116.6667 21800.0000
+1885 37116.6667 21833.3333
+1886 37116.6667 21933.3333
+1887 37116.6667 21966.6667
+1888 37116.6667 22033.3333
+1889 37116.6667 22066.6667
+1890 37116.6667 22250.0000
+1891 37116.6667 22333.3333
+1892 37116.6667 22350.0000
+1893 37116.6667 22383.3333
+1894 37116.6667 22866.6667
+1895 37116.6667 25233.3333
+1896 37116.6667 25416.6667
+1897 37116.6667 25433.3333
+1898 37116.6667 25516.6667
+1899 37116.6667 25533.3333
+1900 37116.6667 25816.6667
+1901 37116.6667 26866.6667
+1902 37133.3333 21683.3333
+1903 37133.3333 21750.0000
+1904 37133.3333 21766.6667
+1905 37133.3333 21816.6667
+1906 37133.3333 21866.6667
+1907 37133.3333 21883.3333
+1908 37133.3333 21916.6667
+1909 37133.3333 21966.6667
+1910 37133.3333 21983.3333
+1911 37133.3333 22000.0000
+1912 37133.3333 22016.6667
+1913 37133.3333 22033.3333
+1914 37133.3333 22066.6667
+1915 37133.3333 22333.3333
+1916 37133.3333 22450.0000
+1917 37133.3333 22583.3333
+1918 37133.3333 24450.0000
+1919 37133.3333 24466.6667
+1920 37133.3333 24500.0000
+1921 37133.3333 24516.6667
+1922 37133.3333 26850.0000
+1923 37150.0000 21583.3333
+1924 37150.0000 21766.6667
+1925 37150.0000 21783.3333
+1926 37150.0000 21800.0000
+1927 37150.0000 21833.3333
+1928 37150.0000 21850.0000
+1929 37150.0000 21883.3333
+1930 37150.0000 21966.6667
+1931 37150.0000 22033.3333
+1932 37150.0000 22050.0000
+1933 37150.0000 22083.3333
+1934 37150.0000 22233.3333
+1935 37150.0000 22433.3333
+1936 37150.0000 22900.0000
+1937 37150.0000 24433.3333
+1938 37150.0000 24450.0000
+1939 37150.0000 24500.0000
+1940 37150.0000 24516.6667
+1941 37150.0000 25466.6667
+1942 37150.0000 25533.3333
+1943 37150.0000 25550.0000
+1944 37150.0000 26866.6667
+1945 37166.6667 21616.6667
+1946 37166.6667 21666.6667
+1947 37166.6667 21700.0000
+1948 37166.6667 21716.6667
+1949 37166.6667 21750.0000
+1950 37166.6667 21783.3333
+1951 37166.6667 21833.3333
+1952 37166.6667 21883.3333
+1953 37166.6667 21916.6667
+1954 37166.6667 21983.3333
+1955 37166.6667 22033.3333
+1956 37166.6667 22066.6667
+1957 37166.6667 22083.3333
+1958 37166.6667 22133.3333
+1959 37166.6667 22316.6667
+1960 37166.6667 22416.6667
+1961 37166.6667 22450.0000
+1962 37166.6667 22500.0000
+1963 37166.6667 22666.6667
+1964 37166.6667 22716.6667
+1965 37166.6667 22866.6667
+1966 37166.6667 22900.0000
+1967 37166.6667 24433.3333
+1968 37166.6667 24450.0000
+1969 37166.6667 24483.3333
+1970 37166.6667 26800.0000
+1971 37166.6667 26833.3333
+1972 37183.3333 21600.0000
+1973 37183.3333 21616.6667
+1974 37183.3333 21683.3333
+1975 37183.3333 21750.0000
+1976 37183.3333 21766.6667
+1977 37183.3333 21816.6667
+1978 37183.3333 21850.0000
+1979 37183.3333 21933.3333
+1980 37183.3333 22050.0000
+1981 37183.3333 22183.3333
+1982 37183.3333 22200.0000
+1983 37183.3333 22233.3333
+1984 37183.3333 22300.0000
+1985 37183.3333 22316.6667
+1986 37183.3333 22550.0000
+1987 37183.3333 22600.0000
+1988 37183.3333 22683.3333
+1989 37183.3333 22900.0000
+1990 37183.3333 24483.3333
+1991 37183.3333 24516.6667
+1992 37183.3333 25550.0000
+1993 37200.0000 21616.6667
+1994 37200.0000 21783.3333
+1995 37200.0000 21800.0000
+1996 37200.0000 21883.3333
+1997 37200.0000 21933.3333
+1998 37200.0000 21966.6667
+1999 37200.0000 22000.0000
+2000 37200.0000 22016.6667
+2001 37200.0000 22050.0000
+2002 37200.0000 22083.3333
+2003 37200.0000 22166.6667
+2004 37200.0000 22266.6667
+2005 37200.0000 22283.3333
+2006 37200.0000 22316.6667
+2007 37200.0000 22350.0000
+2008 37200.0000 22366.6667
+2009 37200.0000 22400.0000
+2010 37200.0000 22783.3333
+2011 37200.0000 22883.3333
+2012 37200.0000 24500.0000
+2013 37216.6667 21600.0000
+2014 37216.6667 21633.3333
+2015 37216.6667 21650.0000
+2016 37216.6667 21666.6667
+2017 37216.6667 21683.3333
+2018 37216.6667 21716.6667
+2019 37216.6667 21733.3333
+2020 37216.6667 21750.0000
+2021 37216.6667 21850.0000
+2022 37216.6667 21950.0000
+2023 37216.6667 21966.6667
+2024 37216.6667 22033.3333
+2025 37216.6667 22283.3333
+2026 37216.6667 22300.0000
+2027 37216.6667 22883.3333
+2028 37233.3333 21650.0000
+2029 37233.3333 21666.6667
+2030 37233.3333 21800.0000
+2031 37233.3333 21816.6667
+2032 37233.3333 21850.0000
+2033 37233.3333 21866.6667
+2034 37233.3333 21900.0000
+2035 37233.3333 21933.3333
+2036 37233.3333 21966.6667
+2037 37233.3333 21983.3333
+2038 37233.3333 22016.6667
+2039 37233.3333 22033.3333
+2040 37233.3333 22133.3333
+2041 37233.3333 22166.6667
+2042 37233.3333 22183.3333
+2043 37233.3333 22200.0000
+2044 37233.3333 22250.0000
+2045 37233.3333 22266.6667
+2046 37233.3333 22283.3333
+2047 37233.3333 22500.0000
+2048 37233.3333 22533.3333
+2049 37233.3333 22850.0000
+2050 37250.0000 21666.6667
+2051 37250.0000 21683.3333
+2052 37250.0000 21700.0000
+2053 37250.0000 21716.6667
+2054 37250.0000 21733.3333
+2055 37250.0000 21783.3333
+2056 37250.0000 21816.6667
+2057 37250.0000 21833.3333
+2058 37250.0000 21966.6667
+2059 37250.0000 21983.3333
+2060 37250.0000 22000.0000
+2061 37250.0000 22016.6667
+2062 37250.0000 22116.6667
+2063 37250.0000 22183.3333
+2064 37250.0000 22333.3333
+2065 37250.0000 22550.0000
+2066 37250.0000 22833.3333
+2067 37250.0000 22866.6667
+2068 37250.0000 23150.0000
+2069 37266.6667 21750.0000
+2070 37266.6667 21766.6667
+2071 37266.6667 21866.6667
+2072 37266.6667 21900.0000
+2073 37266.6667 21933.3333
+2074 37266.6667 21950.0000
+2075 37266.6667 21966.6667
+2076 37266.6667 21983.3333
+2077 37266.6667 22000.0000
+2078 37266.6667 22016.6667
+2079 37266.6667 22166.6667
+2080 37266.6667 22250.0000
+2081 37266.6667 22316.6667
+2082 37266.6667 22533.3333
+2083 37266.6667 22650.0000
+2084 37266.6667 22683.3333
+2085 37266.6667 23150.0000
+2086 37283.3333 21700.0000
+2087 37283.3333 21716.6667
+2088 37283.3333 21816.6667
+2089 37283.3333 21850.0000
+2090 37283.3333 21900.0000
+2091 37283.3333 21916.6667
+2092 37283.3333 21933.3333
+2093 37283.3333 21966.6667
+2094 37283.3333 22050.0000
+2095 37283.3333 22066.6667
+2096 37283.3333 22150.0000
+2097 37283.3333 22166.6667
+2098 37283.3333 22200.0000
+2099 37283.3333 22350.0000
+2100 37283.3333 22366.6667
+2101 37283.3333 22650.0000
+2102 37283.3333 26766.6667
+2103 37300.0000 21716.6667
+2104 37300.0000 21750.0000
+2105 37300.0000 21766.6667
+2106 37300.0000 21783.3333
+2107 37300.0000 21816.6667
+2108 37300.0000 21833.3333
+2109 37300.0000 21850.0000
+2110 37300.0000 21883.3333
+2111 37300.0000 21916.6667
+2112 37300.0000 21950.0000
+2113 37300.0000 21966.6667
+2114 37300.0000 21983.3333
+2115 37300.0000 22000.0000
+2116 37300.0000 22050.0000
+2117 37300.0000 22116.6667
+2118 37300.0000 22150.0000
+2119 37300.0000 22250.0000
+2120 37300.0000 22500.0000
+2121 37300.0000 22766.6667
+2122 37300.0000 23183.3333
+2123 37300.0000 26516.6667
+2124 37316.6667 21733.3333
+2125 37316.6667 21816.6667
+2126 37316.6667 21833.3333
+2127 37316.6667 21850.0000
+2128 37316.6667 21866.6667
+2129 37316.6667 21883.3333
+2130 37316.6667 21916.6667
+2131 37316.6667 21933.3333
+2132 37316.6667 21950.0000
+2133 37316.6667 22000.0000
+2134 37316.6667 22066.6667
+2135 37316.6667 22083.3333
+2136 37316.6667 22133.3333
+2137 37316.6667 22150.0000
+2138 37316.6667 22183.3333
+2139 37316.6667 22233.3333
+2140 37316.6667 22283.3333
+2141 37316.6667 22316.6667
+2142 37316.6667 22650.0000
+2143 37316.6667 23150.0000
+2144 37316.6667 23166.6667
+2145 37316.6667 23416.6667
+2146 37316.6667 26533.3333
+2147 37333.3333 21766.6667
+2148 37333.3333 21833.3333
+2149 37333.3333 21866.6667
+2150 37333.3333 21883.3333
+2151 37333.3333 21900.0000
+2152 37333.3333 21933.3333
+2153 37333.3333 21950.0000
+2154 37333.3333 21966.6667
+2155 37333.3333 22033.3333
+2156 37333.3333 22116.6667
+2157 37333.3333 22133.3333
+2158 37333.3333 22200.0000
+2159 37333.3333 22233.3333
+2160 37333.3333 22300.0000
+2161 37333.3333 22316.6667
+2162 37333.3333 22500.0000
+2163 37333.3333 22550.0000
+2164 37333.3333 22683.3333
+2165 37333.3333 22700.0000
+2166 37333.3333 22750.0000
+2167 37333.3333 23150.0000
+2168 37333.3333 23500.0000
+2169 37350.0000 21700.0000
+2170 37350.0000 21733.3333
+2171 37350.0000 21750.0000
+2172 37350.0000 21850.0000
+2173 37350.0000 21866.6667
+2174 37350.0000 21916.6667
+2175 37350.0000 21933.3333
+2176 37350.0000 21950.0000
+2177 37350.0000 21966.6667
+2178 37350.0000 22066.6667
+2179 37350.0000 22150.0000
+2180 37350.0000 22183.3333
+2181 37350.0000 22400.0000
+2182 37350.0000 22433.3333
+2183 37350.0000 22550.0000
+2184 37350.0000 22583.3333
+2185 37350.0000 22600.0000
+2186 37350.0000 22666.6667
+2187 37350.0000 22733.3333
+2188 37350.0000 22766.6667
+2189 37350.0000 23316.6667
+2190 37350.0000 23350.0000
+2191 37350.0000 23450.0000
+2192 37350.0000 23466.6667
+2193 37350.0000 26566.6667
+2194 37366.6667 21700.0000
+2195 37366.6667 21750.0000
+2196 37366.6667 21816.6667
+2197 37366.6667 21900.0000
+2198 37366.6667 21983.3333
+2199 37366.6667 22016.6667
+2200 37366.6667 22050.0000
+2201 37366.6667 22100.0000
+2202 37366.6667 22133.3333
+2203 37366.6667 22150.0000
+2204 37366.6667 22216.6667
+2205 37366.6667 22266.6667
+2206 37366.6667 22283.3333
+2207 37366.6667 22300.0000
+2208 37366.6667 22333.3333
+2209 37366.6667 22383.3333
+2210 37366.6667 22400.0000
+2211 37366.6667 22466.6667
+2212 37366.6667 22500.0000
+2213 37366.6667 22533.3333
+2214 37366.6667 22550.0000
+2215 37366.6667 22633.3333
+2216 37366.6667 22716.6667
+2217 37366.6667 22750.0000
+2218 37366.6667 23216.6667
+2219 37366.6667 24883.3333
+2220 37383.3333 21750.0000
+2221 37383.3333 21766.6667
+2222 37383.3333 21816.6667
+2223 37383.3333 21833.3333
+2224 37383.3333 21850.0000
+2225 37383.3333 21883.3333
+2226 37383.3333 21916.6667
+2227 37383.3333 22033.3333
+2228 37383.3333 22083.3333
+2229 37383.3333 22116.6667
+2230 37383.3333 22133.3333
+2231 37383.3333 22166.6667
+2232 37383.3333 22200.0000
+2233 37383.3333 22233.3333
+2234 37383.3333 22300.0000
+2235 37383.3333 22450.0000
+2236 37383.3333 22500.0000
+2237 37383.3333 22566.6667
+2238 37383.3333 22650.0000
+2239 37383.3333 22683.3333
+2240 37383.3333 22733.3333
+2241 37383.3333 23150.0000
+2242 37383.3333 23250.0000
+2243 37383.3333 24400.0000
+2244 37383.3333 24433.3333
+2245 37383.3333 24883.3333
+2246 37383.3333 24900.0000
+2247 37383.3333 24916.6667
+2248 37400.0000 21683.3333
+2249 37400.0000 21716.6667
+2250 37400.0000 21733.3333
+2251 37400.0000 21816.6667
+2252 37400.0000 21850.0000
+2253 37400.0000 21883.3333
+2254 37400.0000 21916.6667
+2255 37400.0000 21933.3333
+2256 37400.0000 22016.6667
+2257 37400.0000 22100.0000
+2258 37400.0000 22133.3333
+2259 37400.0000 22183.3333
+2260 37400.0000 22216.6667
+2261 37400.0000 22250.0000
+2262 37400.0000 22316.6667
+2263 37400.0000 22600.0000
+2264 37400.0000 22616.6667
+2265 37400.0000 22650.0000
+2266 37400.0000 22716.6667
+2267 37400.0000 22733.3333
+2268 37400.0000 23233.3333
+2269 37400.0000 24400.0000
+2270 37400.0000 24450.0000
+2271 37400.0000 24883.3333
+2272 37400.0000 24900.0000
+2273 37400.0000 24916.6667
+2274 37400.0000 24933.3333
+2275 37400.0000 24950.0000
+2276 37400.0000 25266.6667
+2277 37416.6667 21666.6667
+2278 37416.6667 21700.0000
+2279 37416.6667 21850.0000
+2280 37416.6667 21866.6667
+2281 37416.6667 21950.0000
+2282 37416.6667 21966.6667
+2283 37416.6667 22000.0000
+2284 37416.6667 22033.3333
+2285 37416.6667 22050.0000
+2286 37416.6667 22083.3333
+2287 37416.6667 22100.0000
+2288 37416.6667 22116.6667
+2289 37416.6667 22166.6667
+2290 37416.6667 22233.3333
+2291 37416.6667 22266.6667
+2292 37416.6667 22366.6667
+2293 37416.6667 22400.0000
+2294 37416.6667 22466.6667
+2295 37416.6667 22566.6667
+2296 37416.6667 22583.3333
+2297 37416.6667 22600.0000
+2298 37416.6667 22766.6667
+2299 37416.6667 23133.3333
+2300 37416.6667 23150.0000
+2301 37416.6667 23316.6667
+2302 37416.6667 23350.0000
+2303 37416.6667 23383.3333
+2304 37416.6667 23400.0000
+2305 37416.6667 23466.6667
+2306 37416.6667 24433.3333
+2307 37416.6667 24883.3333
+2308 37416.6667 24900.0000
+2309 37416.6667 24916.6667
+2310 37416.6667 24933.3333
+2311 37416.6667 24950.0000
+2312 37416.6667 24966.6667
+2313 37433.3333 21666.6667
+2314 37433.3333 21716.6667
+2315 37433.3333 21733.3333
+2316 37433.3333 21766.6667
+2317 37433.3333 21833.3333
+2318 37433.3333 21950.0000
+2319 37433.3333 22000.0000
+2320 37433.3333 22050.0000
+2321 37433.3333 22116.6667
+2322 37433.3333 22300.0000
+2323 37433.3333 22416.6667
+2324 37433.3333 22533.3333
+2325 37433.3333 22616.6667
+2326 37433.3333 22633.3333
+2327 37433.3333 22650.0000
+2328 37433.3333 22683.3333
+2329 37433.3333 22733.3333
+2330 37433.3333 23183.3333
+2331 37433.3333 23300.0000
+2332 37433.3333 23400.0000
+2333 37433.3333 23466.6667
+2334 37433.3333 24900.0000
+2335 37433.3333 24916.6667
+2336 37433.3333 24950.0000
+2337 37450.0000 21683.3333
+2338 37450.0000 21733.3333
+2339 37450.0000 21750.0000
+2340 37450.0000 21866.6667
+2341 37450.0000 21916.6667
+2342 37450.0000 21950.0000
+2343 37450.0000 22033.3333
+2344 37450.0000 22066.6667
+2345 37450.0000 22100.0000
+2346 37450.0000 22116.6667
+2347 37450.0000 22150.0000
+2348 37450.0000 22166.6667
+2349 37450.0000 22250.0000
+2350 37450.0000 22366.6667
+2351 37450.0000 22400.0000
+2352 37450.0000 22416.6667
+2353 37450.0000 22433.3333
+2354 37450.0000 22450.0000
+2355 37450.0000 22466.6667
+2356 37450.0000 22566.6667
+2357 37450.0000 22583.3333
+2358 37450.0000 22616.6667
+2359 37450.0000 23233.3333
+2360 37450.0000 23266.6667
+2361 37450.0000 23283.3333
+2362 37450.0000 23483.3333
+2363 37450.0000 24416.6667
+2364 37450.0000 24900.0000
+2365 37450.0000 24933.3333
+2366 37450.0000 25333.3333
+2367 37450.0000 25400.0000
+2368 37466.6667 21650.0000
+2369 37466.6667 21700.0000
+2370 37466.6667 21800.0000
+2371 37466.6667 21966.6667
+2372 37466.6667 22000.0000
+2373 37466.6667 22083.3333
+2374 37466.6667 22116.6667
+2375 37466.6667 22166.6667
+2376 37466.6667 22200.0000
+2377 37466.6667 22333.3333
+2378 37466.6667 22366.6667
+2379 37466.6667 22383.3333
+2380 37466.6667 22400.0000
+2381 37466.6667 22416.6667
+2382 37466.6667 22433.3333
+2383 37466.6667 22450.0000
+2384 37466.6667 22516.6667
+2385 37466.6667 22616.6667
+2386 37466.6667 23166.6667
+2387 37466.6667 24916.6667
+2388 37466.6667 24933.3333
+2389 37483.3333 21650.0000
+2390 37483.3333 21683.3333
+2391 37483.3333 21716.6667
+2392 37483.3333 21733.3333
+2393 37483.3333 21816.6667
+2394 37483.3333 21833.3333
+2395 37483.3333 21900.0000
+2396 37483.3333 21933.3333
+2397 37483.3333 22016.6667
+2398 37483.3333 22033.3333
+2399 37483.3333 22083.3333
+2400 37483.3333 22116.6667
+2401 37483.3333 22133.3333
+2402 37483.3333 22150.0000
+2403 37483.3333 22283.3333
+2404 37483.3333 22366.6667
+2405 37483.3333 22416.6667
+2406 37483.3333 22433.3333
+2407 37483.3333 22466.6667
+2408 37483.3333 22733.3333
+2409 37483.3333 23000.0000
+2410 37483.3333 23016.6667
+2411 37483.3333 23266.6667
+2412 37483.3333 24916.6667
+2413 37483.3333 24933.3333
+2414 37500.0000 21650.0000
+2415 37500.0000 21700.0000
+2416 37500.0000 21766.6667
+2417 37500.0000 21800.0000
+2418 37500.0000 21850.0000
+2419 37500.0000 21866.6667
+2420 37500.0000 21916.6667
+2421 37500.0000 22100.0000
+2422 37500.0000 22116.6667
+2423 37500.0000 22166.6667
+2424 37500.0000 22450.0000
+2425 37500.0000 22466.6667
+2426 37500.0000 22483.3333
+2427 37500.0000 23016.6667
+2428 37500.0000 23033.3333
+2429 37500.0000 23050.0000
+2430 37500.0000 23066.6667
+2431 37500.0000 23183.3333
+2432 37500.0000 23366.6667
+2433 37500.0000 23383.3333
+2434 37500.0000 23450.0000
+2435 37516.6667 21600.0000
+2436 37516.6667 21650.0000
+2437 37516.6667 21733.3333
+2438 37516.6667 21750.0000
+2439 37516.6667 21766.6667
+2440 37516.6667 21883.3333
+2441 37516.6667 21950.0000
+2442 37516.6667 22066.6667
+2443 37516.6667 22116.6667
+2444 37516.6667 22233.3333
+2445 37516.6667 22300.0000
+2446 37516.6667 22316.6667
+2447 37516.6667 22366.6667
+2448 37516.6667 22383.3333
+2449 37516.6667 22416.6667
+2450 37516.6667 22433.3333
+2451 37516.6667 22450.0000
+2452 37516.6667 22583.3333
+2453 37516.6667 22700.0000
+2454 37516.6667 22733.3333
+2455 37516.6667 22850.0000
+2456 37516.6667 23083.3333
+2457 37516.6667 23100.0000
+2458 37516.6667 23116.6667
+2459 37516.6667 23200.0000
+2460 37516.6667 23283.3333
+2461 37516.6667 23300.0000
+2462 37516.6667 23366.6667
+2463 37516.6667 23383.3333
+2464 37516.6667 26016.6667
+2465 37533.3333 21700.0000
+2466 37533.3333 21733.3333
+2467 37533.3333 21750.0000
+2468 37533.3333 21800.0000
+2469 37533.3333 21816.6667
+2470 37533.3333 21850.0000
+2471 37533.3333 21916.6667
+2472 37533.3333 21950.0000
+2473 37533.3333 21983.3333
+2474 37533.3333 22016.6667
+2475 37533.3333 22266.6667
+2476 37533.3333 22283.3333
+2477 37533.3333 22316.6667
+2478 37533.3333 22350.0000
+2479 37533.3333 22416.6667
+2480 37533.3333 22433.3333
+2481 37533.3333 22700.0000
+2482 37533.3333 22716.6667
+2483 37533.3333 22883.3333
+2484 37533.3333 22916.6667
+2485 37533.3333 22966.6667
+2486 37533.3333 23083.3333
+2487 37533.3333 23133.3333
+2488 37533.3333 23150.0000
+2489 37533.3333 23183.3333
+2490 37533.3333 23200.0000
+2491 37533.3333 23233.3333
+2492 37533.3333 23283.3333
+2493 37533.3333 23350.0000
+2494 37533.3333 25166.6667
+2495 37533.3333 26000.0000
+2496 37550.0000 21600.0000
+2497 37550.0000 21683.3333
+2498 37550.0000 21783.3333
+2499 37550.0000 21816.6667
+2500 37550.0000 21866.6667
+2501 37550.0000 21916.6667
+2502 37550.0000 21933.3333
+2503 37550.0000 21983.3333
+2504 37550.0000 22083.3333
+2505 37550.0000 22216.6667
+2506 37550.0000 22283.3333
+2507 37550.0000 22366.6667
+2508 37550.0000 22416.6667
+2509 37550.0000 22716.6667
+2510 37550.0000 22850.0000
+2511 37550.0000 22866.6667
+2512 37550.0000 22883.3333
+2513 37550.0000 22916.6667
+2514 37550.0000 22983.3333
+2515 37550.0000 23116.6667
+2516 37550.0000 23166.6667
+2517 37550.0000 23200.0000
+2518 37550.0000 23366.6667
+2519 37550.0000 26000.0000
+2520 37550.0000 26016.6667
+2521 37566.6667 21583.3333
+2522 37566.6667 21633.3333
+2523 37566.6667 21700.0000
+2524 37566.6667 21750.0000
+2525 37566.6667 21783.3333
+2526 37566.6667 21950.0000
+2527 37566.6667 22033.3333
+2528 37566.6667 22383.3333
+2529 37566.6667 22466.6667
+2530 37566.6667 22683.3333
+2531 37566.6667 22800.0000
+2532 37566.6667 22833.3333
+2533 37566.6667 23066.6667
+2534 37566.6667 23150.0000
+2535 37566.6667 23250.0000
+2536 37566.6667 25150.0000
+2537 37566.6667 25166.6667
+2538 37566.6667 25183.3333
+2539 37566.6667 25200.0000
+2540 37566.6667 26000.0000
+2541 37566.6667 26116.6667
+2542 37583.3333 21566.6667
+2543 37583.3333 21616.6667
+2544 37583.3333 21666.6667
+2545 37583.3333 21733.3333
+2546 37583.3333 21816.6667
+2547 37583.3333 21866.6667
+2548 37583.3333 21916.6667
+2549 37583.3333 21950.0000
+2550 37583.3333 21983.3333
+2551 37583.3333 22016.6667
+2552 37583.3333 22083.3333
+2553 37583.3333 22233.3333
+2554 37583.3333 22283.3333
+2555 37583.3333 22366.6667
+2556 37583.3333 22533.3333
+2557 37583.3333 22566.6667
+2558 37583.3333 22750.0000
+2559 37583.3333 22883.3333
+2560 37583.3333 23166.6667
+2561 37583.3333 23233.3333
+2562 37583.3333 23383.3333
+2563 37583.3333 25150.0000
+2564 37583.3333 25166.6667
+2565 37583.3333 25183.3333
+2566 37583.3333 25200.0000
+2567 37583.3333 25216.6667
+2568 37583.3333 26016.6667
+2569 37583.3333 26233.3333
+2570 37600.0000 21550.0000
+2571 37600.0000 21583.3333
+2572 37600.0000 21683.3333
+2573 37600.0000 21750.0000
+2574 37600.0000 21800.0000
+2575 37600.0000 21816.6667
+2576 37600.0000 21866.6667
+2577 37600.0000 21883.3333
+2578 37600.0000 21900.0000
+2579 37600.0000 21916.6667
+2580 37600.0000 21950.0000
+2581 37600.0000 21983.3333
+2582 37600.0000 22033.3333
+2583 37600.0000 22050.0000
+2584 37600.0000 22400.0000
+2585 37600.0000 22516.6667
+2586 37600.0000 22683.3333
+2587 37600.0000 22800.0000
+2588 37600.0000 22816.6667
+2589 37600.0000 22833.3333
+2590 37600.0000 22950.0000
+2591 37600.0000 22966.6667
+2592 37600.0000 22983.3333
+2593 37600.0000 23050.0000
+2594 37600.0000 23333.3333
+2595 37600.0000 23350.0000
+2596 37600.0000 23366.6667
+2597 37600.0000 24283.3333
+2598 37600.0000 24300.0000
+2599 37600.0000 24333.3333
+2600 37600.0000 25083.3333
+2601 37600.0000 25133.3333
+2602 37600.0000 25150.0000
+2603 37600.0000 25166.6667
+2604 37600.0000 25183.3333
+2605 37600.0000 26250.0000
+2606 37616.6667 21516.6667
+2607 37616.6667 21600.0000
+2608 37616.6667 21633.3333
+2609 37616.6667 21650.0000
+2610 37616.6667 21700.0000
+2611 37616.6667 21716.6667
+2612 37616.6667 21766.6667
+2613 37616.6667 21800.0000
+2614 37616.6667 21833.3333
+2615 37616.6667 21866.6667
+2616 37616.6667 21900.0000
+2617 37616.6667 21916.6667
+2618 37616.6667 21933.3333
+2619 37616.6667 22100.0000
+2620 37616.6667 22216.6667
+2621 37616.6667 22333.3333
+2622 37616.6667 22433.3333
+2623 37616.6667 22466.6667
+2624 37616.6667 22550.0000
+2625 37616.6667 22600.0000
+2626 37616.6667 22666.6667
+2627 37616.6667 22766.6667
+2628 37616.6667 22800.0000
+2629 37616.6667 22850.0000
+2630 37616.6667 22983.3333
+2631 37616.6667 23000.0000
+2632 37616.6667 23033.3333
+2633 37616.6667 23333.3333
+2634 37616.6667 23350.0000
+2635 37616.6667 23400.0000
+2636 37616.6667 24283.3333
+2637 37616.6667 25050.0000
+2638 37616.6667 25116.6667
+2639 37616.6667 25133.3333
+2640 37616.6667 26183.3333
+2641 37628.6111 26791.3889
+2642 37633.3333 21500.0000
+2643 37633.3333 21683.3333
+2644 37633.3333 21750.0000
+2645 37633.3333 21833.3333
+2646 37633.3333 21850.0000
+2647 37633.3333 21866.6667
+2648 37633.3333 21883.3333
+2649 37633.3333 21900.0000
+2650 37633.3333 21933.3333
+2651 37633.3333 21950.0000
+2652 37633.3333 21983.3333
+2653 37633.3333 22083.3333
+2654 37633.3333 22150.0000
+2655 37633.3333 22166.6667
+2656 37633.3333 22300.0000
+2657 37633.3333 22533.3333
+2658 37633.3333 22683.3333
+2659 37633.3333 22733.3333
+2660 37633.3333 22766.6667
+2661 37633.3333 22783.3333
+2662 37633.3333 22800.0000
+2663 37633.3333 22816.6667
+2664 37633.3333 22933.3333
+2665 37633.3333 23066.6667
+2666 37633.3333 23083.3333
+2667 37633.3333 23116.6667
+2668 37633.3333 23150.0000
+2669 37633.3333 23366.6667
+2670 37633.3333 24316.6667
+2671 37633.3333 24350.0000
+2672 37633.3333 24383.3333
+2673 37633.3333 25033.3333
+2674 37633.3333 25050.0000
+2675 37633.3333 26083.3333
+2676 37650.0000 21316.6667
+2677 37650.0000 21433.3333
+2678 37650.0000 21500.0000
+2679 37650.0000 21533.3333
+2680 37650.0000 21616.6667
+2681 37650.0000 21633.3333
+2682 37650.0000 21650.0000
+2683 37650.0000 21683.3333
+2684 37650.0000 21700.0000
+2685 37650.0000 21733.3333
+2686 37650.0000 21750.0000
+2687 37650.0000 21850.0000
+2688 37650.0000 21900.0000
+2689 37650.0000 21933.3333
+2690 37650.0000 21950.0000
+2691 37650.0000 21983.3333
+2692 37650.0000 22333.3333
+2693 37650.0000 22416.6667
+2694 37650.0000 22766.6667
+2695 37650.0000 22800.0000
+2696 37650.0000 22816.6667
+2697 37650.0000 22833.3333
+2698 37650.0000 23066.6667
+2699 37650.0000 23083.3333
+2700 37650.0000 24100.0000
+2701 37650.0000 24300.0000
+2702 37650.0000 24383.3333
+2703 37650.0000 25016.6667
+2704 37658.8889 26780.8333
+2705 37663.8889 26882.5000
+2706 37666.6667 20816.6667
+2707 37666.6667 21316.6667
+2708 37666.6667 21533.3333
+2709 37666.6667 21550.0000
+2710 37666.6667 21616.6667
+2711 37666.6667 21633.3333
+2712 37666.6667 21783.3333
+2713 37666.6667 21816.6667
+2714 37666.6667 21833.3333
+2715 37666.6667 21866.6667
+2716 37666.6667 21916.6667
+2717 37666.6667 21933.3333
+2718 37666.6667 22183.3333
+2719 37666.6667 22366.6667
+2720 37666.6667 22450.0000
+2721 37666.6667 22483.3333
+2722 37666.6667 22583.3333
+2723 37666.6667 22666.6667
+2724 37666.6667 22750.0000
+2725 37666.6667 22766.6667
+2726 37666.6667 22783.3333
+2727 37666.6667 22816.6667
+2728 37666.6667 22850.0000
+2729 37666.6667 23133.3333
+2730 37666.6667 23983.3333
+2731 37666.6667 24016.6667
+2732 37666.6667 24033.3333
+2733 37666.6667 24050.0000
+2734 37666.6667 24316.6667
+2735 37666.6667 24333.3333
+2736 37666.6667 24350.0000
+2737 37672.7778 26831.9444
+2738 37675.5556 26769.1667
+2739 37678.6111 26801.3889
+2740 37679.7222 26861.1111
+2741 37683.3333 21316.6667
+2742 37683.3333 21333.3333
+2743 37683.3333 21366.6667
+2744 37683.3333 21383.3333
+2745 37683.3333 21450.0000
+2746 37683.3333 21483.3333
+2747 37683.3333 21500.0000
+2748 37683.3333 21516.6667
+2749 37683.3333 21550.0000
+2750 37683.3333 21583.3333
+2751 37683.3333 21616.6667
+2752 37683.3333 21650.0000
+2753 37683.3333 21683.3333
+2754 37683.3333 21783.3333
+2755 37683.3333 21833.3333
+2756 37683.3333 21866.6667
+2757 37683.3333 21916.6667
+2758 37683.3333 21966.6667
+2759 37683.3333 22033.3333
+2760 37683.3333 22133.3333
+2761 37683.3333 22183.3333
+2762 37683.3333 22300.0000
+2763 37683.3333 22516.6667
+2764 37683.3333 22616.6667
+2765 37683.3333 22716.6667
+2766 37683.3333 22750.0000
+2767 37683.3333 22816.6667
+2768 37683.3333 22833.3333
+2769 37683.3333 22966.6667
+2770 37683.3333 23150.0000
+2771 37683.3333 23350.0000
+2772 37683.3333 23450.0000
+2773 37683.3333 23483.3333
+2774 37684.7222 26759.1667
+2775 37686.6667 26918.8889
+2776 37691.9444 26948.3333
+2777 37692.5000 26774.1667
+2778 37692.7778 26588.0556
+2779 37698.3333 26618.6111
+2780 37699.4444 26746.1111
+2781 37700.0000 21333.3333
+2782 37700.0000 21416.6667
+2783 37700.0000 21466.6667
+2784 37700.0000 21516.6667
+2785 37700.0000 21566.6667
+2786 37700.0000 21783.3333
+2787 37700.0000 21916.6667
+2788 37700.0000 21950.0000
+2789 37700.0000 21966.6667
+2790 37700.0000 22050.0000
+2791 37700.0000 22133.3333
+2792 37700.0000 22433.3333
+2793 37700.0000 22483.3333
+2794 37700.0000 22550.0000
+2795 37700.0000 22750.0000
+2796 37700.0000 23066.6667
+2797 37700.0000 23366.6667
+2798 37700.0000 23500.0000
+2799 37700.0000 23516.6667
+2800 37700.0000 24116.6667
+2801 37703.6111 26905.5556
+2802 37704.7222 26839.4444
+2803 37706.6667 26771.3889
+2804 37707.7778 26669.1667
+2805 37708.6111 27018.0556
+2806 37709.7222 26749.7222
+2807 37709.7222 27046.9444
+2808 37710.2778 26685.8333
+2809 37710.8333 26700.0000
+2810 37711.6667 26804.1667
+2811 37713.6111 26975.5556
+2812 37714.1667 27059.1667
+2813 37716.1111 26782.2222
+2814 37716.6667 20783.3333
+2815 37716.6667 20833.3333
+2816 37716.6667 20983.3333
+2817 37716.6667 21333.3333
+2818 37716.6667 21350.0000
+2819 37716.6667 21416.6667
+2820 37716.6667 21433.3333
+2821 37716.6667 21483.3333
+2822 37716.6667 21566.6667
+2823 37716.6667 21583.3333
+2824 37716.6667 21616.6667
+2825 37716.6667 21650.0000
+2826 37716.6667 21716.6667
+2827 37716.6667 21833.3333
+2828 37716.6667 21950.0000
+2829 37716.6667 21983.3333
+2830 37716.6667 22100.0000
+2831 37716.6667 22150.0000
+2832 37716.6667 22250.0000
+2833 37716.6667 22316.6667
+2834 37716.6667 22350.0000
+2835 37716.6667 22600.0000
+2836 37716.6667 22650.0000
+2837 37716.6667 22750.0000
+2838 37716.6667 22833.3333
+2839 37716.6667 22883.3333
+2840 37716.6667 23350.0000
+2841 37716.6667 23450.0000
+2842 37716.6667 23466.6667
+2843 37716.6667 23483.3333
+2844 37716.6667 23500.0000
+2845 37716.6667 23516.6667
+2846 37716.6667 23950.0000
+2847 37716.6667 24050.0000
+2848 37716.6667 24116.6667
+2849 37718.0556 26861.9444
+2850 37719.1667 27000.2778
+2851 37726.3889 26690.0000
+2852 37727.2222 26822.2222
+2853 37728.6111 26908.3333
+2854 37730.8333 26829.4444
+2855 37733.3333 20816.6667
+2856 37733.3333 20833.3333
+2857 37733.3333 20916.6667
+2858 37733.3333 21350.0000
+2859 37733.3333 21366.6667
+2860 37733.3333 21383.3333
+2861 37733.3333 21400.0000
+2862 37733.3333 21416.6667
+2863 37733.3333 21466.6667
+2864 37733.3333 21500.0000
+2865 37733.3333 21516.6667
+2866 37733.3333 21533.3333
+2867 37733.3333 21550.0000
+2868 37733.3333 21666.6667
+2869 37733.3333 21700.0000
+2870 37733.3333 21783.3333
+2871 37733.3333 21933.3333
+2872 37733.3333 21950.0000
+2873 37733.3333 21983.3333
+2874 37733.3333 22016.6667
+2875 37733.3333 22200.0000
+2876 37733.3333 22283.3333
+2877 37733.3333 22300.0000
+2878 37733.3333 22500.0000
+2879 37733.3333 22516.6667
+2880 37733.3333 22533.3333
+2881 37733.3333 22683.3333
+2882 37733.3333 22716.6667
+2883 37733.3333 23466.6667
+2884 37733.3333 23483.3333
+2885 37733.3333 23516.6667
+2886 37733.3333 23950.0000
+2887 37733.3333 24000.0000
+2888 37733.3333 24016.6667
+2889 37733.3333 24050.0000
+2890 37733.3333 26583.3333
+2891 37735.2778 26945.0000
+2892 37738.0556 27000.5556
+2893 37738.3333 26745.2778
+2894 37741.3889 26715.5556
+2895 37747.2222 26728.6111
+2896 37750.0000 20783.3333
+2897 37750.0000 20816.6667
+2898 37750.0000 20950.0000
+2899 37750.0000 21316.6667
+2900 37750.0000 21333.3333
+2901 37750.0000 21366.6667
+2902 37750.0000 21433.3333
+2903 37750.0000 21450.0000
+2904 37750.0000 21466.6667
+2905 37750.0000 21516.6667
+2906 37750.0000 21550.0000
+2907 37750.0000 21683.3333
+2908 37750.0000 21883.3333
+2909 37750.0000 21900.0000
+2910 37750.0000 22000.0000
+2911 37750.0000 22016.6667
+2912 37750.0000 22050.0000
+2913 37750.0000 22083.3333
+2914 37750.0000 22100.0000
+2915 37750.0000 22183.3333
+2916 37750.0000 22416.6667
+2917 37750.0000 22483.3333
+2918 37750.0000 22833.3333
+2919 37750.0000 22883.3333
+2920 37750.0000 23000.0000
+2921 37750.0000 23433.3333
+2922 37750.0000 23450.0000
+2923 37750.0000 23483.3333
+2924 37750.0000 23516.6667
+2925 37750.0000 23533.3333
+2926 37750.0000 24916.6667
+2927 37750.0000 24933.3333
+2928 37750.0000 24950.0000
+2929 37750.0000 26983.3333
+2930 37750.2778 26716.1111
+2931 37751.1111 27005.5556
+2932 37751.6667 26592.2222
+2933 37754.4444 26677.2222
+2934 37755.2778 26738.3333
+2935 37755.8333 26715.8333
+2936 37757.2222 26607.2222
+2937 37757.2222 26976.9444
+2938 37758.0556 27024.4444
+2939 37758.8889 26946.3889
+2940 37759.1667 26660.0000
+2941 37761.3889 27009.7222
+2942 37766.6667 20800.0000
+2943 37766.6667 20816.6667
+2944 37766.6667 20866.6667
+2945 37766.6667 20916.6667
+2946 37766.6667 21333.3333
+2947 37766.6667 21500.0000
+2948 37766.6667 21616.6667
+2949 37766.6667 21666.6667
+2950 37766.6667 21833.3333
+2951 37766.6667 21866.6667
+2952 37766.6667 22016.6667
+2953 37766.6667 22083.3333
+2954 37766.6667 22116.6667
+2955 37766.6667 22150.0000
+2956 37766.6667 22183.3333
+2957 37766.6667 22216.6667
+2958 37766.6667 22250.0000
+2959 37766.6667 22383.3333
+2960 37766.6667 22483.3333
+2961 37766.6667 22566.6667
+2962 37766.6667 22966.6667
+2963 37766.6667 23133.3333
+2964 37766.6667 23433.3333
+2965 37766.6667 23483.3333
+2966 37766.6667 23516.6667
+2967 37766.6667 23533.3333
+2968 37766.6667 23966.6667
+2969 37766.6667 24033.3333
+2970 37766.6667 24916.6667
+2971 37766.6667 24933.3333
+2972 37766.6667 24950.0000
+2973 37767.7778 26966.9444
+2974 37769.7222 26919.7222
+2975 37772.2222 26658.8889
+2976 37773.3333 26685.8333
+2977 37776.3889 26893.8889
+2978 37778.0556 26673.3333
+2979 37779.1667 26993.3333
+2980 37779.4444 26751.6667
+2981 37783.3333 20683.3333
+2982 37783.3333 20716.6667
+2983 37783.3333 20783.3333
+2984 37783.3333 20800.0000
+2985 37783.3333 20833.3333
+2986 37783.3333 20850.0000
+2987 37783.3333 20866.6667
+2988 37783.3333 20900.0000
+2989 37783.3333 21300.0000
+2990 37783.3333 21316.6667
+2991 37783.3333 21400.0000
+2992 37783.3333 21466.6667
+2993 37783.3333 21566.6667
+2994 37783.3333 21633.3333
+2995 37783.3333 21683.3333
+2996 37783.3333 21716.6667
+2997 37783.3333 21866.6667
+2998 37783.3333 21933.3333
+2999 37783.3333 22033.3333
+3000 37783.3333 22066.6667
+3001 37783.3333 22116.6667
+3002 37783.3333 22150.0000
+3003 37783.3333 22283.3333
+3004 37783.3333 22316.6667
+3005 37783.3333 22433.3333
+3006 37783.3333 22866.6667
+3007 37783.3333 23900.0000
+3008 37783.3333 23916.6667
+3009 37783.3333 23950.0000
+3010 37783.3333 24066.6667
+3011 37783.3333 24083.3333
+3012 37783.3333 24883.3333
+3013 37783.3333 24933.3333
+3014 37783.3333 24950.0000
+3015 37783.3333 26850.0000
+3016 37784.4444 26828.6111
+3017 37789.4444 26666.3889
+3018 37790.2778 26683.8889
+3019 37790.2778 26704.4444
+3020 37792.2222 26828.8889
+3021 37792.5000 26696.6667
+3022 37796.1111 26812.5000
+3023 37797.5000 26859.1667
+3024 37798.3333 26738.3333
+3025 37798.6111 26706.1111
+3026 37799.1667 26750.8333
+3027 37800.0000 20683.3333
+3028 37800.0000 20733.3333
+3029 37800.0000 20766.6667
+3030 37800.0000 20783.3333
+3031 37800.0000 20800.0000
+3032 37800.0000 20833.3333
+3033 37800.0000 20850.0000
+3034 37800.0000 20866.6667
+3035 37800.0000 21300.0000
+3036 37800.0000 21350.0000
+3037 37800.0000 21383.3333
+3038 37800.0000 21433.3333
+3039 37800.0000 21466.6667
+3040 37800.0000 21533.3333
+3041 37800.0000 21566.6667
+3042 37800.0000 21583.3333
+3043 37800.0000 21616.6667
+3044 37800.0000 21633.3333
+3045 37800.0000 21716.6667
+3046 37800.0000 21750.0000
+3047 37800.0000 21816.6667
+3048 37800.0000 21900.0000
+3049 37800.0000 21950.0000
+3050 37800.0000 22000.0000
+3051 37800.0000 22016.6667
+3052 37800.0000 22200.0000
+3053 37800.0000 22250.0000
+3054 37800.0000 22283.3333
+3055 37800.0000 22583.3333
+3056 37800.0000 22716.6667
+3057 37800.0000 22800.0000
+3058 37800.0000 23050.0000
+3059 37800.0000 23883.3333
+3060 37800.0000 23983.3333
+3061 37800.0000 24050.0000
+3062 37800.0000 24866.6667
+3063 37800.0000 24900.0000
+3064 37800.0000 24916.6667
+3065 37800.0000 24933.3333
+3066 37800.0000 24950.0000
+3067 37801.1111 26803.3333
+3068 37801.3889 26745.5556
+3069 37802.2222 26841.3889
+3070 37802.7778 26812.2222
+3071 37805.8333 26815.2778
+3072 37806.6667 26732.2222
+3073 37808.3333 26794.7222
+3074 37808.6111 26738.8889
+3075 37816.6667 20683.3333
+3076 37816.6667 20766.6667
+3077 37816.6667 20800.0000
+3078 37816.6667 20833.3333
+3079 37816.6667 20850.0000
+3080 37816.6667 21266.6667
+3081 37816.6667 21283.3333
+3082 37816.6667 21350.0000
+3083 37816.6667 21383.3333
+3084 37816.6667 21416.6667
+3085 37816.6667 21583.3333
+3086 37816.6667 21616.6667
+3087 37816.6667 21700.0000
+3088 37816.6667 21850.0000
+3089 37816.6667 21866.6667
+3090 37816.6667 22000.0000
+3091 37816.6667 22133.3333
+3092 37816.6667 22150.0000
+3093 37816.6667 22166.6667
+3094 37816.6667 22333.3333
+3095 37816.6667 22516.6667
+3096 37816.6667 22533.3333
+3097 37816.6667 22666.6667
+3098 37816.6667 22700.0000
+3099 37816.6667 22750.0000
+3100 37816.6667 22866.6667
+3101 37816.6667 22933.3333
+3102 37816.6667 23000.0000
+3103 37816.6667 23783.3333
+3104 37816.6667 23800.0000
+3105 37816.6667 24050.0000
+3106 37816.6667 24833.3333
+3107 37816.6667 24883.3333
+3108 37816.6667 24900.0000
+3109 37816.6667 24916.6667
+3110 37816.6667 24933.3333
+3111 37816.6667 24950.0000
+3112 37833.3333 20750.0000
+3113 37833.3333 20766.6667
+3114 37833.3333 21300.0000
+3115 37833.3333 21383.3333
+3116 37833.3333 21433.3333
+3117 37833.3333 21450.0000
+3118 37833.3333 21533.3333
+3119 37833.3333 21566.6667
+3120 37833.3333 21583.3333
+3121 37833.3333 21600.0000
+3122 37833.3333 21700.0000
+3123 37833.3333 21766.6667
+3124 37833.3333 21833.3333
+3125 37833.3333 21850.0000
+3126 37833.3333 21933.3333
+3127 37833.3333 21983.3333
+3128 37833.3333 22000.0000
+3129 37833.3333 22100.0000
+3130 37833.3333 22116.6667
+3131 37833.3333 22166.6667
+3132 37833.3333 22316.6667
+3133 37833.3333 22383.3333
+3134 37833.3333 22566.6667
+3135 37833.3333 22583.3333
+3136 37833.3333 23016.6667
+3137 37833.3333 23033.3333
+3138 37833.3333 23800.0000
+3139 37833.3333 23866.6667
+3140 37833.3333 23916.6667
+3141 37833.3333 23966.6667
+3142 37833.3333 24816.6667
+3143 37833.3333 24900.0000
+3144 37833.3333 24916.6667
+3145 37833.3333 24933.3333
+3146 37850.0000 20650.0000
+3147 37850.0000 20700.0000
+3148 37850.0000 20783.3333
+3149 37850.0000 21116.6667
+3150 37850.0000 21150.0000
+3151 37850.0000 21216.6667
+3152 37850.0000 21250.0000
+3153 37850.0000 21316.6667
+3154 37850.0000 21366.6667
+3155 37850.0000 21383.3333
+3156 37850.0000 21433.3333
+3157 37850.0000 21450.0000
+3158 37850.0000 21500.0000
+3159 37850.0000 21516.6667
+3160 37850.0000 21566.6667
+3161 37850.0000 21616.6667
+3162 37850.0000 21766.6667
+3163 37850.0000 21800.0000
+3164 37850.0000 21983.3333
+3165 37850.0000 22016.6667
+3166 37850.0000 22066.6667
+3167 37850.0000 22083.3333
+3168 37850.0000 22116.6667
+3169 37850.0000 22150.0000
+3170 37850.0000 22166.6667
+3171 37850.0000 22216.6667
+3172 37850.0000 22316.6667
+3173 37850.0000 22416.6667
+3174 37850.0000 22600.0000
+3175 37850.0000 22666.6667
+3176 37850.0000 22800.0000
+3177 37850.0000 22883.3333
+3178 37850.0000 22916.6667
+3179 37850.0000 22983.3333
+3180 37850.0000 23000.0000
+3181 37850.0000 23766.6667
+3182 37850.0000 24783.3333
+3183 37850.0000 24916.6667
+3184 37850.0000 24933.3333
+3185 37866.6667 20650.0000
+3186 37866.6667 20666.6667
+3187 37866.6667 21116.6667
+3188 37866.6667 21150.0000
+3189 37866.6667 21183.3333
+3190 37866.6667 21200.0000
+3191 37866.6667 21266.6667
+3192 37866.6667 21300.0000
+3193 37866.6667 21350.0000
+3194 37866.6667 21433.3333
+3195 37866.6667 21450.0000
+3196 37866.6667 21483.3333
+3197 37866.6667 21500.0000
+3198 37866.6667 21616.6667
+3199 37866.6667 21650.0000
+3200 37866.6667 21750.0000
+3201 37866.6667 21850.0000
+3202 37866.6667 21900.0000
+3203 37866.6667 21950.0000
+3204 37866.6667 22016.6667
+3205 37866.6667 22033.3333
+3206 37866.6667 22066.6667
+3207 37866.6667 22116.6667
+3208 37866.6667 22166.6667
+3209 37866.6667 22383.3333
+3210 37866.6667 22416.6667
+3211 37866.6667 22450.0000
+3212 37866.6667 22466.6667
+3213 37866.6667 22533.3333
+3214 37866.6667 22783.3333
+3215 37866.6667 22900.0000
+3216 37866.6667 23000.0000
+3217 37866.6667 23750.0000
+3218 37866.6667 23933.3333
+3219 37866.6667 24816.6667
+3220 37866.6667 24833.3333
+3221 37866.6667 24850.0000
+3222 37866.6667 24866.6667
+3223 37866.6667 24883.3333
+3224 37883.3333 20700.0000
+3225 37883.3333 21133.3333
+3226 37883.3333 21200.0000
+3227 37883.3333 21233.3333
+3228 37883.3333 21250.0000
+3229 37883.3333 21283.3333
+3230 37883.3333 21316.6667
+3231 37883.3333 21366.6667
+3232 37883.3333 21383.3333
+3233 37883.3333 21416.6667
+3234 37883.3333 21433.3333
+3235 37883.3333 21450.0000
+3236 37883.3333 21500.0000
+3237 37883.3333 21550.0000
+3238 37883.3333 21583.3333
+3239 37883.3333 21683.3333
+3240 37883.3333 21900.0000
+3241 37883.3333 21916.6667
+3242 37883.3333 21983.3333
+3243 37883.3333 22016.6667
+3244 37883.3333 22050.0000
+3245 37883.3333 22150.0000
+3246 37883.3333 22333.3333
+3247 37883.3333 22466.6667
+3248 37883.3333 22483.3333
+3249 37883.3333 22566.6667
+3250 37883.3333 22633.3333
+3251 37883.3333 22733.3333
+3252 37883.3333 22833.3333
+3253 37883.3333 22883.3333
+3254 37883.3333 22950.0000
+3255 37883.3333 23416.6667
+3256 37883.3333 23433.3333
+3257 37883.3333 23733.3333
+3258 37883.3333 23750.0000
+3259 37883.3333 23933.3333
+3260 37883.3333 24016.6667
+3261 37883.3333 24733.3333
+3262 37900.0000 21233.3333
+3263 37900.0000 21266.6667
+3264 37900.0000 21350.0000
+3265 37900.0000 21383.3333
+3266 37900.0000 21400.0000
+3267 37900.0000 21450.0000
+3268 37900.0000 21466.6667
+3269 37900.0000 21500.0000
+3270 37900.0000 21533.3333
+3271 37900.0000 21550.0000
+3272 37900.0000 21600.0000
+3273 37900.0000 21650.0000
+3274 37900.0000 21766.6667
+3275 37900.0000 21833.3333
+3276 37900.0000 21916.6667
+3277 37900.0000 22000.0000
+3278 37900.0000 22033.3333
+3279 37900.0000 22050.0000
+3280 37900.0000 22083.3333
+3281 37900.0000 22116.6667
+3282 37900.0000 22133.3333
+3283 37900.0000 22150.0000
+3284 37900.0000 22333.3333
+3285 37900.0000 22466.6667
+3286 37900.0000 22600.0000
+3287 37900.0000 22650.0000
+3288 37900.0000 22733.3333
+3289 37900.0000 22933.3333
+3290 37900.0000 23416.6667
+3291 37900.0000 23483.3333
+3292 37900.0000 23733.3333
+3293 37900.0000 23750.0000
+3294 37900.0000 23883.3333
+3295 37900.0000 24733.3333
+3296 37900.0000 24750.0000
+3297 37900.0000 24766.6667
+3298 37900.0000 24783.3333
+3299 37900.0000 24833.3333
+3300 37900.0000 24916.6667
+3301 37916.6667 20700.0000
+3302 37916.6667 21183.3333
+3303 37916.6667 21200.0000
+3304 37916.6667 21233.3333
+3305 37916.6667 21250.0000
+3306 37916.6667 21283.3333
+3307 37916.6667 21333.3333
+3308 37916.6667 21400.0000
+3309 37916.6667 21416.6667
+3310 37916.6667 21433.3333
+3311 37916.6667 21466.6667
+3312 37916.6667 21500.0000
+3313 37916.6667 21533.3333
+3314 37916.6667 21666.6667
+3315 37916.6667 21716.6667
+3316 37916.6667 21750.0000
+3317 37916.6667 21800.0000
+3318 37916.6667 21866.6667
+3319 37916.6667 21933.3333
+3320 37916.6667 22133.3333
+3321 37916.6667 22166.6667
+3322 37916.6667 22200.0000
+3323 37916.6667 22283.3333
+3324 37916.6667 22300.0000
+3325 37916.6667 22316.6667
+3326 37916.6667 22516.6667
+3327 37916.6667 22616.6667
+3328 37916.6667 22700.0000
+3329 37916.6667 22883.3333
+3330 37916.6667 22983.3333
+3331 37916.6667 23000.0000
+3332 37916.6667 23150.0000
+3333 37916.6667 23466.6667
+3334 37916.6667 23500.0000
+3335 37916.6667 23716.6667
+3336 37916.6667 23733.3333
+3337 37916.6667 23966.6667
+3338 37933.3333 21150.0000
+3339 37933.3333 21266.6667
+3340 37933.3333 21316.6667
+3341 37933.3333 21333.3333
+3342 37933.3333 21350.0000
+3343 37933.3333 21400.0000
+3344 37933.3333 21466.6667
+3345 37933.3333 21566.6667
+3346 37933.3333 21616.6667
+3347 37933.3333 21633.3333
+3348 37933.3333 21650.0000
+3349 37933.3333 21750.0000
+3350 37933.3333 21850.0000
+3351 37933.3333 21916.6667
+3352 37933.3333 21966.6667
+3353 37933.3333 22000.0000
+3354 37933.3333 22033.3333
+3355 37933.3333 22050.0000
+3356 37933.3333 22083.3333
+3357 37933.3333 22100.0000
+3358 37933.3333 22166.6667
+3359 37933.3333 22183.3333
+3360 37933.3333 22200.0000
+3361 37933.3333 22333.3333
+3362 37933.3333 22633.3333
+3363 37933.3333 22716.6667
+3364 37933.3333 22800.0000
+3365 37933.3333 22833.3333
+3366 37933.3333 22850.0000
+3367 37933.3333 22933.3333
+3368 37933.3333 23033.3333
+3369 37933.3333 23533.3333
+3370 37933.3333 23700.0000
+3371 37933.3333 23733.3333
+3372 37933.3333 24716.6667
+3373 37933.3333 24766.6667
+3374 37933.3333 24800.0000
+3375 37950.0000 21316.6667
+3376 37950.0000 21350.0000
+3377 37950.0000 21366.6667
+3378 37950.0000 21383.3333
+3379 37950.0000 21400.0000
+3380 37950.0000 21416.6667
+3381 37950.0000 21450.0000
+3382 37950.0000 21483.3333
+3383 37950.0000 21500.0000
+3384 37950.0000 21533.3333
+3385 37950.0000 21550.0000
+3386 37950.0000 21700.0000
+3387 37950.0000 21716.6667
+3388 37950.0000 21766.6667
+3389 37950.0000 21850.0000
+3390 37950.0000 21933.3333
+3391 37950.0000 22016.6667
+3392 37950.0000 22133.3333
+3393 37950.0000 22316.6667
+3394 37950.0000 22350.0000
+3395 37950.0000 22566.6667
+3396 37950.0000 22650.0000
+3397 37950.0000 22750.0000
+3398 37950.0000 22783.3333
+3399 37950.0000 22800.0000
+3400 37950.0000 22833.3333
+3401 37950.0000 22966.6667
+3402 37950.0000 23533.3333
+3403 37950.0000 23633.3333
+3404 37950.0000 23666.6667
+3405 37950.0000 23700.0000
+3406 37950.0000 23716.6667
+3407 37950.0000 23766.6667
+3408 37950.0000 23850.0000
+3409 37950.0000 24750.0000
+3410 37950.0000 24800.0000
+3411 37966.6667 21250.0000
+3412 37966.6667 21266.6667
+3413 37966.6667 21283.3333
+3414 37966.6667 21300.0000
+3415 37966.6667 21333.3333
+3416 37966.6667 21350.0000
+3417 37966.6667 21400.0000
+3418 37966.6667 21516.6667
+3419 37966.6667 21550.0000
+3420 37966.6667 21633.3333
+3421 37966.6667 21666.6667
+3422 37966.6667 21700.0000
+3423 37966.6667 22050.0000
+3424 37966.6667 22083.3333
+3425 37966.6667 22116.6667
+3426 37966.6667 22566.6667
+3427 37966.6667 22633.3333
+3428 37966.6667 22766.6667
+3429 37966.6667 22783.3333
+3430 37966.6667 22816.6667
+3431 37966.6667 23200.0000
+3432 37966.6667 23366.6667
+3433 37966.6667 23450.0000
+3434 37966.6667 23483.3333
+3435 37966.6667 23516.6667
+3436 37966.6667 23566.6667
+3437 37966.6667 23633.3333
+3438 37966.6667 23650.0000
+3439 37966.6667 23683.3333
+3440 37966.6667 23750.0000
+3441 37966.6667 23800.0000
+3442 37966.6667 23916.6667
+3443 37966.6667 24000.0000
+3444 37966.6667 24483.3333
+3445 37966.6667 24733.3333
+3446 37966.6667 24750.0000
+3447 37966.6667 24766.6667
+3448 37983.3333 21266.6667
+3449 37983.3333 21316.6667
+3450 37983.3333 21350.0000
+3451 37983.3333 21400.0000
+3452 37983.3333 21416.6667
+3453 37983.3333 21450.0000
+3454 37983.3333 21466.6667
+3455 37983.3333 21583.3333
+3456 37983.3333 21666.6667
+3457 37983.3333 21733.3333
+3458 37983.3333 21766.6667
+3459 37983.3333 21800.0000
+3460 37983.3333 22000.0000
+3461 37983.3333 22066.6667
+3462 37983.3333 22133.3333
+3463 37983.3333 22266.6667
+3464 37983.3333 22350.0000
+3465 37983.3333 22466.6667
+3466 37983.3333 22483.3333
+3467 37983.3333 22516.6667
+3468 37983.3333 22566.6667
+3469 37983.3333 22650.0000
+3470 37983.3333 22733.3333
+3471 37983.3333 22783.3333
+3472 37983.3333 22966.6667
+3473 37983.3333 23350.0000
+3474 37983.3333 23533.3333
+3475 37983.3333 23666.6667
+3476 37983.3333 23683.3333
+3477 37983.3333 23733.3333
+3478 37983.3333 23766.6667
+3479 37983.3333 23816.6667
+3480 37983.3333 23866.6667
+3481 37983.3333 23883.3333
+3482 37983.3333 23900.0000
+3483 37983.3333 24016.6667
+3484 38000.0000 21316.6667
+3485 38000.0000 21350.0000
+3486 38000.0000 21366.6667
+3487 38000.0000 21383.3333
+3488 38000.0000 21516.6667
+3489 38000.0000 21666.6667
+3490 38000.0000 21716.6667
+3491 38000.0000 21766.6667
+3492 38000.0000 21916.6667
+3493 38000.0000 22000.0000
+3494 38000.0000 22133.3333
+3495 38000.0000 22266.6667
+3496 38000.0000 22366.6667
+3497 38000.0000 22466.6667
+3498 38000.0000 22483.3333
+3499 38000.0000 22533.3333
+3500 38000.0000 22566.6667
+3501 38000.0000 22650.0000
+3502 38000.0000 22733.3333
+3503 38000.0000 22750.0000
+3504 38000.0000 23350.0000
+3505 38000.0000 23433.3333
+3506 38000.0000 23583.3333
+3507 38000.0000 23666.6667
+3508 38000.0000 23683.3333
+3509 38000.0000 23700.0000
+3510 38000.0000 23733.3333
+3511 38000.0000 23800.0000
+3512 38000.0000 23883.3333
+3513 38000.0000 23916.6667
+3514 38000.0000 23950.0000
+3515 38016.6667 21366.6667
+3516 38016.6667 21383.3333
+3517 38016.6667 21400.0000
+3518 38016.6667 21416.6667
+3519 38016.6667 21433.3333
+3520 38016.6667 21466.6667
+3521 38016.6667 21550.0000
+3522 38016.6667 21566.6667
+3523 38016.6667 21600.0000
+3524 38016.6667 21633.3333
+3525 38016.6667 21700.0000
+3526 38016.6667 21733.3333
+3527 38016.6667 21766.6667
+3528 38016.6667 21900.0000
+3529 38016.6667 21966.6667
+3530 38016.6667 21983.3333
+3531 38016.6667 22233.3333
+3532 38016.6667 22250.0000
+3533 38016.6667 22266.6667
+3534 38016.6667 22416.6667
+3535 38016.6667 22483.3333
+3536 38016.6667 22500.0000
+3537 38016.6667 22616.6667
+3538 38016.6667 22650.0000
+3539 38016.6667 22683.3333
+3540 38016.6667 22716.6667
+3541 38016.6667 22733.3333
+3542 38016.6667 22750.0000
+3543 38016.6667 22983.3333
+3544 38016.6667 23666.6667
+3545 38016.6667 23700.0000
+3546 38016.6667 23733.3333
+3547 38016.6667 23750.0000
+3548 38016.6667 23766.6667
+3549 38016.6667 23833.3333
+3550 38016.6667 24000.0000
+3551 38016.6667 24266.6667
+3552 38016.6667 24283.3333
+3553 38016.6667 24333.3333
+3554 38016.6667 24416.6667
+3555 38016.6667 24450.0000
+3556 38016.6667 24466.6667
+3557 38016.6667 24516.6667
+3558 38016.6667 24533.3333
+3559 38016.6667 24550.0000
+3560 38016.6667 24566.6667
+3561 38033.3333 21366.6667
+3562 38033.3333 21466.6667
+3563 38033.3333 21500.0000
+3564 38033.3333 21550.0000
+3565 38033.3333 21633.3333
+3566 38033.3333 21700.0000
+3567 38033.3333 21716.6667
+3568 38033.3333 21733.3333
+3569 38033.3333 21750.0000
+3570 38033.3333 21800.0000
+3571 38033.3333 21866.6667
+3572 38033.3333 21883.3333
+3573 38033.3333 21900.0000
+3574 38033.3333 21933.3333
+3575 38033.3333 21966.6667
+3576 38033.3333 22000.0000
+3577 38033.3333 22116.6667
+3578 38033.3333 22250.0000
+3579 38033.3333 22266.6667
+3580 38033.3333 22333.3333
+3581 38033.3333 22366.6667
+3582 38033.3333 22483.3333
+3583 38033.3333 22533.3333
+3584 38033.3333 22566.6667
+3585 38033.3333 22583.3333
+3586 38033.3333 22600.0000
+3587 38033.3333 22666.6667
+3588 38033.3333 22716.6667
+3589 38033.3333 22733.3333
+3590 38033.3333 22950.0000
+3591 38033.3333 23166.6667
+3592 38033.3333 23500.0000
+3593 38033.3333 23533.3333
+3594 38033.3333 23700.0000
+3595 38033.3333 23733.3333
+3596 38033.3333 23750.0000
+3597 38033.3333 23766.6667
+3598 38033.3333 23783.3333
+3599 38033.3333 23800.0000
+3600 38033.3333 23916.6667
+3601 38033.3333 24316.6667
+3602 38033.3333 24400.0000
+3603 38033.3333 24416.6667
+3604 38033.3333 24433.3333
+3605 38033.3333 24500.0000
+3606 38033.3333 24533.3333
+3607 38050.0000 21316.6667
+3608 38050.0000 21350.0000
+3609 38050.0000 21366.6667
+3610 38050.0000 21383.3333
+3611 38050.0000 21450.0000
+3612 38050.0000 21483.3333
+3613 38050.0000 21550.0000
+3614 38050.0000 21583.3333
+3615 38050.0000 21666.6667
+3616 38050.0000 21700.0000
+3617 38050.0000 21750.0000
+3618 38050.0000 21766.6667
+3619 38050.0000 21783.3333
+3620 38050.0000 21816.6667
+3621 38050.0000 21850.0000
+3622 38050.0000 21866.6667
+3623 38050.0000 21916.6667
+3624 38050.0000 21933.3333
+3625 38050.0000 21983.3333
+3626 38050.0000 22016.6667
+3627 38050.0000 22066.6667
+3628 38050.0000 22316.6667
+3629 38050.0000 22350.0000
+3630 38050.0000 22450.0000
+3631 38050.0000 22500.0000
+3632 38050.0000 22533.3333
+3633 38050.0000 22550.0000
+3634 38050.0000 22583.3333
+3635 38050.0000 22600.0000
+3636 38050.0000 22616.6667
+3637 38050.0000 22650.0000
+3638 38050.0000 22683.3333
+3639 38050.0000 22933.3333
+3640 38050.0000 22966.6667
+3641 38050.0000 23016.6667
+3642 38050.0000 23683.3333
+3643 38050.0000 23766.6667
+3644 38050.0000 23800.0000
+3645 38050.0000 23833.3333
+3646 38050.0000 23866.6667
+3647 38050.0000 24316.6667
+3648 38050.0000 24366.6667
+3649 38050.0000 24383.3333
+3650 38050.0000 24416.6667
+3651 38050.0000 24533.3333
+3652 38050.0000 24550.0000
+3653 38066.6667 20733.3333
+3654 38066.6667 20750.0000
+3655 38066.6667 20783.3333
+3656 38066.6667 21350.0000
+3657 38066.6667 21400.0000
+3658 38066.6667 21433.3333
+3659 38066.6667 21500.0000
+3660 38066.6667 21516.6667
+3661 38066.6667 21550.0000
+3662 38066.6667 21600.0000
+3663 38066.6667 21616.6667
+3664 38066.6667 21650.0000
+3665 38066.6667 21666.6667
+3666 38066.6667 21683.3333
+3667 38066.6667 21716.6667
+3668 38066.6667 21733.3333
+3669 38066.6667 21750.0000
+3670 38066.6667 21766.6667
+3671 38066.6667 21800.0000
+3672 38066.6667 21850.0000
+3673 38066.6667 21900.0000
+3674 38066.6667 21933.3333
+3675 38066.6667 21950.0000
+3676 38066.6667 22033.3333
+3677 38066.6667 22233.3333
+3678 38066.6667 22316.6667
+3679 38066.6667 22333.3333
+3680 38066.6667 22350.0000
+3681 38066.6667 22400.0000
+3682 38066.6667 22450.0000
+3683 38066.6667 22500.0000
+3684 38066.6667 22516.6667
+3685 38066.6667 22633.3333
+3686 38066.6667 22650.0000
+3687 38066.6667 22666.6667
+3688 38066.6667 23500.0000
+3689 38066.6667 23583.3333
+3690 38066.6667 23700.0000
+3691 38066.6667 23766.6667
+3692 38066.6667 23783.3333
+3693 38066.6667 23816.6667
+3694 38066.6667 24000.0000
+3695 38066.6667 24316.6667
+3696 38066.6667 24333.3333
+3697 38066.6667 24350.0000
+3698 38066.6667 24433.3333
+3699 38066.6667 24533.3333
+3700 38083.3333 20716.6667
+3701 38083.3333 20733.3333
+3702 38083.3333 20750.0000
+3703 38083.3333 20783.3333
+3704 38083.3333 21383.3333
+3705 38083.3333 21466.6667
+3706 38083.3333 21483.3333
+3707 38083.3333 21500.0000
+3708 38083.3333 21533.3333
+3709 38083.3333 21566.6667
+3710 38083.3333 21583.3333
+3711 38083.3333 21616.6667
+3712 38083.3333 21633.3333
+3713 38083.3333 21666.6667
+3714 38083.3333 21733.3333
+3715 38083.3333 21766.6667
+3716 38083.3333 21833.3333
+3717 38083.3333 21900.0000
+3718 38083.3333 21916.6667
+3719 38083.3333 22033.3333
+3720 38083.3333 22100.0000
+3721 38083.3333 22133.3333
+3722 38083.3333 22166.6667
+3723 38083.3333 22216.6667
+3724 38083.3333 22333.3333
+3725 38083.3333 22350.0000
+3726 38083.3333 22416.6667
+3727 38083.3333 22433.3333
+3728 38083.3333 22483.3333
+3729 38083.3333 22533.3333
+3730 38083.3333 22583.3333
+3731 38083.3333 22600.0000
+3732 38083.3333 22616.6667
+3733 38083.3333 22633.3333
+3734 38083.3333 23183.3333
+3735 38083.3333 23216.6667
+3736 38083.3333 23516.6667
+3737 38083.3333 23700.0000
+3738 38083.3333 23733.3333
+3739 38083.3333 23983.3333
+3740 38083.3333 24283.3333
+3741 38083.3333 24316.6667
+3742 38083.3333 24333.3333
+3743 38083.3333 24366.6667
+3744 38083.3333 24383.3333
+3745 38083.3333 24533.3333
+3746 38083.3333 24566.6667
+3747 38100.0000 20716.6667
+3748 38100.0000 20750.0000
+3749 38100.0000 20766.6667
+3750 38100.0000 20783.3333
+3751 38100.0000 21416.6667
+3752 38100.0000 21450.0000
+3753 38100.0000 21466.6667
+3754 38100.0000 21483.3333
+3755 38100.0000 21516.6667
+3756 38100.0000 21533.3333
+3757 38100.0000 21550.0000
+3758 38100.0000 21600.0000
+3759 38100.0000 21616.6667
+3760 38100.0000 21633.3333
+3761 38100.0000 21666.6667
+3762 38100.0000 21700.0000
+3763 38100.0000 21716.6667
+3764 38100.0000 21733.3333
+3765 38100.0000 21816.6667
+3766 38100.0000 21833.3333
+3767 38100.0000 21916.6667
+3768 38100.0000 22033.3333
+3769 38100.0000 22100.0000
+3770 38100.0000 22133.3333
+3771 38100.0000 22166.6667
+3772 38100.0000 22233.3333
+3773 38100.0000 22283.3333
+3774 38100.0000 22316.6667
+3775 38100.0000 22333.3333
+3776 38100.0000 22350.0000
+3777 38100.0000 22366.6667
+3778 38100.0000 22450.0000
+3779 38100.0000 22483.3333
+3780 38100.0000 22533.3333
+3781 38100.0000 22566.6667
+3782 38100.0000 22583.3333
+3783 38100.0000 23666.6667
+3784 38100.0000 23816.6667
+3785 38100.0000 23883.3333
+3786 38100.0000 24250.0000
+3787 38100.0000 24333.3333
+3788 38100.0000 24400.0000
+3789 38100.0000 24433.3333
+3790 38100.0000 24483.3333
+3791 38100.0000 24566.6667
+3792 38116.6667 20516.6667
+3793 38116.6667 20533.3333
+3794 38116.6667 20550.0000
+3795 38116.6667 20566.6667
+3796 38116.6667 20583.3333
+3797 38116.6667 20633.3333
+3798 38116.6667 20650.0000
+3799 38116.6667 20750.0000
+3800 38116.6667 20766.6667
+3801 38116.6667 20783.3333
+3802 38116.6667 21466.6667
+3803 38116.6667 21483.3333
+3804 38116.6667 21500.0000
+3805 38116.6667 21516.6667
+3806 38116.6667 21566.6667
+3807 38116.6667 21583.3333
+3808 38116.6667 21600.0000
+3809 38116.6667 21633.3333
+3810 38116.6667 21650.0000
+3811 38116.6667 21666.6667
+3812 38116.6667 21716.6667
+3813 38116.6667 21783.3333
+3814 38116.6667 21900.0000
+3815 38116.6667 21933.3333
+3816 38116.6667 21966.6667
+3817 38116.6667 22066.6667
+3818 38116.6667 22083.3333
+3819 38116.6667 22116.6667
+3820 38116.6667 22216.6667
+3821 38116.6667 22283.3333
+3822 38116.6667 22383.3333
+3823 38116.6667 22400.0000
+3824 38116.6667 22433.3333
+3825 38116.6667 22466.6667
+3826 38116.6667 22483.3333
+3827 38116.6667 22533.3333
+3828 38116.6667 22550.0000
+3829 38116.6667 23400.0000
+3830 38116.6667 23833.3333
+3831 38116.6667 23850.0000
+3832 38116.6667 23866.6667
+3833 38116.6667 23883.3333
+3834 38116.6667 23950.0000
+3835 38116.6667 24216.6667
+3836 38116.6667 24300.0000
+3837 38116.6667 24316.6667
+3838 38116.6667 24483.3333
+3839 38116.6667 24500.0000
+3840 38116.6667 24583.3333
+3841 38133.3333 20500.0000
+3842 38133.3333 20516.6667
+3843 38133.3333 20533.3333
+3844 38133.3333 20550.0000
+3845 38133.3333 20566.6667
+3846 38133.3333 20583.3333
+3847 38133.3333 20616.6667
+3848 38133.3333 20716.6667
+3849 38133.3333 20733.3333
+3850 38133.3333 20750.0000
+3851 38133.3333 21400.0000
+3852 38133.3333 21466.6667
+3853 38133.3333 21533.3333
+3854 38133.3333 21550.0000
+3855 38133.3333 21566.6667
+3856 38133.3333 21583.3333
+3857 38133.3333 21600.0000
+3858 38133.3333 21633.3333
+3859 38133.3333 21700.0000
+3860 38133.3333 21716.6667
+3861 38133.3333 21766.6667
+3862 38133.3333 21783.3333
+3863 38133.3333 21833.3333
+3864 38133.3333 21900.0000
+3865 38133.3333 21916.6667
+3866 38133.3333 21983.3333
+3867 38133.3333 22150.0000
+3868 38133.3333 22200.0000
+3869 38133.3333 22216.6667
+3870 38133.3333 22233.3333
+3871 38133.3333 22283.3333
+3872 38133.3333 22316.6667
+3873 38133.3333 22333.3333
+3874 38133.3333 22366.6667
+3875 38133.3333 22383.3333
+3876 38133.3333 22400.0000
+3877 38133.3333 22416.6667
+3878 38133.3333 22433.3333
+3879 38133.3333 22450.0000
+3880 38133.3333 22466.6667
+3881 38133.3333 22483.3333
+3882 38133.3333 22516.6667
+3883 38133.3333 23800.0000
+3884 38133.3333 23850.0000
+3885 38133.3333 23883.3333
+3886 38133.3333 24000.0000
+3887 38133.3333 24250.0000
+3888 38133.3333 24366.6667
+3889 38133.3333 24383.3333
+3890 38133.3333 24466.6667
+3891 38133.3333 24483.3333
+3892 38133.3333 24533.3333
+3893 38133.3333 24566.6667
+3894 38150.0000 20500.0000
+3895 38150.0000 20550.0000
+3896 38150.0000 20566.6667
+3897 38150.0000 20733.3333
+3898 38150.0000 20750.0000
+3899 38150.0000 20783.3333
+3900 38150.0000 21516.6667
+3901 38150.0000 21550.0000
+3902 38150.0000 21616.6667
+3903 38150.0000 21650.0000
+3904 38150.0000 21666.6667
+3905 38150.0000 21733.3333
+3906 38150.0000 21750.0000
+3907 38150.0000 21800.0000
+3908 38150.0000 21833.3333
+3909 38150.0000 21850.0000
+3910 38150.0000 21866.6667
+3911 38150.0000 21900.0000
+3912 38150.0000 22033.3333
+3913 38150.0000 22066.6667
+3914 38150.0000 22166.6667
+3915 38150.0000 22183.3333
+3916 38150.0000 22200.0000
+3917 38150.0000 22266.6667
+3918 38150.0000 22283.3333
+3919 38150.0000 22300.0000
+3920 38150.0000 22316.6667
+3921 38150.0000 22333.3333
+3922 38150.0000 22350.0000
+3923 38150.0000 23233.3333
+3924 38150.0000 23533.3333
+3925 38150.0000 23716.6667
+3926 38150.0000 23833.3333
+3927 38150.0000 23850.0000
+3928 38150.0000 23866.6667
+3929 38150.0000 23966.6667
+3930 38150.0000 24233.3333
+3931 38150.0000 24316.6667
+3932 38150.0000 24350.0000
+3933 38150.0000 24383.3333
+3934 38150.0000 24400.0000
+3935 38166.6667 20483.3333
+3936 38166.6667 20550.0000
+3937 38166.6667 20600.0000
+3938 38166.6667 20666.6667
+3939 38166.6667 20683.3333
+3940 38166.6667 20700.0000
+3941 38166.6667 20716.6667
+3942 38166.6667 21416.6667
+3943 38166.6667 21450.0000
+3944 38166.6667 21466.6667
+3945 38166.6667 21483.3333
+3946 38166.6667 21666.6667
+3947 38166.6667 21683.3333
+3948 38166.6667 21700.0000
+3949 38166.6667 21716.6667
+3950 38166.6667 21733.3333
+3951 38166.6667 21816.6667
+3952 38166.6667 21850.0000
+3953 38166.6667 22000.0000
+3954 38166.6667 22066.6667
+3955 38166.6667 22100.0000
+3956 38166.6667 22133.3333
+3957 38166.6667 22233.3333
+3958 38166.6667 22266.6667
+3959 38166.6667 22283.3333
+3960 38166.6667 22316.6667
+3961 38166.6667 22333.3333
+3962 38166.6667 22350.0000
+3963 38166.6667 23333.3333
+3964 38166.6667 23416.6667
+3965 38166.6667 23783.3333
+3966 38166.6667 23866.6667
+3967 38166.6667 24000.0000
+3968 38166.6667 24233.3333
+3969 38166.6667 24250.0000
+3970 38166.6667 24266.6667
+3971 38166.6667 24316.6667
+3972 38183.3333 20383.3333
+3973 38183.3333 20400.0000
+3974 38183.3333 20416.6667
+3975 38183.3333 20433.3333
+3976 38183.3333 20483.3333
+3977 38183.3333 20533.3333
+3978 38183.3333 20583.3333
+3979 38183.3333 20683.3333
+3980 38183.3333 20700.0000
+3981 38183.3333 21383.3333
+3982 38183.3333 21416.6667
+3983 38183.3333 21433.3333
+3984 38183.3333 21683.3333
+3985 38183.3333 21700.0000
+3986 38183.3333 21716.6667
+3987 38183.3333 21733.3333
+3988 38183.3333 21750.0000
+3989 38183.3333 21766.6667
+3990 38183.3333 21816.6667
+3991 38183.3333 21950.0000
+3992 38183.3333 21983.3333
+3993 38183.3333 22066.6667
+3994 38183.3333 22133.3333
+3995 38183.3333 22150.0000
+3996 38183.3333 22183.3333
+3997 38183.3333 22266.6667
+3998 38183.3333 23150.0000
+3999 38183.3333 23383.3333
+4000 38183.3333 23500.0000
+4001 38183.3333 23516.6667
+4002 38183.3333 23550.0000
+4003 38183.3333 23850.0000
+4004 38183.3333 23916.6667
+4005 38183.3333 23983.3333
+4006 38183.3333 24033.3333
+4007 38183.3333 24200.0000
+4008 38183.3333 24233.3333
+4009 38183.3333 24266.6667
+4010 38183.3333 26016.6667
+4011 38200.0000 20383.3333
+4012 38200.0000 20400.0000
+4013 38200.0000 20416.6667
+4014 38200.0000 20433.3333
+4015 38200.0000 20516.6667
+4016 38200.0000 20666.6667
+4017 38200.0000 21700.0000
+4018 38200.0000 21733.3333
+4019 38200.0000 22000.0000
+4020 38200.0000 22050.0000
+4021 38200.0000 22083.3333
+4022 38200.0000 22116.6667
+4023 38200.0000 22150.0000
+4024 38200.0000 22166.6667
+4025 38200.0000 22200.0000
+4026 38200.0000 23050.0000
+4027 38200.0000 23116.6667
+4028 38200.0000 23966.6667
+4029 38200.0000 24200.0000
+4030 38216.6667 20383.3333
+4031 38216.6667 20400.0000
+4032 38216.6667 20500.0000
+4033 38216.6667 20516.6667
+4034 38216.6667 20616.6667
+4035 38216.6667 20650.0000
+4036 38216.6667 20666.6667
+4037 38216.6667 21716.6667
+4038 38216.6667 21733.3333
+4039 38216.6667 21750.0000
+4040 38216.6667 21766.6667
+4041 38216.6667 21783.3333
+4042 38216.6667 21800.0000
+4043 38216.6667 21816.6667
+4044 38216.6667 21900.0000
+4045 38216.6667 21966.6667
+4046 38216.6667 22033.3333
+4047 38216.6667 22066.6667
+4048 38216.6667 22100.0000
+4049 38216.6667 22116.6667
+4050 38216.6667 22133.3333
+4051 38216.6667 23266.6667
+4052 38216.6667 23316.6667
+4053 38216.6667 23500.0000
+4054 38216.6667 23550.0000
+4055 38216.6667 23616.6667
+4056 38216.6667 23783.3333
+4057 38216.6667 23833.3333
+4058 38216.6667 23866.6667
+4059 38216.6667 23883.3333
+4060 38216.6667 23916.6667
+4061 38216.6667 24250.0000
+4062 38233.3333 20366.6667
+4063 38233.3333 20383.3333
+4064 38233.3333 20400.0000
+4065 38233.3333 20416.6667
+4066 38233.3333 20483.3333
+4067 38233.3333 20600.0000
+4068 38233.3333 20650.0000
+4069 38233.3333 21733.3333
+4070 38233.3333 21750.0000
+4071 38233.3333 21766.6667
+4072 38233.3333 21783.3333
+4073 38233.3333 21916.6667
+4074 38233.3333 21966.6667
+4075 38233.3333 21983.3333
+4076 38233.3333 22033.3333
+4077 38233.3333 22083.3333
+4078 38233.3333 22100.0000
+4079 38233.3333 22116.6667
+4080 38233.3333 22133.3333
+4081 38233.3333 23216.6667
+4082 38233.3333 23416.6667
+4083 38233.3333 23800.0000
+4084 38233.3333 23900.0000
+4085 38233.3333 24216.6667
+4086 38233.3333 26000.0000
+4087 38233.3333 26050.0000
+4088 38233.3333 26066.6667
+4089 38233.3333 26083.3333
+4090 38233.3333 26100.0000
+4091 38250.0000 20383.3333
+4092 38250.0000 20400.0000
+4093 38250.0000 20600.0000
+4094 38250.0000 20650.0000
+4095 38250.0000 21733.3333
+4096 38250.0000 21750.0000
+4097 38250.0000 21800.0000
+4098 38250.0000 21933.3333
+4099 38250.0000 21950.0000
+4100 38250.0000 21966.6667
+4101 38250.0000 21983.3333
+4102 38250.0000 22000.0000
+4103 38250.0000 22016.6667
+4104 38250.0000 22050.0000
+4105 38250.0000 22083.3333
+4106 38250.0000 22116.6667
+4107 38250.0000 22983.3333
+4108 38250.0000 23066.6667
+4109 38250.0000 23183.3333
+4110 38250.0000 23266.6667
+4111 38250.0000 23466.6667
+4112 38250.0000 23700.0000
+4113 38250.0000 24200.0000
+4114 38250.0000 24216.6667
+4115 38250.0000 25933.3333
+4116 38250.0000 26033.3333
+4117 38250.0000 26066.6667
+4118 38250.0000 26083.3333
+4119 38250.0000 26100.0000
+4120 38266.6667 20466.6667
+4121 38266.6667 20683.3333
+4122 38266.6667 21733.3333
+4123 38266.6667 21750.0000
+4124 38266.6667 21766.6667
+4125 38266.6667 21783.3333
+4126 38266.6667 21816.6667
+4127 38266.6667 21833.3333
+4128 38266.6667 21900.0000
+4129 38266.6667 21916.6667
+4130 38266.6667 21933.3333
+4131 38266.6667 21966.6667
+4132 38266.6667 21983.3333
+4133 38266.6667 22000.0000
+4134 38266.6667 22016.6667
+4135 38266.6667 22050.0000
+4136 38266.6667 22916.6667
+4137 38266.6667 22966.6667
+4138 38266.6667 23116.6667
+4139 38266.6667 23233.3333
+4140 38266.6667 23566.6667
+4141 38266.6667 23800.0000
+4142 38266.6667 23816.6667
+4143 38266.6667 24166.6667
+4144 38266.6667 24183.3333
+4145 38266.6667 25916.6667
+4146 38266.6667 26066.6667
+4147 38266.6667 26083.3333
+4148 38266.6667 26100.0000
+4149 38283.3333 20433.3333
+4150 38283.3333 20466.6667
+4151 38283.3333 20583.3333
+4152 38283.3333 21766.6667
+4153 38283.3333 21800.0000
+4154 38283.3333 21866.6667
+4155 38283.3333 21883.3333
+4156 38283.3333 21900.0000
+4157 38283.3333 21966.6667
+4158 38283.3333 22000.0000
+4159 38283.3333 22033.3333
+4160 38283.3333 22766.6667
+4161 38283.3333 22783.3333
+4162 38283.3333 22800.0000
+4163 38283.3333 23266.6667
+4164 38283.3333 23350.0000
+4165 38283.3333 23583.3333
+4166 38283.3333 23750.0000
+4167 38283.3333 23800.0000
+4168 38283.3333 23816.6667
+4169 38283.3333 23833.3333
+4170 38283.3333 23866.6667
+4171 38283.3333 24133.3333
+4172 38283.3333 25983.3333
+4173 38283.3333 26083.3333
+4174 38300.0000 20483.3333
+4175 38300.0000 20550.0000
+4176 38300.0000 20566.6667
+4177 38300.0000 20583.3333
+4178 38300.0000 20600.0000
+4179 38300.0000 21783.3333
+4180 38300.0000 21800.0000
+4181 38300.0000 21833.3333
+4182 38300.0000 21900.0000
+4183 38300.0000 21950.0000
+4184 38300.0000 21983.3333
+4185 38300.0000 22000.0000
+4186 38300.0000 22016.6667
+4187 38300.0000 22550.0000
+4188 38300.0000 22583.3333
+4189 38300.0000 23116.6667
+4190 38300.0000 23150.0000
+4191 38300.0000 23166.6667
+4192 38300.0000 23266.6667
+4193 38300.0000 23316.6667
+4194 38300.0000 23383.3333
+4195 38300.0000 23500.0000
+4196 38300.0000 23733.3333
+4197 38300.0000 23750.0000
+4198 38300.0000 23900.0000
+4199 38300.0000 24116.6667
+4200 38300.0000 24200.0000
+4201 38300.0000 26016.6667
+4202 38300.0000 26066.6667
+4203 38300.0000 26100.0000
+4204 38300.0000 26116.6667
+4205 38316.6667 20416.6667
+4206 38316.6667 20466.6667
+4207 38316.6667 20550.0000
+4208 38316.6667 20566.6667
+4209 38316.6667 20583.3333
+4210 38316.6667 21816.6667
+4211 38316.6667 21850.0000
+4212 38316.6667 21983.3333
+4213 38316.6667 22583.3333
+4214 38316.6667 22900.0000
+4215 38316.6667 23116.6667
+4216 38316.6667 23183.3333
+4217 38316.6667 23316.6667
+4218 38316.6667 23333.3333
+4219 38316.6667 23450.0000
+4220 38316.6667 23533.3333
+4221 38316.6667 23616.6667
+4222 38316.6667 23633.3333
+4223 38316.6667 23800.0000
+4224 38316.6667 24150.0000
+4225 38316.6667 26050.0000
+4226 38316.6667 26100.0000
+4227 38316.6667 26133.3333
+4228 38333.3333 20550.0000
+4229 38333.3333 21566.6667
+4230 38333.3333 21766.6667
+4231 38333.3333 21850.0000
+4232 38333.3333 21866.6667
+4233 38333.3333 23133.3333
+4234 38333.3333 23316.6667
+4235 38333.3333 23733.3333
+4236 38333.3333 23783.3333
+4237 38333.3333 26000.0000
+4238 38333.3333 26083.3333
+4239 38333.3333 26100.0000
+4240 38333.3333 26116.6667
+4241 38350.0000 20616.6667
+4242 38350.0000 20683.3333
+4243 38350.0000 20716.6667
+4244 38350.0000 21533.3333
+4245 38350.0000 21566.6667
+4246 38350.0000 21600.0000
+4247 38350.0000 21633.3333
+4248 38350.0000 21650.0000
+4249 38350.0000 21700.0000
+4250 38350.0000 21716.6667
+4251 38350.0000 21733.3333
+4252 38350.0000 21750.0000
+4253 38350.0000 22783.3333
+4254 38350.0000 22916.6667
+4255 38350.0000 23016.6667
+4256 38350.0000 23483.3333
+4257 38350.0000 23583.3333
+4258 38350.0000 23666.6667
+4259 38350.0000 24100.0000
+4260 38350.0000 24150.0000
+4261 38350.0000 26083.3333
+4262 38366.6667 20566.6667
+4263 38366.6667 20583.3333
+4264 38366.6667 20600.0000
+4265 38366.6667 20716.6667
+4266 38366.6667 21433.3333
+4267 38366.6667 21533.3333
+4268 38366.6667 21566.6667
+4269 38366.6667 21633.3333
+4270 38366.6667 21666.6667
+4271 38366.6667 21716.6667
+4272 38366.6667 21750.0000
+4273 38366.6667 21766.6667
+4274 38366.6667 21783.3333
+4275 38366.6667 22083.3333
+4276 38366.6667 22133.3333
+4277 38366.6667 22200.0000
+4278 38366.6667 22233.3333
+4279 38366.6667 22250.0000
+4280 38366.6667 22283.3333
+4281 38366.6667 22833.3333
+4282 38366.6667 22933.3333
+4283 38366.6667 22966.6667
+4284 38366.6667 23016.6667
+4285 38366.6667 23066.6667
+4286 38366.6667 23083.3333
+4287 38366.6667 23100.0000
+4288 38366.6667 23450.0000
+4289 38366.6667 24183.3333
+4290 38366.6667 26133.3333
+4291 38383.3333 20533.3333
+4292 38383.3333 20550.0000
+4293 38383.3333 20566.6667
+4294 38383.3333 20583.3333
+4295 38383.3333 20666.6667
+4296 38383.3333 21500.0000
+4297 38383.3333 21533.3333
+4298 38383.3333 21566.6667
+4299 38383.3333 21600.0000
+4300 38383.3333 21633.3333
+4301 38383.3333 21683.3333
+4302 38383.3333 21716.6667
+4303 38383.3333 21800.0000
+4304 38383.3333 21850.0000
+4305 38383.3333 21916.6667
+4306 38383.3333 22116.6667
+4307 38383.3333 22383.3333
+4308 38383.3333 22633.3333
+4309 38383.3333 23000.0000
+4310 38383.3333 23400.0000
+4311 38383.3333 23600.0000
+4312 38383.3333 23633.3333
+4313 38383.3333 24050.0000
+4314 38383.3333 24066.6667
+4315 38383.3333 24083.3333
+4316 38383.3333 24116.6667
+4317 38383.3333 24133.3333
+4318 38383.3333 24166.6667
+4319 38383.3333 26016.6667
+4320 38383.3333 26100.0000
+4321 38400.0000 20550.0000
+4322 38400.0000 20566.6667
+4323 38400.0000 20583.3333
+4324 38400.0000 21266.6667
+4325 38400.0000 21433.3333
+4326 38400.0000 21483.3333
+4327 38400.0000 21533.3333
+4328 38400.0000 21550.0000
+4329 38400.0000 21650.0000
+4330 38400.0000 21733.3333
+4331 38400.0000 21750.0000
+4332 38400.0000 21766.6667
+4333 38400.0000 21783.3333
+4334 38400.0000 21800.0000
+4335 38400.0000 21816.6667
+4336 38400.0000 21833.3333
+4337 38400.0000 21866.6667
+4338 38400.0000 21883.3333
+4339 38400.0000 21900.0000
+4340 38400.0000 22000.0000
+4341 38400.0000 22016.6667
+4342 38400.0000 22050.0000
+4343 38400.0000 22150.0000
+4344 38400.0000 22716.6667
+4345 38400.0000 22933.3333
+4346 38400.0000 22983.3333
+4347 38400.0000 23600.0000
+4348 38400.0000 23616.6667
+4349 38400.0000 23633.3333
+4350 38400.0000 23766.6667
+4351 38400.0000 23800.0000
+4352 38400.0000 23883.3333
+4353 38400.0000 23916.6667
+4354 38400.0000 24050.0000
+4355 38400.0000 24083.3333
+4356 38400.0000 24100.0000
+4357 38400.0000 24133.3333
+4358 38400.0000 24166.6667
+4359 38400.0000 26016.6667
+4360 38416.6667 20550.0000
+4361 38416.6667 20566.6667
+4362 38416.6667 20650.0000
+4363 38416.6667 20666.6667
+4364 38416.6667 21250.0000
+4365 38416.6667 21283.3333
+4366 38416.6667 21316.6667
+4367 38416.6667 21466.6667
+4368 38416.6667 21516.6667
+4369 38416.6667 21566.6667
+4370 38416.6667 21616.6667
+4371 38416.6667 21633.3333
+4372 38416.6667 21750.0000
+4373 38416.6667 21766.6667
+4374 38416.6667 21783.3333
+4375 38416.6667 21816.6667
+4376 38416.6667 21833.3333
+4377 38416.6667 21850.0000
+4378 38416.6667 21866.6667
+4379 38416.6667 21883.3333
+4380 38416.6667 21900.0000
+4381 38416.6667 21933.3333
+4382 38416.6667 21950.0000
+4383 38416.6667 21966.6667
+4384 38416.6667 21983.3333
+4385 38416.6667 22000.0000
+4386 38416.6667 22016.6667
+4387 38416.6667 22050.0000
+4388 38416.6667 22100.0000
+4389 38416.6667 22183.3333
+4390 38416.6667 22216.6667
+4391 38416.6667 22316.6667
+4392 38416.6667 22533.3333
+4393 38416.6667 22816.6667
+4394 38416.6667 22833.3333
+4395 38416.6667 22983.3333
+4396 38416.6667 23000.0000
+4397 38416.6667 23016.6667
+4398 38416.6667 23350.0000
+4399 38416.6667 23516.6667
+4400 38416.6667 23650.0000
+4401 38416.6667 23683.3333
+4402 38416.6667 23816.6667
+4403 38416.6667 23833.3333
+4404 38416.6667 24033.3333
+4405 38416.6667 24100.0000
+4406 38416.6667 24133.3333
+4407 38416.6667 24200.0000
+4408 38416.6667 26133.3333
+4409 38433.3333 20550.0000
+4410 38433.3333 20566.6667
+4411 38433.3333 20583.3333
+4412 38433.3333 21283.3333
+4413 38433.3333 21350.0000
+4414 38433.3333 21416.6667
+4415 38433.3333 21516.6667
+4416 38433.3333 21600.0000
+4417 38433.3333 21633.3333
+4418 38433.3333 21716.6667
+4419 38433.3333 21750.0000
+4420 38433.3333 21766.6667
+4421 38433.3333 21833.3333
+4422 38433.3333 21866.6667
+4423 38433.3333 21950.0000
+4424 38433.3333 21966.6667
+4425 38433.3333 21983.3333
+4426 38433.3333 22066.6667
+4427 38433.3333 22116.6667
+4428 38433.3333 22416.6667
+4429 38433.3333 22450.0000
+4430 38433.3333 22666.6667
+4431 38433.3333 22833.3333
+4432 38433.3333 22883.3333
+4433 38433.3333 22900.0000
+4434 38433.3333 22916.6667
+4435 38433.3333 22966.6667
+4436 38433.3333 22983.3333
+4437 38433.3333 23033.3333
+4438 38433.3333 23300.0000
+4439 38433.3333 23400.0000
+4440 38433.3333 23600.0000
+4441 38433.3333 23633.3333
+4442 38433.3333 23650.0000
+4443 38433.3333 23666.6667
+4444 38433.3333 23683.3333
+4445 38433.3333 23883.3333
+4446 38433.3333 23900.0000
+4447 38433.3333 24033.3333
+4448 38433.3333 24066.6667
+4449 38433.3333 24116.6667
+4450 38433.3333 25966.6667
+4451 38450.0000 20533.3333
+4452 38450.0000 20550.0000
+4453 38450.0000 20566.6667
+4454 38450.0000 20583.3333
+4455 38450.0000 20633.3333
+4456 38450.0000 20650.0000
+4457 38450.0000 20666.6667
+4458 38450.0000 20683.3333
+4459 38450.0000 21116.6667
+4460 38450.0000 21233.3333
+4461 38450.0000 21383.3333
+4462 38450.0000 21400.0000
+4463 38450.0000 21516.6667
+4464 38450.0000 21583.3333
+4465 38450.0000 21600.0000
+4466 38450.0000 21633.3333
+4467 38450.0000 21666.6667
+4468 38450.0000 21683.3333
+4469 38450.0000 21700.0000
+4470 38450.0000 21800.0000
+4471 38450.0000 21816.6667
+4472 38450.0000 21916.6667
+4473 38450.0000 21983.3333
+4474 38450.0000 22000.0000
+4475 38450.0000 22033.3333
+4476 38450.0000 22150.0000
+4477 38450.0000 22233.3333
+4478 38450.0000 22300.0000
+4479 38450.0000 22366.6667
+4480 38450.0000 22816.6667
+4481 38450.0000 22833.3333
+4482 38450.0000 22866.6667
+4483 38450.0000 23000.0000
+4484 38450.0000 23216.6667
+4485 38450.0000 23683.3333
+4486 38450.0000 23816.6667
+4487 38450.0000 24000.0000
+4488 38450.0000 24016.6667
+4489 38450.0000 24083.3333
+4490 38450.0000 24116.6667
+4491 38450.0000 24133.3333
+4492 38450.0000 24150.0000
+4493 38450.0000 24166.6667
+4494 38466.6667 20550.0000
+4495 38466.6667 20566.6667
+4496 38466.6667 20583.3333
+4497 38466.6667 20633.3333
+4498 38466.6667 20650.0000
+4499 38466.6667 21266.6667
+4500 38466.6667 21366.6667
+4501 38466.6667 21500.0000
+4502 38466.6667 21566.6667
+4503 38466.6667 21583.3333
+4504 38466.6667 21600.0000
+4505 38466.6667 21616.6667
+4506 38466.6667 21650.0000
+4507 38466.6667 21700.0000
+4508 38466.6667 21733.3333
+4509 38466.6667 21800.0000
+4510 38466.6667 21816.6667
+4511 38466.6667 21866.6667
+4512 38466.6667 21933.3333
+4513 38466.6667 21950.0000
+4514 38466.6667 22100.0000
+4515 38466.6667 22183.3333
+4516 38466.6667 22466.6667
+4517 38466.6667 22783.3333
+4518 38466.6667 22800.0000
+4519 38466.6667 22866.6667
+4520 38466.6667 22950.0000
+4521 38466.6667 22966.6667
+4522 38466.6667 23000.0000
+4523 38466.6667 23283.3333
+4524 38466.6667 23583.3333
+4525 38466.6667 23600.0000
+4526 38466.6667 23650.0000
+4527 38466.6667 23766.6667
+4528 38466.6667 23966.6667
+4529 38466.6667 24116.6667
+4530 38466.6667 24150.0000
+4531 38466.6667 25916.6667
+4532 38466.6667 25966.6667
+4533 38466.6667 26116.6667
+4534 38483.3333 20666.6667
+4535 38483.3333 21100.0000
+4536 38483.3333 21250.0000
+4537 38483.3333 21283.3333
+4538 38483.3333 21350.0000
+4539 38483.3333 21416.6667
+4540 38483.3333 21450.0000
+4541 38483.3333 21583.3333
+4542 38483.3333 21633.3333
+4543 38483.3333 21650.0000
+4544 38483.3333 21666.6667
+4545 38483.3333 21766.6667
+4546 38483.3333 21833.3333
+4547 38483.3333 21850.0000
+4548 38483.3333 22016.6667
+4549 38483.3333 22033.3333
+4550 38483.3333 22050.0000
+4551 38483.3333 22083.3333
+4552 38483.3333 22166.6667
+4553 38483.3333 22183.3333
+4554 38483.3333 22366.6667
+4555 38483.3333 22400.0000
+4556 38483.3333 22500.0000
+4557 38483.3333 22583.3333
+4558 38483.3333 22883.3333
+4559 38483.3333 22933.3333
+4560 38483.3333 23100.0000
+4561 38483.3333 23233.3333
+4562 38483.3333 23450.0000
+4563 38483.3333 23550.0000
+4564 38483.3333 23750.0000
+4565 38483.3333 23800.0000
+4566 38483.3333 23900.0000
+4567 38483.3333 24116.6667
+4568 38483.3333 24133.3333
+4569 38483.3333 24166.6667
+4570 38483.3333 25916.6667
+4571 38483.3333 26050.0000
+4572 38500.0000 21350.0000
+4573 38500.0000 21383.3333
+4574 38500.0000 21483.3333
+4575 38500.0000 21516.6667
+4576 38500.0000 21550.0000
+4577 38500.0000 21583.3333
+4578 38500.0000 21600.0000
+4579 38500.0000 21616.6667
+4580 38500.0000 21633.3333
+4581 38500.0000 21650.0000
+4582 38500.0000 21666.6667
+4583 38500.0000 21700.0000
+4584 38500.0000 21800.0000
+4585 38500.0000 21833.3333
+4586 38500.0000 21850.0000
+4587 38500.0000 21883.3333
+4588 38500.0000 22133.3333
+4589 38500.0000 22233.3333
+4590 38500.0000 22383.3333
+4591 38500.0000 22800.0000
+4592 38500.0000 22850.0000
+4593 38500.0000 22883.3333
+4594 38500.0000 22933.3333
+4595 38500.0000 22983.3333
+4596 38500.0000 23166.6667
+4597 38500.0000 23266.6667
+4598 38500.0000 23616.6667
+4599 38500.0000 23966.6667
+4600 38500.0000 24016.6667
+4601 38500.0000 24083.3333
+4602 38500.0000 24116.6667
+4603 38500.0000 24133.3333
+4604 38500.0000 25916.6667
+4605 38516.6667 21283.3333
+4606 38516.6667 21383.3333
+4607 38516.6667 21433.3333
+4608 38516.6667 21466.6667
+4609 38516.6667 21533.3333
+4610 38516.6667 21550.0000
+4611 38516.6667 21566.6667
+4612 38516.6667 21666.6667
+4613 38516.6667 21683.3333
+4614 38516.6667 21716.6667
+4615 38516.6667 21766.6667
+4616 38516.6667 21783.3333
+4617 38516.6667 21833.3333
+4618 38516.6667 21866.6667
+4619 38516.6667 21883.3333
+4620 38516.6667 21916.6667
+4621 38516.6667 21950.0000
+4622 38516.6667 21966.6667
+4623 38516.6667 22166.6667
+4624 38516.6667 22383.3333
+4625 38516.6667 22550.0000
+4626 38516.6667 22733.3333
+4627 38516.6667 22783.3333
+4628 38516.6667 22950.0000
+4629 38516.6667 23033.3333
+4630 38516.6667 23633.3333
+4631 38516.6667 23650.0000
+4632 38516.6667 23783.3333
+4633 38516.6667 23850.0000
+4634 38516.6667 23983.3333
+4635 38516.6667 24000.0000
+4636 38516.6667 24033.3333
+4637 38516.6667 24100.0000
+4638 38516.6667 24133.3333
+4639 38516.6667 24150.0000
+4640 38516.6667 24166.6667
+4641 38516.6667 25883.3333
+4642 38516.6667 26216.6667
+4643 38533.3333 21083.3333
+4644 38533.3333 21183.3333
+4645 38533.3333 21216.6667
+4646 38533.3333 21366.6667
+4647 38533.3333 21383.3333
+4648 38533.3333 21400.0000
+4649 38533.3333 21416.6667
+4650 38533.3333 21433.3333
+4651 38533.3333 21450.0000
+4652 38533.3333 21500.0000
+4653 38533.3333 21533.3333
+4654 38533.3333 21550.0000
+4655 38533.3333 21566.6667
+4656 38533.3333 21683.3333
+4657 38533.3333 21700.0000
+4658 38533.3333 21766.6667
+4659 38533.3333 21816.6667
+4660 38533.3333 21833.3333
+4661 38533.3333 21900.0000
+4662 38533.3333 21916.6667
+4663 38533.3333 21933.3333
+4664 38533.3333 21983.3333
+4665 38533.3333 22033.3333
+4666 38533.3333 22100.0000
+4667 38533.3333 22200.0000
+4668 38533.3333 22266.6667
+4669 38533.3333 22383.3333
+4670 38533.3333 22500.0000
+4671 38533.3333 22850.0000
+4672 38533.3333 23016.6667
+4673 38533.3333 23100.0000
+4674 38533.3333 23716.6667
+4675 38533.3333 23816.6667
+4676 38533.3333 23850.0000
+4677 38533.3333 23916.6667
+4678 38533.3333 23933.3333
+4679 38533.3333 23983.3333
+4680 38533.3333 24050.0000
+4681 38533.3333 24066.6667
+4682 38533.3333 24083.3333
+4683 38533.3333 24116.6667
+4684 38533.3333 24133.3333
+4685 38533.3333 25566.6667
+4686 38533.3333 25933.3333
+4687 38533.3333 25950.0000
+4688 38533.3333 26100.0000
+4689 38533.3333 26116.6667
+4690 38550.0000 21233.3333
+4691 38550.0000 21333.3333
+4692 38550.0000 21366.6667
+4693 38550.0000 21383.3333
+4694 38550.0000 21533.3333
+4695 38550.0000 21650.0000
+4696 38550.0000 21666.6667
+4697 38550.0000 21700.0000
+4698 38550.0000 21800.0000
+4699 38550.0000 21816.6667
+4700 38550.0000 21866.6667
+4701 38550.0000 22016.6667
+4702 38550.0000 22066.6667
+4703 38550.0000 22116.6667
+4704 38550.0000 22166.6667
+4705 38550.0000 22416.6667
+4706 38550.0000 22833.3333
+4707 38550.0000 23083.3333
+4708 38550.0000 23783.3333
+4709 38550.0000 23850.0000
+4710 38550.0000 23900.0000
+4711 38550.0000 24000.0000
+4712 38550.0000 24050.0000
+4713 38550.0000 24083.3333
+4714 38550.0000 25850.0000
+4715 38550.0000 25933.3333
+4716 38566.6667 20916.6667
+4717 38566.6667 21100.0000
+4718 38566.6667 21300.0000
+4719 38566.6667 21633.3333
+4720 38566.6667 21650.0000
+4721 38566.6667 21666.6667
+4722 38566.6667 21683.3333
+4723 38566.6667 21700.0000
+4724 38566.6667 21850.0000
+4725 38566.6667 21916.6667
+4726 38566.6667 21966.6667
+4727 38566.6667 22016.6667
+4728 38566.6667 22150.0000
+4729 38566.6667 22700.0000
+4730 38566.6667 22750.0000
+4731 38566.6667 22783.3333
+4732 38566.6667 22866.6667
+4733 38566.6667 23100.0000
+4734 38566.6667 23216.6667
+4735 38566.6667 23283.3333
+4736 38566.6667 23600.0000
+4737 38566.6667 23633.3333
+4738 38566.6667 23766.6667
+4739 38566.6667 23816.6667
+4740 38566.6667 23833.3333
+4741 38566.6667 23850.0000
+4742 38566.6667 24050.0000
+4743 38566.6667 24066.6667
+4744 38566.6667 24083.3333
+4745 38566.6667 25866.6667
+4746 38566.6667 25883.3333
+4747 38566.6667 25916.6667
+4748 38566.6667 25950.0000
+4749 38566.6667 25983.3333
+4750 38566.6667 26033.3333
+4751 38583.3333 20550.0000
+4752 38583.3333 21066.6667
+4753 38583.3333 21150.0000
+4754 38583.3333 21166.6667
+4755 38583.3333 21233.3333
+4756 38583.3333 21383.3333
+4757 38583.3333 21450.0000
+4758 38583.3333 21616.6667
+4759 38583.3333 21633.3333
+4760 38583.3333 21650.0000
+4761 38583.3333 21666.6667
+4762 38583.3333 21683.3333
+4763 38583.3333 21716.6667
+4764 38583.3333 21750.0000
+4765 38583.3333 21833.3333
+4766 38583.3333 21883.3333
+4767 38583.3333 21933.3333
+4768 38583.3333 21983.3333
+4769 38583.3333 22050.0000
+4770 38583.3333 22333.3333
+4771 38583.3333 22416.6667
+4772 38583.3333 22666.6667
+4773 38583.3333 22750.0000
+4774 38583.3333 22800.0000
+4775 38583.3333 22950.0000
+4776 38583.3333 23033.3333
+4777 38583.3333 23550.0000
+4778 38583.3333 23633.3333
+4779 38583.3333 23716.6667
+4780 38583.3333 23766.6667
+4781 38583.3333 23800.0000
+4782 38583.3333 23833.3333
+4783 38583.3333 24050.0000
+4784 38583.3333 24066.6667
+4785 38583.3333 24083.3333
+4786 38583.3333 24100.0000
+4787 38583.3333 24116.6667
+4788 38583.3333 24133.3333
+4789 38583.3333 25916.6667
+4790 38583.3333 25966.6667
+4791 38583.3333 26016.6667
+4792 38600.0000 20883.3333
+4793 38600.0000 21083.3333
+4794 38600.0000 21183.3333
+4795 38600.0000 21316.6667
+4796 38600.0000 21400.0000
+4797 38600.0000 21450.0000
+4798 38600.0000 21483.3333
+4799 38600.0000 21500.0000
+4800 38600.0000 21550.0000
+4801 38600.0000 21566.6667
+4802 38600.0000 21583.3333
+4803 38600.0000 21600.0000
+4804 38600.0000 21650.0000
+4805 38600.0000 21666.6667
+4806 38600.0000 21733.3333
+4807 38600.0000 21800.0000
+4808 38600.0000 21850.0000
+4809 38600.0000 21933.3333
+4810 38600.0000 22050.0000
+4811 38600.0000 22116.6667
+4812 38600.0000 22183.3333
+4813 38600.0000 22500.0000
+4814 38600.0000 22716.6667
+4815 38600.0000 22766.6667
+4816 38600.0000 22850.0000
+4817 38600.0000 23216.6667
+4818 38600.0000 23550.0000
+4819 38600.0000 23666.6667
+4820 38600.0000 23783.3333
+4821 38600.0000 24083.3333
+4822 38600.0000 24100.0000
+4823 38600.0000 24116.6667
+4824 38616.6667 20600.0000
+4825 38616.6667 20666.6667
+4826 38616.6667 20683.3333
+4827 38616.6667 20933.3333
+4828 38616.6667 21216.6667
+4829 38616.6667 21300.0000
+4830 38616.6667 21316.6667
+4831 38616.6667 21383.3333
+4832 38616.6667 21450.0000
+4833 38616.6667 21500.0000
+4834 38616.6667 21516.6667
+4835 38616.6667 21533.3333
+4836 38616.6667 21566.6667
+4837 38616.6667 21600.0000
+4838 38616.6667 21616.6667
+4839 38616.6667 21683.3333
+4840 38616.6667 21700.0000
+4841 38616.6667 21783.3333
+4842 38616.6667 21883.3333
+4843 38616.6667 22200.0000
+4844 38616.6667 22550.0000
+4845 38616.6667 22650.0000
+4846 38616.6667 23116.6667
+4847 38616.6667 23166.6667
+4848 38616.6667 23233.3333
+4849 38616.6667 23533.3333
+4850 38616.6667 23566.6667
+4851 38616.6667 23700.0000
+4852 38616.6667 23733.3333
+4853 38616.6667 23750.0000
+4854 38616.6667 23883.3333
+4855 38616.6667 23950.0000
+4856 38616.6667 24050.0000
+4857 38616.6667 24066.6667
+4858 38616.6667 24083.3333
+4859 38616.6667 24116.6667
+4860 38633.3333 20600.0000
+4861 38633.3333 20633.3333
+4862 38633.3333 20650.0000
+4863 38633.3333 20716.6667
+4864 38633.3333 21150.0000
+4865 38633.3333 21183.3333
+4866 38633.3333 21350.0000
+4867 38633.3333 21366.6667
+4868 38633.3333 21400.0000
+4869 38633.3333 21416.6667
+4870 38633.3333 21433.3333
+4871 38633.3333 21450.0000
+4872 38633.3333 21466.6667
+4873 38633.3333 21483.3333
+4874 38633.3333 21566.6667
+4875 38633.3333 21583.3333
+4876 38633.3333 21616.6667
+4877 38633.3333 21666.6667
+4878 38633.3333 21683.3333
+4879 38633.3333 21700.0000
+4880 38633.3333 21716.6667
+4881 38633.3333 21733.3333
+4882 38633.3333 21800.0000
+4883 38633.3333 21983.3333
+4884 38633.3333 22016.6667
+4885 38633.3333 22100.0000
+4886 38633.3333 22183.3333
+4887 38633.3333 22216.6667
+4888 38633.3333 22500.0000
+4889 38633.3333 22533.3333
+4890 38633.3333 22583.3333
+4891 38633.3333 22733.3333
+4892 38633.3333 22766.6667
+4893 38633.3333 22883.3333
+4894 38633.3333 23083.3333
+4895 38633.3333 23600.0000
+4896 38633.3333 23616.6667
+4897 38633.3333 23633.3333
+4898 38633.3333 23933.3333
+4899 38633.3333 24050.0000
+4900 38633.3333 24066.6667
+4901 38633.3333 24083.3333
+4902 38633.3333 24100.0000
+4903 38633.3333 24133.3333
+4904 38650.0000 20683.3333
+4905 38650.0000 20783.3333
+4906 38650.0000 20933.3333
+4907 38650.0000 21283.3333
+4908 38650.0000 21383.3333
+4909 38650.0000 21416.6667
+4910 38650.0000 21450.0000
+4911 38650.0000 21483.3333
+4912 38650.0000 21533.3333
+4913 38650.0000 21550.0000
+4914 38650.0000 21616.6667
+4915 38650.0000 21650.0000
+4916 38650.0000 21683.3333
+4917 38650.0000 21750.0000
+4918 38650.0000 21766.6667
+4919 38650.0000 21833.3333
+4920 38650.0000 21916.6667
+4921 38650.0000 21966.6667
+4922 38650.0000 22033.3333
+4923 38650.0000 22066.6667
+4924 38650.0000 22416.6667
+4925 38650.0000 22466.6667
+4926 38650.0000 23000.0000
+4927 38650.0000 23166.6667
+4928 38650.0000 23183.3333
+4929 38650.0000 23583.3333
+4930 38650.0000 23900.0000
+4931 38666.6667 20566.6667
+4932 38666.6667 20600.0000
+4933 38666.6667 20650.0000
+4934 38666.6667 20700.0000
+4935 38666.6667 20766.6667
+4936 38666.6667 20783.3333
+4937 38666.6667 20933.3333
+4938 38666.6667 21083.3333
+4939 38666.6667 21150.0000
+4940 38666.6667 21316.6667
+4941 38666.6667 21366.6667
+4942 38666.6667 21383.3333
+4943 38666.6667 21433.3333
+4944 38666.6667 21500.0000
+4945 38666.6667 21516.6667
+4946 38666.6667 21533.3333
+4947 38666.6667 21616.6667
+4948 38666.6667 21633.3333
+4949 38666.6667 21716.6667
+4950 38666.6667 21733.3333
+4951 38666.6667 21816.6667
+4952 38666.6667 21833.3333
+4953 38666.6667 21866.6667
+4954 38666.6667 21900.0000
+4955 38666.6667 22000.0000
+4956 38666.6667 22433.3333
+4957 38666.6667 22566.6667
+4958 38666.6667 22666.6667
+4959 38666.6667 22883.3333
+4960 38666.6667 23083.3333
+4961 38666.6667 23783.3333
+4962 38666.6667 23816.6667
+4963 38683.3333 20583.3333
+4964 38683.3333 20616.6667
+4965 38683.3333 20666.6667
+4966 38683.3333 20683.3333
+4967 38683.3333 20700.0000
+4968 38683.3333 21266.6667
+4969 38683.3333 21366.6667
+4970 38683.3333 21416.6667
+4971 38683.3333 21466.6667
+4972 38683.3333 21483.3333
+4973 38683.3333 21533.3333
+4974 38683.3333 21666.6667
+4975 38683.3333 21750.0000
+4976 38683.3333 21800.0000
+4977 38683.3333 21833.3333
+4978 38683.3333 21866.6667
+4979 38683.3333 21900.0000
+4980 38683.3333 21983.3333
+4981 38683.3333 22200.0000
+4982 38683.3333 22333.3333
+4983 38683.3333 23000.0000
+4984 38683.3333 23583.3333
+4985 38683.3333 23733.3333
+4986 38683.3333 23766.6667
+4987 38683.3333 23783.3333
+4988 38700.0000 20616.6667
+4989 38700.0000 20633.3333
+4990 38700.0000 20683.3333
+4991 38700.0000 20700.0000
+4992 38700.0000 20716.6667
+4993 38700.0000 20933.3333
+4994 38700.0000 20966.6667
+4995 38700.0000 21000.0000
+4996 38700.0000 21033.3333
+4997 38700.0000 21183.3333
+4998 38700.0000 21283.3333
+4999 38700.0000 21333.3333
+5000 38700.0000 21350.0000
+5001 38700.0000 21366.6667
+5002 38700.0000 21450.0000
+5003 38700.0000 21600.0000
+5004 38700.0000 21650.0000
+5005 38700.0000 21700.0000
+5006 38700.0000 21733.3333
+5007 38700.0000 21783.3333
+5008 38700.0000 21933.3333
+5009 38700.0000 22033.3333
+5010 38700.0000 22183.3333
+5011 38700.0000 22250.0000
+5012 38700.0000 22283.3333
+5013 38700.0000 22350.0000
+5014 38700.0000 22416.6667
+5015 38700.0000 22633.3333
+5016 38700.0000 23583.3333
+5017 38716.6667 20583.3333
+5018 38716.6667 20600.0000
+5019 38716.6667 20666.6667
+5020 38716.6667 20683.3333
+5021 38716.6667 20733.3333
+5022 38716.6667 20933.3333
+5023 38716.6667 21083.3333
+5024 38716.6667 21166.6667
+5025 38716.6667 21466.6667
+5026 38716.6667 21516.6667
+5027 38716.6667 21533.3333
+5028 38716.6667 21566.6667
+5029 38716.6667 21650.0000
+5030 38716.6667 21683.3333
+5031 38716.6667 21700.0000
+5032 38716.6667 21800.0000
+5033 38716.6667 21866.6667
+5034 38716.6667 21966.6667
+5035 38716.6667 22366.6667
+5036 38716.6667 22400.0000
+5037 38716.6667 22466.6667
+5038 38716.6667 22483.3333
+5039 38716.6667 22550.0000
+5040 38716.6667 22583.3333
+5041 38716.6667 22700.0000
+5042 38716.6667 22883.3333
+5043 38716.6667 22933.3333
+5044 38716.6667 23050.0000
+5045 38716.6667 23433.3333
+5046 38716.6667 23450.0000
+5047 38716.6667 23733.3333
+5048 38716.6667 23750.0000
+5049 38733.3333 20650.0000
+5050 38733.3333 20666.6667
+5051 38733.3333 20983.3333
+5052 38733.3333 21116.6667
+5053 38733.3333 21350.0000
+5054 38733.3333 21450.0000
+5055 38733.3333 21466.6667
+5056 38733.3333 21516.6667
+5057 38733.3333 21650.0000
+5058 38733.3333 21666.6667
+5059 38733.3333 21700.0000
+5060 38733.3333 21716.6667
+5061 38733.3333 21733.3333
+5062 38733.3333 21916.6667
+5063 38733.3333 21933.3333
+5064 38733.3333 21966.6667
+5065 38733.3333 22000.0000
+5066 38733.3333 22233.3333
+5067 38733.3333 22333.3333
+5068 38733.3333 22400.0000
+5069 38733.3333 22450.0000
+5070 38733.3333 22666.6667
+5071 38733.3333 22733.3333
+5072 38733.3333 22750.0000
+5073 38733.3333 22933.3333
+5074 38733.3333 23333.3333
+5075 38733.3333 23416.6667
+5076 38733.3333 23483.3333
+5077 38750.0000 20600.0000
+5078 38750.0000 20616.6667
+5079 38750.0000 20650.0000
+5080 38750.0000 20683.3333
+5081 38750.0000 20716.6667
+5082 38750.0000 21033.3333
+5083 38750.0000 21066.6667
+5084 38750.0000 21133.3333
+5085 38750.0000 21200.0000
+5086 38750.0000 21400.0000
+5087 38750.0000 21433.3333
+5088 38750.0000 21450.0000
+5089 38750.0000 21516.6667
+5090 38750.0000 21533.3333
+5091 38750.0000 21616.6667
+5092 38750.0000 21666.6667
+5093 38750.0000 21683.3333
+5094 38750.0000 21700.0000
+5095 38750.0000 21750.0000
+5096 38750.0000 21783.3333
+5097 38750.0000 21816.6667
+5098 38750.0000 21850.0000
+5099 38750.0000 21916.6667
+5100 38750.0000 22166.6667
+5101 38750.0000 22216.6667
+5102 38750.0000 22266.6667
+5103 38750.0000 22450.0000
+5104 38750.0000 22616.6667
+5105 38750.0000 22700.0000
+5106 38750.0000 22783.3333
+5107 38750.0000 22950.0000
+5108 38750.0000 23033.3333
+5109 38750.0000 23400.0000
+5110 38750.0000 23433.3333
+5111 38750.0000 23583.3333
+5112 38750.0000 23666.6667
+5113 38750.0000 23733.3333
+5114 38766.6667 20633.3333
+5115 38766.6667 20650.0000
+5116 38766.6667 20716.6667
+5117 38766.6667 20883.3333
+5118 38766.6667 20983.3333
+5119 38766.6667 21400.0000
+5120 38766.6667 21416.6667
+5121 38766.6667 21433.3333
+5122 38766.6667 21483.3333
+5123 38766.6667 21583.3333
+5124 38766.6667 21616.6667
+5125 38766.6667 21700.0000
+5126 38766.6667 21750.0000
+5127 38766.6667 21783.3333
+5128 38766.6667 21800.0000
+5129 38766.6667 21883.3333
+5130 38766.6667 22133.3333
+5131 38766.6667 22366.6667
+5132 38766.6667 22400.0000
+5133 38766.6667 22450.0000
+5134 38766.6667 22616.6667
+5135 38766.6667 22650.0000
+5136 38766.6667 22850.0000
+5137 38766.6667 22900.0000
+5138 38766.6667 23316.6667
+5139 38766.6667 23433.3333
+5140 38766.6667 23550.0000
+5141 38766.6667 23700.0000
+5142 38783.3333 20616.6667
+5143 38783.3333 20650.0000
+5144 38783.3333 20666.6667
+5145 38783.3333 20700.0000
+5146 38783.3333 20833.3333
+5147 38783.3333 20883.3333
+5148 38783.3333 20900.0000
+5149 38783.3333 21033.3333
+5150 38783.3333 21116.6667
+5151 38783.3333 21283.3333
+5152 38783.3333 21433.3333
+5153 38783.3333 21450.0000
+5154 38783.3333 21483.3333
+5155 38783.3333 21533.3333
+5156 38783.3333 21616.6667
+5157 38783.3333 21633.3333
+5158 38783.3333 21683.3333
+5159 38783.3333 21716.6667
+5160 38783.3333 21866.6667
+5161 38783.3333 22083.3333
+5162 38783.3333 22366.6667
+5163 38783.3333 22416.6667
+5164 38783.3333 22583.3333
+5165 38783.3333 22783.3333
+5166 38783.3333 23266.6667
+5167 38783.3333 23300.0000
+5168 38783.3333 23333.3333
+5169 38783.3333 23400.0000
+5170 38783.3333 23433.3333
+5171 38783.3333 23500.0000
+5172 38800.0000 20716.6667
+5173 38800.0000 20766.6667
+5174 38800.0000 21166.6667
+5175 38800.0000 21366.6667
+5176 38800.0000 21450.0000
+5177 38800.0000 21466.6667
+5178 38800.0000 21516.6667
+5179 38800.0000 21583.3333
+5180 38800.0000 21616.6667
+5181 38800.0000 21633.3333
+5182 38800.0000 21650.0000
+5183 38800.0000 21716.6667
+5184 38800.0000 21733.3333
+5185 38800.0000 21800.0000
+5186 38800.0000 22050.0000
+5187 38800.0000 22116.6667
+5188 38800.0000 22200.0000
+5189 38800.0000 22383.3333
+5190 38800.0000 22416.6667
+5191 38800.0000 22450.0000
+5192 38800.0000 22466.6667
+5193 38800.0000 22500.0000
+5194 38800.0000 22533.3333
+5195 38800.0000 22550.0000
+5196 38800.0000 22700.0000
+5197 38800.0000 22716.6667
+5198 38800.0000 23350.0000
+5199 38800.0000 23433.3333
+5200 38800.0000 23483.3333
+5201 38800.0000 23500.0000
+5202 38800.0000 23516.6667
+5203 38800.0000 24583.3333
+5204 38816.6667 20650.0000
+5205 38816.6667 20683.3333
+5206 38816.6667 20716.6667
+5207 38816.6667 20750.0000
+5208 38816.6667 20833.3333
+5209 38816.6667 20916.6667
+5210 38816.6667 21016.6667
+5211 38816.6667 21233.3333
+5212 38816.6667 21333.3333
+5213 38816.6667 21366.6667
+5214 38816.6667 21383.3333
+5215 38816.6667 21400.0000
+5216 38816.6667 21433.3333
+5217 38816.6667 21466.6667
+5218 38816.6667 21500.0000
+5219 38816.6667 21616.6667
+5220 38816.6667 22000.0000
+5221 38816.6667 22016.6667
+5222 38816.6667 22166.6667
+5223 38816.6667 22433.3333
+5224 38816.6667 22600.0000
+5225 38816.6667 22650.0000
+5226 38816.6667 22683.3333
+5227 38816.6667 22733.3333
+5228 38816.6667 23233.3333
+5229 38816.6667 23250.0000
+5230 38816.6667 23266.6667
+5231 38816.6667 23366.6667
+5232 38816.6667 23416.6667
+5233 38816.6667 23450.0000
+5234 38833.3333 20683.3333
+5235 38833.3333 20700.0000
+5236 38833.3333 20750.0000
+5237 38833.3333 20900.0000
+5238 38833.3333 21000.0000
+5239 38833.3333 21066.6667
+5240 38833.3333 21183.3333
+5241 38833.3333 21250.0000
+5242 38833.3333 21416.6667
+5243 38833.3333 21466.6667
+5244 38833.3333 21516.6667
+5245 38833.3333 21533.3333
+5246 38833.3333 21583.3333
+5247 38833.3333 21600.0000
+5248 38833.3333 21616.6667
+5249 38833.3333 21633.3333
+5250 38833.3333 21716.6667
+5251 38833.3333 21733.3333
+5252 38833.3333 21800.0000
+5253 38833.3333 21966.6667
+5254 38833.3333 22050.0000
+5255 38833.3333 22083.3333
+5256 38833.3333 22166.6667
+5257 38833.3333 22400.0000
+5258 38833.3333 22416.6667
+5259 38833.3333 22450.0000
+5260 38833.3333 22883.3333
+5261 38833.3333 23250.0000
+5262 38833.3333 23283.3333
+5263 38833.3333 23333.3333
+5264 38833.3333 23366.6667
+5265 38833.3333 23400.0000
+5266 38833.3333 23466.6667
+5267 38833.3333 24533.3333
+5268 38850.0000 20950.0000
+5269 38850.0000 21333.3333
+5270 38850.0000 21383.3333
+5271 38850.0000 21450.0000
+5272 38850.0000 21466.6667
+5273 38850.0000 21516.6667
+5274 38850.0000 21633.3333
+5275 38850.0000 21916.6667
+5276 38850.0000 21933.3333
+5277 38850.0000 21966.6667
+5278 38850.0000 22183.3333
+5279 38850.0000 22216.6667
+5280 38850.0000 22366.6667
+5281 38850.0000 22383.3333
+5282 38850.0000 22433.3333
+5283 38850.0000 22466.6667
+5284 38850.0000 22866.6667
+5285 38850.0000 22900.0000
+5286 38850.0000 23050.0000
+5287 38850.0000 23066.6667
+5288 38850.0000 23100.0000
+5289 38850.0000 23116.6667
+5290 38850.0000 23133.3333
+5291 38850.0000 23250.0000
+5292 38850.0000 23283.3333
+5293 38850.0000 23300.0000
+5294 38850.0000 23400.0000
+5295 38866.6667 20800.0000
+5296 38866.6667 20983.3333
+5297 38866.6667 21000.0000
+5298 38866.6667 21016.6667
+5299 38866.6667 21033.3333
+5300 38866.6667 21066.6667
+5301 38866.6667 21166.6667
+5302 38866.6667 21283.3333
+5303 38866.6667 21350.0000
+5304 38866.6667 21366.6667
+5305 38866.6667 21500.0000
+5306 38866.6667 21516.6667
+5307 38866.6667 21566.6667
+5308 38866.6667 21583.3333
+5309 38866.6667 21616.6667
+5310 38866.6667 21633.3333
+5311 38866.6667 21666.6667
+5312 38866.6667 21683.3333
+5313 38866.6667 21700.0000
+5314 38866.6667 21733.3333
+5315 38866.6667 21750.0000
+5316 38866.6667 21766.6667
+5317 38866.6667 21783.3333
+5318 38866.6667 21966.6667
+5319 38866.6667 22033.3333
+5320 38866.6667 22133.3333
+5321 38866.6667 22200.0000
+5322 38866.6667 22233.3333
+5323 38866.6667 22350.0000
+5324 38866.6667 22750.0000
+5325 38866.6667 22966.6667
+5326 38866.6667 23216.6667
+5327 38866.6667 23233.3333
+5328 38866.6667 23366.6667
+5329 38866.6667 23400.0000
+5330 38883.3333 21200.0000
+5331 38883.3333 21550.0000
+5332 38883.3333 21566.6667
+5333 38883.3333 21600.0000
+5334 38883.3333 21650.0000
+5335 38883.3333 21700.0000
+5336 38883.3333 21750.0000
+5337 38883.3333 21800.0000
+5338 38883.3333 21833.3333
+5339 38883.3333 21966.6667
+5340 38883.3333 22050.0000
+5341 38883.3333 22100.0000
+5342 38883.3333 22116.6667
+5343 38883.3333 22200.0000
+5344 38883.3333 22216.6667
+5345 38883.3333 22250.0000
+5346 38883.3333 22266.6667
+5347 38883.3333 22316.6667
+5348 38883.3333 22400.0000
+5349 38883.3333 22416.6667
+5350 38883.3333 22433.3333
+5351 38883.3333 22466.6667
+5352 38883.3333 22483.3333
+5353 38883.3333 22716.6667
+5354 38883.3333 22783.3333
+5355 38883.3333 22816.6667
+5356 38883.3333 23050.0000
+5357 38883.3333 23166.6667
+5358 38900.0000 21100.0000
+5359 38900.0000 21316.6667
+5360 38900.0000 21333.3333
+5361 38900.0000 21450.0000
+5362 38900.0000 21566.6667
+5363 38900.0000 21583.3333
+5364 38900.0000 21600.0000
+5365 38900.0000 21633.3333
+5366 38900.0000 21716.6667
+5367 38900.0000 21766.6667
+5368 38900.0000 21866.6667
+5369 38900.0000 22033.3333
+5370 38900.0000 22050.0000
+5371 38900.0000 22066.6667
+5372 38900.0000 22100.0000
+5373 38900.0000 22116.6667
+5374 38900.0000 22166.6667
+5375 38900.0000 22216.6667
+5376 38900.0000 22233.3333
+5377 38900.0000 22283.3333
+5378 38900.0000 22333.3333
+5379 38900.0000 22366.6667
+5380 38900.0000 22433.3333
+5381 38900.0000 22583.3333
+5382 38900.0000 22733.3333
+5383 38900.0000 23033.3333
+5384 38900.0000 23050.0000
+5385 38900.0000 23066.6667
+5386 38900.0000 23133.3333
+5387 38900.0000 23166.6667
+5388 38900.0000 23183.3333
+5389 38900.0000 23216.6667
+5390 38900.0000 23266.6667
+5391 38900.0000 23333.3333
+5392 38900.0000 23350.0000
+5393 38900.0000 23400.0000
+5394 38904.1667 24563.0556
+5395 38916.6667 20883.3333
+5396 38916.6667 20950.0000
+5397 38916.6667 21200.0000
+5398 38916.6667 21216.6667
+5399 38916.6667 21266.6667
+5400 38916.6667 21483.3333
+5401 38916.6667 21633.3333
+5402 38916.6667 21666.6667
+5403 38916.6667 21683.3333
+5404 38916.6667 21783.3333
+5405 38916.6667 21916.6667
+5406 38916.6667 22000.0000
+5407 38916.6667 22166.6667
+5408 38916.6667 22216.6667
+5409 38916.6667 22233.3333
+5410 38916.6667 22300.0000
+5411 38916.6667 22550.0000
+5412 38916.6667 22616.6667
+5413 38916.6667 22650.0000
+5414 38916.6667 22700.0000
+5415 38916.6667 22800.0000
+5416 38916.6667 23116.6667
+5417 38916.6667 23183.3333
+5418 38916.6667 23200.0000
+5419 38916.6667 23216.6667
+5420 38933.3333 20850.0000
+5421 38933.3333 21150.0000
+5422 38933.3333 21400.0000
+5423 38933.3333 21433.3333
+5424 38933.3333 21600.0000
+5425 38933.3333 21700.0000
+5426 38933.3333 21716.6667
+5427 38933.3333 21916.6667
+5428 38933.3333 21983.3333
+5429 38933.3333 22016.6667
+5430 38933.3333 22033.3333
+5431 38933.3333 22116.6667
+5432 38933.3333 22250.0000
+5433 38933.3333 22350.0000
+5434 38933.3333 22400.0000
+5435 38933.3333 22416.6667
+5436 38933.3333 22733.3333
+5437 38933.3333 22783.3333
+5438 38933.3333 23066.6667
+5439 38933.3333 23150.0000
+5440 38933.3333 23166.6667
+5441 38933.3333 23283.3333
+5442 38933.3333 23366.6667
+5443 38933.3333 23416.6667
+5444 38950.0000 20733.3333
+5445 38950.0000 20750.0000
+5446 38950.0000 21183.3333
+5447 38950.0000 21200.0000
+5448 38950.0000 21416.6667
+5449 38950.0000 21516.6667
+5450 38950.0000 21600.0000
+5451 38950.0000 21650.0000
+5452 38950.0000 21666.6667
+5453 38950.0000 21883.3333
+5454 38950.0000 21966.6667
+5455 38950.0000 22050.0000
+5456 38950.0000 22150.0000
+5457 38950.0000 22200.0000
+5458 38950.0000 22216.6667
+5459 38950.0000 22316.6667
+5460 38950.0000 22516.6667
+5461 38950.0000 22633.3333
+5462 38950.0000 22833.3333
+5463 38950.0000 22916.6667
+5464 38950.0000 22966.6667
+5465 38950.0000 23100.0000
+5466 38950.0000 23150.0000
+5467 38950.0000 23183.3333
+5468 38950.0000 23266.6667
+5469 38962.5000 21150.0000
+5470 38966.6667 20783.3333
+5471 38966.6667 21166.6667
+5472 38966.6667 21183.3333
+5473 38966.6667 21200.0000
+5474 38966.6667 21216.6667
+5475 38966.6667 21283.3333
+5476 38966.6667 21316.6667
+5477 38966.6667 21333.3333
+5478 38966.6667 21450.0000
+5479 38966.6667 21483.3333
+5480 38966.6667 21566.6667
+5481 38966.6667 21616.6667
+5482 38966.6667 21716.6667
+5483 38966.6667 21866.6667
+5484 38966.6667 21966.6667
+5485 38966.6667 22000.0000
+5486 38966.6667 22100.0000
+5487 38966.6667 22116.6667
+5488 38966.6667 22166.6667
+5489 38966.6667 22200.0000
+5490 38966.6667 22450.0000
+5491 38966.6667 22500.0000
+5492 38966.6667 22800.0000
+5493 38966.6667 22900.0000
+5494 38966.6667 23150.0000
+5495 38966.6667 23166.6667
+5496 38966.6667 23233.3333
+5497 38966.6667 23300.0000
+5498 38966.6667 23350.0000
+5499 38976.3889 26368.3333
+5500 38983.3333 20783.3333
+5501 38983.3333 21300.0000
+5502 38983.3333 21350.0000
+5503 38983.3333 21366.6667
+5504 38983.3333 21383.3333
+5505 38983.3333 21400.0000
+5506 38983.3333 21433.3333
+5507 38983.3333 21616.6667
+5508 38983.3333 21683.3333
+5509 38983.3333 21816.6667
+5510 38983.3333 21900.0000
+5511 38983.3333 22000.0000
+5512 38983.3333 22566.6667
+5513 38983.3333 22850.0000
+5514 38983.3333 23233.3333
+5515 38983.3333 23316.6667
+5516 38983.3333 26383.3333
+5517 38983.3333 26400.0000
+5518 38988.3333 26311.3889
+5519 39000.0000 20700.0000
+5520 39000.0000 21150.0000
+5521 39000.0000 21166.6667
+5522 39000.0000 21200.0000
+5523 39000.0000 21250.0000
+5524 39000.0000 21300.0000
+5525 39000.0000 21383.3333
+5526 39000.0000 21466.6667
+5527 39000.0000 21600.0000
+5528 39000.0000 21616.6667
+5529 39000.0000 21633.3333
+5530 39000.0000 21716.6667
+5531 39000.0000 21733.3333
+5532 39000.0000 21800.0000
+5533 39000.0000 21850.0000
+5534 39000.0000 21916.6667
+5535 39000.0000 21933.3333
+5536 39000.0000 22000.0000
+5537 39000.0000 22116.6667
+5538 39000.0000 22216.6667
+5539 39000.0000 22266.6667
+5540 39000.0000 22350.0000
+5541 39000.0000 22933.3333
+5542 39000.0000 22950.0000
+5543 39000.0000 23116.6667
+5544 39000.0000 23200.0000
+5545 39000.0000 23250.0000
+5546 39000.0000 23333.3333
+5547 39000.0000 26316.6667
+5548 39016.6667 20916.6667
+5549 39016.6667 21200.0000
+5550 39016.6667 21266.6667
+5551 39016.6667 21316.6667
+5552 39016.6667 21383.3333
+5553 39016.6667 21400.0000
+5554 39016.6667 21550.0000
+5555 39016.6667 21683.3333
+5556 39016.6667 21700.0000
+5557 39016.6667 21766.6667
+5558 39016.6667 21783.3333
+5559 39016.6667 21816.6667
+5560 39016.6667 21900.0000
+5561 39016.6667 22133.3333
+5562 39016.6667 22250.0000
+5563 39016.6667 22616.6667
+5564 39016.6667 22850.0000
+5565 39016.6667 23033.3333
+5566 39016.6667 23233.3333
+5567 39016.6667 23250.0000
+5568 39016.6667 23300.0000
+5569 39019.1667 26365.8333
+5570 39026.3889 26307.7778
+5571 39028.8889 26321.1111
+5572 39029.7222 26448.3333
+5573 39033.3333 20733.3333
+5574 39033.3333 20750.0000
+5575 39033.3333 20866.6667
+5576 39033.3333 21083.3333
+5577 39033.3333 21150.0000
+5578 39033.3333 21300.0000
+5579 39033.3333 21316.6667
+5580 39033.3333 21450.0000
+5581 39033.3333 21583.3333
+5582 39033.3333 21666.6667
+5583 39033.3333 21700.0000
+5584 39033.3333 21733.3333
+5585 39033.3333 21816.6667
+5586 39033.3333 22066.6667
+5587 39033.3333 22116.6667
+5588 39033.3333 22283.3333
+5589 39033.3333 22333.3333
+5590 39033.3333 22400.0000
+5591 39033.3333 22416.6667
+5592 39033.3333 22516.6667
+5593 39033.3333 22800.0000
+5594 39033.3333 22950.0000
+5595 39033.3333 22966.6667
+5596 39033.3333 26316.6667
+5597 39036.3889 26444.4444
+5598 39039.4444 26201.1111
+5599 39039.4444 26454.7222
+5600 39045.5556 26454.4444
+5601 39046.3889 26533.0556
+5602 39048.3333 26497.2222
+5603 39050.0000 21033.3333
+5604 39050.0000 21116.6667
+5605 39050.0000 21150.0000
+5606 39050.0000 21166.6667
+5607 39050.0000 21216.6667
+5608 39050.0000 21250.0000
+5609 39050.0000 21266.6667
+5610 39050.0000 21283.3333
+5611 39050.0000 21300.0000
+5612 39050.0000 21366.6667
+5613 39050.0000 21450.0000
+5614 39050.0000 21466.6667
+5615 39050.0000 21533.3333
+5616 39050.0000 21566.6667
+5617 39050.0000 21583.3333
+5618 39050.0000 21633.3333
+5619 39050.0000 21750.0000
+5620 39050.0000 22316.6667
+5621 39050.0000 22450.0000
+5622 39050.0000 22950.0000
+5623 39050.0000 26266.6667
+5624 39050.0000 26316.6667
+5625 39055.8333 26451.1111
+5626 39056.9444 26545.0000
+5627 39066.6667 20700.0000
+5628 39066.6667 20750.0000
+5629 39066.6667 20933.3333
+5630 39066.6667 21016.6667
+5631 39066.6667 21033.3333
+5632 39066.6667 21050.0000
+5633 39066.6667 21100.0000
+5634 39066.6667 21116.6667
+5635 39066.6667 21150.0000
+5636 39066.6667 21183.3333
+5637 39066.6667 21216.6667
+5638 39066.6667 21233.3333
+5639 39066.6667 21266.6667
+5640 39066.6667 21283.3333
+5641 39066.6667 21400.0000
+5642 39066.6667 21450.0000
+5643 39066.6667 21466.6667
+5644 39066.6667 21483.3333
+5645 39066.6667 21516.6667
+5646 39066.6667 21533.3333
+5647 39066.6667 21550.0000
+5648 39066.6667 21633.3333
+5649 39066.6667 21683.3333
+5650 39066.6667 21733.3333
+5651 39066.6667 21800.0000
+5652 39066.6667 21883.3333
+5653 39066.6667 21983.3333
+5654 39066.6667 22066.6667
+5655 39066.6667 22116.6667
+5656 39066.6667 22183.3333
+5657 39066.6667 22483.3333
+5658 39066.6667 22550.0000
+5659 39066.6667 22800.0000
+5660 39066.6667 26566.6667
+5661 39066.6667 26583.3333
+5662 39081.1111 26183.3333
+5663 39083.3333 20716.6667
+5664 39083.3333 20750.0000
+5665 39083.3333 20866.6667
+5666 39083.3333 20916.6667
+5667 39083.3333 20933.3333
+5668 39083.3333 20950.0000
+5669 39083.3333 21016.6667
+5670 39083.3333 21050.0000
+5671 39083.3333 21083.3333
+5672 39083.3333 21100.0000
+5673 39083.3333 21150.0000
+5674 39083.3333 21200.0000
+5675 39083.3333 21250.0000
+5676 39083.3333 21266.6667
+5677 39083.3333 21283.3333
+5678 39083.3333 21383.3333
+5679 39083.3333 21433.3333
+5680 39083.3333 21483.3333
+5681 39083.3333 21500.0000
+5682 39083.3333 21566.6667
+5683 39083.3333 21583.3333
+5684 39083.3333 21633.3333
+5685 39083.3333 21650.0000
+5686 39083.3333 21833.3333
+5687 39083.3333 22150.0000
+5688 39083.3333 22316.6667
+5689 39083.3333 22350.0000
+5690 39083.3333 22416.6667
+5691 39083.3333 22783.3333
+5692 39083.3333 22866.6667
+5693 39083.3333 26433.3333
+5694 39083.3333 26550.0000
+5695 39083.3333 26566.6667
+5696 39085.0000 26370.0000
+5697 39100.0000 20700.0000
+5698 39100.0000 20883.3333
+5699 39100.0000 20950.0000
+5700 39100.0000 20983.3333
+5701 39100.0000 21000.0000
+5702 39100.0000 21016.6667
+5703 39100.0000 21083.3333
+5704 39100.0000 21100.0000
+5705 39100.0000 21150.0000
+5706 39100.0000 21233.3333
+5707 39100.0000 21266.6667
+5708 39100.0000 21283.3333
+5709 39100.0000 21433.3333
+5710 39100.0000 21500.0000
+5711 39100.0000 21516.6667
+5712 39100.0000 21666.6667
+5713 39100.0000 21783.3333
+5714 39100.0000 21816.6667
+5715 39100.0000 21850.0000
+5716 39100.0000 21866.6667
+5717 39100.0000 21983.3333
+5718 39100.0000 22200.0000
+5719 39100.0000 22233.3333
+5720 39100.0000 22266.6667
+5721 39100.0000 22350.0000
+5722 39100.0000 22416.6667
+5723 39100.0000 22716.6667
+5724 39100.0000 22866.6667
+5725 39100.0000 22900.0000
+5726 39100.0000 23066.6667
+5727 39100.0000 23083.3333
+5728 39100.0000 26166.6667
+5729 39100.0000 26383.3333
+5730 39100.0000 26433.3333
+5731 39100.0000 26516.6667
+5732 39100.0000 26550.0000
+5733 39102.5000 26552.5000
+5734 39103.8889 26241.3889
+5735 39105.0000 26440.2778
+5736 39105.5556 20637.7778
+5737 39105.8333 26218.6111
+5738 39110.5556 26411.1111
+5739 39116.6667 20900.0000
+5740 39116.6667 21016.6667
+5741 39116.6667 21050.0000
+5742 39116.6667 21083.3333
+5743 39116.6667 21133.3333
+5744 39116.6667 21150.0000
+5745 39116.6667 21200.0000
+5746 39116.6667 21216.6667
+5747 39116.6667 21233.3333
+5748 39116.6667 21250.0000
+5749 39116.6667 21416.6667
+5750 39116.6667 21466.6667
+5751 39116.6667 21516.6667
+5752 39116.6667 21583.3333
+5753 39116.6667 21633.3333
+5754 39116.6667 22050.0000
+5755 39116.6667 22100.0000
+5756 39116.6667 22200.0000
+5757 39116.6667 22450.0000
+5758 39116.6667 22466.6667
+5759 39116.6667 23100.0000
+5760 39116.6667 23733.3333
+5761 39116.6667 26413.0556
+5762 39132.7778 20631.3889
+5763 39133.3333 20600.0000
+5764 39133.3333 20633.3333
+5765 39133.3333 20666.6667
+5766 39133.3333 20816.6667
+5767 39133.3333 20916.6667
+5768 39133.3333 20933.3333
+5769 39133.3333 20950.0000
+5770 39133.3333 20983.3333
+5771 39133.3333 21050.0000
+5772 39133.3333 21066.6667
+5773 39133.3333 21116.6667
+5774 39133.3333 21200.0000
+5775 39133.3333 21216.6667
+5776 39133.3333 21250.0000
+5777 39133.3333 21416.6667
+5778 39133.3333 21450.0000
+5779 39133.3333 21483.3333
+5780 39133.3333 21500.0000
+5781 39133.3333 21516.6667
+5782 39133.3333 21566.6667
+5783 39133.3333 21650.0000
+5784 39133.3333 21700.0000
+5785 39133.3333 21783.3333
+5786 39133.3333 21800.0000
+5787 39133.3333 21816.6667
+5788 39133.3333 21950.0000
+5789 39133.3333 22016.6667
+5790 39133.3333 22116.6667
+5791 39133.3333 22150.0000
+5792 39133.3333 22300.0000
+5793 39133.3333 22350.0000
+5794 39133.3333 22383.3333
+5795 39133.3333 23166.6667
+5796 39133.3333 23266.6667
+5797 39133.3333 25933.3333
+5798 39133.3333 26000.0000
+5799 39133.3333 26400.0000
+5800 39133.3333 26416.6667
+5801 39133.3333 26516.6667
+5802 39146.1111 26529.7222
+5803 39148.0556 26514.4444
+5804 39150.0000 20233.3333
+5805 39150.0000 20583.3333
+5806 39150.0000 20666.6667
+5807 39150.0000 20700.0000
+5808 39150.0000 20816.6667
+5809 39150.0000 20866.6667
+5810 39150.0000 20933.3333
+5811 39150.0000 20983.3333
+5812 39150.0000 21116.6667
+5813 39150.0000 21133.3333
+5814 39150.0000 21150.0000
+5815 39150.0000 21183.3333
+5816 39150.0000 21200.0000
+5817 39150.0000 21233.3333
+5818 39150.0000 21250.0000
+5819 39150.0000 21266.6667
+5820 39150.0000 21283.3333
+5821 39150.0000 21383.3333
+5822 39150.0000 21400.0000
+5823 39150.0000 21433.3333
+5824 39150.0000 21450.0000
+5825 39150.0000 21483.3333
+5826 39150.0000 21616.6667
+5827 39150.0000 21650.0000
+5828 39150.0000 21666.6667
+5829 39150.0000 21783.3333
+5830 39150.0000 21833.3333
+5831 39150.0000 21866.6667
+5832 39150.0000 22183.3333
+5833 39150.0000 22250.0000
+5834 39150.0000 22283.3333
+5835 39150.0000 22300.0000
+5836 39150.0000 22366.6667
+5837 39150.0000 22566.6667
+5838 39150.0000 22683.3333
+5839 39150.0000 22716.6667
+5840 39150.0000 22750.0000
+5841 39150.0000 22766.6667
+5842 39150.0000 23083.3333
+5843 39150.0000 23200.0000
+5844 39150.0000 23850.0000
+5845 39150.0000 23866.6667
+5846 39156.6667 26521.6667
+5847 39166.6667 20183.3333
+5848 39166.6667 20566.6667
+5849 39166.6667 20600.0000
+5850 39166.6667 20716.6667
+5851 39166.6667 20750.0000
+5852 39166.6667 20933.3333
+5853 39166.6667 20950.0000
+5854 39166.6667 21000.0000
+5855 39166.6667 21033.3333
+5856 39166.6667 21116.6667
+5857 39166.6667 21133.3333
+5858 39166.6667 21166.6667
+5859 39166.6667 21183.3333
+5860 39166.6667 21200.0000
+5861 39166.6667 21216.6667
+5862 39166.6667 21266.6667
+5863 39166.6667 21433.3333
+5864 39166.6667 21466.6667
+5865 39166.6667 21516.6667
+5866 39166.6667 21700.0000
+5867 39166.6667 21766.6667
+5868 39166.6667 21816.6667
+5869 39166.6667 21833.3333
+5870 39166.6667 22166.6667
+5871 39166.6667 22416.6667
+5872 39166.6667 22466.6667
+5873 39166.6667 22516.6667
+5874 39166.6667 22600.0000
+5875 39166.6667 22616.6667
+5876 39166.6667 22633.3333
+5877 39166.6667 22650.0000
+5878 39166.6667 22783.3333
+5879 39166.6667 22850.0000
+5880 39166.6667 22883.3333
+5881 39166.6667 23216.6667
+5882 39166.6667 23283.3333
+5883 39166.6667 23350.0000
+5884 39166.6667 23483.3333
+5885 39166.6667 23616.6667
+5886 39166.6667 25933.3333
+5887 39166.6667 26050.0000
+5888 39166.6667 26066.6667
+5889 39166.6667 26133.3333
+5890 39166.6667 26500.0000
+5891 39180.5556 26486.3889
+5892 39183.3333 20166.6667
+5893 39183.3333 20183.3333
+5894 39183.3333 20200.0000
+5895 39183.3333 20633.3333
+5896 39183.3333 20716.6667
+5897 39183.3333 20783.3333
+5898 39183.3333 20983.3333
+5899 39183.3333 21083.3333
+5900 39183.3333 21150.0000
+5901 39183.3333 21183.3333
+5902 39183.3333 21333.3333
+5903 39183.3333 21383.3333
+5904 39183.3333 21416.6667
+5905 39183.3333 21433.3333
+5906 39183.3333 21450.0000
+5907 39183.3333 21466.6667
+5908 39183.3333 21483.3333
+5909 39183.3333 21500.0000
+5910 39183.3333 21616.6667
+5911 39183.3333 21650.0000
+5912 39183.3333 21683.3333
+5913 39183.3333 21733.3333
+5914 39183.3333 21766.6667
+5915 39183.3333 21783.3333
+5916 39183.3333 21866.6667
+5917 39183.3333 21966.6667
+5918 39183.3333 22133.3333
+5919 39183.3333 22383.3333
+5920 39183.3333 22600.0000
+5921 39183.3333 22683.3333
+5922 39183.3333 22766.6667
+5923 39183.3333 23216.6667
+5924 39183.3333 23250.0000
+5925 39183.3333 23283.3333
+5926 39183.3333 23333.3333
+5927 39183.3333 23616.6667
+5928 39183.3333 26416.6667
+5929 39183.8889 26406.3889
+5930 39197.2222 20530.2778
+5931 39199.4444 20184.4444
+5932 39200.0000 20166.6667
+5933 39200.0000 20183.3333
+5934 39200.0000 20566.6667
+5935 39200.0000 20616.6667
+5936 39200.0000 20650.0000
+5937 39200.0000 20666.6667
+5938 39200.0000 20733.3333
+5939 39200.0000 20883.3333
+5940 39200.0000 20933.3333
+5941 39200.0000 20983.3333
+5942 39200.0000 21083.3333
+5943 39200.0000 21150.0000
+5944 39200.0000 21166.6667
+5945 39200.0000 21216.6667
+5946 39200.0000 21350.0000
+5947 39200.0000 21400.0000
+5948 39200.0000 21416.6667
+5949 39200.0000 21566.6667
+5950 39200.0000 21616.6667
+5951 39200.0000 21650.0000
+5952 39200.0000 21683.3333
+5953 39200.0000 21750.0000
+5954 39200.0000 21933.3333
+5955 39200.0000 22083.3333
+5956 39200.0000 22100.0000
+5957 39200.0000 22250.0000
+5958 39200.0000 22316.6667
+5959 39200.0000 22333.3333
+5960 39200.0000 22450.0000
+5961 39200.0000 22483.3333
+5962 39200.0000 22516.6667
+5963 39200.0000 22583.3333
+5964 39200.0000 22733.3333
+5965 39200.0000 22750.0000
+5966 39200.0000 23216.6667
+5967 39200.0000 23333.3333
+5968 39200.0000 23916.6667
+5969 39200.0000 23966.6667
+5970 39200.0000 26016.6667
+5971 39206.6667 26212.5000
+5972 39210.8333 26461.3889
+5973 39216.6667 20116.6667
+5974 39216.6667 20133.3333
+5975 39216.6667 20150.0000
+5976 39216.6667 20166.6667
+5977 39216.6667 20500.0000
+5978 39216.6667 20533.3333
+5979 39216.6667 20633.3333
+5980 39216.6667 20783.3333
+5981 39216.6667 20850.0000
+5982 39216.6667 20883.3333
+5983 39216.6667 20900.0000
+5984 39216.6667 20950.0000
+5985 39216.6667 20983.3333
+5986 39216.6667 21033.3333
+5987 39216.6667 21066.6667
+5988 39216.6667 21200.0000
+5989 39216.6667 21233.3333
+5990 39216.6667 21250.0000
+5991 39216.6667 21300.0000
+5992 39216.6667 21316.6667
+5993 39216.6667 21333.3333
+5994 39216.6667 21350.0000
+5995 39216.6667 21366.6667
+5996 39216.6667 21416.6667
+5997 39216.6667 21450.0000
+5998 39216.6667 21616.6667
+5999 39216.6667 21783.3333
+6000 39216.6667 21816.6667
+6001 39216.6667 21866.6667
+6002 39216.6667 21983.3333
+6003 39216.6667 22016.6667
+6004 39216.6667 22050.0000
+6005 39216.6667 22516.6667
+6006 39216.6667 22566.6667
+6007 39216.6667 22600.0000
+6008 39216.6667 22616.6667
+6009 39216.6667 22650.0000
+6010 39216.6667 23933.3333
+6011 39216.6667 25850.0000
+6012 39216.6667 26033.3333
+6013 39216.6667 26050.0000
+6014 39216.6667 26200.0000
+6015 39219.1667 26206.6667
+6016 39219.7222 20518.8889
+6017 39225.5556 26439.4444
+6018 39227.7778 20158.8889
+6019 39229.4444 26457.7778
+6020 39230.0000 26218.6111
+6021 39232.7778 26208.0556
+6022 39233.3333 20133.3333
+6023 39233.3333 20150.0000
+6024 39233.3333 20166.6667
+6025 39233.3333 20600.0000
+6026 39233.3333 20616.6667
+6027 39233.3333 20650.0000
+6028 39233.3333 20683.3333
+6029 39233.3333 20716.6667
+6030 39233.3333 20866.6667
+6031 39233.3333 20883.3333
+6032 39233.3333 20933.3333
+6033 39233.3333 21050.0000
+6034 39233.3333 21100.0000
+6035 39233.3333 21150.0000
+6036 39233.3333 21183.3333
+6037 39233.3333 21216.6667
+6038 39233.3333 21233.3333
+6039 39233.3333 21316.6667
+6040 39233.3333 21333.3333
+6041 39233.3333 21366.6667
+6042 39233.3333 21383.3333
+6043 39233.3333 21433.3333
+6044 39233.3333 21450.0000
+6045 39233.3333 21516.6667
+6046 39233.3333 21600.0000
+6047 39233.3333 21633.3333
+6048 39233.3333 21666.6667
+6049 39233.3333 21683.3333
+6050 39233.3333 21766.6667
+6051 39233.3333 21783.3333
+6052 39233.3333 21800.0000
+6053 39233.3333 21866.6667
+6054 39233.3333 21950.0000
+6055 39233.3333 22250.0000
+6056 39233.3333 22666.6667
+6057 39233.3333 22683.3333
+6058 39233.3333 22700.0000
+6059 39233.3333 22766.6667
+6060 39233.3333 23200.0000
+6061 39233.3333 23216.6667
+6062 39233.3333 23250.0000
+6063 39233.3333 23283.3333
+6064 39233.3333 23300.0000
+6065 39233.3333 23316.6667
+6066 39233.3333 25983.3333
+6067 39233.3333 26000.0000
+6068 39233.3333 26050.0000
+6069 39236.3889 20131.6667
+6070 39236.6667 20539.7222
+6071 39239.1667 20485.0000
+6072 39240.2778 26200.5556
+6073 39248.0556 26271.6667
+6074 39250.0000 20533.3333
+6075 39250.0000 20566.6667
+6076 39250.0000 20583.3333
+6077 39250.0000 20616.6667
+6078 39250.0000 20633.3333
+6079 39250.0000 20750.0000
+6080 39250.0000 20783.3333
+6081 39250.0000 20833.3333
+6082 39250.0000 20983.3333
+6083 39250.0000 21000.0000
+6084 39250.0000 21016.6667
+6085 39250.0000 21033.3333
+6086 39250.0000 21050.0000
+6087 39250.0000 21133.3333
+6088 39250.0000 21166.6667
+6089 39250.0000 21183.3333
+6090 39250.0000 21200.0000
+6091 39250.0000 21233.3333
+6092 39250.0000 21316.6667
+6093 39250.0000 21383.3333
+6094 39250.0000 21400.0000
+6095 39250.0000 21500.0000
+6096 39250.0000 21550.0000
+6097 39250.0000 21666.6667
+6098 39250.0000 21716.6667
+6099 39250.0000 21733.3333
+6100 39250.0000 21833.3333
+6101 39250.0000 22050.0000
+6102 39250.0000 22100.0000
+6103 39250.0000 22183.3333
+6104 39250.0000 22216.6667
+6105 39250.0000 22383.3333
+6106 39250.0000 22450.0000
+6107 39250.0000 22483.3333
+6108 39250.0000 22583.3333
+6109 39250.0000 22616.6667
+6110 39250.0000 22750.0000
+6111 39250.0000 23183.3333
+6112 39250.0000 23266.6667
+6113 39250.0000 23283.3333
+6114 39250.0000 23300.0000
+6115 39250.0000 26100.0000
+6116 39266.6667 20533.3333
+6117 39266.6667 20566.6667
+6118 39266.6667 20600.0000
+6119 39266.6667 20700.0000
+6120 39266.6667 20800.0000
+6121 39266.6667 20850.0000
+6122 39266.6667 20883.3333
+6123 39266.6667 20950.0000
+6124 39266.6667 20983.3333
+6125 39266.6667 21000.0000
+6126 39266.6667 21016.6667
+6127 39266.6667 21166.6667
+6128 39266.6667 21183.3333
+6129 39266.6667 21216.6667
+6130 39266.6667 21300.0000
+6131 39266.6667 21333.3333
+6132 39266.6667 21366.6667
+6133 39266.6667 21383.3333
+6134 39266.6667 21433.3333
+6135 39266.6667 21483.3333
+6136 39266.6667 21533.3333
+6137 39266.6667 21550.0000
+6138 39266.6667 21583.3333
+6139 39266.6667 21600.0000
+6140 39266.6667 21666.6667
+6141 39266.6667 21700.0000
+6142 39266.6667 21716.6667
+6143 39266.6667 21933.3333
+6144 39266.6667 22033.3333
+6145 39266.6667 22083.3333
+6146 39266.6667 22150.0000
+6147 39266.6667 22216.6667
+6148 39266.6667 22333.3333
+6149 39266.6667 22416.6667
+6150 39266.6667 22466.6667
+6151 39266.6667 22516.6667
+6152 39266.6667 22750.0000
+6153 39266.6667 23166.6667
+6154 39266.6667 23950.0000
+6155 39266.6667 25966.6667
+6156 39266.6667 26066.6667
+6157 39266.6667 26150.0000
+6158 39270.0000 26287.5000
+6159 39275.0000 26376.6667
+6160 39280.8333 20427.7778
+6161 39283.3333 20450.0000
+6162 39283.3333 20550.0000
+6163 39283.3333 20600.0000
+6164 39283.3333 20633.3333
+6165 39283.3333 20666.6667
+6166 39283.3333 20683.3333
+6167 39283.3333 20700.0000
+6168 39283.3333 20766.6667
+6169 39283.3333 20800.0000
+6170 39283.3333 20900.0000
+6171 39283.3333 20933.3333
+6172 39283.3333 21000.0000
+6173 39283.3333 21033.3333
+6174 39283.3333 21050.0000
+6175 39283.3333 21066.6667
+6176 39283.3333 21100.0000
+6177 39283.3333 21116.6667
+6178 39283.3333 21133.3333
+6179 39283.3333 21200.0000
+6180 39283.3333 21233.3333
+6181 39283.3333 21266.6667
+6182 39283.3333 21283.3333
+6183 39283.3333 21333.3333
+6184 39283.3333 21366.6667
+6185 39283.3333 21383.3333
+6186 39283.3333 21416.6667
+6187 39283.3333 21433.3333
+6188 39283.3333 21450.0000
+6189 39283.3333 21466.6667
+6190 39283.3333 21483.3333
+6191 39283.3333 21500.0000
+6192 39283.3333 21533.3333
+6193 39283.3333 21566.6667
+6194 39283.3333 21583.3333
+6195 39283.3333 21600.0000
+6196 39283.3333 21700.0000
+6197 39283.3333 21733.3333
+6198 39283.3333 21750.0000
+6199 39283.3333 21783.3333
+6200 39283.3333 21800.0000
+6201 39283.3333 21850.0000
+6202 39283.3333 21900.0000
+6203 39283.3333 21966.6667
+6204 39283.3333 22050.0000
+6205 39283.3333 22116.6667
+6206 39283.3333 22283.3333
+6207 39283.3333 22550.0000
+6208 39283.3333 22650.0000
+6209 39283.3333 22816.6667
+6210 39283.3333 23183.3333
+6211 39283.3333 23216.6667
+6212 39283.3333 23266.6667
+6213 39284.1667 20402.2222
+6214 39300.0000 20366.6667
+6215 39300.0000 20483.3333
+6216 39300.0000 20550.0000
+6217 39300.0000 20683.3333
+6218 39300.0000 20716.6667
+6219 39300.0000 20766.6667
+6220 39300.0000 20800.0000
+6221 39300.0000 20866.6667
+6222 39300.0000 20900.0000
+6223 39300.0000 20983.3333
+6224 39300.0000 21016.6667
+6225 39300.0000 21200.0000
+6226 39300.0000 21216.6667
+6227 39300.0000 21283.3333
+6228 39300.0000 21316.6667
+6229 39300.0000 21400.0000
+6230 39300.0000 21416.6667
+6231 39300.0000 21533.3333
+6232 39300.0000 21683.3333
+6233 39300.0000 21700.0000
+6234 39300.0000 21716.6667
+6235 39300.0000 21733.3333
+6236 39300.0000 21833.3333
+6237 39300.0000 21933.3333
+6238 39300.0000 22050.0000
+6239 39300.0000 22066.6667
+6240 39300.0000 22133.3333
+6241 39300.0000 22200.0000
+6242 39300.0000 22383.3333
+6243 39300.0000 22500.0000
+6244 39300.0000 22600.0000
+6245 39300.0000 22616.6667
+6246 39300.0000 23116.6667
+6247 39300.0000 26133.3333
+6248 39300.0000 26183.3333
+6249 39311.6667 26219.7222
+6250 39311.6667 26333.8889
+6251 39312.7778 20357.7778
+6252 39313.6111 20427.7778
+6253 39316.6667 20333.3333
+6254 39316.6667 20433.3333
+6255 39316.6667 20450.0000
+6256 39316.6667 20500.0000
+6257 39316.6667 20583.3333
+6258 39316.6667 20600.0000
+6259 39316.6667 20616.6667
+6260 39316.6667 20700.0000
+6261 39316.6667 20766.6667
+6262 39316.6667 20800.0000
+6263 39316.6667 20883.3333
+6264 39316.6667 20933.3333
+6265 39316.6667 20950.0000
+6266 39316.6667 21000.0000
+6267 39316.6667 21016.6667
+6268 39316.6667 21033.3333
+6269 39316.6667 21083.3333
+6270 39316.6667 21216.6667
+6271 39316.6667 21300.0000
+6272 39316.6667 21433.3333
+6273 39316.6667 21466.6667
+6274 39316.6667 21500.0000
+6275 39316.6667 21700.0000
+6276 39316.6667 21716.6667
+6277 39316.6667 21783.3333
+6278 39316.6667 21800.0000
+6279 39316.6667 21816.6667
+6280 39316.6667 21866.6667
+6281 39316.6667 21883.3333
+6282 39316.6667 21900.0000
+6283 39316.6667 21916.6667
+6284 39316.6667 22233.3333
+6285 39316.6667 22300.0000
+6286 39316.6667 22316.6667
+6287 39316.6667 22500.0000
+6288 39316.6667 22633.3333
+6289 39316.6667 22683.3333
+6290 39316.6667 22716.6667
+6291 39316.6667 23100.0000
+6292 39316.6667 23133.3333
+6293 39317.5000 26244.1667
+6294 39328.6111 26279.4444
+6295 39333.3333 20450.0000
+6296 39333.3333 20600.0000
+6297 39333.3333 20716.6667
+6298 39333.3333 20733.3333
+6299 39333.3333 20766.6667
+6300 39333.3333 20783.3333
+6301 39333.3333 20883.3333
+6302 39333.3333 20900.0000
+6303 39333.3333 20916.6667
+6304 39333.3333 20933.3333
+6305 39333.3333 20950.0000
+6306 39333.3333 21000.0000
+6307 39333.3333 21050.0000
+6308 39333.3333 21066.6667
+6309 39333.3333 21083.3333
+6310 39333.3333 21183.3333
+6311 39333.3333 21233.3333
+6312 39333.3333 21266.6667
+6313 39333.3333 21300.0000
+6314 39333.3333 21333.3333
+6315 39333.3333 21400.0000
+6316 39333.3333 21416.6667
+6317 39333.3333 21433.3333
+6318 39333.3333 21466.6667
+6319 39333.3333 21483.3333
+6320 39333.3333 21500.0000
+6321 39333.3333 21516.6667
+6322 39333.3333 21683.3333
+6323 39333.3333 21833.3333
+6324 39333.3333 21866.6667
+6325 39333.3333 21950.0000
+6326 39333.3333 21983.3333
+6327 39333.3333 22016.6667
+6328 39333.3333 22100.0000
+6329 39333.3333 22150.0000
+6330 39333.3333 22366.6667
+6331 39333.3333 22383.3333
+6332 39333.3333 22416.6667
+6333 39333.3333 22433.3333
+6334 39333.3333 22450.0000
+6335 39333.3333 22500.0000
+6336 39333.3333 22550.0000
+6337 39333.3333 22583.3333
+6338 39333.3333 22700.0000
+6339 39333.3333 22766.6667
+6340 39333.3333 23016.6667
+6341 39333.3333 23033.3333
+6342 39333.3333 23050.0000
+6343 39333.3333 23116.6667
+6344 39333.3333 23133.3333
+6345 39333.3333 23150.0000
+6346 39333.3333 23216.6667
+6347 39333.3333 26183.3333
+6348 39333.3333 26216.6667
+6349 39334.7222 26311.3889
+6350 39344.7222 26362.5000
+6351 39348.0556 26321.6667
+6352 39350.0000 20416.6667
+6353 39350.0000 20433.3333
+6354 39350.0000 20450.0000
+6355 39350.0000 20550.0000
+6356 39350.0000 20583.3333
+6357 39350.0000 20650.0000
+6358 39350.0000 20700.0000
+6359 39350.0000 20750.0000
+6360 39350.0000 20766.6667
+6361 39350.0000 20800.0000
+6362 39350.0000 20883.3333
+6363 39350.0000 20916.6667
+6364 39350.0000 20950.0000
+6365 39350.0000 20966.6667
+6366 39350.0000 21000.0000
+6367 39350.0000 21016.6667
+6368 39350.0000 21033.3333
+6369 39350.0000 21050.0000
+6370 39350.0000 21066.6667
+6371 39350.0000 21100.0000
+6372 39350.0000 21150.0000
+6373 39350.0000 21183.3333
+6374 39350.0000 21200.0000
+6375 39350.0000 21216.6667
+6376 39350.0000 21266.6667
+6377 39350.0000 21283.3333
+6378 39350.0000 21300.0000
+6379 39350.0000 21316.6667
+6380 39350.0000 21333.3333
+6381 39350.0000 21350.0000
+6382 39350.0000 21450.0000
+6383 39350.0000 21466.6667
+6384 39350.0000 21500.0000
+6385 39350.0000 21533.3333
+6386 39350.0000 21666.6667
+6387 39350.0000 21683.3333
+6388 39350.0000 21750.0000
+6389 39350.0000 21766.6667
+6390 39350.0000 21833.3333
+6391 39350.0000 21900.0000
+6392 39350.0000 22083.3333
+6393 39350.0000 22216.6667
+6394 39350.0000 22266.6667
+6395 39350.0000 22300.0000
+6396 39350.0000 22333.3333
+6397 39350.0000 22500.0000
+6398 39350.0000 22550.0000
+6399 39350.0000 22616.6667
+6400 39350.0000 22833.3333
+6401 39350.0000 22866.6667
+6402 39350.0000 22900.0000
+6403 39350.0000 23066.6667
+6404 39350.0000 23083.3333
+6405 39350.0000 23200.0000
+6406 39360.8333 26263.6111
+6407 39361.3889 26295.8333
+6408 39366.6667 20283.3333
+6409 39366.6667 20400.0000
+6410 39366.6667 20533.3333
+6411 39366.6667 20566.6667
+6412 39366.6667 20583.3333
+6413 39366.6667 20700.0000
+6414 39366.6667 20783.3333
+6415 39366.6667 20866.6667
+6416 39366.6667 20883.3333
+6417 39366.6667 20950.0000
+6418 39366.6667 21016.6667
+6419 39366.6667 21033.3333
+6420 39366.6667 21050.0000
+6421 39366.6667 21066.6667
+6422 39366.6667 21100.0000
+6423 39366.6667 21116.6667
+6424 39366.6667 21133.3333
+6425 39366.6667 21200.0000
+6426 39366.6667 21216.6667
+6427 39366.6667 21233.3333
+6428 39366.6667 21266.6667
+6429 39366.6667 21283.3333
+6430 39366.6667 21300.0000
+6431 39366.6667 21333.3333
+6432 39366.6667 21400.0000
+6433 39366.6667 21416.6667
+6434 39366.6667 21533.3333
+6435 39366.6667 21600.0000
+6436 39366.6667 21616.6667
+6437 39366.6667 21633.3333
+6438 39366.6667 21666.6667
+6439 39366.6667 21816.6667
+6440 39366.6667 21916.6667
+6441 39366.6667 21966.6667
+6442 39366.6667 22000.0000
+6443 39366.6667 22083.3333
+6444 39366.6667 22133.3333
+6445 39366.6667 22400.0000
+6446 39366.6667 22516.6667
+6447 39366.6667 22766.6667
+6448 39366.6667 22950.0000
+6449 39366.6667 22983.3333
+6450 39366.6667 23066.6667
+6451 39366.6667 23183.3333
+6452 39366.6667 26166.6667
+6453 39366.6667 26283.3333
+6454 39368.8889 20303.8889
+6455 39373.6111 26303.6111
+6456 39383.3333 20066.6667
+6457 39383.3333 20083.3333
+6458 39383.3333 20116.6667
+6459 39383.3333 20383.3333
+6460 39383.3333 20483.3333
+6461 39383.3333 20566.6667
+6462 39383.3333 20583.3333
+6463 39383.3333 20700.0000
+6464 39383.3333 20850.0000
+6465 39383.3333 20900.0000
+6466 39383.3333 21000.0000
+6467 39383.3333 21016.6667
+6468 39383.3333 21033.3333
+6469 39383.3333 21050.0000
+6470 39383.3333 21066.6667
+6471 39383.3333 21100.0000
+6472 39383.3333 21133.3333
+6473 39383.3333 21183.3333
+6474 39383.3333 21200.0000
+6475 39383.3333 21216.6667
+6476 39383.3333 21233.3333
+6477 39383.3333 21250.0000
+6478 39383.3333 21266.6667
+6479 39383.3333 21283.3333
+6480 39383.3333 21400.0000
+6481 39383.3333 21466.6667
+6482 39383.3333 21633.3333
+6483 39383.3333 21700.0000
+6484 39383.3333 21766.6667
+6485 39383.3333 21816.6667
+6486 39383.3333 21866.6667
+6487 39383.3333 21916.6667
+6488 39383.3333 21983.3333
+6489 39383.3333 22233.3333
+6490 39383.3333 22266.6667
+6491 39383.3333 22333.3333
+6492 39383.3333 22350.0000
+6493 39383.3333 22500.0000
+6494 39383.3333 22516.6667
+6495 39383.3333 22566.6667
+6496 39383.3333 22750.0000
+6497 39383.3333 22916.6667
+6498 39383.3333 22966.6667
+6499 39383.3333 22983.3333
+6500 39383.3333 23000.0000
+6501 39383.3333 23050.0000
+6502 39383.3333 23183.3333
+6503 39400.0000 20050.0000
+6504 39400.0000 20066.6667
+6505 39400.0000 20083.3333
+6506 39400.0000 20333.3333
+6507 39400.0000 20350.0000
+6508 39400.0000 20366.6667
+6509 39400.0000 20383.3333
+6510 39400.0000 20416.6667
+6511 39400.0000 20483.3333
+6512 39400.0000 20566.6667
+6513 39400.0000 20783.3333
+6514 39400.0000 20816.6667
+6515 39400.0000 20966.6667
+6516 39400.0000 21016.6667
+6517 39400.0000 21050.0000
+6518 39400.0000 21066.6667
+6519 39400.0000 21083.3333
+6520 39400.0000 21100.0000
+6521 39400.0000 21116.6667
+6522 39400.0000 21283.3333
+6523 39400.0000 21333.3333
+6524 39400.0000 21366.6667
+6525 39400.0000 21600.0000
+6526 39400.0000 21633.3333
+6527 39400.0000 21666.6667
+6528 39400.0000 21700.0000
+6529 39400.0000 21733.3333
+6530 39400.0000 21750.0000
+6531 39400.0000 21800.0000
+6532 39400.0000 21816.6667
+6533 39400.0000 21900.0000
+6534 39400.0000 22016.6667
+6535 39400.0000 22066.6667
+6536 39400.0000 22200.0000
+6537 39400.0000 22216.6667
+6538 39400.0000 22416.6667
+6539 39400.0000 22433.3333
+6540 39400.0000 22466.6667
+6541 39400.0000 22716.6667
+6542 39400.0000 22733.3333
+6543 39400.0000 22983.3333
+6544 39400.0000 23133.3333
+6545 39400.0000 23166.6667
+6546 39405.2778 20253.0556
+6547 39416.6667 20016.6667
+6548 39416.6667 20066.6667
+6549 39416.6667 20083.3333
+6550 39416.6667 20300.0000
+6551 39416.6667 20316.6667
+6552 39416.6667 20366.6667
+6553 39416.6667 20383.3333
+6554 39416.6667 20500.0000
+6555 39416.6667 20550.0000
+6556 39416.6667 20566.6667
+6557 39416.6667 20616.6667
+6558 39416.6667 20633.3333
+6559 39416.6667 20700.0000
+6560 39416.6667 20766.6667
+6561 39416.6667 20783.3333
+6562 39416.6667 20816.6667
+6563 39416.6667 20833.3333
+6564 39416.6667 20850.0000
+6565 39416.6667 20866.6667
+6566 39416.6667 20900.0000
+6567 39416.6667 20916.6667
+6568 39416.6667 20933.3333
+6569 39416.6667 20950.0000
+6570 39416.6667 20983.3333
+6571 39416.6667 21016.6667
+6572 39416.6667 21033.3333
+6573 39416.6667 21050.0000
+6574 39416.6667 21066.6667
+6575 39416.6667 21083.3333
+6576 39416.6667 21100.0000
+6577 39416.6667 21116.6667
+6578 39416.6667 21266.6667
+6579 39416.6667 21383.3333
+6580 39416.6667 21483.3333
+6581 39416.6667 21500.0000
+6582 39416.6667 21533.3333
+6583 39416.6667 21583.3333
+6584 39416.6667 21600.0000
+6585 39416.6667 21633.3333
+6586 39416.6667 21700.0000
+6587 39416.6667 21733.3333
+6588 39416.6667 21750.0000
+6589 39416.6667 21783.3333
+6590 39416.6667 21800.0000
+6591 39416.6667 21966.6667
+6592 39416.6667 22100.0000
+6593 39416.6667 22166.6667
+6594 39416.6667 22383.3333
+6595 39416.6667 22433.3333
+6596 39416.6667 22616.6667
+6597 39416.6667 22650.0000
+6598 39416.6667 22933.3333
+6599 39416.6667 23133.3333
+6600 39416.6667 23150.0000
+6601 39419.7222 20084.1667
+6602 39424.4444 20073.0556
+6603 39433.3333 19983.3333
+6604 39433.3333 20000.0000
+6605 39433.3333 20050.0000
+6606 39433.3333 20283.3333
+6607 39433.3333 20333.3333
+6608 39433.3333 20400.0000
+6609 39433.3333 20433.3333
+6610 39433.3333 20466.6667
+6611 39433.3333 20483.3333
+6612 39433.3333 20533.3333
+6613 39433.3333 20550.0000
+6614 39433.3333 20633.3333
+6615 39433.3333 20683.3333
+6616 39433.3333 20716.6667
+6617 39433.3333 20733.3333
+6618 39433.3333 20750.0000
+6619 39433.3333 20766.6667
+6620 39433.3333 20783.3333
+6621 39433.3333 20833.3333
+6622 39433.3333 20883.3333
+6623 39433.3333 20916.6667
+6624 39433.3333 20950.0000
+6625 39433.3333 20983.3333
+6626 39433.3333 21016.6667
+6627 39433.3333 21033.3333
+6628 39433.3333 21050.0000
+6629 39433.3333 21083.3333
+6630 39433.3333 21100.0000
+6631 39433.3333 21116.6667
+6632 39433.3333 21216.6667
+6633 39433.3333 21350.0000
+6634 39433.3333 21366.6667
+6635 39433.3333 21383.3333
+6636 39433.3333 21433.3333
+6637 39433.3333 21516.6667
+6638 39433.3333 21533.3333
+6639 39433.3333 21566.6667
+6640 39433.3333 21666.6667
+6641 39433.3333 21716.6667
+6642 39433.3333 21750.0000
+6643 39433.3333 21766.6667
+6644 39433.3333 21833.3333
+6645 39433.3333 21866.6667
+6646 39433.3333 22050.0000
+6647 39433.3333 22100.0000
+6648 39433.3333 22133.3333
+6649 39433.3333 22183.3333
+6650 39433.3333 22300.0000
+6651 39433.3333 22333.3333
+6652 39433.3333 22683.3333
+6653 39433.3333 22750.0000
+6654 39433.3333 22883.3333
+6655 39433.3333 23116.6667
+6656 39436.1111 19978.3333
+6657 39450.0000 19983.3333
+6658 39450.0000 20000.0000
+6659 39450.0000 20066.6667
+6660 39450.0000 20266.6667
+6661 39450.0000 20283.3333
+6662 39450.0000 20300.0000
+6663 39450.0000 20316.6667
+6664 39450.0000 20400.0000
+6665 39450.0000 20450.0000
+6666 39450.0000 20533.3333
+6667 39450.0000 20600.0000
+6668 39450.0000 20683.3333
+6669 39450.0000 20716.6667
+6670 39450.0000 20733.3333
+6671 39450.0000 20766.6667
+6672 39450.0000 20816.6667
+6673 39450.0000 20833.3333
+6674 39450.0000 21000.0000
+6675 39450.0000 21016.6667
+6676 39450.0000 21033.3333
+6677 39450.0000 21066.6667
+6678 39450.0000 21083.3333
+6679 39450.0000 21100.0000
+6680 39450.0000 21116.6667
+6681 39450.0000 21233.3333
+6682 39450.0000 21250.0000
+6683 39450.0000 21316.6667
+6684 39450.0000 21333.3333
+6685 39450.0000 21366.6667
+6686 39450.0000 21383.3333
+6687 39450.0000 21416.6667
+6688 39450.0000 21466.6667
+6689 39450.0000 21483.3333
+6690 39450.0000 21500.0000
+6691 39450.0000 21516.6667
+6692 39450.0000 21533.3333
+6693 39450.0000 21550.0000
+6694 39450.0000 21566.6667
+6695 39450.0000 21800.0000
+6696 39450.0000 21833.3333
+6697 39450.0000 21966.6667
+6698 39450.0000 22083.3333
+6699 39450.0000 22150.0000
+6700 39450.0000 22250.0000
+6701 39450.0000 22333.3333
+6702 39450.0000 22350.0000
+6703 39450.0000 22483.3333
+6704 39450.0000 22533.3333
+6705 39450.0000 22550.0000
+6706 39450.0000 23100.0000
+6707 39450.0000 23116.6667
+6708 39458.0556 19958.0556
+6709 39466.6667 19916.6667
+6710 39466.6667 19933.3333
+6711 39466.6667 19950.0000
+6712 39466.6667 20316.6667
+6713 39466.6667 20333.3333
+6714 39466.6667 20350.0000
+6715 39466.6667 20366.6667
+6716 39466.6667 20416.6667
+6717 39466.6667 20433.3333
+6718 39466.6667 20516.6667
+6719 39466.6667 20666.6667
+6720 39466.6667 20716.6667
+6721 39466.6667 20750.0000
+6722 39466.6667 20816.6667
+6723 39466.6667 20833.3333
+6724 39466.6667 20850.0000
+6725 39466.6667 20900.0000
+6726 39466.6667 20916.6667
+6727 39466.6667 20966.6667
+6728 39466.6667 21033.3333
+6729 39466.6667 21050.0000
+6730 39466.6667 21083.3333
+6731 39466.6667 21100.0000
+6732 39466.6667 21250.0000
+6733 39466.6667 21283.3333
+6734 39466.6667 21316.6667
+6735 39466.6667 21350.0000
+6736 39466.6667 21366.6667
+6737 39466.6667 21416.6667
+6738 39466.6667 21433.3333
+6739 39466.6667 21450.0000
+6740 39466.6667 21533.3333
+6741 39466.6667 21566.6667
+6742 39466.6667 21616.6667
+6743 39466.6667 21666.6667
+6744 39466.6667 21700.0000
+6745 39466.6667 21733.3333
+6746 39466.6667 21833.3333
+6747 39466.6667 21866.6667
+6748 39466.6667 21900.0000
+6749 39466.6667 22083.3333
+6750 39466.6667 22166.6667
+6751 39466.6667 22216.6667
+6752 39466.6667 22283.3333
+6753 39466.6667 22450.0000
+6754 39466.6667 22500.0000
+6755 39466.6667 22733.3333
+6756 39466.6667 22916.6667
+6757 39474.4444 19931.9444
+6758 39483.3333 19916.6667
+6759 39483.3333 20266.6667
+6760 39483.3333 20300.0000
+6761 39483.3333 20333.3333
+6762 39483.3333 20400.0000
+6763 39483.3333 20466.6667
+6764 39483.3333 20500.0000
+6765 39483.3333 20566.6667
+6766 39483.3333 20666.6667
+6767 39483.3333 20850.0000
+6768 39483.3333 20866.6667
+6769 39483.3333 20883.3333
+6770 39483.3333 20916.6667
+6771 39483.3333 20966.6667
+6772 39483.3333 21033.3333
+6773 39483.3333 21050.0000
+6774 39483.3333 21066.6667
+6775 39483.3333 21083.3333
+6776 39483.3333 21100.0000
+6777 39483.3333 21316.6667
+6778 39483.3333 21333.3333
+6779 39483.3333 21533.3333
+6780 39483.3333 21550.0000
+6781 39483.3333 21716.6667
+6782 39483.3333 21850.0000
+6783 39483.3333 21900.0000
+6784 39483.3333 21983.3333
+6785 39483.3333 22200.0000
+6786 39483.3333 22266.6667
+6787 39483.3333 22600.0000
+6788 39483.3333 22700.0000
+6789 39483.3333 22950.0000
+6790 39483.3333 23100.0000
+6791 39495.8333 19873.0556
+6792 39500.0000 19916.6667
+6793 39500.0000 20266.6667
+6794 39500.0000 20316.6667
+6795 39500.0000 20366.6667
+6796 39500.0000 20383.3333
+6797 39500.0000 20416.6667
+6798 39500.0000 20433.3333
+6799 39500.0000 20466.6667
+6800 39500.0000 20500.0000
+6801 39500.0000 20533.3333
+6802 39500.0000 20650.0000
+6803 39500.0000 20683.3333
+6804 39500.0000 20750.0000
+6805 39500.0000 20866.6667
+6806 39500.0000 20916.6667
+6807 39500.0000 20950.0000
+6808 39500.0000 20966.6667
+6809 39500.0000 20983.3333
+6810 39500.0000 21000.0000
+6811 39500.0000 21033.3333
+6812 39500.0000 21050.0000
+6813 39500.0000 21083.3333
+6814 39500.0000 21316.6667
+6815 39500.0000 21350.0000
+6816 39500.0000 21516.6667
+6817 39500.0000 21533.3333
+6818 39500.0000 21616.6667
+6819 39500.0000 21683.3333
+6820 39500.0000 21783.3333
+6821 39500.0000 21900.0000
+6822 39500.0000 22016.6667
+6823 39500.0000 22050.0000
+6824 39500.0000 22150.0000
+6825 39500.0000 22250.0000
+6826 39500.0000 22450.0000
+6827 39500.0000 22550.0000
+6828 39500.0000 22633.3333
+6829 39500.0000 22650.0000
+6830 39500.0000 22700.0000
+6831 39500.0000 22883.3333
+6832 39500.0000 23066.6667
+6833 39516.6667 19866.6667
+6834 39516.6667 19900.0000
+6835 39516.6667 20350.0000
+6836 39516.6667 20433.3333
+6837 39516.6667 20550.0000
+6838 39516.6667 20566.6667
+6839 39516.6667 20600.0000
+6840 39516.6667 20633.3333
+6841 39516.6667 20683.3333
+6842 39516.6667 20733.3333
+6843 39516.6667 20800.0000
+6844 39516.6667 20816.6667
+6845 39516.6667 20950.0000
+6846 39516.6667 20983.3333
+6847 39516.6667 21050.0000
+6848 39516.6667 21066.6667
+6849 39516.6667 21083.3333
+6850 39516.6667 21150.0000
+6851 39516.6667 21600.0000
+6852 39516.6667 21650.0000
+6853 39516.6667 21666.6667
+6854 39516.6667 21700.0000
+6855 39516.6667 21750.0000
+6856 39516.6667 21800.0000
+6857 39516.6667 21866.6667
+6858 39516.6667 21950.0000
+6859 39516.6667 22083.3333
+6860 39516.6667 22100.0000
+6861 39516.6667 22116.6667
+6862 39516.6667 22316.6667
+6863 39516.6667 22466.6667
+6864 39516.6667 22550.0000
+6865 39516.6667 22683.3333
+6866 39525.5556 20257.2222
+6867 39533.3333 19850.0000
+6868 39533.3333 19866.6667
+6869 39533.3333 19900.0000
+6870 39533.3333 19916.6667
+6871 39533.3333 20283.3333
+6872 39533.3333 20350.0000
+6873 39533.3333 20400.0000
+6874 39533.3333 20466.6667
+6875 39533.3333 20550.0000
+6876 39533.3333 20666.6667
+6877 39533.3333 20716.6667
+6878 39533.3333 20733.3333
+6879 39533.3333 20783.3333
+6880 39533.3333 20850.0000
+6881 39533.3333 20916.6667
+6882 39533.3333 21033.3333
+6883 39533.3333 21050.0000
+6884 39533.3333 21066.6667
+6885 39533.3333 21083.3333
+6886 39533.3333 21100.0000
+6887 39533.3333 21116.6667
+6888 39533.3333 21250.0000
+6889 39533.3333 21300.0000
+6890 39533.3333 21366.6667
+6891 39533.3333 21400.0000
+6892 39533.3333 21433.3333
+6893 39533.3333 21466.6667
+6894 39533.3333 21566.6667
+6895 39533.3333 21583.3333
+6896 39533.3333 21616.6667
+6897 39533.3333 21633.3333
+6898 39533.3333 21683.3333
+6899 39533.3333 21700.0000
+6900 39533.3333 21766.6667
+6901 39533.3333 21800.0000
+6902 39533.3333 21833.3333
+6903 39533.3333 21866.6667
+6904 39533.3333 21933.3333
+6905 39533.3333 21983.3333
+6906 39533.3333 22000.0000
+6907 39533.3333 22166.6667
+6908 39533.3333 22233.3333
+6909 39533.3333 22266.6667
+6910 39533.3333 22366.6667
+6911 39533.3333 22500.0000
+6912 39533.3333 22666.6667
+6913 39538.8889 24991.6667
+6914 39546.3889 19911.1111
+6915 39550.0000 19866.6667
+6916 39550.0000 19883.3333
+6917 39550.0000 20266.6667
+6918 39550.0000 20316.6667
+6919 39550.0000 20366.6667
+6920 39550.0000 20433.3333
+6921 39550.0000 20516.6667
+6922 39550.0000 20550.0000
+6923 39550.0000 20583.3333
+6924 39550.0000 20600.0000
+6925 39550.0000 20633.3333
+6926 39550.0000 20683.3333
+6927 39550.0000 20766.6667
+6928 39550.0000 20900.0000
+6929 39550.0000 20950.0000
+6930 39550.0000 21016.6667
+6931 39550.0000 21033.3333
+6932 39550.0000 21050.0000
+6933 39550.0000 21116.6667
+6934 39550.0000 21366.6667
+6935 39550.0000 21583.3333
+6936 39550.0000 21616.6667
+6937 39550.0000 21633.3333
+6938 39550.0000 21650.0000
+6939 39550.0000 21666.6667
+6940 39550.0000 21683.3333
+6941 39550.0000 21700.0000
+6942 39550.0000 21750.0000
+6943 39550.0000 21766.6667
+6944 39550.0000 21900.0000
+6945 39550.0000 22200.0000
+6946 39550.0000 22616.6667
+6947 39550.0000 22650.0000
+6948 39550.0000 22750.0000
+6949 39550.0000 22983.3333
+6950 39566.6667 19850.0000
+6951 39566.6667 19866.6667
+6952 39566.6667 19883.3333
+6953 39566.6667 19900.0000
+6954 39566.6667 19916.6667
+6955 39566.6667 20200.0000
+6956 39566.6667 20283.3333
+6957 39566.6667 20316.6667
+6958 39566.6667 20433.3333
+6959 39566.6667 20550.0000
+6960 39566.6667 20633.3333
+6961 39566.6667 20700.0000
+6962 39566.6667 20733.3333
+6963 39566.6667 20833.3333
+6964 39566.6667 20883.3333
+6965 39566.6667 20950.0000
+6966 39566.6667 21000.0000
+6967 39566.6667 21083.3333
+6968 39566.6667 21166.6667
+6969 39566.6667 21250.0000
+6970 39566.6667 21366.6667
+6971 39566.6667 21583.3333
+6972 39566.6667 21616.6667
+6973 39566.6667 21700.0000
+6974 39566.6667 21716.6667
+6975 39566.6667 21750.0000
+6976 39566.6667 21766.6667
+6977 39566.6667 21833.3333
+6978 39566.6667 21933.3333
+6979 39566.6667 22000.0000
+6980 39566.6667 22016.6667
+6981 39566.6667 22083.3333
+6982 39566.6667 22216.6667
+6983 39566.6667 22366.6667
+6984 39566.6667 22466.6667
+6985 39566.6667 22533.3333
+6986 39566.6667 22600.0000
+6987 39566.6667 22750.0000
+6988 39566.6667 22766.6667
+6989 39583.3333 19850.0000
+6990 39583.3333 19866.6667
+6991 39583.3333 19883.3333
+6992 39583.3333 19900.0000
+6993 39583.3333 19916.6667
+6994 39583.3333 20333.3333
+6995 39583.3333 20400.0000
+6996 39583.3333 20466.6667
+6997 39583.3333 20550.0000
+6998 39583.3333 20600.0000
+6999 39583.3333 20616.6667
+7000 39583.3333 20666.6667
+7001 39583.3333 20700.0000
+7002 39583.3333 20716.6667
+7003 39583.3333 20800.0000
+7004 39583.3333 20883.3333
+7005 39583.3333 20916.6667
+7006 39583.3333 20933.3333
+7007 39583.3333 20950.0000
+7008 39583.3333 20983.3333
+7009 39583.3333 21000.0000
+7010 39583.3333 21033.3333
+7011 39583.3333 21066.6667
+7012 39583.3333 21083.3333
+7013 39583.3333 21116.6667
+7014 39583.3333 21583.3333
+7015 39583.3333 21683.3333
+7016 39583.3333 21733.3333
+7017 39583.3333 21750.0000
+7018 39583.3333 21783.3333
+7019 39583.3333 21800.0000
+7020 39583.3333 21816.6667
+7021 39583.3333 21850.0000
+7022 39583.3333 21900.0000
+7023 39583.3333 21916.6667
+7024 39583.3333 21966.6667
+7025 39583.3333 22166.6667
+7026 39583.3333 22300.0000
+7027 39583.3333 22333.3333
+7028 39583.3333 22583.3333
+7029 39583.3333 22783.3333
+7030 39583.3333 22916.6667
+7031 39593.8889 19823.6111
+7032 39600.0000 19866.6667
+7033 39600.0000 19900.0000
+7034 39600.0000 19916.6667
+7035 39600.0000 20233.3333
+7036 39600.0000 20266.6667
+7037 39600.0000 20283.3333
+7038 39600.0000 20316.6667
+7039 39600.0000 20433.3333
+7040 39600.0000 20466.6667
+7041 39600.0000 20533.3333
+7042 39600.0000 20566.6667
+7043 39600.0000 20650.0000
+7044 39600.0000 20683.3333
+7045 39600.0000 20750.0000
+7046 39600.0000 20850.0000
+7047 39600.0000 20883.3333
+7048 39600.0000 21000.0000
+7049 39600.0000 21050.0000
+7050 39600.0000 21100.0000
+7051 39600.0000 21283.3333
+7052 39600.0000 21300.0000
+7053 39600.0000 21466.6667
+7054 39600.0000 21500.0000
+7055 39600.0000 21650.0000
+7056 39600.0000 21766.6667
+7057 39600.0000 21816.6667
+7058 39600.0000 21983.3333
+7059 39600.0000 22050.0000
+7060 39600.0000 22066.6667
+7061 39600.0000 22583.3333
+7062 39600.0000 22716.6667
+7063 39616.6667 19800.0000
+7064 39616.6667 19816.6667
+7065 39616.6667 19850.0000
+7066 39616.6667 19900.0000
+7067 39616.6667 19916.6667
+7068 39616.6667 20183.3333
+7069 39616.6667 20333.3333
+7070 39616.6667 20500.0000
+7071 39616.6667 20533.3333
+7072 39616.6667 20583.3333
+7073 39616.6667 20633.3333
+7074 39616.6667 20733.3333
+7075 39616.6667 20833.3333
+7076 39616.6667 20883.3333
+7077 39616.6667 20950.0000
+7078 39616.6667 20966.6667
+7079 39616.6667 20983.3333
+7080 39616.6667 21050.0000
+7081 39616.6667 21350.0000
+7082 39616.6667 21416.6667
+7083 39616.6667 21533.3333
+7084 39616.6667 21650.0000
+7085 39616.6667 21750.0000
+7086 39616.6667 21766.6667
+7087 39616.6667 22016.6667
+7088 39616.6667 22133.3333
+7089 39616.6667 22233.3333
+7090 39616.6667 22266.6667
+7091 39616.6667 22300.0000
+7092 39616.6667 22366.6667
+7093 39616.6667 22433.3333
+7094 39616.6667 22533.3333
+7095 39616.6667 22566.6667
+7096 39616.6667 22616.6667
+7097 39616.6667 22683.3333
+7098 39616.6667 22883.3333
+7099 39620.0000 19919.7222
+7100 39625.0000 19875.5556
+7101 39626.9444 20187.2222
+7102 39633.0556 19764.4444
+7103 39633.3333 19900.0000
+7104 39633.3333 20416.6667
+7105 39633.3333 20450.0000
+7106 39633.3333 20566.6667
+7107 39633.3333 20700.0000
+7108 39633.3333 20716.6667
+7109 39633.3333 20733.3333
+7110 39633.3333 20766.6667
+7111 39633.3333 20783.3333
+7112 39633.3333 20866.6667
+7113 39633.3333 20916.6667
+7114 39633.3333 20966.6667
+7115 39633.3333 21033.3333
+7116 39633.3333 21066.6667
+7117 39633.3333 21250.0000
+7118 39633.3333 21300.0000
+7119 39633.3333 21350.0000
+7120 39633.3333 21583.3333
+7121 39633.3333 21700.0000
+7122 39633.3333 21783.3333
+7123 39633.3333 22016.6667
+7124 39633.3333 22050.0000
+7125 39633.3333 22400.0000
+7126 39633.3333 22416.6667
+7127 39633.3333 22500.0000
+7128 39633.3333 22516.6667
+7129 39650.0000 19766.6667
+7130 39650.0000 19850.0000
+7131 39650.0000 20283.3333
+7132 39650.0000 20316.6667
+7133 39650.0000 20366.6667
+7134 39650.0000 20483.3333
+7135 39650.0000 20516.6667
+7136 39650.0000 20616.6667
+7137 39650.0000 20666.6667
+7138 39650.0000 20700.0000
+7139 39650.0000 20716.6667
+7140 39650.0000 20733.3333
+7141 39650.0000 20800.0000
+7142 39650.0000 20950.0000
+7143 39650.0000 21033.3333
+7144 39650.0000 21483.3333
+7145 39650.0000 21616.6667
+7146 39650.0000 21650.0000
+7147 39650.0000 21816.6667
+7148 39650.0000 22266.6667
+7149 39650.0000 22283.3333
+7150 39650.0000 22433.3333
+7151 39650.0000 22716.6667
+7152 39663.8889 20101.3889
+7153 39666.6667 19816.6667
+7154 39666.6667 20250.0000
+7155 39666.6667 20366.6667
+7156 39666.6667 20433.3333
+7157 39666.6667 20516.6667
+7158 39666.6667 20533.3333
+7159 39666.6667 20550.0000
+7160 39666.6667 20566.6667
+7161 39666.6667 20583.3333
+7162 39666.6667 20650.0000
+7163 39666.6667 20716.6667
+7164 39666.6667 20733.3333
+7165 39666.6667 20833.3333
+7166 39666.6667 20933.3333
+7167 39666.6667 20950.0000
+7168 39666.6667 21033.3333
+7169 39666.6667 21216.6667
+7170 39666.6667 21450.0000
+7171 39666.6667 21566.6667
+7172 39666.6667 21633.3333
+7173 39666.6667 21700.0000
+7174 39666.6667 21733.3333
+7175 39666.6667 21766.6667
+7176 39666.6667 21833.3333
+7177 39666.6667 22383.3333
+7178 39666.6667 22483.3333
+7179 39666.6667 22666.6667
+7180 39666.6667 22733.3333
+7181 39666.6667 22783.3333
+7182 39666.6667 22866.6667
+7183 39670.0000 19740.8333
+7184 39681.6667 19706.9444
+7185 39683.3333 19683.3333
+7186 39683.3333 19700.0000
+7187 39683.3333 19733.3333
+7188 39683.3333 19750.0000
+7189 39683.3333 19816.6667
+7190 39683.3333 20066.6667
+7191 39683.3333 20300.0000
+7192 39683.3333 20466.6667
+7193 39683.3333 20533.3333
+7194 39683.3333 20616.6667
+7195 39683.3333 20666.6667
+7196 39683.3333 20766.6667
+7197 39683.3333 20783.3333
+7198 39683.3333 20866.6667
+7199 39683.3333 20883.3333
+7200 39683.3333 21050.0000
+7201 39683.3333 21183.3333
+7202 39683.3333 21300.0000
+7203 39683.3333 21550.0000
+7204 39683.3333 21583.3333
+7205 39683.3333 21683.3333
+7206 39683.3333 21800.0000
+7207 39683.3333 22300.0000
+7208 39683.3333 22316.6667
+7209 39683.3333 22333.3333
+7210 39683.3333 22500.0000
+7211 39683.3333 22583.3333
+7212 39683.3333 22633.3333
+7213 39683.3333 22700.0000
+7214 39683.3333 22733.3333
+7215 39683.3333 22833.3333
+7216 39694.4444 19836.6667
+7217 39700.0000 19700.0000
+7218 39700.0000 19716.6667
+7219 39700.0000 19733.3333
+7220 39700.0000 19833.3333
+7221 39700.0000 20266.6667
+7222 39700.0000 20333.3333
+7223 39700.0000 20400.0000
+7224 39700.0000 20533.3333
+7225 39700.0000 20566.6667
+7226 39700.0000 20633.3333
+7227 39700.0000 20666.6667
+7228 39700.0000 20783.3333
+7229 39700.0000 20800.0000
+7230 39700.0000 20816.6667
+7231 39700.0000 20850.0000
+7232 39700.0000 20950.0000
+7233 39700.0000 21033.3333
+7234 39700.0000 21066.6667
+7235 39700.0000 21383.3333
+7236 39700.0000 21516.6667
+7237 39700.0000 21633.3333
+7238 39700.0000 21716.6667
+7239 39700.0000 22016.6667
+7240 39700.0000 22083.3333
+7241 39700.0000 22416.6667
+7242 39700.0000 22433.3333
+7243 39700.0000 22700.0000
+7244 39707.7778 19795.5556
+7245 39709.7222 19702.2222
+7246 39716.6667 19666.6667
+7247 39716.6667 19716.6667
+7248 39716.6667 19733.3333
+7249 39716.6667 19750.0000
+7250 39716.6667 19766.6667
+7251 39716.6667 19783.3333
+7252 39716.6667 19833.3333
+7253 39716.6667 19900.0000
+7254 39716.6667 20350.0000
+7255 39716.6667 20450.0000
+7256 39716.6667 20483.3333
+7257 39716.6667 20533.3333
+7258 39716.6667 20600.0000
+7259 39716.6667 20716.6667
+7260 39716.6667 20750.0000
+7261 39716.6667 20833.3333
+7262 39716.6667 21066.6667
+7263 39716.6667 21083.3333
+7264 39716.6667 21383.3333
+7265 39716.6667 21466.6667
+7266 39716.6667 21616.6667
+7267 39716.6667 21683.3333
+7268 39716.6667 21783.3333
+7269 39716.6667 21933.3333
+7270 39716.6667 22166.6667
+7271 39716.6667 22183.3333
+7272 39716.6667 22400.0000
+7273 39716.6667 22550.0000
+7274 39716.6667 22566.6667
+7275 39716.6667 22733.3333
+7276 39716.6667 22766.6667
+7277 39733.3333 19666.6667
+7278 39733.3333 19683.3333
+7279 39733.3333 19700.0000
+7280 39733.3333 19716.6667
+7281 39733.3333 19733.3333
+7282 39733.3333 19750.0000
+7283 39733.3333 19766.6667
+7284 39733.3333 19800.0000
+7285 39733.3333 19816.6667
+7286 39733.3333 19900.0000
+7287 39733.3333 19916.6667
+7288 39733.3333 19933.3333
+7289 39733.3333 20416.6667
+7290 39733.3333 20450.0000
+7291 39733.3333 20516.6667
+7292 39733.3333 20566.6667
+7293 39733.3333 20583.3333
+7294 39733.3333 20616.6667
+7295 39733.3333 20633.3333
+7296 39733.3333 20666.6667
+7297 39733.3333 20766.6667
+7298 39733.3333 20816.6667
+7299 39733.3333 20916.6667
+7300 39733.3333 20933.3333
+7301 39733.3333 21033.3333
+7302 39733.3333 21066.6667
+7303 39733.3333 21100.0000
+7304 39733.3333 21133.3333
+7305 39733.3333 21883.3333
+7306 39733.3333 22350.0000
+7307 39733.3333 22533.3333
+7308 39733.3333 22600.0000
+7309 39733.3333 22733.3333
+7310 39733.3333 22750.0000
+7311 39733.3333 22800.0000
+7312 39736.1111 19928.0556
+7313 39743.6111 19932.2222
+7314 39748.8889 19938.8889
+7315 39750.0000 19683.3333
+7316 39750.0000 19700.0000
+7317 39750.0000 19716.6667
+7318 39750.0000 19733.3333
+7319 39750.0000 19750.0000
+7320 39750.0000 19766.6667
+7321 39750.0000 19783.3333
+7322 39750.0000 19833.3333
+7323 39750.0000 19883.3333
+7324 39750.0000 19916.6667
+7325 39750.0000 19933.3333
+7326 39750.0000 20333.3333
+7327 39750.0000 20416.6667
+7328 39750.0000 20466.6667
+7329 39750.0000 20533.3333
+7330 39750.0000 20566.6667
+7331 39750.0000 20633.3333
+7332 39750.0000 20650.0000
+7333 39750.0000 20716.6667
+7334 39750.0000 20750.0000
+7335 39750.0000 20800.0000
+7336 39750.0000 21050.0000
+7337 39750.0000 21083.3333
+7338 39750.0000 21100.0000
+7339 39750.0000 21333.3333
+7340 39750.0000 21366.6667
+7341 39750.0000 21416.6667
+7342 39750.0000 21500.0000
+7343 39750.0000 21750.0000
+7344 39750.0000 22083.3333
+7345 39750.0000 22100.0000
+7346 39750.0000 22283.3333
+7347 39750.0000 22366.6667
+7348 39750.0000 22433.3333
+7349 39750.0000 22583.3333
+7350 39750.0000 22700.0000
+7351 39750.0000 22800.0000
+7352 39755.8333 19676.3889
+7353 39763.0556 19873.0556
+7354 39766.6667 19533.3333
+7355 39766.6667 19750.0000
+7356 39766.6667 19783.3333
+7357 39766.6667 19816.6667
+7358 39766.6667 19833.3333
+7359 39766.6667 19916.6667
+7360 39766.6667 19933.3333
+7361 39766.6667 20316.6667
+7362 39766.6667 20383.3333
+7363 39766.6667 20533.3333
+7364 39766.6667 20583.3333
+7365 39766.6667 20600.0000
+7366 39766.6667 20783.3333
+7367 39766.6667 20866.6667
+7368 39766.6667 21000.0000
+7369 39766.6667 21033.3333
+7370 39766.6667 21050.0000
+7371 39766.6667 21066.6667
+7372 39766.6667 21116.6667
+7373 39766.6667 21183.3333
+7374 39766.6667 21466.6667
+7375 39766.6667 21666.6667
+7376 39766.6667 21733.3333
+7377 39766.6667 22383.3333
+7378 39766.6667 22533.3333
+7379 39766.6667 22583.3333
+7380 39767.5000 19946.6667
+7381 39775.0000 19662.5000
+7382 39783.3333 19516.6667
+7383 39783.3333 19683.3333
+7384 39783.3333 19750.0000
+7385 39783.3333 19783.3333
+7386 39783.3333 19833.3333
+7387 39783.3333 19850.0000
+7388 39783.3333 19866.6667
+7389 39783.3333 19883.3333
+7390 39783.3333 19916.6667
+7391 39783.3333 20350.0000
+7392 39783.3333 20466.6667
+7393 39783.3333 20616.6667
+7394 39783.3333 20683.3333
+7395 39783.3333 20716.6667
+7396 39783.3333 20750.0000
+7397 39783.3333 20800.0000
+7398 39783.3333 20816.6667
+7399 39783.3333 20833.3333
+7400 39783.3333 20866.6667
+7401 39783.3333 21000.0000
+7402 39783.3333 21083.3333
+7403 39783.3333 21100.0000
+7404 39783.3333 21116.6667
+7405 39783.3333 21283.3333
+7406 39783.3333 21416.6667
+7407 39783.3333 21550.0000
+7408 39783.3333 21800.0000
+7409 39783.3333 21983.3333
+7410 39783.3333 22083.3333
+7411 39783.3333 22400.0000
+7412 39783.3333 22583.3333
+7413 39785.5556 19673.0556
+7414 39788.6111 19787.5000
+7415 39790.5556 19707.5000
+7416 39793.3333 19759.1667
+7417 39795.5556 19811.1111
+7418 39800.0000 19683.3333
+7419 39800.0000 19833.3333
+7420 39800.0000 19850.0000
+7421 39800.0000 19866.6667
+7422 39800.0000 20433.3333
+7423 39800.0000 20516.6667
+7424 39800.0000 20583.3333
+7425 39800.0000 20600.0000
+7426 39800.0000 20666.6667
+7427 39800.0000 20700.0000
+7428 39800.0000 21000.0000
+7429 39800.0000 21333.3333
+7430 39800.0000 21383.3333
+7431 39800.0000 21600.0000
+7432 39800.0000 21633.3333
+7433 39800.0000 21766.6667
+7434 39800.0000 21850.0000
+7435 39800.0000 21900.0000
+7436 39800.0000 22066.6667
+7437 39800.0000 22116.6667
+7438 39800.0000 22183.3333
+7439 39800.0000 22333.3333
+7440 39800.0000 22366.6667
+7441 39800.0000 22483.3333
+7442 39800.0000 22650.0000
+7443 39800.0000 25333.3333
+7444 39816.6667 19850.0000
+7445 39816.6667 20516.6667
+7446 39816.6667 20550.0000
+7447 39816.6667 20633.3333
+7448 39816.6667 20650.0000
+7449 39816.6667 20733.3333
+7450 39816.6667 20916.6667
+7451 39816.6667 20950.0000
+7452 39816.6667 21350.0000
+7453 39816.6667 21733.3333
+7454 39816.6667 22083.3333
+7455 39816.6667 22233.3333
+7456 39816.6667 22533.3333
+7457 39816.6667 25350.0000
+7458 39833.3333 20433.3333
+7459 39833.3333 20483.3333
+7460 39833.3333 20500.0000
+7461 39833.3333 20550.0000
+7462 39833.3333 20583.3333
+7463 39833.3333 20600.0000
+7464 39833.3333 20616.6667
+7465 39833.3333 20750.0000
+7466 39833.3333 20883.3333
+7467 39833.3333 21300.0000
+7468 39833.3333 21433.3333
+7469 39833.3333 21500.0000
+7470 39833.3333 21616.6667
+7471 39833.3333 21866.6667
+7472 39833.3333 21883.3333
+7473 39833.3333 22033.3333
+7474 39833.3333 22050.0000
+7475 39833.3333 22100.0000
+7476 39833.3333 22200.0000
+7477 39833.3333 22300.0000
+7478 39833.3333 22466.6667
+7479 39833.3333 22516.6667
+7480 39833.3333 22766.6667
+7481 39833.3333 22783.3333
+7482 39833.3333 25333.3333
+7483 39843.6111 19402.7778
+7484 39850.0000 19416.6667
+7485 39850.0000 20483.3333
+7486 39850.0000 20516.6667
+7487 39850.0000 20583.3333
+7488 39850.0000 20666.6667
+7489 39850.0000 20683.3333
+7490 39850.0000 20766.6667
+7491 39850.0000 20950.0000
+7492 39850.0000 20983.3333
+7493 39850.0000 21233.3333
+7494 39850.0000 21350.0000
+7495 39850.0000 21450.0000
+7496 39850.0000 21600.0000
+7497 39850.0000 21666.6667
+7498 39850.0000 21700.0000
+7499 39850.0000 21716.6667
+7500 39850.0000 21783.3333
+7501 39850.0000 21800.0000
+7502 39850.0000 22066.6667
+7503 39850.0000 22166.6667
+7504 39850.0000 22183.3333
+7505 39850.0000 22550.0000
+7506 39850.0000 25083.3333
+7507 39866.6667 19383.3333
+7508 39866.6667 19416.6667
+7509 39866.6667 20400.0000
+7510 39866.6667 20516.6667
+7511 39866.6667 20550.0000
+7512 39866.6667 20566.6667
+7513 39866.6667 20750.0000
+7514 39866.6667 20783.3333
+7515 39866.6667 20850.0000
+7516 39866.6667 20966.6667
+7517 39866.6667 20983.3333
+7518 39866.6667 21466.6667
+7519 39866.6667 21566.6667
+7520 39866.6667 21683.3333
+7521 39866.6667 21766.6667
+7522 39866.6667 22116.6667
+7523 39866.6667 22416.6667
+7524 39866.6667 22433.3333
+7525 39866.6667 22466.6667
+7526 39866.6667 22516.6667
+7527 39866.6667 22533.3333
+7528 39866.6667 25066.6667
+7529 39866.6667 25150.0000
+7530 39866.6667 25166.6667
+7531 39866.6667 25266.6667
+7532 39866.6667 25316.6667
+7533 39883.3333 19583.3333
+7534 39883.3333 20466.6667
+7535 39883.3333 20500.0000
+7536 39883.3333 20633.3333
+7537 39883.3333 20650.0000
+7538 39883.3333 20666.6667
+7539 39883.3333 20700.0000
+7540 39883.3333 20750.0000
+7541 39883.3333 20783.3333
+7542 39883.3333 21333.3333
+7543 39883.3333 21366.6667
+7544 39883.3333 21616.6667
+7545 39883.3333 21650.0000
+7546 39883.3333 21733.3333
+7547 39883.3333 21816.6667
+7548 39883.3333 22066.6667
+7549 39883.3333 22233.3333
+7550 39883.3333 22716.6667
+7551 39883.3333 25183.3333
+7552 39883.3333 25316.6667
+7553 39900.0000 20383.3333
+7554 39900.0000 20400.0000
+7555 39900.0000 20466.6667
+7556 39900.0000 20583.3333
+7557 39900.0000 20650.0000
+7558 39900.0000 20683.3333
+7559 39900.0000 20783.3333
+7560 39900.0000 20816.6667
+7561 39900.0000 21283.3333
+7562 39900.0000 21683.3333
+7563 39900.0000 22183.3333
+7564 39900.0000 22550.0000
+7565 39900.0000 22633.3333
+7566 39900.0000 25183.3333
+7567 39900.0000 25200.0000
+7568 39900.0000 25216.6667
+7569 39900.0000 25283.3333
+7570 39916.6667 20383.3333
+7571 39916.6667 20400.0000
+7572 39916.6667 20533.3333
+7573 39916.6667 20566.6667
+7574 39916.6667 20850.0000
+7575 39916.6667 21400.0000
+7576 39916.6667 21450.0000
+7577 39916.6667 21516.6667
+7578 39916.6667 21566.6667
+7579 39916.6667 21766.6667
+7580 39916.6667 21816.6667
+7581 39916.6667 22150.0000
+7582 39916.6667 22583.3333
+7583 39916.6667 22683.3333
+7584 39916.6667 25083.3333
+7585 39916.6667 25116.6667
+7586 39916.6667 25150.0000
+7587 39916.6667 25200.0000
+7588 39916.6667 25266.6667
+7589 39916.6667 25300.0000
+7590 39916.6667 25333.3333
+7591 39933.3333 20366.6667
+7592 39933.3333 20400.0000
+7593 39933.3333 20416.6667
+7594 39933.3333 20466.6667
+7595 39933.3333 20600.0000
+7596 39933.3333 20650.0000
+7597 39933.3333 20666.6667
+7598 39933.3333 21050.0000
+7599 39933.3333 21350.0000
+7600 39933.3333 22050.0000
+7601 39933.3333 22150.0000
+7602 39933.3333 22566.6667
+7603 39933.3333 22683.3333
+7604 39933.3333 25133.3333
+7605 39933.3333 25183.3333
+7606 39933.3333 25233.3333
+7607 39933.3333 25266.6667
+7608 39933.3333 25333.3333
+7609 39950.0000 20350.0000
+7610 39950.0000 20433.3333
+7611 39950.0000 20533.3333
+7612 39950.0000 20616.6667
+7613 39950.0000 20666.6667
+7614 39950.0000 20700.0000
+7615 39950.0000 21233.3333
+7616 39950.0000 21366.6667
+7617 39950.0000 21400.0000
+7618 39950.0000 21616.6667
+7619 39950.0000 21666.6667
+7620 39950.0000 21733.3333
+7621 39950.0000 21966.6667
+7622 39950.0000 22066.6667
+7623 39950.0000 22616.6667
+7624 39950.0000 23533.3333
+7625 39950.0000 23616.6667
+7626 39950.0000 23666.6667
+7627 39950.0000 25166.6667
+7628 39950.0000 25200.0000
+7629 39950.0000 25216.6667
+7630 39950.0000 25300.0000
+7631 39966.6667 20333.3333
+7632 39966.6667 20350.0000
+7633 39966.6667 20383.3333
+7634 39966.6667 20566.6667
+7635 39966.6667 20583.3333
+7636 39966.6667 20633.3333
+7637 39966.6667 20683.3333
+7638 39966.6667 20716.6667
+7639 39966.6667 20950.0000
+7640 39966.6667 21266.6667
+7641 39966.6667 21450.0000
+7642 39966.6667 21500.0000
+7643 39966.6667 21733.3333
+7644 39966.6667 21933.3333
+7645 39966.6667 22116.6667
+7646 39966.6667 22250.0000
+7647 39966.6667 22350.0000
+7648 39966.6667 22583.3333
+7649 39966.6667 23400.0000
+7650 39966.6667 23916.6667
+7651 39966.6667 25150.0000
+7652 39966.6667 25233.3333
+7653 39966.6667 25366.6667
+7654 39983.3333 20433.3333
+7655 39983.3333 20550.0000
+7656 39983.3333 20666.6667
+7657 39983.3333 20916.6667
+7658 39983.3333 21116.6667
+7659 39983.3333 21316.6667
+7660 39983.3333 21416.6667
+7661 39983.3333 21816.6667
+7662 39983.3333 22033.3333
+7663 39983.3333 22150.0000
+7664 39983.3333 22183.3333
+7665 39983.3333 22250.0000
+7666 39983.3333 22333.3333
+7667 39983.3333 22400.0000
+7668 39983.3333 22466.6667
+7669 39983.3333 22616.6667
+7670 39983.3333 23616.6667
+7671 39983.3333 23983.3333
+7672 39983.3333 25400.0000
+7673 40000.0000 20416.6667
+7674 40000.0000 20600.0000
+7675 40000.0000 20683.3333
+7676 40000.0000 20883.3333
+7677 40000.0000 21133.3333
+7678 40000.0000 21283.3333
+7679 40000.0000 21300.0000
+7680 40000.0000 21333.3333
+7681 40000.0000 21600.0000
+7682 40000.0000 21650.0000
+7683 40000.0000 21683.3333
+7684 40000.0000 21966.6667
+7685 40000.0000 22083.3333
+7686 40000.0000 22233.3333
+7687 40000.0000 22283.3333
+7688 40000.0000 22533.3333
+7689 40000.0000 22583.3333
+7690 40000.0000 23383.3333
+7691 40000.0000 23416.6667
+7692 40000.0000 23583.3333
+7693 40000.0000 25416.6667
+7694 40016.6667 20516.6667
+7695 40016.6667 20566.6667
+7696 40016.6667 20633.3333
+7697 40016.6667 20666.6667
+7698 40016.6667 21316.6667
+7699 40016.6667 21433.3333
+7700 40016.6667 21533.3333
+7701 40016.6667 21616.6667
+7702 40016.6667 21850.0000
+7703 40016.6667 22133.3333
+7704 40016.6667 22183.3333
+7705 40016.6667 22200.0000
+7706 40016.6667 22550.0000
+7707 40016.6667 22583.3333
+7708 40016.6667 23450.0000
+7709 40016.6667 23533.3333
+7710 40016.6667 23916.6667
+7711 40033.3333 20433.3333
+7712 40033.3333 20466.6667
+7713 40033.3333 20483.3333
+7714 40033.3333 20666.6667
+7715 40033.3333 20883.3333
+7716 40033.3333 20916.6667
+7717 40033.3333 20966.6667
+7718 40033.3333 21016.6667
+7719 40033.3333 21183.3333
+7720 40033.3333 21200.0000
+7721 40033.3333 21266.6667
+7722 40033.3333 21350.0000
+7723 40033.3333 21616.6667
+7724 40033.3333 21650.0000
+7725 40033.3333 21933.3333
+7726 40033.3333 22050.0000
+7727 40033.3333 22066.6667
+7728 40033.3333 22166.6667
+7729 40033.3333 23366.6667
+7730 40033.3333 23466.6667
+7731 40033.3333 23883.3333
+7732 40033.3333 23933.3333
+7733 40033.3333 24000.0000
+7734 40050.0000 20550.0000
+7735 40050.0000 20600.0000
+7736 40050.0000 20650.0000
+7737 40050.0000 20683.3333
+7738 40050.0000 20700.0000
+7739 40050.0000 20750.0000
+7740 40050.0000 20850.0000
+7741 40050.0000 21200.0000
+7742 40050.0000 21683.3333
+7743 40050.0000 21766.6667
+7744 40050.0000 21866.6667
+7745 40050.0000 22033.3333
+7746 40050.0000 22516.6667
+7747 40050.0000 23416.6667
+7748 40050.0000 23816.6667
+7749 40050.0000 24000.0000
+7750 40066.6667 20433.3333
+7751 40066.6667 20566.6667
+7752 40066.6667 20616.6667
+7753 40066.6667 20750.0000
+7754 40066.6667 20783.3333
+7755 40066.6667 21116.6667
+7756 40066.6667 21216.6667
+7757 40066.6667 21283.3333
+7758 40066.6667 21333.3333
+7759 40066.6667 21400.0000
+7760 40066.6667 21516.6667
+7761 40066.6667 21566.6667
+7762 40066.6667 21616.6667
+7763 40066.6667 21683.3333
+7764 40066.6667 21816.6667
+7765 40066.6667 22050.0000
+7766 40066.6667 22166.6667
+7767 40066.6667 22233.3333
+7768 40066.6667 22566.6667
+7769 40083.3333 20616.6667
+7770 40083.3333 20666.6667
+7771 40083.3333 20716.6667
+7772 40083.3333 20783.3333
+7773 40083.3333 21150.0000
+7774 40083.3333 21200.0000
+7775 40083.3333 21283.3333
+7776 40083.3333 21333.3333
+7777 40083.3333 21416.6667
+7778 40083.3333 21516.6667
+7779 40083.3333 21550.0000
+7780 40083.3333 21650.0000
+7781 40083.3333 21883.3333
+7782 40083.3333 21966.6667
+7783 40083.3333 23450.0000
+7784 40083.3333 23800.0000
+7785 40100.0000 20733.3333
+7786 40100.0000 21016.6667
+7787 40100.0000 21366.6667
+7788 40100.0000 21533.3333
+7789 40100.0000 21600.0000
+7790 40100.0000 21616.6667
+7791 40100.0000 22250.0000
+7792 40100.0000 22500.0000
+7793 40100.0000 23433.3333
+7794 40100.0000 23783.3333
+7795 40100.0000 23983.3333
+7796 40116.6667 20716.6667
+7797 40116.6667 20750.0000
+7798 40116.6667 20800.0000
+7799 40116.6667 20850.0000
+7800 40116.6667 21150.0000
+7801 40116.6667 21266.6667
+7802 40116.6667 21316.6667
+7803 40116.6667 21350.0000
+7804 40116.6667 21416.6667
+7805 40116.6667 21483.3333
+7806 40116.6667 21516.6667
+7807 40116.6667 21933.3333
+7808 40116.6667 23333.3333
+7809 40116.6667 23816.6667
+7810 40133.3333 20683.3333
+7811 40133.3333 20750.0000
+7812 40133.3333 20816.6667
+7813 40133.3333 21133.3333
+7814 40133.3333 21200.0000
+7815 40133.3333 21233.3333
+7816 40133.3333 21666.6667
+7817 40133.3333 21733.3333
+7818 40133.3333 21866.6667
+7819 40133.3333 21950.0000
+7820 40133.3333 22150.0000
+7821 40133.3333 23400.0000
+7822 40133.3333 23766.6667
+7823 40133.3333 24283.3333
+7824 40133.3333 24350.0000
+7825 40150.0000 20733.3333
+7826 40150.0000 20850.0000
+7827 40150.0000 20900.0000
+7828 40150.0000 21250.0000
+7829 40150.0000 21333.3333
+7830 40150.0000 21366.6667
+7831 40150.0000 21433.3333
+7832 40150.0000 21483.3333
+7833 40150.0000 21516.6667
+7834 40150.0000 21550.0000
+7835 40150.0000 21950.0000
+7836 40150.0000 22016.6667
+7837 40150.0000 22233.3333
+7838 40150.0000 22550.0000
+7839 40150.0000 23350.0000
+7840 40150.0000 24300.0000
+7841 40150.0000 24383.3333
+7842 40166.6667 20733.3333
+7843 40166.6667 20783.3333
+7844 40166.6667 20950.0000
+7845 40166.6667 21166.6667
+7846 40166.6667 21183.3333
+7847 40166.6667 21216.6667
+7848 40166.6667 21283.3333
+7849 40166.6667 21466.6667
+7850 40166.6667 21633.3333
+7851 40166.6667 21816.6667
+7852 40166.6667 21866.6667
+7853 40166.6667 21916.6667
+7854 40166.6667 22016.6667
+7855 40166.6667 22483.3333
+7856 40166.6667 23866.6667
+7857 40183.3333 21033.3333
+7858 40183.3333 21516.6667
+7859 40183.3333 21583.3333
+7860 40183.3333 21766.6667
+7861 40183.3333 21850.0000
+7862 40183.3333 21966.6667
+7863 40183.3333 22000.0000
+7864 40183.3333 22433.3333
+7865 40183.3333 22483.3333
+7866 40183.3333 22566.6667
+7867 40200.0000 20850.0000
+7868 40200.0000 21133.3333
+7869 40200.0000 21183.3333
+7870 40200.0000 21233.3333
+7871 40200.0000 21316.6667
+7872 40200.0000 21366.6667
+7873 40200.0000 21400.0000
+7874 40200.0000 21433.3333
+7875 40200.0000 21483.3333
+7876 40200.0000 21600.0000
+7877 40200.0000 21750.0000
+7878 40200.0000 21800.0000
+7879 40200.0000 21866.6667
+7880 40200.0000 21950.0000
+7881 40200.0000 22033.3333
+7882 40200.0000 22233.3333
+7883 40200.0000 22450.0000
+7884 40200.0000 23333.3333
+7885 40200.0000 24316.6667
+7886 40216.6667 20816.6667
+7887 40216.6667 20866.6667
+7888 40216.6667 20916.6667
+7889 40216.6667 21016.6667
+7890 40216.6667 21200.0000
+7891 40216.6667 21250.0000
+7892 40216.6667 21283.3333
+7893 40216.6667 21483.3333
+7894 40216.6667 21783.3333
+7895 40216.6667 21850.0000
+7896 40216.6667 21883.3333
+7897 40216.6667 21900.0000
+7898 40216.6667 22066.6667
+7899 40216.6667 23666.6667
+7900 40216.6667 24216.6667
+7901 40233.3333 20783.3333
+7902 40233.3333 20850.0000
+7903 40233.3333 20933.3333
+7904 40233.3333 21166.6667
+7905 40233.3333 21216.6667
+7906 40233.3333 21283.3333
+7907 40233.3333 21316.6667
+7908 40233.3333 21350.0000
+7909 40233.3333 21383.3333
+7910 40233.3333 21416.6667
+7911 40233.3333 21750.0000
+7912 40233.3333 21833.3333
+7913 40233.3333 21900.0000
+7914 40233.3333 21966.6667
+7915 40233.3333 22300.0000
+7916 40233.3333 22466.6667
+7917 40233.3333 22500.0000
+7918 40233.3333 22583.3333
+7919 40233.3333 23600.0000
+7920 40233.3333 23666.6667
+7921 40250.0000 20816.6667
+7922 40250.0000 21200.0000
+7923 40250.0000 21266.6667
+7924 40250.0000 21433.3333
+7925 40250.0000 21683.3333
+7926 40250.0000 21750.0000
+7927 40250.0000 21800.0000
+7928 40250.0000 21900.0000
+7929 40250.0000 21916.6667
+7930 40250.0000 22066.6667
+7931 40250.0000 22333.3333
+7932 40250.0000 22366.6667
+7933 40250.0000 22383.3333
+7934 40250.0000 22566.6667
+7935 40250.0000 23283.3333
+7936 40250.0000 23550.0000
+7937 40250.0000 23700.0000
+7938 40250.0000 24200.0000
+7939 40250.0000 24250.0000
+7940 40266.6667 20733.3333
+7941 40266.6667 20750.0000
+7942 40266.6667 20766.6667
+7943 40266.6667 20900.0000
+7944 40266.6667 21200.0000
+7945 40266.6667 21283.3333
+7946 40266.6667 21316.6667
+7947 40266.6667 21383.3333
+7948 40266.6667 21416.6667
+7949 40266.6667 21450.0000
+7950 40266.6667 21500.0000
+7951 40266.6667 21550.0000
+7952 40266.6667 21750.0000
+7953 40266.6667 21783.3333
+7954 40266.6667 21816.6667
+7955 40266.6667 21933.3333
+7956 40266.6667 22033.3333
+7957 40266.6667 22083.3333
+7958 40266.6667 22150.0000
+7959 40266.6667 22283.3333
+7960 40266.6667 22300.0000
+7961 40266.6667 22416.6667
+7962 40266.6667 22466.6667
+7963 40266.6667 22500.0000
+7964 40266.6667 22533.3333
+7965 40266.6667 22583.3333
+7966 40266.6667 22600.0000
+7967 40266.6667 23200.0000
+7968 40266.6667 23216.6667
+7969 40266.6667 23266.6667
+7970 40266.6667 23333.3333
+7971 40266.6667 23500.0000
+7972 40266.6667 24250.0000
+7973 40283.3333 20966.6667
+7974 40283.3333 21033.3333
+7975 40283.3333 21150.0000
+7976 40283.3333 21166.6667
+7977 40283.3333 21200.0000
+7978 40283.3333 21216.6667
+7979 40283.3333 21233.3333
+7980 40283.3333 21350.0000
+7981 40283.3333 21483.3333
+7982 40283.3333 21733.3333
+7983 40283.3333 21866.6667
+7984 40283.3333 21966.6667
+7985 40283.3333 22116.6667
+7986 40283.3333 22283.3333
+7987 40283.3333 22433.3333
+7988 40283.3333 22466.6667
+7989 40283.3333 22600.0000
+7990 40283.3333 23150.0000
+7991 40283.3333 23250.0000
+7992 40283.3333 23300.0000
+7993 40283.3333 23350.0000
+7994 40283.3333 23400.0000
+7995 40283.3333 23450.0000
+7996 40283.3333 24250.0000
+7997 40300.0000 20766.6667
+7998 40300.0000 20950.0000
+7999 40300.0000 21133.3333
+8000 40300.0000 21200.0000
+8001 40300.0000 21216.6667
+8002 40300.0000 21233.3333
+8003 40300.0000 21266.6667
+8004 40300.0000 21283.3333
+8005 40300.0000 21300.0000
+8006 40300.0000 21366.6667
+8007 40300.0000 21416.6667
+8008 40300.0000 21650.0000
+8009 40300.0000 21783.3333
+8010 40300.0000 22033.3333
+8011 40300.0000 22500.0000
+8012 40300.0000 23200.0000
+8013 40300.0000 23350.0000
+8014 40300.0000 23550.0000
+8015 40300.0000 24050.0000
+8016 40300.0000 24066.6667
+8017 40300.0000 24216.6667
+8018 40316.6667 20850.0000
+8019 40316.6667 21133.3333
+8020 40316.6667 21183.3333
+8021 40316.6667 21333.3333
+8022 40316.6667 21383.3333
+8023 40316.6667 21433.3333
+8024 40316.6667 21550.0000
+8025 40316.6667 21650.0000
+8026 40316.6667 21666.6667
+8027 40316.6667 21700.0000
+8028 40316.6667 21916.6667
+8029 40316.6667 22116.6667
+8030 40316.6667 22250.0000
+8031 40316.6667 22350.0000
+8032 40316.6667 22466.6667
+8033 40316.6667 22500.0000
+8034 40316.6667 22583.3333
+8035 40316.6667 23066.6667
+8036 40316.6667 23350.0000
+8037 40333.3333 21000.0000
+8038 40333.3333 21133.3333
+8039 40333.3333 21183.3333
+8040 40333.3333 21233.3333
+8041 40333.3333 21250.0000
+8042 40333.3333 21283.3333
+8043 40333.3333 21366.6667
+8044 40333.3333 21666.6667
+8045 40333.3333 21683.3333
+8046 40333.3333 21716.6667
+8047 40333.3333 21733.3333
+8048 40333.3333 21783.3333
+8049 40333.3333 21800.0000
+8050 40333.3333 21866.6667
+8051 40333.3333 21883.3333
+8052 40333.3333 22016.6667
+8053 40333.3333 22166.6667
+8054 40333.3333 22333.3333
+8055 40333.3333 22533.3333
+8056 40333.3333 23066.6667
+8057 40333.3333 23133.3333
+8058 40333.3333 23150.0000
+8059 40333.3333 23166.6667
+8060 40333.3333 23233.3333
+8061 40333.3333 23266.6667
+8062 40333.3333 23400.0000
+8063 40333.3333 23616.6667
+8064 40333.3333 23650.0000
+8065 40333.3333 23716.6667
+8066 40333.3333 23916.6667
+8067 40333.3333 23983.3333
+8068 40350.0000 20933.3333
+8069 40350.0000 21083.3333
+8070 40350.0000 21333.3333
+8071 40350.0000 21400.0000
+8072 40350.0000 21516.6667
+8073 40350.0000 21716.6667
+8074 40350.0000 21816.6667
+8075 40350.0000 21833.3333
+8076 40350.0000 21866.6667
+8077 40350.0000 21916.6667
+8078 40350.0000 21933.3333
+8079 40350.0000 21950.0000
+8080 40350.0000 21966.6667
+8081 40350.0000 22033.3333
+8082 40350.0000 22200.0000
+8083 40350.0000 22433.3333
+8084 40350.0000 22500.0000
+8085 40350.0000 22550.0000
+8086 40350.0000 23016.6667
+8087 40350.0000 23133.3333
+8088 40350.0000 23183.3333
+8089 40350.0000 23233.3333
+8090 40350.0000 23316.6667
+8091 40350.0000 23583.3333
+8092 40350.0000 23733.3333
+8093 40366.6667 21016.6667
+8094 40366.6667 21116.6667
+8095 40366.6667 21150.0000
+8096 40366.6667 21183.3333
+8097 40366.6667 21200.0000
+8098 40366.6667 21233.3333
+8099 40366.6667 21316.6667
+8100 40366.6667 21350.0000
+8101 40366.6667 21433.3333
+8102 40366.6667 21466.6667
+8103 40366.6667 21983.3333
+8104 40366.6667 22066.6667
+8105 40366.6667 22466.6667
+8106 40366.6667 22583.3333
+8107 40366.6667 22616.6667
+8108 40366.6667 23050.0000
+8109 40366.6667 23100.0000
+8110 40366.6667 23166.6667
+8111 40366.6667 23233.3333
+8112 40366.6667 23266.6667
+8113 40366.6667 23283.3333
+8114 40366.6667 23533.3333
+8115 40366.6667 23583.3333
+8116 40366.6667 23650.0000
+8117 40366.6667 23666.6667
+8118 40366.6667 23700.0000
+8119 40366.6667 23833.3333
+8120 40366.6667 23883.3333
+8121 40383.3333 20833.3333
+8122 40383.3333 20950.0000
+8123 40383.3333 21000.0000
+8124 40383.3333 21100.0000
+8125 40383.3333 21166.6667
+8126 40383.3333 21200.0000
+8127 40383.3333 21300.0000
+8128 40383.3333 21316.6667
+8129 40383.3333 21350.0000
+8130 40383.3333 21700.0000
+8131 40383.3333 21716.6667
+8132 40383.3333 21766.6667
+8133 40383.3333 21966.6667
+8134 40383.3333 21983.3333
+8135 40383.3333 22000.0000
+8136 40383.3333 22216.6667
+8137 40383.3333 22516.6667
+8138 40383.3333 22633.3333
+8139 40383.3333 23050.0000
+8140 40383.3333 23083.3333
+8141 40383.3333 23450.0000
+8142 40383.3333 23616.6667
+8143 40383.3333 23916.6667
+8144 40383.3333 23983.3333
+8145 40400.0000 21000.0000
+8146 40400.0000 21133.3333
+8147 40400.0000 21166.6667
+8148 40400.0000 21250.0000
+8149 40400.0000 21933.3333
+8150 40400.0000 22150.0000
+8151 40400.0000 22383.3333
+8152 40400.0000 22550.0000
+8153 40400.0000 22900.0000
+8154 40400.0000 23150.0000
+8155 40400.0000 23200.0000
+8156 40400.0000 23800.0000
+8157 40400.0000 23883.3333
+8158 40416.6667 20883.3333
+8159 40416.6667 20966.6667
+8160 40416.6667 21066.6667
+8161 40416.6667 21233.3333
+8162 40416.6667 21283.3333
+8163 40416.6667 21300.0000
+8164 40416.6667 21383.3333
+8165 40416.6667 21516.6667
+8166 40416.6667 21683.3333
+8167 40416.6667 21766.6667
+8168 40416.6667 21916.6667
+8169 40416.6667 22116.6667
+8170 40416.6667 22233.3333
+8171 40416.6667 22300.0000
+8172 40416.6667 22450.0000
+8173 40416.6667 22466.6667
+8174 40416.6667 22550.0000
+8175 40416.6667 22600.0000
+8176 40416.6667 23000.0000
+8177 40416.6667 23100.0000
+8178 40416.6667 23133.3333
+8179 40416.6667 23250.0000
+8180 40416.6667 23583.3333
+8181 40416.6667 24000.0000
+8182 40433.3333 21033.3333
+8183 40433.3333 21066.6667
+8184 40433.3333 21083.3333
+8185 40433.3333 21116.6667
+8186 40433.3333 21266.6667
+8187 40433.3333 21333.3333
+8188 40433.3333 21500.0000
+8189 40433.3333 21866.6667
+8190 40433.3333 21900.0000
+8191 40433.3333 22183.3333
+8192 40433.3333 22583.3333
+8193 40433.3333 22933.3333
+8194 40433.3333 23033.3333
+8195 40433.3333 23100.0000
+8196 40433.3333 23133.3333
+8197 40433.3333 23316.6667
+8198 40433.3333 23416.6667
+8199 40433.3333 23516.6667
+8200 40433.3333 25533.3333
+8201 40450.0000 20850.0000
+8202 40450.0000 20933.3333
+8203 40450.0000 21133.3333
+8204 40450.0000 21166.6667
+8205 40450.0000 21183.3333
+8206 40450.0000 21216.6667
+8207 40450.0000 21333.3333
+8208 40450.0000 21433.3333
+8209 40450.0000 21516.6667
+8210 40450.0000 21733.3333
+8211 40450.0000 21800.0000
+8212 40450.0000 21833.3333
+8213 40450.0000 22266.6667
+8214 40450.0000 22383.3333
+8215 40450.0000 22450.0000
+8216 40450.0000 22583.3333
+8217 40450.0000 23033.3333
+8218 40450.0000 23683.3333
+8219 40450.0000 25516.6667
+8220 40466.6667 20866.6667
+8221 40466.6667 20900.0000
+8222 40466.6667 20966.6667
+8223 40466.6667 21000.0000
+8224 40466.6667 21066.6667
+8225 40466.6667 21100.0000
+8226 40466.6667 21266.6667
+8227 40466.6667 21300.0000
+8228 40466.6667 21666.6667
+8229 40466.6667 21766.6667
+8230 40466.6667 21866.6667
+8231 40466.6667 22083.3333
+8232 40466.6667 22166.6667
+8233 40466.6667 22550.0000
+8234 40466.6667 22583.3333
+8235 40466.6667 22866.6667
+8236 40466.6667 22950.0000
+8237 40466.6667 22966.6667
+8238 40466.6667 22983.3333
+8239 40466.6667 23000.0000
+8240 40466.6667 23083.3333
+8241 40466.6667 23133.3333
+8242 40466.6667 23183.3333
+8243 40466.6667 23283.3333
+8244 40466.6667 23383.3333
+8245 40466.6667 25500.0000
+8246 40483.3333 20983.3333
+8247 40483.3333 21016.6667
+8248 40483.3333 21133.3333
+8249 40483.3333 21166.6667
+8250 40483.3333 21183.3333
+8251 40483.3333 21216.6667
+8252 40483.3333 21283.3333
+8253 40483.3333 21550.0000
+8254 40483.3333 21566.6667
+8255 40483.3333 21600.0000
+8256 40483.3333 21633.3333
+8257 40483.3333 21716.6667
+8258 40483.3333 21816.6667
+8259 40483.3333 22116.6667
+8260 40483.3333 22216.6667
+8261 40483.3333 22233.3333
+8262 40483.3333 22316.6667
+8263 40483.3333 22350.0000
+8264 40483.3333 22483.3333
+8265 40483.3333 22833.3333
+8266 40483.3333 22866.6667
+8267 40483.3333 23016.6667
+8268 40483.3333 23050.0000
+8269 40483.3333 23133.3333
+8270 40483.3333 23600.0000
+8271 40483.3333 25466.6667
+8272 40483.3333 25516.6667
+8273 40500.0000 21050.0000
+8274 40500.0000 21166.6667
+8275 40500.0000 21216.6667
+8276 40500.0000 21250.0000
+8277 40500.0000 21383.3333
+8278 40500.0000 21533.3333
+8279 40500.0000 21766.6667
+8280 40500.0000 21816.6667
+8281 40500.0000 21850.0000
+8282 40500.0000 22183.3333
+8283 40500.0000 22250.0000
+8284 40500.0000 22416.6667
+8285 40500.0000 22433.3333
+8286 40500.0000 22550.0000
+8287 40500.0000 22833.3333
+8288 40500.0000 22883.3333
+8289 40500.0000 22916.6667
+8290 40500.0000 22933.3333
+8291 40500.0000 22983.3333
+8292 40500.0000 23383.3333
+8293 40500.0000 23433.3333
+8294 40500.0000 23450.0000
+8295 40500.0000 23650.0000
+8296 40500.0000 25533.3333
+8297 40516.6667 21000.0000
+8298 40516.6667 21050.0000
+8299 40516.6667 21083.3333
+8300 40516.6667 21200.0000
+8301 40516.6667 21266.6667
+8302 40516.6667 21316.6667
+8303 40516.6667 21416.6667
+8304 40516.6667 21550.0000
+8305 40516.6667 21683.3333
+8306 40516.6667 21750.0000
+8307 40516.6667 22083.3333
+8308 40516.6667 22200.0000
+8309 40516.6667 22233.3333
+8310 40516.6667 22383.3333
+8311 40516.6667 22400.0000
+8312 40516.6667 22500.0000
+8313 40516.6667 22966.6667
+8314 40516.6667 23116.6667
+8315 40516.6667 23216.6667
+8316 40516.6667 23283.3333
+8317 40516.6667 23683.3333
+8318 40516.6667 23833.3333
+8319 40533.3333 21016.6667
+8320 40533.3333 21033.3333
+8321 40533.3333 21116.6667
+8322 40533.3333 21183.3333
+8323 40533.3333 21216.6667
+8324 40533.3333 21466.6667
+8325 40533.3333 21500.0000
+8326 40533.3333 21600.0000
+8327 40533.3333 22133.3333
+8328 40533.3333 22266.6667
+8329 40533.3333 22316.6667
+8330 40533.3333 22433.3333
+8331 40533.3333 23050.0000
+8332 40533.3333 23750.0000
+8333 40533.3333 23766.6667
+8334 40550.0000 21350.0000
+8335 40550.0000 21400.0000
+8336 40550.0000 21433.3333
+8337 40550.0000 21716.6667
+8338 40550.0000 21750.0000
+8339 40550.0000 22033.3333
+8340 40550.0000 22250.0000
+8341 40550.0000 22266.6667
+8342 40550.0000 22316.6667
+8343 40550.0000 22400.0000
+8344 40550.0000 22416.6667
+8345 40550.0000 22450.0000
+8346 40550.0000 22466.6667
+8347 40550.0000 22500.0000
+8348 40550.0000 23016.6667
+8349 40550.0000 23050.0000
+8350 40550.0000 23133.3333
+8351 40550.0000 23166.6667
+8352 40550.0000 23300.0000
+8353 40550.0000 23416.6667
+8354 40550.0000 23450.0000
+8355 40550.0000 23583.3333
+8356 40550.0000 23850.0000
+8357 40566.6667 21250.0000
+8358 40566.6667 21266.6667
+8359 40566.6667 21316.6667
+8360 40566.6667 21433.3333
+8361 40566.6667 21600.0000
+8362 40566.6667 21700.0000
+8363 40566.6667 22116.6667
+8364 40566.6667 22150.0000
+8365 40566.6667 22183.3333
+8366 40566.6667 22200.0000
+8367 40566.6667 22216.6667
+8368 40566.6667 22233.3333
+8369 40566.6667 22333.3333
+8370 40566.6667 22350.0000
+8371 40566.6667 22366.6667
+8372 40566.6667 22516.6667
+8373 40566.6667 22550.0000
+8374 40566.6667 22583.3333
+8375 40566.6667 23100.0000
+8376 40566.6667 23283.3333
+8377 40566.6667 23350.0000
+8378 40566.6667 23366.6667
+8379 40566.6667 23466.6667
+8380 40566.6667 23666.6667
+8381 40583.3333 21066.6667
+8382 40583.3333 21083.3333
+8383 40583.3333 21150.0000
+8384 40583.3333 21300.0000
+8385 40583.3333 21400.0000
+8386 40583.3333 21483.3333
+8387 40583.3333 22066.6667
+8388 40583.3333 22250.0000
+8389 40583.3333 22300.0000
+8390 40583.3333 22400.0000
+8391 40583.3333 22516.6667
+8392 40583.3333 22600.0000
+8393 40583.3333 22966.6667
+8394 40583.3333 23033.3333
+8395 40583.3333 23216.6667
+8396 40583.3333 23350.0000
+8397 40583.3333 23400.0000
+8398 40583.3333 23416.6667
+8399 40583.3333 23433.3333
+8400 40583.3333 24650.0000
+8401 40600.0000 21266.6667
+8402 40600.0000 21366.6667
+8403 40600.0000 21616.6667
+8404 40600.0000 21783.3333
+8405 40600.0000 22133.3333
+8406 40600.0000 22200.0000
+8407 40600.0000 22216.6667
+8408 40600.0000 22233.3333
+8409 40600.0000 22333.3333
+8410 40600.0000 22350.0000
+8411 40600.0000 22366.6667
+8412 40600.0000 22450.0000
+8413 40600.0000 22483.3333
+8414 40600.0000 22500.0000
+8415 40600.0000 22550.0000
+8416 40600.0000 22983.3333
+8417 40600.0000 23100.0000
+8418 40600.0000 23183.3333
+8419 40600.0000 23450.0000
+8420 40600.0000 23483.3333
+8421 40600.0000 23750.0000
+8422 40600.0000 23783.3333
+8423 40600.0000 24750.0000
+8424 40616.6667 21216.6667
+8425 40616.6667 21316.6667
+8426 40616.6667 21350.0000
+8427 40616.6667 21466.6667
+8428 40616.6667 21500.0000
+8429 40616.6667 21750.0000
+8430 40616.6667 22183.3333
+8431 40616.6667 22366.6667
+8432 40616.6667 22400.0000
+8433 40616.6667 22433.3333
+8434 40616.6667 22683.3333
+8435 40616.6667 22700.0000
+8436 40616.6667 23433.3333
+8437 40616.6667 23566.6667
+8438 40633.3333 21083.3333
+8439 40633.3333 21183.3333
+8440 40633.3333 21233.3333
+8441 40633.3333 21283.3333
+8442 40633.3333 21566.6667
+8443 40633.3333 21583.3333
+8444 40633.3333 21700.0000
+8445 40633.3333 21833.3333
+8446 40633.3333 22066.6667
+8447 40633.3333 22133.3333
+8448 40633.3333 22383.3333
+8449 40633.3333 22450.0000
+8450 40633.3333 22500.0000
+8451 40633.3333 22733.3333
+8452 40633.3333 22933.3333
+8453 40633.3333 22950.0000
+8454 40633.3333 23183.3333
+8455 40633.3333 23216.6667
+8456 40633.3333 23250.0000
+8457 40633.3333 23266.6667
+8458 40633.3333 23350.0000
+8459 40633.3333 23450.0000
+8460 40633.3333 23483.3333
+8461 40633.3333 23616.6667
+8462 40633.3333 24566.6667
+8463 40633.3333 24583.3333
+8464 40650.0000 21066.6667
+8465 40650.0000 21233.3333
+8466 40650.0000 21500.0000
+8467 40650.0000 21700.0000
+8468 40650.0000 21766.6667
+8469 40650.0000 22116.6667
+8470 40650.0000 22166.6667
+8471 40650.0000 22216.6667
+8472 40650.0000 22233.3333
+8473 40650.0000 22433.3333
+8474 40650.0000 22533.3333
+8475 40650.0000 22866.6667
+8476 40650.0000 22883.3333
+8477 40650.0000 22900.0000
+8478 40650.0000 23033.3333
+8479 40650.0000 23300.0000
+8480 40650.0000 23400.0000
+8481 40650.0000 23483.3333
+8482 40650.0000 23616.6667
+8483 40650.0000 23700.0000
+8484 40650.0000 24516.6667
+8485 40666.6667 21100.0000
+8486 40666.6667 21150.0000
+8487 40666.6667 21266.6667
+8488 40666.6667 21333.3333
+8489 40666.6667 21550.0000
+8490 40666.6667 21583.3333
+8491 40666.6667 21600.0000
+8492 40666.6667 21633.3333
+8493 40666.6667 21833.3333
+8494 40666.6667 22050.0000
+8495 40666.6667 22450.0000
+8496 40666.6667 22516.6667
+8497 40666.6667 22600.0000
+8498 40666.6667 22633.3333
+8499 40666.6667 22716.6667
+8500 40666.6667 22800.0000
+8501 40666.6667 22900.0000
+8502 40666.6667 22916.6667
+8503 40666.6667 22933.3333
+8504 40666.6667 22950.0000
+8505 40666.6667 22983.3333
+8506 40666.6667 23116.6667
+8507 40666.6667 23333.3333
+8508 40666.6667 23700.0000
+8509 40666.6667 24650.0000
+8510 40666.6667 24700.0000
+8511 40666.6667 24766.6667
+8512 40683.3333 21450.0000
+8513 40683.3333 21616.6667
+8514 40683.3333 21666.6667
+8515 40683.3333 21683.3333
+8516 40683.3333 21716.6667
+8517 40683.3333 22133.3333
+8518 40683.3333 22200.0000
+8519 40683.3333 22250.0000
+8520 40683.3333 22266.6667
+8521 40683.3333 22300.0000
+8522 40683.3333 22533.3333
+8523 40683.3333 22850.0000
+8524 40683.3333 22950.0000
+8525 40683.3333 23000.0000
+8526 40683.3333 23083.3333
+8527 40683.3333 23250.0000
+8528 40683.3333 23283.3333
+8529 40683.3333 23566.6667
+8530 40683.3333 23616.6667
+8531 40683.3333 24616.6667
+8532 40700.0000 21166.6667
+8533 40700.0000 21266.6667
+8534 40700.0000 21300.0000
+8535 40700.0000 21400.0000
+8536 40700.0000 21466.6667
+8537 40700.0000 21516.6667
+8538 40700.0000 21783.3333
+8539 40700.0000 21900.0000
+8540 40700.0000 21933.3333
+8541 40700.0000 22016.6667
+8542 40700.0000 22100.0000
+8543 40700.0000 22266.6667
+8544 40700.0000 22550.0000
+8545 40700.0000 22600.0000
+8546 40700.0000 23216.6667
+8547 40700.0000 23333.3333
+8548 40700.0000 23433.3333
+8549 40700.0000 23650.0000
+8550 40700.0000 24550.0000
+8551 40700.0000 24766.6667
+8552 40716.6667 21050.0000
+8553 40716.6667 21100.0000
+8554 40716.6667 21150.0000
+8555 40716.6667 21200.0000
+8556 40716.6667 21266.6667
+8557 40716.6667 21366.6667
+8558 40716.6667 21466.6667
+8559 40716.6667 21783.3333
+8560 40716.6667 22000.0000
+8561 40716.6667 22083.3333
+8562 40716.6667 22116.6667
+8563 40716.6667 22150.0000
+8564 40716.6667 22166.6667
+8565 40716.6667 22216.6667
+8566 40716.6667 22300.0000
+8567 40716.6667 22633.3333
+8568 40716.6667 22733.3333
+8569 40716.6667 22783.3333
+8570 40716.6667 23000.0000
+8571 40716.6667 23050.0000
+8572 40716.6667 23183.3333
+8573 40716.6667 23283.3333
+8574 40716.6667 23383.3333
+8575 40716.6667 23700.0000
+8576 40716.6667 24533.3333
+8577 40716.6667 24550.0000
+8578 40716.6667 24583.3333
+8579 40716.6667 24616.6667
+8580 40716.6667 24733.3333
+8581 40733.3333 21016.6667
+8582 40733.3333 21133.3333
+8583 40733.3333 21200.0000
+8584 40733.3333 21400.0000
+8585 40733.3333 21433.3333
+8586 40733.3333 21483.3333
+8587 40733.3333 21666.6667
+8588 40733.3333 21750.0000
+8589 40733.3333 21816.6667
+8590 40733.3333 22133.3333
+8591 40733.3333 22216.6667
+8592 40733.3333 22600.0000
+8593 40733.3333 22700.0000
+8594 40733.3333 22883.3333
+8595 40733.3333 22916.6667
+8596 40733.3333 23250.0000
+8597 40733.3333 23550.0000
+8598 40733.3333 24116.6667
+8599 40733.3333 24616.6667
+8600 40733.3333 24733.3333
+8601 40750.0000 21000.0000
+8602 40750.0000 21066.6667
+8603 40750.0000 21116.6667
+8604 40750.0000 21300.0000
+8605 40750.0000 21466.6667
+8606 40750.0000 21516.6667
+8607 40750.0000 21633.3333
+8608 40750.0000 22016.6667
+8609 40750.0000 22216.6667
+8610 40750.0000 22250.0000
+8611 40750.0000 22283.3333
+8612 40750.0000 22333.3333
+8613 40750.0000 22583.3333
+8614 40750.0000 22633.3333
+8615 40750.0000 22766.6667
+8616 40750.0000 22850.0000
+8617 40750.0000 22983.3333
+8618 40750.0000 23033.3333
+8619 40750.0000 23066.6667
+8620 40750.0000 23133.3333
+8621 40750.0000 23383.3333
+8622 40750.0000 23466.6667
+8623 40750.0000 23583.3333
+8624 40750.0000 23983.3333
+8625 40750.0000 24583.3333
+8626 40750.0000 24633.3333
+8627 40758.0556 24577.5000
+8628 40766.6667 21033.3333
+8629 40766.6667 21150.0000
+8630 40766.6667 21200.0000
+8631 40766.6667 21350.0000
+8632 40766.6667 21400.0000
+8633 40766.6667 21533.3333
+8634 40766.6667 21616.6667
+8635 40766.6667 21900.0000
+8636 40766.6667 22050.0000
+8637 40766.6667 22066.6667
+8638 40766.6667 22116.6667
+8639 40766.6667 22150.0000
+8640 40766.6667 22166.6667
+8641 40766.6667 22183.3333
+8642 40766.6667 22250.0000
+8643 40766.6667 22316.6667
+8644 40766.6667 22500.0000
+8645 40766.6667 22533.3333
+8646 40766.6667 22583.3333
+8647 40766.6667 22716.6667
+8648 40766.6667 22933.3333
+8649 40766.6667 23033.3333
+8650 40766.6667 23083.3333
+8651 40766.6667 23216.6667
+8652 40766.6667 23250.0000
+8653 40766.6667 23383.3333
+8654 40766.6667 23450.0000
+8655 40766.6667 23483.3333
+8656 40766.6667 23583.3333
+8657 40766.6667 24633.3333
+8658 40770.0000 24723.8889
+8659 40778.0556 24709.4444
+8660 40778.8889 24611.6667
+8661 40783.3333 21083.3333
+8662 40783.3333 21133.3333
+8663 40783.3333 21250.0000
+8664 40783.3333 21300.0000
+8665 40783.3333 21400.0000
+8666 40783.3333 21466.6667
+8667 40783.3333 21483.3333
+8668 40783.3333 21550.0000
+8669 40783.3333 21683.3333
+8670 40783.3333 22083.3333
+8671 40783.3333 22166.6667
+8672 40783.3333 22266.6667
+8673 40783.3333 22483.3333
+8674 40783.3333 22583.3333
+8675 40783.3333 22883.3333
+8676 40783.3333 22966.6667
+8677 40783.3333 23533.3333
+8678 40783.3333 23850.0000
+8679 40783.3333 23950.0000
+8680 40783.3333 24033.3333
+8681 40800.0000 21150.0000
+8682 40800.0000 21466.6667
+8683 40800.0000 21516.6667
+8684 40800.0000 21583.3333
+8685 40800.0000 21783.3333
+8686 40800.0000 21833.3333
+8687 40800.0000 21850.0000
+8688 40800.0000 21866.6667
+8689 40800.0000 21916.6667
+8690 40800.0000 22000.0000
+8691 40800.0000 22033.3333
+8692 40800.0000 22050.0000
+8693 40800.0000 22216.6667
+8694 40800.0000 22233.3333
+8695 40800.0000 22333.3333
+8696 40800.0000 22366.6667
+8697 40800.0000 22416.6667
+8698 40800.0000 22466.6667
+8699 40800.0000 22566.6667
+8700 40800.0000 22666.6667
+8701 40800.0000 22766.6667
+8702 40800.0000 22783.3333
+8703 40800.0000 22833.3333
+8704 40800.0000 22866.6667
+8705 40800.0000 22900.0000
+8706 40800.0000 23116.6667
+8707 40800.0000 23466.6667
+8708 40800.0000 23850.0000
+8709 40800.0000 23916.6667
+8710 40800.0000 23950.0000
+8711 40816.6667 21116.6667
+8712 40816.6667 21133.3333
+8713 40816.6667 21300.0000
+8714 40816.6667 21400.0000
+8715 40816.6667 21933.3333
+8716 40816.6667 22066.6667
+8717 40816.6667 22100.0000
+8718 40816.6667 22166.6667
+8719 40816.6667 22183.3333
+8720 40816.6667 22266.6667
+8721 40816.6667 22350.0000
+8722 40816.6667 22416.6667
+8723 40816.6667 22533.3333
+8724 40816.6667 22666.6667
+8725 40816.6667 22700.0000
+8726 40816.6667 22733.3333
+8727 40816.6667 23033.3333
+8728 40816.6667 23116.6667
+8729 40816.6667 23150.0000
+8730 40816.6667 23283.3333
+8731 40816.6667 23300.0000
+8732 40816.6667 23350.0000
+8733 40816.6667 23516.6667
+8734 40816.6667 23566.6667
+8735 40816.6667 23650.0000
+8736 40816.6667 24150.0000
+8737 40816.6667 24250.0000
+8738 40833.3333 21033.3333
+8739 40833.3333 21133.3333
+8740 40833.3333 21150.0000
+8741 40833.3333 21166.6667
+8742 40833.3333 21300.0000
+8743 40833.3333 21400.0000
+8744 40833.3333 21500.0000
+8745 40833.3333 21516.6667
+8746 40833.3333 21533.3333
+8747 40833.3333 21583.3333
+8748 40833.3333 21766.6667
+8749 40833.3333 22000.0000
+8750 40833.3333 22200.0000
+8751 40833.3333 22250.0000
+8752 40833.3333 22300.0000
+8753 40833.3333 22350.0000
+8754 40833.3333 22383.3333
+8755 40833.3333 22450.0000
+8756 40833.3333 22600.0000
+8757 40833.3333 22650.0000
+8758 40833.3333 22783.3333
+8759 40833.3333 22850.0000
+8760 40833.3333 22983.3333
+8761 40833.3333 23200.0000
+8762 40833.3333 23783.3333
+8763 40833.3333 23850.0000
+8764 40833.3333 23933.3333
+8765 40833.3333 24000.0000
+8766 40833.3333 24016.6667
+8767 40833.3333 24200.0000
+8768 40838.8889 24303.6111
+8769 40850.0000 21316.6667
+8770 40850.0000 21383.3333
+8771 40850.0000 21400.0000
+8772 40850.0000 21816.6667
+8773 40850.0000 21850.0000
+8774 40850.0000 21950.0000
+8775 40850.0000 22100.0000
+8776 40850.0000 22216.6667
+8777 40850.0000 22250.0000
+8778 40850.0000 22283.3333
+8779 40850.0000 22300.0000
+8780 40850.0000 22500.0000
+8781 40850.0000 22716.6667
+8782 40850.0000 22833.3333
+8783 40850.0000 22916.6667
+8784 40850.0000 23166.6667
+8785 40850.0000 23650.0000
+8786 40850.0000 23733.3333
+8787 40850.0000 24066.6667
+8788 40850.0000 24150.0000
+8789 40850.0000 24166.6667
+8790 40850.0000 24250.0000
+8791 40850.0000 25750.0000
+8792 40850.0000 25833.3333
+8793 40850.0000 25866.6667
+8794 40850.0000 25933.3333
+8795 40850.0000 26100.0000
+8796 40858.3333 24706.1111
+8797 40864.4444 24315.8333
+8798 40866.6667 21350.0000
+8799 40866.6667 21366.6667
+8800 40866.6667 21450.0000
+8801 40866.6667 21466.6667
+8802 40866.6667 21500.0000
+8803 40866.6667 21600.0000
+8804 40866.6667 21616.6667
+8805 40866.6667 21633.3333
+8806 40866.6667 22050.0000
+8807 40866.6667 22216.6667
+8808 40866.6667 22416.6667
+8809 40866.6667 22466.6667
+8810 40866.6667 22533.3333
+8811 40866.6667 22583.3333
+8812 40866.6667 22683.3333
+8813 40866.6667 22816.6667
+8814 40866.6667 22883.3333
+8815 40866.6667 22916.6667
+8816 40866.6667 22966.6667
+8817 40866.6667 23000.0000
+8818 40866.6667 23583.3333
+8819 40866.6667 23616.6667
+8820 40866.6667 23766.6667
+8821 40866.6667 23900.0000
+8822 40866.6667 23933.3333
+8823 40866.6667 24083.3333
+8824 40866.6667 24116.6667
+8825 40866.6667 24150.0000
+8826 40866.6667 24166.6667
+8827 40866.6667 24183.3333
+8828 40866.6667 24200.0000
+8829 40866.6667 24283.3333
+8830 40866.6667 25683.3333
+8831 40866.6667 25700.0000
+8832 40866.6667 25900.0000
+8833 40866.6667 25983.3333
+8834 40866.6667 26000.0000
+8835 40866.6667 26116.6667
+8836 40875.5556 24706.9444
+8837 40878.6111 24731.3889
+8838 40883.3333 21383.3333
+8839 40883.3333 21400.0000
+8840 40883.3333 21516.6667
+8841 40883.3333 21683.3333
+8842 40883.3333 21966.6667
+8843 40883.3333 22033.3333
+8844 40883.3333 22416.6667
+8845 40883.3333 22516.6667
+8846 40883.3333 22566.6667
+8847 40883.3333 22633.3333
+8848 40883.3333 22650.0000
+8849 40883.3333 22733.3333
+8850 40883.3333 22816.6667
+8851 40883.3333 22866.6667
+8852 40883.3333 22916.6667
+8853 40883.3333 22950.0000
+8854 40883.3333 23100.0000
+8855 40883.3333 23183.3333
+8856 40883.3333 23233.3333
+8857 40883.3333 23250.0000
+8858 40883.3333 23600.0000
+8859 40883.3333 23616.6667
+8860 40883.3333 23633.3333
+8861 40883.3333 23700.0000
+8862 40883.3333 23766.6667
+8863 40883.3333 23950.0000
+8864 40883.3333 24166.6667
+8865 40883.3333 24183.3333
+8866 40883.3333 24200.0000
+8867 40883.3333 24233.3333
+8868 40883.3333 25516.6667
+8869 40883.3333 25733.3333
+8870 40883.3333 25866.6667
+8871 40883.3333 25983.3333
+8872 40883.3333 26050.0000
+8873 40900.0000 21466.6667
+8874 40900.0000 21516.6667
+8875 40900.0000 22050.0000
+8876 40900.0000 22150.0000
+8877 40900.0000 22183.3333
+8878 40900.0000 22333.3333
+8879 40900.0000 22450.0000
+8880 40900.0000 22483.3333
+8881 40900.0000 22550.0000
+8882 40900.0000 22633.3333
+8883 40900.0000 22783.3333
+8884 40900.0000 22966.6667
+8885 40900.0000 22983.3333
+8886 40900.0000 23500.0000
+8887 40900.0000 23550.0000
+8888 40900.0000 23616.6667
+8889 40900.0000 23700.0000
+8890 40900.0000 23750.0000
+8891 40900.0000 23816.6667
+8892 40900.0000 24216.6667
+8893 40900.0000 25616.6667
+8894 40900.0000 25833.3333
+8895 40900.0000 25916.6667
+8896 40900.0000 26000.0000
+8897 40900.0000 26050.0000
+8898 40900.0000 26166.6667
+8899 40900.0000 26216.6667
+8900 40903.3333 24348.0556
+8901 40904.1667 24670.8333
+8902 40907.5000 24708.3333
+8903 40908.8889 24657.2222
+8904 40916.6667 21416.6667
+8905 40916.6667 21683.3333
+8906 40916.6667 21933.3333
+8907 40916.6667 21950.0000
+8908 40916.6667 22400.0000
+8909 40916.6667 22700.0000
+8910 40916.6667 22750.0000
+8911 40916.6667 22766.6667
+8912 40916.6667 22866.6667
+8913 40916.6667 22950.0000
+8914 40916.6667 23050.0000
+8915 40916.6667 23083.3333
+8916 40916.6667 23300.0000
+8917 40916.6667 23483.3333
+8918 40916.6667 23566.6667
+8919 40916.6667 23650.0000
+8920 40916.6667 23866.6667
+8921 40916.6667 23983.3333
+8922 40916.6667 24216.6667
+8923 40916.6667 24250.0000
+8924 40916.6667 25516.6667
+8925 40916.6667 25650.0000
+8926 40916.6667 25666.6667
+8927 40916.6667 25700.0000
+8928 40916.6667 25866.6667
+8929 40916.6667 25983.3333
+8930 40933.3333 21966.6667
+8931 40933.3333 22016.6667
+8932 40933.3333 22100.0000
+8933 40933.3333 22416.6667
+8934 40933.3333 22550.0000
+8935 40933.3333 22566.6667
+8936 40933.3333 22966.6667
+8937 40933.3333 23183.3333
+8938 40933.3333 23233.3333
+8939 40933.3333 23433.3333
+8940 40933.3333 23566.6667
+8941 40933.3333 24300.0000
+8942 40933.3333 24350.0000
+8943 40933.3333 24716.6667
+8944 40933.3333 24733.3333
+8945 40933.3333 24816.6667
+8946 40933.3333 24833.3333
+8947 40933.3333 24983.3333
+8948 40933.3333 25566.6667
+8949 40933.3333 25683.3333
+8950 40933.3333 25916.6667
+8951 40933.3333 26116.6667
+8952 40933.3333 26166.6667
+8953 40933.3333 26216.6667
+8954 40939.7222 24401.9444
+8955 40950.0000 21933.3333
+8956 40950.0000 21966.6667
+8957 40950.0000 22050.0000
+8958 40950.0000 22116.6667
+8959 40950.0000 22200.0000
+8960 40950.0000 22416.6667
+8961 40950.0000 22450.0000
+8962 40950.0000 22500.0000
+8963 40950.0000 22566.6667
+8964 40950.0000 22683.3333
+8965 40950.0000 22750.0000
+8966 40950.0000 22800.0000
+8967 40950.0000 22816.6667
+8968 40950.0000 22900.0000
+8969 40950.0000 22933.3333
+8970 40950.0000 23350.0000
+8971 40950.0000 23400.0000
+8972 40950.0000 23416.6667
+8973 40950.0000 23466.6667
+8974 40950.0000 23500.0000
+8975 40950.0000 23883.3333
+8976 40950.0000 23916.6667
+8977 40950.0000 24000.0000
+8978 40950.0000 24150.0000
+8979 40950.0000 24183.3333
+8980 40950.0000 24216.6667
+8981 40950.0000 24433.3333
+8982 40950.0000 24633.3333
+8983 40950.0000 24783.3333
+8984 40950.0000 24866.6667
+8985 40950.0000 25166.6667
+8986 40950.0000 25433.3333
+8987 40950.0000 25466.6667
+8988 40950.0000 25566.6667
+8989 40950.0000 25650.0000
+8990 40950.0000 26000.0000
+8991 40950.0000 26100.0000
+8992 40950.0000 26233.3333
+8993 40950.0000 26300.0000
+8994 40961.6667 24510.0000
+8995 40966.6667 21950.0000
+8996 40966.6667 22016.6667
+8997 40966.6667 22033.3333
+8998 40966.6667 22083.3333
+8999 40966.6667 22516.6667
+9000 40966.6667 22783.3333
+9001 40966.6667 22866.6667
+9002 40966.6667 22933.3333
+9003 40966.6667 23050.0000
+9004 40966.6667 23200.0000
+9005 40966.6667 23716.6667
+9006 40966.6667 24033.3333
+9007 40966.6667 24316.6667
+9008 40966.6667 24333.3333
+9009 40966.6667 24366.6667
+9010 40966.6667 24583.3333
+9011 40966.6667 24700.0000
+9012 40966.6667 24800.0000
+9013 40966.6667 24933.3333
+9014 40966.6667 25133.3333
+9015 40966.6667 25366.6667
+9016 40966.6667 25716.6667
+9017 40966.6667 26183.3333
+9018 40966.6667 26266.6667
+9019 40966.6667 26333.3333
+9020 40983.3333 21966.6667
+9021 40983.3333 21983.3333
+9022 40983.3333 22066.6667
+9023 40983.3333 22133.3333
+9024 40983.3333 22383.3333
+9025 40983.3333 22416.6667
+9026 40983.3333 22550.0000
+9027 40983.3333 22616.6667
+9028 40983.3333 22650.0000
+9029 40983.3333 22666.6667
+9030 40983.3333 22950.0000
+9031 40983.3333 23000.0000
+9032 40983.3333 23116.6667
+9033 40983.3333 23233.3333
+9034 40983.3333 23283.3333
+9035 40983.3333 23350.0000
+9036 40983.3333 23416.6667
+9037 40983.3333 23433.3333
+9038 40983.3333 23516.6667
+9039 40983.3333 23666.6667
+9040 40983.3333 23866.6667
+9041 40983.3333 23966.6667
+9042 40983.3333 24033.3333
+9043 40983.3333 24050.0000
+9044 40983.3333 24333.3333
+9045 40983.3333 24466.6667
+9046 40983.3333 24500.0000
+9047 40983.3333 24516.6667
+9048 40983.3333 24566.6667
+9049 40983.3333 24616.6667
+9050 40983.3333 24700.0000
+9051 40983.3333 24783.3333
+9052 40983.3333 24800.0000
+9053 40983.3333 24833.3333
+9054 40983.3333 24933.3333
+9055 40983.3333 24950.0000
+9056 40983.3333 24966.6667
+9057 40983.3333 25216.6667
+9058 40983.3333 25233.3333
+9059 40983.3333 25300.0000
+9060 40983.3333 25416.6667
+9061 40983.3333 25566.6667
+9062 40983.3333 25616.6667
+9063 40983.3333 25650.0000
+9064 40983.3333 25666.6667
+9065 40983.3333 25783.3333
+9066 40983.3333 26150.0000
+9067 40983.3333 26216.6667
+9068 40983.3333 26250.0000
+9069 41000.0000 22033.3333
+9070 41000.0000 22050.0000
+9071 41000.0000 22150.0000
+9072 41000.0000 22175.2778
+9073 41000.0000 22573.8889
+9074 41000.0000 22725.5556
+9075 41000.0000 22766.6667
+9076 41000.0000 22933.3333
+9077 41000.0000 23033.3333
+9078 41000.0000 23100.0000
+9079 41000.0000 23133.3333
+9080 41000.0000 23366.6667
+9081 41000.0000 23483.3333
+9082 41000.0000 23566.6667
+9083 41000.0000 23600.0000
+9084 41000.0000 23633.3333
+9085 41000.0000 23783.3333
+9086 41000.0000 23866.6667
+9087 41000.0000 23966.6667
+9088 41000.0000 24633.3333
+9089 41000.0000 24650.0000
+9090 41000.0000 24966.6667
+9091 41000.0000 24983.3333
+9092 41000.0000 25383.3333
+9093 41000.0000 25450.0000
+9094 41000.0000 25466.6667
+9095 41000.0000 25483.3333
+9096 41000.0000 25533.3333
+9097 41000.0000 25550.0000
+9098 41000.0000 25733.3333
+9099 41000.0000 25866.6667
+9100 41000.0000 26266.6667
+9101 41002.7778 22882.2222
+9102 41006.1111 22292.2222
+9103 41008.6111 22796.9444
+9104 41008.8889 22133.8889
+9105 41009.1667 22065.2778
+9106 41010.5556 22177.5000
+9107 41010.5556 22499.7222
+9108 41010.5556 22664.4444
+9109 41014.4444 22595.8333
+9110 41016.6667 22816.6667
+9111 41016.6667 23333.3333
+9112 41016.6667 23400.0000
+9113 41016.6667 23433.3333
+9114 41016.6667 23466.6667
+9115 41016.6667 23483.3333
+9116 41016.6667 23516.6667
+9117 41016.6667 23550.0000
+9118 41016.6667 23616.6667
+9119 41016.6667 23650.0000
+9120 41016.6667 23700.0000
+9121 41016.6667 23766.6667
+9122 41016.6667 24166.6667
+9123 41016.6667 24216.6667
+9124 41016.6667 24316.6667
+9125 41016.6667 24383.3333
+9126 41016.6667 24416.6667
+9127 41016.6667 24633.3333
+9128 41016.6667 24766.6667
+9129 41016.6667 24800.0000
+9130 41016.6667 24900.0000
+9131 41016.6667 24916.6667
+9132 41016.6667 25116.6667
+9133 41016.6667 25200.0000
+9134 41016.6667 25233.3333
+9135 41016.6667 25350.0000
+9136 41016.6667 25366.6667
+9137 41016.6667 25516.6667
+9138 41016.6667 25600.0000
+9139 41016.6667 25683.3333
+9140 41016.6667 25950.0000
+9141 41016.6667 26200.0000
+9142 41020.0000 22953.6111
+9143 41023.6111 22886.6667
+9144 41024.1667 22190.8333
+9145 41026.1111 22007.5000
+9146 41026.1111 22048.3333
+9147 41026.9444 22767.2222
+9148 41028.8889 22100.0000
+9149 41029.4444 22081.1111
+9150 41030.5556 22191.3889
+9151 41030.8333 22598.0556
+9152 41033.3333 22800.0000
+9153 41033.3333 22866.6667
+9154 41033.3333 23366.6667
+9155 41033.3333 23816.6667
+9156 41033.3333 23833.3333
+9157 41033.3333 23916.6667
+9158 41033.3333 23933.3333
+9159 41033.3333 24033.3333
+9160 41033.3333 24283.3333
+9161 41033.3333 24300.0000
+9162 41033.3333 24333.3333
+9163 41033.3333 24383.3333
+9164 41033.3333 24666.6667
+9165 41033.3333 24800.0000
+9166 41033.3333 24850.0000
+9167 41033.3333 24866.6667
+9168 41033.3333 25033.3333
+9169 41033.3333 25066.6667
+9170 41033.3333 25216.6667
+9171 41033.3333 25316.6667
+9172 41033.3333 25400.0000
+9173 41033.3333 25566.6667
+9174 41033.3333 25700.0000
+9175 41033.3333 26250.0000
+9176 41033.3333 26283.3333
+9177 41033.6111 22045.0000
+9178 41035.0000 22154.7222
+9179 41036.9444 22238.8889
+9180 41038.6111 22952.5000
+9181 41041.9444 22578.8889
+9182 41044.1667 22696.1111
+9183 41050.0000 22516.6667
+9184 41050.0000 23000.0000
+9185 41050.0000 23050.0000
+9186 41050.0000 23316.6667
+9187 41050.0000 23550.0000
+9188 41050.0000 23583.3333
+9189 41050.0000 23683.3333
+9190 41050.0000 23766.6667
+9191 41050.0000 23916.6667
+9192 41050.0000 24050.0000
+9193 41050.0000 24100.0000
+9194 41050.0000 24133.3333
+9195 41050.0000 24183.3333
+9196 41050.0000 24266.6667
+9197 41050.0000 24450.0000
+9198 41050.0000 24550.0000
+9199 41050.0000 24583.3333
+9200 41050.0000 24600.0000
+9201 41050.0000 24650.0000
+9202 41050.0000 24700.0000
+9203 41050.0000 24716.6667
+9204 41050.0000 24766.6667
+9205 41050.0000 24783.3333
+9206 41050.0000 24816.6667
+9207 41050.0000 24850.0000
+9208 41050.0000 25016.6667
+9209 41050.0000 25200.0000
+9210 41050.0000 25333.3333
+9211 41050.0000 25366.6667
+9212 41050.0000 25400.0000
+9213 41050.0000 25416.6667
+9214 41050.0000 25466.6667
+9215 41050.0000 25483.3333
+9216 41050.0000 25500.0000
+9217 41050.0000 25533.3333
+9218 41050.0000 25683.3333
+9219 41050.0000 26266.6667
+9220 41057.2222 22175.2778
+9221 41058.6111 22162.2222
+9222 41063.8889 22733.8889
+9223 41066.6667 22083.3333
+9224 41066.6667 22633.3333
+9225 41066.6667 22966.6667
+9226 41066.6667 23066.6667
+9227 41066.6667 23166.6667
+9228 41066.6667 23383.3333
+9229 41066.6667 23400.0000
+9230 41066.6667 23433.3333
+9231 41066.6667 23450.0000
+9232 41066.6667 23600.0000
+9233 41066.6667 23650.0000
+9234 41066.6667 23750.0000
+9235 41066.6667 23816.6667
+9236 41066.6667 23883.3333
+9237 41066.6667 23933.3333
+9238 41066.6667 23950.0000
+9239 41066.6667 24066.6667
+9240 41066.6667 24250.0000
+9241 41066.6667 24266.6667
+9242 41066.6667 24366.6667
+9243 41066.6667 24483.3333
+9244 41066.6667 24566.6667
+9245 41066.6667 24600.0000
+9246 41066.6667 24616.6667
+9247 41066.6667 24733.3333
+9248 41066.6667 24750.0000
+9249 41066.6667 24783.3333
+9250 41066.6667 24833.3333
+9251 41066.6667 24850.0000
+9252 41066.6667 24900.0000
+9253 41066.6667 24916.6667
+9254 41066.6667 24933.3333
+9255 41066.6667 24966.6667
+9256 41066.6667 25066.6667
+9257 41066.6667 25233.3333
+9258 41066.6667 25333.3333
+9259 41066.6667 25450.0000
+9260 41066.6667 25533.3333
+9261 41066.6667 25550.0000
+9262 41066.6667 25583.3333
+9263 41066.6667 25616.6667
+9264 41066.6667 25650.0000
+9265 41066.6667 25716.6667
+9266 41066.6667 25766.6667
+9267 41066.6667 25900.0000
+9268 41066.6667 26266.6667
+9269 41068.0556 22595.8333
+9270 41071.1111 22359.4444
+9271 41071.1111 22572.5000
+9272 41072.2222 22907.2222
+9273 41072.5000 22704.4444
+9274 41072.5000 22761.9444
+9275 41074.4444 22635.0000
+9276 41075.8333 22428.6111
+9277 41076.3889 22851.1111
+9278 41080.8333 22475.8333
+9279 41082.2222 22498.3333
+9280 41083.3333 22900.0000
+9281 41083.3333 23016.6667
+9282 41083.3333 23033.3333
+9283 41083.3333 23133.3333
+9284 41083.3333 23250.0000
+9285 41083.3333 23283.3333
+9286 41083.3333 23350.0000
+9287 41083.3333 23466.6667
+9288 41083.3333 23550.0000
+9289 41083.3333 23716.6667
+9290 41083.3333 23733.3333
+9291 41083.3333 23750.0000
+9292 41083.3333 23833.3333
+9293 41083.3333 23950.0000
+9294 41083.3333 24183.3333
+9295 41083.3333 24300.0000
+9296 41083.3333 24400.0000
+9297 41083.3333 24483.3333
+9298 41083.3333 24500.0000
+9299 41083.3333 24516.6667
+9300 41083.3333 24533.3333
+9301 41083.3333 24566.6667
+9302 41083.3333 24666.6667
+9303 41083.3333 24766.6667
+9304 41083.3333 24800.0000
+9305 41083.3333 24850.0000
+9306 41083.3333 24866.6667
+9307 41083.3333 24900.0000
+9308 41083.3333 24916.6667
+9309 41083.3333 24950.0000
+9310 41083.3333 24966.6667
+9311 41083.3333 25016.6667
+9312 41083.3333 25233.3333
+9313 41083.3333 25266.6667
+9314 41083.3333 25283.3333
+9315 41083.3333 25333.3333
+9316 41083.3333 25416.6667
+9317 41083.3333 25483.3333
+9318 41083.3333 25550.0000
+9319 41083.3333 25566.6667
+9320 41083.3333 25616.6667
+9321 41083.3333 25650.0000
+9322 41083.3333 25700.0000
+9323 41083.3333 25766.6667
+9324 41083.3333 25783.3333
+9325 41083.3333 25800.0000
+9326 41083.3333 26300.0000
+9327 41084.1667 22280.0000
+9328 41085.8333 22678.6111
+9329 41091.1111 22783.6111
+9330 41091.6667 22726.9444
+9331 41095.2778 22382.5000
+9332 41095.5556 22176.1111
+9333 41095.5556 22523.8889
+9334 41100.0000 22900.0000
+9335 41100.0000 23416.6667
+9336 41100.0000 23500.0000
+9337 41100.0000 23583.3333
+9338 41100.0000 23616.6667
+9339 41100.0000 23650.0000
+9340 41100.0000 23683.3333
+9341 41100.0000 23900.0000
+9342 41100.0000 24083.3333
+9343 41100.0000 24116.6667
+9344 41100.0000 24183.3333
+9345 41100.0000 24233.3333
+9346 41100.0000 24283.3333
+9347 41100.0000 24300.0000
+9348 41100.0000 24533.3333
+9349 41100.0000 24600.0000
+9350 41100.0000 24633.3333
+9351 41100.0000 24783.3333
+9352 41100.0000 24800.0000
+9353 41100.0000 24900.0000
+9354 41100.0000 24916.6667
+9355 41100.0000 24933.3333
+9356 41100.0000 25150.0000
+9357 41100.0000 25200.0000
+9358 41100.0000 25300.0000
+9359 41100.0000 25350.0000
+9360 41100.0000 25383.3333
+9361 41100.0000 25450.0000
+9362 41100.0000 25583.3333
+9363 41100.0000 25766.6667
+9364 41100.0000 25783.3333
+9365 41102.5000 22920.8333
+9366 41103.3333 22208.0556
+9367 41103.6111 22262.7778
+9368 41103.6111 22845.0000
+9369 41104.4444 22623.0556
+9370 41105.0000 22481.9444
+9371 41105.5556 22557.7778
+9372 41106.1111 22733.3333
+9373 41108.0556 22993.8889
+9374 41109.7222 22046.9444
+9375 41111.6667 22271.3889
+9376 41114.7222 22897.5000
+9377 41115.5556 22794.7222
+9378 41116.6667 22833.3333
+9379 41116.6667 23066.6667
+9380 41116.6667 23183.3333
+9381 41116.6667 23250.0000
+9382 41116.6667 23300.0000
+9383 41116.6667 23333.3333
+9384 41116.6667 23383.3333
+9385 41116.6667 23466.6667
+9386 41116.6667 23516.6667
+9387 41116.6667 23650.0000
+9388 41116.6667 23916.6667
+9389 41116.6667 24000.0000
+9390 41116.6667 24033.3333
+9391 41116.6667 24050.0000
+9392 41116.6667 24083.3333
+9393 41116.6667 24100.0000
+9394 41116.6667 24133.3333
+9395 41116.6667 24150.0000
+9396 41116.6667 24283.3333
+9397 41116.6667 24300.0000
+9398 41116.6667 24350.0000
+9399 41116.6667 24383.3333
+9400 41116.6667 24433.3333
+9401 41116.6667 24583.3333
+9402 41116.6667 24700.0000
+9403 41116.6667 24783.3333
+9404 41116.6667 24816.6667
+9405 41116.6667 24833.3333
+9406 41116.6667 24850.0000
+9407 41116.6667 24866.6667
+9408 41116.6667 24916.6667
+9409 41116.6667 24950.0000
+9410 41116.6667 25000.0000
+9411 41116.6667 25016.6667
+9412 41116.6667 25066.6667
+9413 41116.6667 25116.6667
+9414 41116.6667 25200.0000
+9415 41116.6667 25300.0000
+9416 41116.6667 25366.6667
+9417 41116.6667 25400.0000
+9418 41116.6667 25433.3333
+9419 41116.6667 25633.3333
+9420 41116.6667 25650.0000
+9421 41116.6667 25683.3333
+9422 41116.6667 25716.6667
+9423 41116.6667 26283.3333
+9424 41120.2778 22661.1111
+9425 41122.7778 22511.9444
+9426 41128.3333 22876.1111
+9427 41133.3333 23066.6667
+9428 41133.3333 23216.6667
+9429 41133.3333 23383.3333
+9430 41133.3333 23933.3333
+9431 41133.3333 24000.0000
+9432 41133.3333 24116.6667
+9433 41133.3333 24150.0000
+9434 41133.3333 24166.6667
+9435 41133.3333 24216.6667
+9436 41133.3333 24266.6667
+9437 41133.3333 24316.6667
+9438 41133.3333 24366.6667
+9439 41133.3333 24700.0000
+9440 41133.3333 24733.3333
+9441 41133.3333 24850.0000
+9442 41133.3333 24866.6667
+9443 41133.3333 24883.3333
+9444 41133.3333 24983.3333
+9445 41133.3333 25000.0000
+9446 41133.3333 25050.0000
+9447 41133.3333 25183.3333
+9448 41133.3333 25216.6667
+9449 41133.3333 25266.6667
+9450 41133.3333 25283.3333
+9451 41133.3333 25550.0000
+9452 41133.3333 25600.0000
+9453 41133.3333 25650.0000
+9454 41133.3333 25716.6667
+9455 41133.3333 26216.6667
+9456 41134.4444 22917.2222
+9457 41139.1667 22668.6111
+9458 41144.7222 22972.7778
+9459 41146.9444 22744.7222
+9460 41150.0000 22833.3333
+9461 41150.0000 23000.0000
+9462 41150.0000 23166.6667
+9463 41150.0000 23283.3333
+9464 41150.0000 23333.3333
+9465 41150.0000 23416.6667
+9466 41150.0000 23450.0000
+9467 41150.0000 23583.3333
+9468 41150.0000 23900.0000
+9469 41150.0000 24066.6667
+9470 41150.0000 24133.3333
+9471 41150.0000 24150.0000
+9472 41150.0000 24483.3333
+9473 41150.0000 24933.3333
+9474 41150.0000 24966.6667
+9475 41150.0000 25066.6667
+9476 41150.0000 25300.0000
+9477 41150.0000 25316.6667
+9478 41150.0000 25333.3333
+9479 41150.0000 25350.0000
+9480 41150.0000 25433.3333
+9481 41150.0000 25466.6667
+9482 41150.0000 25500.0000
+9483 41150.0000 25533.3333
+9484 41150.0000 25566.6667
+9485 41150.0000 25683.3333
+9486 41150.0000 26216.6667
+9487 41150.0000 26300.0000
+9488 41162.5000 22894.4444
+9489 41164.4444 22668.6111
+9490 41166.6667 22800.0000
+9491 41166.6667 23016.6667
+9492 41166.6667 23266.6667
+9493 41166.6667 23283.3333
+9494 41166.6667 23366.6667
+9495 41166.6667 23850.0000
+9496 41166.6667 24216.6667
+9497 41166.6667 24316.6667
+9498 41166.6667 24333.3333
+9499 41166.6667 24366.6667
+9500 41166.6667 24383.3333
+9501 41166.6667 24400.0000
+9502 41166.6667 24550.0000
+9503 41166.6667 24633.3333
+9504 41166.6667 24733.3333
+9505 41166.6667 24850.0000
+9506 41166.6667 24966.6667
+9507 41166.6667 24983.3333
+9508 41166.6667 25366.6667
+9509 41166.6667 25383.3333
+9510 41166.6667 25466.6667
+9511 41166.6667 25483.3333
+9512 41166.6667 25616.6667
+9513 41166.6667 25633.3333
+9514 41166.6667 26116.6667
+9515 41178.0556 22760.8333
+9516 41183.3333 22850.0000
+9517 41183.3333 22883.3333
+9518 41183.3333 22900.0000
+9519 41183.3333 22916.6667
+9520 41183.3333 23083.3333
+9521 41183.3333 23233.3333
+9522 41183.3333 23250.0000
+9523 41183.3333 23266.6667
+9524 41183.3333 23316.6667
+9525 41183.3333 23400.0000
+9526 41183.3333 23933.3333
+9527 41183.3333 23966.6667
+9528 41183.3333 24166.6667
+9529 41183.3333 24316.6667
+9530 41183.3333 24366.6667
+9531 41183.3333 24383.3333
+9532 41183.3333 24416.6667
+9533 41183.3333 24833.3333
+9534 41183.3333 24900.0000
+9535 41183.3333 24950.0000
+9536 41183.3333 25283.3333
+9537 41183.3333 25333.3333
+9538 41183.3333 25416.6667
+9539 41183.3333 25433.3333
+9540 41183.3333 25883.3333
+9541 41186.6667 22815.8333
+9542 41200.0000 22816.6667
+9543 41200.0000 23200.0000
+9544 41200.0000 23250.0000
+9545 41200.0000 23283.3333
+9546 41200.0000 23366.6667
+9547 41200.0000 23550.0000
+9548 41200.0000 23583.3333
+9549 41200.0000 23600.0000
+9550 41200.0000 23816.6667
+9551 41200.0000 23900.0000
+9552 41200.0000 24016.6667
+9553 41200.0000 24100.0000
+9554 41200.0000 24333.3333
+9555 41200.0000 24383.3333
+9556 41200.0000 24416.6667
+9557 41200.0000 24700.0000
+9558 41200.0000 24816.6667
+9559 41200.0000 24883.3333
+9560 41200.0000 24916.6667
+9561 41200.0000 25016.6667
+9562 41200.0000 25033.3333
+9563 41200.0000 25133.3333
+9564 41200.0000 25166.6667
+9565 41200.0000 25383.3333
+9566 41200.0000 25516.6667
+9567 41200.0000 25583.3333
+9568 41200.0000 26300.0000
+9569 41216.6667 22816.6667
+9570 41216.6667 22900.0000
+9571 41216.6667 23033.3333
+9572 41216.6667 23050.0000
+9573 41216.6667 23083.3333
+9574 41216.6667 23300.0000
+9575 41216.6667 23366.6667
+9576 41216.6667 23400.0000
+9577 41216.6667 23900.0000
+9578 41216.6667 23916.6667
+9579 41216.6667 24266.6667
+9580 41216.6667 24350.0000
+9581 41216.6667 24366.6667
+9582 41216.6667 24433.3333
+9583 41216.6667 24450.0000
+9584 41216.6667 24466.6667
+9585 41216.6667 24550.0000
+9586 41216.6667 24633.3333
+9587 41216.6667 24666.6667
+9588 41216.6667 24783.3333
+9589 41216.6667 24800.0000
+9590 41216.6667 24866.6667
+9591 41216.6667 24900.0000
+9592 41216.6667 24933.3333
+9593 41216.6667 24950.0000
+9594 41216.6667 25450.0000
+9595 41216.6667 25566.6667
+9596 41216.6667 25683.3333
+9597 41216.6667 25700.0000
+9598 41216.6667 25733.3333
+9599 41216.6667 26016.6667
+9600 41216.6667 26200.0000
+9601 41222.5000 22827.7778
+9602 41226.9444 22790.0000
+9603 41233.3333 22983.3333
+9604 41233.3333 23000.0000
+9605 41233.3333 23250.0000
+9606 41233.3333 23383.3333
+9607 41233.3333 24166.6667
+9608 41233.3333 24183.3333
+9609 41233.3333 24200.0000
+9610 41233.3333 24266.6667
+9611 41233.3333 24383.3333
+9612 41233.3333 24400.0000
+9613 41233.3333 24583.3333
+9614 41233.3333 24600.0000
+9615 41233.3333 24616.6667
+9616 41233.3333 24633.3333
+9617 41233.3333 24816.6667
+9618 41233.3333 24866.6667
+9619 41233.3333 24883.3333
+9620 41233.3333 24950.0000
+9621 41233.3333 25033.3333
+9622 41233.3333 25100.0000
+9623 41233.3333 25200.0000
+9624 41233.3333 25250.0000
+9625 41233.3333 25366.6667
+9626 41233.3333 25533.3333
+9627 41233.3333 25600.0000
+9628 41233.3333 25766.6667
+9629 41233.3333 25850.0000
+9630 41233.3333 25900.0000
+9631 41233.3333 25933.3333
+9632 41233.3333 25966.6667
+9633 41236.6667 22946.9444
+9634 41243.6111 22851.1111
+9635 41250.0000 22783.3333
+9636 41250.0000 22800.0000
+9637 41250.0000 22816.6667
+9638 41250.0000 23016.6667
+9639 41250.0000 23083.3333
+9640 41250.0000 23216.6667
+9641 41250.0000 23283.3333
+9642 41250.0000 23333.3333
+9643 41250.0000 23450.0000
+9644 41250.0000 23816.6667
+9645 41250.0000 24033.3333
+9646 41250.0000 24433.3333
+9647 41250.0000 24500.0000
+9648 41250.0000 24516.6667
+9649 41250.0000 24533.3333
+9650 41250.0000 24566.6667
+9651 41250.0000 24583.3333
+9652 41250.0000 24600.0000
+9653 41250.0000 24633.3333
+9654 41250.0000 24700.0000
+9655 41250.0000 24733.3333
+9656 41250.0000 24900.0000
+9657 41250.0000 24916.6667
+9658 41250.0000 25483.3333
+9659 41250.0000 25533.3333
+9660 41250.0000 25633.3333
+9661 41250.0000 25683.3333
+9662 41250.0000 25866.6667
+9663 41250.0000 26133.3333
+9664 41255.0000 22795.2778
+9665 41260.2778 22789.1667
+9666 41264.7222 22842.2222
+9667 41266.6667 22800.0000
+9668 41266.6667 22833.3333
+9669 41266.6667 22933.3333
+9670 41266.6667 23000.0000
+9671 41266.6667 23133.3333
+9672 41266.6667 23183.3333
+9673 41266.6667 23366.6667
+9674 41266.6667 23383.3333
+9675 41266.6667 23400.0000
+9676 41266.6667 24183.3333
+9677 41266.6667 24400.0000
+9678 41266.6667 24483.3333
+9679 41266.6667 24500.0000
+9680 41266.6667 24566.6667
+9681 41266.6667 24666.6667
+9682 41266.6667 24716.6667
+9683 41266.6667 24800.0000
+9684 41266.6667 24833.3333
+9685 41266.6667 24866.6667
+9686 41266.6667 24933.3333
+9687 41266.6667 25466.6667
+9688 41266.6667 25533.3333
+9689 41266.6667 25733.3333
+9690 41266.6667 25866.6667
+9691 41266.6667 25916.6667
+9692 41266.6667 25950.0000
+9693 41266.6667 25983.3333
+9694 41266.6667 26333.3333
+9695 41266.6667 26383.3333
+9696 41266.6667 26400.0000
+9697 41269.7222 22853.6111
+9698 41276.3889 22893.6111
+9699 41283.0556 22932.2222
+9700 41283.3333 23016.6667
+9701 41283.3333 23033.3333
+9702 41283.3333 23233.3333
+9703 41283.3333 23250.0000
+9704 41283.3333 23300.0000
+9705 41283.3333 23333.3333
+9706 41283.3333 23750.0000
+9707 41283.3333 23933.3333
+9708 41283.3333 24216.6667
+9709 41283.3333 24233.3333
+9710 41283.3333 24316.6667
+9711 41283.3333 24400.0000
+9712 41283.3333 24466.6667
+9713 41283.3333 24483.3333
+9714 41283.3333 24800.0000
+9715 41283.3333 24966.6667
+9716 41283.3333 25116.6667
+9717 41283.3333 25183.3333
+9718 41283.3333 25550.0000
+9719 41283.3333 25616.6667
+9720 41283.3333 25783.3333
+9721 41283.3333 25850.0000
+9722 41283.3333 25983.3333
+9723 41283.3333 26283.3333
+9724 41293.0556 22947.2222
+9725 41295.2778 22833.0556
+9726 41295.8333 22985.2778
+9727 41300.0000 22800.0000
+9728 41300.0000 23500.0000
+9729 41300.0000 23683.3333
+9730 41300.0000 23850.0000
+9731 41300.0000 24466.6667
+9732 41300.0000 24516.6667
+9733 41300.0000 24616.6667
+9734 41300.0000 24783.3333
+9735 41300.0000 24900.0000
+9736 41300.0000 25666.6667
+9737 41300.0000 25983.3333
+9738 41300.0000 26183.3333
+9739 41300.0000 26250.0000
+9740 41300.0000 26433.3333
+9741 41316.6667 23550.0000
+9742 41316.6667 23583.3333
+9743 41316.6667 23783.3333
+9744 41316.6667 24000.0000
+9745 41316.6667 24366.6667
+9746 41316.6667 24416.6667
+9747 41316.6667 24450.0000
+9748 41316.6667 24583.3333
+9749 41316.6667 24766.6667
+9750 41316.6667 25100.0000
+9751 41316.6667 25116.6667
+9752 41316.6667 25816.6667
+9753 41316.6667 26100.0000
+9754 41316.6667 26483.3333
+9755 41333.3333 24333.3333
+9756 41333.3333 24533.3333
+9757 41333.3333 24883.3333
+9758 41333.3333 24933.3333
+9759 41333.3333 25050.0000
+9760 41333.3333 26266.6667
+9761 41350.0000 23683.3333
+9762 41350.0000 23716.6667
+9763 41350.0000 23800.0000
+9764 41350.0000 23866.6667
+9765 41350.0000 24083.3333
+9766 41350.0000 24100.0000
+9767 41350.0000 24450.0000
+9768 41350.0000 24533.3333
+9769 41350.0000 24633.3333
+9770 41350.0000 24850.0000
+9771 41350.0000 24983.3333
+9772 41350.0000 26200.0000
+9773 41350.0000 26366.6667
+9774 41350.0000 26433.3333
+9775 41350.0000 26500.0000
+9776 41350.0000 26583.3333
+9777 41350.0000 26600.0000
+9778 41366.6667 23366.6667
+9779 41366.6667 24183.3333
+9780 41366.6667 24233.3333
+9781 41366.6667 24266.6667
+9782 41366.6667 24316.6667
+9783 41366.6667 24550.0000
+9784 41366.6667 24616.6667
+9785 41366.6667 24916.6667
+9786 41366.6667 24966.6667
+9787 41366.6667 25000.0000
+9788 41366.6667 26383.3333
+9789 41366.6667 26466.6667
+9790 41366.6667 26533.3333
+9791 41383.3333 23300.0000
+9792 41383.3333 23450.0000
+9793 41383.3333 23866.6667
+9794 41383.3333 23983.3333
+9795 41383.3333 24050.0000
+9796 41383.3333 24100.0000
+9797 41383.3333 24283.3333
+9798 41383.3333 24916.6667
+9799 41383.3333 24933.3333
+9800 41383.3333 26300.0000
+9801 41383.3333 26616.6667
+9802 41400.0000 23900.0000
+9803 41400.0000 24016.6667
+9804 41400.0000 24033.3333
+9805 41400.0000 24100.0000
+9806 41400.0000 24216.6667
+9807 41400.0000 26283.3333
+9808 41400.0000 26333.3333
+9809 41400.0000 26416.6667
+9810 41400.0000 26566.6667
+9811 41400.0000 26583.3333
+9812 41416.6667 23833.3333
+9813 41416.6667 24000.0000
+9814 41416.6667 24083.3333
+9815 41416.6667 24133.3333
+9816 41416.6667 24166.6667
+9817 41416.6667 24283.3333
+9818 41416.6667 26250.0000
+9819 41416.6667 26383.3333
+9820 41416.6667 26400.0000
+9821 41416.6667 26516.6667
+9822 41416.6667 26550.0000
+9823 41416.6667 26566.6667
+9824 41433.3333 24466.6667
+9825 41433.3333 26316.6667
+9826 41433.3333 26350.0000
+9827 41433.3333 26550.0000
+9828 41450.0000 26266.6667
+9829 41450.0000 26400.0000
+9830 41450.0000 26466.6667
+9831 41450.0000 26550.0000
+9832 41466.6667 26350.0000
+9833 41466.6667 26383.3333
+9834 41466.6667 26566.6667
+9835 41483.3333 24133.3333
+9836 41483.3333 24150.0000
+9837 41483.3333 26283.3333
+9838 41483.3333 26300.0000
+9839 41483.3333 26316.6667
+9840 41483.3333 26400.0000
+9841 41483.3333 26433.3333
+9842 41483.3333 26550.0000
+9843 41500.0000 24133.3333
+9844 41500.0000 26216.6667
+9845 41500.0000 26233.3333
+9846 41500.0000 26466.6667
+9847 41500.0000 26500.0000
+9848 41500.0000 26516.6667
+9849 41516.6667 26250.0000
+9850 41516.6667 26283.3333
+9851 41516.6667 26300.0000
+9852 41516.6667 26450.0000
+9853 41533.3333 26350.0000
+9854 41533.3333 26533.3333
+9855 41533.3333 26550.0000
+9856 41566.6667 26166.6667
+9857 41566.6667 26183.3333
+9858 41566.6667 26450.0000
+9859 41566.6667 26516.6667
+9860 41583.3333 26183.3333
+9861 41583.3333 26233.3333
+9862 41583.3333 26283.3333
+9863 41583.3333 26533.3333
+9864 41600.0000 26300.0000
+9865 41616.6667 26316.6667
+9866 41616.6667 26350.0000
+9867 41616.6667 26433.3333
+9868 41633.3333 26333.3333
+9869 41633.3333 26383.3333
+9870 41650.0000 26083.3333
+9871 41650.0000 26183.3333
+9872 41650.0000 26316.6667
+9873 41650.0000 26416.6667
+9874 41650.0000 26466.6667
+9875 41666.6667 26350.0000
+9876 41666.6667 26466.6667
+9877 41683.3333 26283.3333
+9878 41700.0000 26133.3333
+9879 41700.0000 26233.3333
+9880 41700.0000 26283.3333
+9881 41700.0000 26383.3333
+9882 41716.6667 26216.6667
+\.
+
+UPDATE gr9882 SET the_geom = ST_makePoint(x,y);
+SELECT * into grece from pgr_eucledianDmatrix('gr9882'::regclass);
+SELECT * from pgr_xydtsp($$SELECT * from grece$$, true);
+-- SELECT * from pgr_xydtsp($$SELECT * from pgr_eucledianDmatrix('gr9882'::regclass)$$, true, 1);
+-- SELECT * from pgr_tsp('SELECT id::integer, x, y from gr9882', 1);
+
diff --git a/src/bd_dijkstra/doc/CMakeLists.txt b/src/tsp/test/development/qa194-tsp.result
similarity index 100%
rename from src/bd_dijkstra/doc/CMakeLists.txt
rename to src/tsp/test/development/qa194-tsp.result
diff --git a/src/tsp/test/development/qa194-tsp.test.sql b/src/tsp/test/development/qa194-tsp.test.sql
new file mode 100644
index 0000000..6e67342
--- /dev/null
+++ b/src/tsp/test/development/qa194-tsp.test.sql
@@ -0,0 +1,272 @@
+-- http://www.math.uwaterloo.ca/tsp/world/qa194.tsp
+
+-- NAME : qa194
+-- COMMENT : 194 locations in Qatar
+-- COMMENT : Derived from National Imagery and Mapping Agency data
+-- TYPE : TSP
+-- DIMENSION : 194
+-- EDGE_WEIGHT_TYPE : EUC_2D
+-- NODE_COORD_SECTION
+
+
+
+CREATE TABLE qa194 (id BIGINT, x FLOAT, y FLOAT, the_geom geometry);
+COPY qa194 (id, x, y) FROM stdin WITH DELIMITER ' ';
+1 24748.3333 50840.0000
+2 24758.8889 51211.9444
+3 24827.2222 51394.7222
+4 24904.4444 51175.0000
+5 24996.1111 51548.8889
+6 25010.0000 51039.4444
+7 25030.8333 51275.2778
+8 25067.7778 51077.5000
+9 25100.0000 51516.6667
+10 25103.3333 51521.6667
+11 25121.9444 51218.3333
+12 25150.8333 51537.7778
+13 25158.3333 51163.6111
+14 25162.2222 51220.8333
+15 25167.7778 51606.9444
+16 25168.8889 51086.3889
+17 25173.8889 51269.4444
+18 25210.8333 51394.1667
+19 25211.3889 51619.1667
+20 25214.1667 50807.2222
+21 25214.4444 51378.8889
+22 25223.3333 51451.6667
+23 25224.1667 51174.4444
+24 25233.3333 51333.3333
+25 25234.1667 51203.0556
+26 25235.5556 51330.0000
+27 25235.5556 51495.5556
+28 25242.7778 51428.8889
+29 25243.0556 51452.5000
+30 25252.5000 51559.1667
+31 25253.8889 51535.2778
+32 25253.8889 51549.7222
+33 25256.9444 51398.8889
+34 25263.6111 51516.3889
+35 25265.8333 51545.2778
+36 25266.6667 50969.1667
+37 25266.6667 51483.3333
+38 25270.5556 51532.7778
+39 25270.8333 51505.8333
+40 25270.8333 51523.0556
+41 25275.8333 51533.6111
+42 25277.2222 51547.7778
+43 25278.3333 51525.5556
+44 25278.3333 51541.3889
+45 25279.1667 51445.5556
+46 25281.1111 51535.0000
+47 25281.3889 51512.5000
+48 25283.3333 51533.3333
+49 25283.6111 51546.6667
+50 25284.7222 51555.2778
+51 25286.1111 51504.1667
+52 25286.1111 51534.1667
+53 25286.6667 51533.3333
+54 25287.5000 51537.7778
+55 25288.0556 51546.6667
+56 25290.8333 51528.3333
+57 25291.9444 51424.4444
+58 25292.5000 51520.8333
+59 25298.6111 51001.6667
+60 25300.8333 51394.4444
+61 25306.9444 51507.7778
+62 25311.9444 51003.0556
+63 25313.8889 50883.3333
+64 25315.2778 51438.6111
+65 25316.6667 50766.6667
+66 25320.5556 51495.5556
+67 25322.5000 51507.7778
+68 25325.2778 51470.0000
+69 25326.6667 51350.2778
+70 25337.5000 51425.0000
+71 25339.1667 51173.3333
+72 25340.5556 51293.6111
+73 25341.9444 51507.5000
+74 25358.8889 51333.6111
+75 25363.6111 51281.1111
+76 25368.6111 51226.3889
+77 25374.4444 51436.6667
+78 25377.7778 51294.7222
+79 25396.9444 51422.5000
+80 25400.0000 51183.3333
+81 25400.0000 51425.0000
+82 25404.7222 51073.0556
+83 25416.9444 51403.8889
+84 25416.9444 51457.7778
+85 25419.4444 50793.6111
+86 25429.7222 50785.8333
+87 25433.3333 51220.0000
+88 25440.8333 51378.0556
+89 25444.4444 50958.3333
+90 25451.3889 50925.0000
+91 25459.1667 51316.6667
+92 25469.7222 51397.5000
+93 25478.0556 51362.5000
+94 25480.5556 50938.8889
+95 25483.3333 51383.3333
+96 25490.5556 51373.6111
+97 25492.2222 51400.2778
+98 25495.0000 50846.6667
+99 25495.0000 50965.2778
+100 25497.5000 51485.2778
+101 25500.8333 50980.5556
+102 25510.5556 51242.2222
+103 25531.9444 51304.4444
+104 25533.3333 50977.2222
+105 25538.8889 51408.3333
+106 25545.8333 51387.5000
+107 25549.7222 51431.9444
+108 25550.0000 51433.3333
+109 25560.2778 51158.6111
+110 25566.9444 51484.7222
+111 25567.5000 50958.8889
+112 25574.7222 51486.3889
+113 25585.5556 51151.3889
+114 25609.4444 51092.2222
+115 25610.2778 51475.2778
+116 25622.5000 51454.4444
+117 25645.8333 51450.0000
+118 25650.0000 51372.2222
+119 25666.9444 51174.4444
+120 25683.8889 51505.8333
+121 25686.3889 51468.8889
+122 25696.1111 51260.8333
+123 25700.8333 51584.7222
+124 25708.3333 51591.6667
+125 25716.6667 51050.0000
+126 25717.5000 51057.7778
+127 25723.0556 51004.1667
+128 25734.7222 51547.5000
+129 25751.1111 51449.1667
+130 25751.9444 50920.8333
+131 25758.3333 51395.8333
+132 25765.2778 51019.7222
+133 25772.2222 51483.3333
+134 25775.8333 51023.0556
+135 25779.1667 51449.7222
+136 25793.3333 51409.4444
+137 25808.3333 51060.5556
+138 25816.6667 51133.3333
+139 25823.6111 51152.5000
+140 25826.6667 51043.8889
+141 25829.7222 51245.2778
+142 25833.3333 51072.2222
+143 25839.1667 51465.2778
+144 25847.7778 51205.8333
+145 25850.0000 51033.3333
+146 25856.6667 51083.3333
+147 25857.5000 51298.8889
+148 25857.5000 51441.3889
+149 25866.6667 51066.6667
+150 25867.7778 51205.5556
+151 25871.9444 51354.7222
+152 25872.5000 51258.3333
+153 25880.8333 51221.3889
+154 25883.0556 51185.2778
+155 25888.0556 51386.3889
+156 25900.0000 51000.0000
+157 25904.1667 51201.6667
+158 25928.3333 51337.5000
+159 25937.5000 51313.3333
+160 25944.7222 51456.3889
+161 25950.0000 51066.6667
+162 25951.6667 51349.7222
+163 25957.7778 51075.2778
+164 25958.3333 51099.4444
+165 25966.6667 51283.3333
+166 25983.3333 51400.0000
+167 25983.6111 51328.0556
+168 26000.2778 51294.4444
+169 26008.6111 51083.6111
+170 26016.6667 51333.3333
+171 26021.6667 51366.9444
+172 26033.3333 51116.6667
+173 26033.3333 51166.6667
+174 26033.6111 51163.8889
+175 26033.6111 51200.2778
+176 26048.8889 51056.9444
+177 26050.0000 51250.0000
+178 26050.2778 51297.5000
+179 26050.5556 51135.8333
+180 26055.0000 51316.1111
+181 26067.2222 51258.6111
+182 26074.7222 51083.6111
+183 26076.6667 51166.9444
+184 26077.2222 51222.2222
+185 26078.0556 51361.6667
+186 26083.6111 51147.2222
+187 26099.7222 51161.1111
+188 26108.0556 51244.7222
+189 26116.6667 51216.6667
+190 26123.6111 51169.1667
+191 26123.6111 51222.7778
+192 26133.3333 51216.6667
+193 26133.3333 51300.0000
+194 26150.2778 51108.0556
+\.
+
+
+UPDATE qa194 SET the_geom = ST_makePoint(x,y);
+-- SELECT * from pgr_tsp('SELECT id::integer, x, y from qa194', 1);
+
+SET client_min_messages TO DEBUG1;
+SELECT * from pgr_eucledianTSP($$SELECT id::integer, x, y from qa194$$);
+SELECT * from pgr_eucledianTSP($$SELECT id::integer, x, y from qa194$$, max_processing_time := 3);
+
+/*
+CREATE VIEW qa194_path AS
+WITH
+results AS (
+    SELECT seq, node, cost, agg_cost from pgr_xydtsp($$select * from pgr_eucledianDmatrix('qa194'::regclass)$$, 1)
+),
+geoms AS (
+    SELECT seq, node, cost, agg_cost, the_geom AS second  FROM results JOIN qa194 ON (node = id)
+),
+edges AS (
+    SELECT seq, node, ST_MakeLine(lag(second) over(), second) AS line, cost, agg_cost FROM geoms
+)
+SELECT * FROM edges;
+
+WITH
+results AS (
+    SELECT * from pgr_xydtsp($$select * from 
+        pgr_eucledianDmatrix('SELECT id::integer, st_x(the_geom) as x, st_y(the_geom) as y FROM edge_table_vertices_pgr')$$, 6, 5)
+),
+geoms AS (
+    SELECT seq, node, cost, agg_cost, the_geom AS second  FROM results JOIN edge_table_vertices_pgr ON (node = id) order by seq
+),
+edges AS (
+    SELECT seq, node, ST_MakeLine(lag(second) over(), second) AS line, cost, agg_cost FROM geoms
+)
+SELECT * INTO newtsp FROM edges;
+
+
+WITH
+results AS (
+    SELECT * from pgr_tsp(
+        'SELECT id::integer, st_x(the_geom) as x, st_y(the_geom) as y FROM edge_table_vertices_pgr', 6, 5)
+),
+geoms AS (
+    SELECT results.*, the_geom AS second  FROM results JOIN edge_table_vertices_pgr ON (id2 = id)
+),
+edges AS (
+    SELECT seq, id1, id2, cost, ST_MakeLine(lag(second) over(), second) AS line FROM geoms order by seq
+)
+SELECT * INTO oldtsp FROM edges;
+
+
+WITH
+results AS (
+    select * from pgr_xydtsp($$SELECT * from pgr_dijkstraDmatrix('SELECT id, source, target, cost, reverse_cost from edge_table', array[1,2,3,4,5,6,7,8,9,10,11,12,13], false)$$, 6,5)
+),
+geoms AS (
+    SELECT seq, node, cost, agg_cost, the_geom AS second  FROM results JOIN edge_table_vertices_pgr ON (node = id) order by seq
+),
+edges AS (
+    SELECT seq, node, ST_MakeLine(lag(second) over(), second) AS line, cost, agg_cost FROM geoms
+)
+SELECT * INTO newtspWdijkstra FROM edges;
+*/
diff --git a/src/tsp/test/development/wi29-tsp.result b/src/tsp/test/development/wi29-tsp.result
new file mode 100644
index 0000000..b03f698
--- /dev/null
+++ b/src/tsp/test/development/wi29-tsp.result
@@ -0,0 +1,226 @@
+NOTICE:  table "wi29" does not exist, skipping
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+0|17|17|683.333268292684
+1|18|18|432.691873944705
+2|19|19|772.082339448903
+3|15|15|2250.24689953989
+4|12|12|1411.95293791574
+5|11|11|106.718669615254
+6|10|10|2113.77757765045
+7|6|6|900.617093380362
+8|2|2|74.535614157127
+9|1|1|2266.91173136004
+10|5|5|1188.01888359478
+11|8|8|994.708187806297
+12|4|4|1172.36699411442
+13|3|3|891.004385199336
+14|7|7|650.85409697993
+15|9|9|1576.30022027673
+16|13|13|1321.76283931305
+17|14|14|2073.38319366628
+18|16|16|1243.87392358622
+19|24|24|559.016994374947
+20|27|27|74.535658878487
+21|25|25|1330.83095428717
+22|20|20|509.901951359278
+23|26|26|648.288376333318
+24|28|28|592.939989005405
+25|29|29|374.139344477991
+26|23|23|220.141999627513
+27|22|22|370.56056393417
+28|21|21|795.67721237329
+NOTICE:  pgr_eucledianTSP Processing Information 
+Initializing tsp class ---> tsp.greedyInitial ---> tsp.annealing ---> OK
+
+Cycle(100)    total changes =13       8 were because  delta energy < 0
+Cycle(90)     total changes =7        3 were because  delta energy < 0
+Cycle(81)     total changes =6        2 were because  delta energy < 0
+Cycle(72.9)   total changes =3        1 were because  delta energy < 0
+Cycle(65.61)  total changes =6        3 were because  delta energy < 0
+Cycle(59.049)         total changes =6        2 were because  delta energy < 0
+Cycle(53.1441)        total changes =7        2 were because  delta energy < 0
+Cycle(47.8297)        total changes =5        2 were because  delta energy < 0
+Cycle(43.0467)        total changes =5        2 were because  delta energy < 0
+Cycle(38.742)         total changes =6        2 were because  delta energy < 0
+Cycle(34.8678)        total changes =6        2 were because  delta energy < 0
+Cycle(31.3811)        total changes =2        0 were because  delta energy < 0
+Cycle(28.243)         total changes =2        0 were because  delta energy < 0
+Cycle(25.4187)        total changes =5        0 were because  delta energy < 0
+Cycle(22.8768)        total changes =0        0 were because  delta energy < 0
+Total swaps: 28
+Total slides: 21
+Total reverses: 58
+Times best tour changed: 22
+Best cost reached = 27601.2
+1|17|683.333268292684|0
+2|18|432.691873944705|683.333268292684
+3|19|772.082339448903|1116.02514223739
+4|15|2250.24689953989|1888.10748168629
+5|12|1411.95293791574|4138.35438122618
+6|11|106.718669615254|5550.30731914192
+7|10|2113.77757765045|5657.02598875718
+8|6|900.617093380362|7770.80356640762
+9|2|74.535614157127|8671.42065978798
+10|1|2266.91173136004|8745.95627394511
+11|5|1188.01888359478|11012.8680053052
+12|8|994.708187806297|12200.8868888999
+13|4|1172.36699411442|13195.5950767062
+14|3|891.004385199336|14367.9620708206
+15|7|650.85409697993|15258.96645602
+16|9|1576.30022027673|15909.8205529999
+17|13|1321.76283931305|17486.1207732766
+18|14|2073.38319366628|18807.8836125897
+19|16|1243.87392358622|20881.266806256
+20|24|559.016994374947|22125.1407298422
+21|27|74.535658878487|22684.1577242171
+22|25|1330.83095428717|22758.6933830956
+23|20|509.901951359278|24089.5243373828
+24|26|648.288376333318|24599.4262887421
+25|28|592.939989005405|25247.7146650754
+26|29|374.139344477991|25840.6546540808
+27|23|220.141999627513|26214.7939985588
+28|22|370.56056393417|26434.9359981863
+29|21|795.67721237329|26805.4965621205
+30|17|0|27601.1737744938
+NOTICE:  pgr_eucledianTSP Processing Information 
+Initializing tsp class ---> tsp.greedyInitial ---> tsp.annealing ---> OK
+
+Cycle(100)    total changes =9        5 were because  delta energy < 0
+Cycle(90)     total changes =8        3 were because  delta energy < 0
+Cycle(81)     total changes =4        2 were because  delta energy < 0
+Cycle(72.9)   total changes =1        0 were because  delta energy < 0
+Cycle(65.61)  total changes =4        2 were because  delta energy < 0
+Cycle(59.049)         total changes =1        0 were because  delta energy < 0
+Cycle(53.1441)        total changes =2        0 were because  delta energy < 0
+Cycle(47.8297)        total changes =2        0 were because  delta energy < 0
+Cycle(43.0467)        total changes =1        1 were because  delta energy < 0
+Cycle(38.742)         total changes =2        0 were because  delta energy < 0
+Cycle(34.8678)        total changes =0        0 were because  delta energy < 0
+Total swaps: 19
+Total slides: 5
+Total reverses: 29
+Times best tour changed: 19
+Best cost reached = 29243
+1|17|1202.91366735569|0
+2|14|2490.66626249105|1202.91366735569
+3|9|650.85409697993|3693.57992984674
+4|7|891.004385199336|4344.43402682667
+5|3|1172.36699411442|5235.438412026
+6|4|994.708187806297|6407.80540614043
+7|8|1188.01888359478|7402.51359394673
+8|5|2266.91173136004|8590.5324775415
+9|1|74.535614157127|10857.4442089015
+10|2|900.617093380362|10931.9798230587
+11|6|2113.77757765045|11832.596916439
+12|10|106.718669615254|13946.3744940895
+13|11|1411.95293791574|14053.0931637047
+14|12|1314.23824873744|15465.0461016205
+15|13|2330.29558544738|16779.2843503579
+16|15|772.082339448903|19109.5799358053
+17|19|432.691873944705|19881.6622752542
+18|18|663.008794943808|20314.3541491989
+19|22|220.141999627513|20977.3629441427
+20|23|197.926372783442|21197.5049437702
+21|21|440.456596290771|21395.4313165537
+22|29|592.939989005405|21835.8879128444
+23|28|648.288376333318|22428.8279018498
+24|26|509.901951359278|23077.1162781832
+25|20|1274.64587544062|23587.0182295424
+26|16|1243.87392358622|24861.6641049831
+27|24|559.016994374947|26105.5380285693
+28|27|74.535658878487|26664.5550229442
+29|25|2503.88589973443|26739.0906818227
+30|17|0|29242.9765815571
+NOTICE:  pgr_eucledianTSP Processing Information 
+Initializing tsp class ---> tsp.greedyInitial ---> tsp.annealing ---> OK
+
+Cycle(100)    total changes =9        5 were because  delta energy < 0
+Cycle(90)     total changes =8        3 were because  delta energy < 0
+Cycle(81)     total changes =4        2 were because  delta energy < 0
+Cycle(72.9)   total changes =1        0 were because  delta energy < 0
+Cycle(65.61)  total changes =4        2 were because  delta energy < 0
+Cycle(59.049)         total changes =1        0 were because  delta energy < 0
+Cycle(53.1441)        total changes =2        0 were because  delta energy < 0
+Cycle(47.8297)        total changes =2        0 were because  delta energy < 0
+Cycle(43.0467)        total changes =1        1 were because  delta energy < 0
+Cycle(38.742)         total changes =2        0 were because  delta energy < 0
+Cycle(34.8678)        total changes =0        0 were because  delta energy < 0
+Total swaps: 19
+Total slides: 5
+Total reverses: 29
+Times best tour changed: 19
+Best cost reached = 29243
+1|117|1202.91366735569|0
+2|114|2490.66626249105|1202.91366735569
+3|109|650.85409697993|3693.57992984674
+4|107|891.004385199336|4344.43402682667
+5|103|1172.36699411442|5235.438412026
+6|104|994.708187806297|6407.80540614043
+7|108|1188.01888359478|7402.51359394673
+8|105|2266.91173136004|8590.5324775415
+9|101|74.535614157127|10857.4442089015
+10|102|900.617093380362|10931.9798230587
+11|106|2113.77757765045|11832.596916439
+12|110|106.718669615254|13946.3744940895
+13|111|1411.95293791574|14053.0931637047
+14|112|1314.23824873744|15465.0461016205
+15|113|2330.29558544738|16779.2843503579
+16|115|772.082339448903|19109.5799358053
+17|119|432.691873944705|19881.6622752542
+18|118|663.008794943808|20314.3541491989
+19|122|220.141999627513|20977.3629441427
+20|123|197.926372783442|21197.5049437702
+21|121|440.456596290771|21395.4313165537
+22|129|592.939989005405|21835.8879128444
+23|128|648.288376333318|22428.8279018498
+24|126|509.901951359278|23077.1162781832
+25|120|1274.64587544062|23587.0182295424
+26|116|1243.87392358622|24861.6641049831
+27|124|559.016994374947|26105.5380285693
+28|127|74.535658878487|26664.5550229442
+29|125|2503.88589973443|26739.0906818227
+30|117|0|29242.9765815571
+NOTICE:  pgr_eucledianTSP Processing Information 
+Initializing tsp class ---> tsp.greedyInitial ---> tsp.annealing ---> OK
+
+Cycle(100)    total changes =11       6 were because  delta energy < 0
+Cycle(90)     total changes =7        2 were because  delta energy < 0
+Cycle(81)     total changes =4        1 were because  delta energy < 0
+Cycle(72.9)   total changes =7        3 were because  delta energy < 0
+Cycle(65.61)  total changes =2        1 were because  delta energy < 0
+Cycle(59.049)         total changes =0        0 were because  delta energy < 0
+Total swaps: 19
+Total slides: 4
+Total reverses: 27
+Times best tour changed: 25
+Best cost reached = 28189.8
+1|101|2266.91173136004|0
+2|105|816.6667|2266.91173136004
+3|104|1172.36699411442|3083.57843136004
+4|103|891.004385199336|4255.94542547447
+5|107|650.85409697993|5146.9498106738
+6|109|1586.48805192125|5797.80390765373
+7|108|1320.77417785513|7384.29195957498
+8|112|1314.23824873744|8705.06613743011
+9|113|1321.76283931305|10019.3043861676
+10|114|1202.91366735569|11341.0672254806
+11|117|1173.07768521763|12543.9808928363
+12|120|1274.64587544062|13717.0585780539
+13|116|1243.87392358622|14991.7044534945
+14|124|559.016994374947|16235.5783770808
+15|127|74.535658878487|16794.5953714557
+16|125|1333.3333|16869.1310303342
+17|126|648.288376333318|18202.4643303342
+18|128|592.939989005405|18850.7527066675
+19|129|440.456596290771|19443.6926956729
+20|121|197.926372783442|19884.1492919637
+21|123|220.141999627513|20082.0756647471
+22|122|663.008794943808|20302.2176643746
+23|118|432.691873944705|20965.2264593185
+24|119|772.082339448903|21397.9183332632
+25|115|2824.10256502447|22170.0006727121
+26|111|106.718669615254|24994.1032377365
+27|110|2113.77757765045|25100.8219073518
+28|106|900.617093380362|27214.5994850022
+29|102|74.535614157127|28115.2165783826
+30|101|0|28189.7521925397
diff --git a/src/tsp/test/development/wi29-tsp.test.sql b/src/tsp/test/development/wi29-tsp.test.sql
new file mode 100644
index 0000000..4b84e56
--- /dev/null
+++ b/src/tsp/test/development/wi29-tsp.test.sql
@@ -0,0 +1,75 @@
+-- http://www.math.uwaterloo.ca/tsp/world/wi29.tsp
+-- http://www.math.uwaterloo.ca/tsp/world/countries.html
+
+-- NAME : wi29
+-- COMMENT : 29 locations in Western Sahara
+-- COMMENT : Derived FROM National Imagery and Mapping Agency data
+-- TYPE : TSP
+-- DIMENSION : 29
+-- EDGE_WEIGHT_TYPE : EUC_2D
+-- NODE_COORD_SECTION
+
+-- best 27603
+
+DROP TABLE IF EXISTS wi29;
+CREATE TABLE wi29 (id BIGINT, x FLOAT, y FLOAT, the_geom geometry);
+COPY wi29 (id, x, y) FROM stdin WITH DELIMITER ' ';
+1 20833.3333 17100.0000
+2 20900.0000 17066.6667
+3 21300.0000 13016.6667
+4 21600.0000 14150.0000
+5 21600.0000 14966.6667
+6 21600.0000 16500.0000
+7 22183.3333 13133.3333
+8 22583.3333 14300.0000
+9 22683.3333 12716.6667
+10 23616.6667 15866.6667
+11 23700.0000 15933.3333
+12 23883.3333 14533.3333
+13 24166.6667 13250.0000
+14 25149.1667 12365.8333
+15 26133.3333 14500.0000
+16 26150.0000 10550.0000
+17 26283.3333 12766.6667
+18 26433.3333 13433.3333
+19 26550.0000 13850.0000
+20 26733.3333 11683.3333
+21 27026.1111 13051.9444
+22 27096.1111 13415.8333
+23 27153.6111 13203.3333
+24 27166.6667 9833.3333
+25 27233.3333 10450.0000
+26 27233.3333 11783.3333
+27 27266.6667 10383.3333
+28 27433.3333 12400.0000
+29 27462.5000 12992.2222
+\.
+
+
+UPDATE wi29 SET the_geom = ST_makePoint(x,y);
+SET client_min_messages TO NOTICE;
+
+SELECT * from pgr_tsp($$SELECT id::INTEGER, x, y FROM wi29$$, 17);
+
+SELECT * FROM pgr_eucledianTSP($$select * FROM wi29$$, 17, randomize := false);
+SELECT * FROM pgr_eucledianTSP($$select * FROM wi29$$, 17, 25, randomize := false);
+
+UPDATE wi29 SET id = id + 100;
+SELECT * FROM pgr_eucledianTSP($$select * FROM wi29$$, 117, 125, randomize := false);
+SELECT * FROM pgr_eucledianTSP($$select * FROM wi29$$, randomize := false);
+
+
+/*
+CREATE VIEW wi29_path AS
+WITH
+results AS (
+    SELECT * FROM pgr_eucledianTSP($$select * FROM wi29$$);
+),
+geoms AS (
+    SELECT seq, node, cost, agg_cost, the_geom AS second  FROM results JOIN wi29 ON (node = id)
+),
+edges AS (
+    SELECT seq, node, ST_MakeLine(lag(second) over(), second) AS line, cost, agg_cost FROM geoms
+)
+SELECT * FROM edges;
+*/
diff --git a/src/tsp/test/doc-pgr_TSP-mac.result b/src/tsp/test/doc-pgr_TSP-mac.result
new file mode 100644
index 0000000..32b34d4
--- /dev/null
+++ b/src/tsp/test/doc-pgr_TSP-mac.result
@@ -0,0 +1,25 @@
+-- q1
+t
+-- q2
+1|7|1|0
+2|8|1|1
+3|5|1|2
+4|2|1|3
+5|1|2|4
+6|3|1|6
+7|4|1|7
+8|9|1|8
+9|12|1|9
+10|11|1|10
+11|10|1|11
+12|13|3|12
+13|6|3|15
+14|7|0|18
+-- q3
+1|5|0.3|0
+2|-6|1.3|0.3
+3|-1|1.6|1.6
+4|3|1|3.2
+5|6|1|4.2
+6|5|0|5.2
+-- q4
diff --git a/src/tsp/test/doc-pgr_TSP-mac.test.sql b/src/tsp/test/doc-pgr_TSP-mac.test.sql
new file mode 100644
index 0000000..e243330
--- /dev/null
+++ b/src/tsp/test/doc-pgr_TSP-mac.test.sql
@@ -0,0 +1,41 @@
+
+SET client_min_messages TO WARNING;
+\echo -- q1
+
+WITH
+query AS (
+    SELECT * FROM pgr_TSP(
+        $$
+        SELECT * FROM pgr_dijkstraCostMatrix(
+            'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+            directed := false
+        )
+        $$
+    )
+)
+SELECT agg_cost < 20 AS under_20 FROM query WHERE seq = 14;
+\echo -- q2
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+        directed := false
+    )
+    $$,
+    start_id := 7,
+    randomize := false
+);
+\echo -- q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 5, 6, -6], directed := false);
+    $$,
+    start_id := 5,
+    randomize := false
+);
+\echo -- q4
diff --git a/src/tsp/test/doc-pgr_TSP-windows.result b/src/tsp/test/doc-pgr_TSP-windows.result
new file mode 100644
index 0000000..32b34d4
--- /dev/null
+++ b/src/tsp/test/doc-pgr_TSP-windows.result
@@ -0,0 +1,25 @@
+-- q1
+t
+-- q2
+1|7|1|0
+2|8|1|1
+3|5|1|2
+4|2|1|3
+5|1|2|4
+6|3|1|6
+7|4|1|7
+8|9|1|8
+9|12|1|9
+10|11|1|10
+11|10|1|11
+12|13|3|12
+13|6|3|15
+14|7|0|18
+-- q3
+1|5|0.3|0
+2|-6|1.3|0.3
+3|-1|1.6|1.6
+4|3|1|3.2
+5|6|1|4.2
+6|5|0|5.2
+-- q4
diff --git a/src/tsp/test/doc-pgr_TSP-windows.test.sql b/src/tsp/test/doc-pgr_TSP-windows.test.sql
new file mode 100644
index 0000000..e243330
--- /dev/null
+++ b/src/tsp/test/doc-pgr_TSP-windows.test.sql
@@ -0,0 +1,41 @@
+
+SET client_min_messages TO WARNING;
+\echo -- q1
+
+WITH
+query AS (
+    SELECT * FROM pgr_TSP(
+        $$
+        SELECT * FROM pgr_dijkstraCostMatrix(
+            'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+            directed := false
+        )
+        $$
+    )
+)
+SELECT agg_cost < 20 AS under_20 FROM query WHERE seq = 14;
+\echo -- q2
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+        directed := false
+    )
+    $$,
+    start_id := 7,
+    randomize := false
+);
+\echo -- q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 5, 6, -6], directed := false);
+    $$,
+    start_id := 5,
+    randomize := false
+);
+\echo -- q4
diff --git a/src/tsp/test/doc-pgr_TSP.result b/src/tsp/test/doc-pgr_TSP.result
new file mode 100644
index 0000000..c06eed1
--- /dev/null
+++ b/src/tsp/test/doc-pgr_TSP.result
@@ -0,0 +1,25 @@
+-- q1
+t
+-- q2
+1|7|1|0
+2|8|1|1
+3|5|1|2
+4|2|1|3
+5|1|2|4
+6|3|1|6
+7|4|1|7
+8|9|1|8
+9|12|1|9
+10|11|1|10
+11|10|1|11
+12|13|3|12
+13|6|3|15
+14|7|0|18
+-- q3
+1|5|1|0
+2|6|1|1
+3|3|1.6|2
+4|-1|1.3|3.6
+5|-6|0.3|4.9
+6|5|0|5.2
+-- q4
diff --git a/src/tsp/test/doc-pgr_TSP.test.sql b/src/tsp/test/doc-pgr_TSP.test.sql
new file mode 100644
index 0000000..e243330
--- /dev/null
+++ b/src/tsp/test/doc-pgr_TSP.test.sql
@@ -0,0 +1,41 @@
+
+SET client_min_messages TO WARNING;
+\echo -- q1
+
+WITH
+query AS (
+    SELECT * FROM pgr_TSP(
+        $$
+        SELECT * FROM pgr_dijkstraCostMatrix(
+            'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+            directed := false
+        )
+        $$
+    )
+)
+SELECT agg_cost < 20 AS under_20 FROM query WHERE seq = 14;
+\echo -- q2
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
+        directed := false
+    )
+    $$,
+    start_id := 7,
+    randomize := false
+);
+\echo -- q3
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_withPointsCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
+        'SELECT pid, edge_id, fraction from pointsOfInterest',
+        array[-1, 3, 5, 6, -6], directed := false);
+    $$,
+    start_id := 5,
+    randomize := false
+);
+\echo -- q4
diff --git a/src/tsp/test/doc-pgr_eucledianTSP.result b/src/tsp/test/doc-pgr_eucledianTSP.result
new file mode 100644
index 0000000..d40e21e
--- /dev/null
+++ b/src/tsp/test/doc-pgr_eucledianTSP.result
@@ -0,0 +1,50 @@
+-- q1
+t
+-- q2
+1|1|1.4142135623731|0
+2|3|1|1.4142135623731
+3|4|1|2.41421356237309
+4|9|0.58309518948453|3.41421356237309
+5|16|0.58309518948453|3.99730875185762
+6|6|1|4.58040394134215
+7|5|1|5.58040394134215
+8|8|1|6.58040394134215
+9|7|1.58113883008419|7.58040394134215
+10|14|1.499999999999|9.16154277142634
+11|15|0.5|10.6615427714253
+12|13|1.5|11.1615427714253
+13|17|1.11803398874989|12.6615427714253
+14|12|1|13.7795767601752
+15|11|1|14.7795767601752
+16|10|2|15.7795767601752
+17|2|1|17.7795767601752
+18|1|0|18.7795767601752
+-- q3
+NOTICE:  pgr_eucledianTSP Processing Information 
+Initializing tsp class ---> tsp.greedyInitial ---> tsp.annealing ---> OK
+
+Cycle(100)    total changes =0        0 were because  delta energy < 0
+Total swaps: 3
+Total slides: 0
+Total reverses: 0
+Times best tour changed: 4
+Best cost reached = 18.7796
+1|1|1.4142135623731|0
+2|3|1|1.4142135623731
+3|4|1|2.41421356237309
+4|9|0.58309518948453|3.41421356237309
+5|16|0.58309518948453|3.99730875185762
+6|6|1|4.58040394134215
+7|5|1|5.58040394134215
+8|8|1|6.58040394134215
+9|7|1.58113883008419|7.58040394134215
+10|14|1.499999999999|9.16154277142634
+11|15|0.5|10.6615427714253
+12|13|1.5|11.1615427714253
+13|17|1.11803398874989|12.6615427714253
+14|12|1|13.7795767601752
+15|11|1|14.7795767601752
+16|10|2|15.7795767601752
+17|2|1|17.7795767601752
+18|1|0|18.7795767601752
+-- q4
diff --git a/src/tsp/test/doc-pgr_eucledianTSP.test.sql b/src/tsp/test/doc-pgr_eucledianTSP.test.sql
new file mode 100644
index 0000000..8da7c99
--- /dev/null
+++ b/src/tsp/test/doc-pgr_eucledianTSP.test.sql
@@ -0,0 +1,35 @@
+BEGIN;
+
+SET client_min_messages TO WARNING;
+\echo -- q1
+WITH
+query AS (
+    SELECT * FROM pgr_eucledianTSP(
+        $$
+        SELECT id, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+        $$
+    )
+)
+SELECT agg_cost < 20 AS under_20 FROM query WHERE seq = 18;
+
+\echo -- q2
+SELECT* from pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom) AS y FROM edge_table_vertices_pgr
+    $$,
+    tries_per_temperature := 3,
+    cooling_factor := 0.5,
+    randomize := false
+);
+\echo -- q3
+SET client_min_messages TO NOTICE;
+SELECT* from pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom) AS y FROM edge_table_vertices_pgr
+    $$,
+    tries_per_temperature := 0,
+    randomize := false
+);
+\echo -- q4
+
+ROLLBACK;
diff --git a/src/tsp/test/doc-tsp-mac.result b/src/tsp/test/doc-tsp-mac.result
new file mode 100644
index 0000000..7d60bc0
--- /dev/null
+++ b/src/tsp/test/doc-tsp-mac.result
@@ -0,0 +1,68 @@
+-- q1
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+0|1|1|1.4142135623731
+1|3|3|1
+2|4|4|1
+3|9|9|1
+4|6|6|0.58309518948453
+5|16|16|0.860232526704263
+6|12|12|1.11803398874989
+7|17|17|1.11803398874989
+8|11|11|1
+9|10|10|0.5
+10|15|15|0.5
+11|13|13|1.58113883008419
+12|14|14|1.58113883008419
+13|7|7|1
+14|8|8|1
+15|5|5|1
+16|2|2|1
+-- q2
+1|1|1.4142135623731|0
+2|3|1|1.4142135623731
+3|4|1|2.41421356237309
+4|9|1|3.41421356237309
+5|6|0.58309518948453|4.41421356237309
+6|16|0.860232526704263|4.99730875185763
+7|12|1.11803398874989|5.85754127856189
+8|17|1.11803398874989|6.97557526731178
+9|11|1|8.09360925606168
+10|10|0.5|9.09360925606168
+11|15|0.5|9.59360925606168
+12|13|1.58113883008419|10.0936092560617
+13|14|1.58113883008419|11.6747480861459
+14|7|1|13.2558869162301
+15|8|1|14.2558869162301
+16|5|1|15.2558869162301
+17|2|1|16.2558869162301
+18|1|0|17.2558869162301
+-- q3
+0|1
+1|2
+2|3
+3|8
+4|11
+5|5
+6|10
+7|12
+8|9
+9|6
+10|7
+11|4
+12|0
+-- q4
+1|1|1|0
+2|2|1|1
+3|3|1|2
+4|4|1|3
+5|9|1|4
+6|12|1|5
+7|11|1|6
+8|6|3|7
+9|7|1|10
+10|8|1|11
+11|5|1|12
+12|10|1|13
+13|13|4|14
+14|1|0|18
+-- q5
diff --git a/src/tsp/test/doc-tsp-mac.test.sql b/src/tsp/test/doc-tsp-mac.test.sql
new file mode 100644
index 0000000..9f7292e
--- /dev/null
+++ b/src/tsp/test/doc-tsp-mac.test.sql
@@ -0,0 +1,40 @@
+BEGIN;
+
+SET client_min_messages TO WARNING;
+\echo -- q1
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT id::INTEGER, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$
+    , 1);
+
+\echo -- q2
+SELECT * FROM pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$,
+    1,
+    randomize := false
+);
+
+\echo -- q3
+SELECT * FROM pgr_TSP(
+    (SELECT * FROM pgr_vidsToDMatrix(
+            'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14)::INTEGER[], false , true, true)
+    ),
+    1
+);
+
+\echo -- q4
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14), false)
+    $$,
+    1,
+    randomize := false
+);
+\echo -- q5
+ROLLBACK;
diff --git a/src/tsp/test/doc-tsp-windows.result b/src/tsp/test/doc-tsp-windows.result
new file mode 100644
index 0000000..870a0d7
--- /dev/null
+++ b/src/tsp/test/doc-tsp-windows.result
@@ -0,0 +1,68 @@
+-- q1
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+0|1|1|1
+1|2|2|1
+2|5|5|1
+3|8|8|1
+4|7|7|1.58113883008419
+5|14|14|1.58113883008419
+6|13|13|0.5
+7|15|15|0.5
+8|10|10|1
+9|11|11|1.11803398874989
+10|17|17|1.11803398874989
+11|12|12|0.860232526704263
+12|16|16|0.58309518948453
+13|6|6|1
+14|9|9|1
+15|4|4|1
+16|3|3|1.4142135623731
+-- q2
+1|1|1|0
+2|2|1|1
+3|5|1|2
+4|8|1|3
+5|7|1.58113883008419|4
+6|14|1.58113883008419|5.58113883008419
+7|13|0.5|7.16227766016838
+8|15|0.5|7.66227766016838
+9|10|1|8.16227766016838
+10|11|1.11803398874989|9.16227766016838
+11|17|1.11803398874989|10.2803116489183
+12|12|0.860232526704263|11.3983456376682
+13|16|0.58309518948453|12.2585781643724
+14|6|1|12.841673353857
+15|9|1|13.841673353857
+16|4|1|14.841673353857
+17|3|1.4142135623731|15.841673353857
+18|1|0|17.2558869162301
+-- q3
+0|1
+1|2
+2|3
+3|8
+4|11
+5|5
+6|10
+7|12
+8|9
+9|6
+10|7
+11|4
+12|0
+-- q4
+1|1|1|0
+2|2|1|1
+3|3|1|2
+4|4|1|3
+5|9|1|4
+6|12|1|5
+7|11|2|6
+8|13|1|8
+9|10|1|9
+10|5|1|10
+11|6|2|11
+12|8|1|13
+13|7|4|14
+14|1|0|18
+-- q5
diff --git a/src/tsp/test/doc-tsp-windows.test.sql b/src/tsp/test/doc-tsp-windows.test.sql
new file mode 100644
index 0000000..9f7292e
--- /dev/null
+++ b/src/tsp/test/doc-tsp-windows.test.sql
@@ -0,0 +1,40 @@
+BEGIN;
+
+SET client_min_messages TO WARNING;
+\echo -- q1
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT id::INTEGER, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$
+    , 1);
+
+\echo -- q2
+SELECT * FROM pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$,
+    1,
+    randomize := false
+);
+
+\echo -- q3
+SELECT * FROM pgr_TSP(
+    (SELECT * FROM pgr_vidsToDMatrix(
+            'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14)::INTEGER[], false , true, true)
+    ),
+    1
+);
+
+\echo -- q4
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14), false)
+    $$,
+    1,
+    randomize := false
+);
+\echo -- q5
+ROLLBACK;
diff --git a/src/tsp/test/doc-tsp.result b/src/tsp/test/doc-tsp.result
new file mode 100644
index 0000000..a7bbe5a
--- /dev/null
+++ b/src/tsp/test/doc-tsp.result
@@ -0,0 +1,68 @@
+-- q1
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+0|1|1|1
+1|2|2|1
+2|5|5|1
+3|8|8|1
+4|7|7|1.58113883008419
+5|14|14|1.58113883008419
+6|13|13|0.5
+7|15|15|0.5
+8|10|10|1
+9|11|11|1.11803398874989
+10|17|17|1.11803398874989
+11|12|12|0.860232526704263
+12|16|16|0.58309518948453
+13|6|6|1
+14|9|9|1
+15|4|4|1
+16|3|3|1.4142135623731
+-- q2
+1|1|1.4142135623731|0
+2|3|1|1.4142135623731
+3|4|1|2.41421356237309
+4|9|1|3.41421356237309
+5|6|0.58309518948453|4.41421356237309
+6|16|0.860232526704263|4.99730875185763
+7|12|1.11803398874989|5.85754127856189
+8|17|1.11803398874989|6.97557526731178
+9|11|1|8.09360925606168
+10|10|0.5|9.09360925606168
+11|15|0.5|9.59360925606168
+12|13|1.58113883008419|10.0936092560617
+13|14|1.58113883008419|11.6747480861459
+14|7|1|13.2558869162301
+15|8|1|14.2558869162301
+16|5|1|15.2558869162301
+17|2|1|16.2558869162301
+18|1|0|17.2558869162301
+-- q3
+0|1
+1|2
+2|3
+3|8
+4|11
+5|5
+6|10
+7|12
+8|9
+9|6
+10|7
+11|4
+12|0
+-- q4
+1|1|3|0
+2|4|1|3
+3|9|1|4
+4|12|1|5
+5|11|2|6
+6|13|1|8
+7|10|1|9
+8|5|2|10
+9|7|1|12
+10|8|2|13
+11|6|1|15
+12|3|1|16
+13|2|1|17
+14|1|0|18
+-- q5
diff --git a/src/tsp/test/doc-tsp.test.sql b/src/tsp/test/doc-tsp.test.sql
new file mode 100644
index 0000000..9f7292e
--- /dev/null
+++ b/src/tsp/test/doc-tsp.test.sql
@@ -0,0 +1,40 @@
+BEGIN;
+
+SET client_min_messages TO WARNING;
+\echo -- q1
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT id::INTEGER, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$
+    , 1);
+
+\echo -- q2
+SELECT * FROM pgr_eucledianTSP(
+    $$
+    SELECT id, st_X(the_geom) AS x, st_Y(the_geom)AS y  FROM edge_table_vertices_pgr
+    $$,
+    1,
+    randomize := false
+);
+
+\echo -- q3
+SELECT * FROM pgr_TSP(
+    (SELECT * FROM pgr_vidsToDMatrix(
+            'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, reverse_cost FROM edge_table',
+            (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14)::INTEGER[], false , true, true)
+    ),
+    1
+);
+
+\echo -- q4
+SELECT * FROM pgr_TSP(
+    $$
+    SELECT * FROM pgr_dijkstraCostMatrix(
+        'SELECT id, source, target, cost, reverse_cost FROM edge_table',
+        (SELECT array_agg(id) from edge_table_vertices_pgr WHERE id < 14), false)
+    $$,
+    1,
+    randomize := false
+);
+\echo -- q5
+ROLLBACK;
diff --git a/src/tsp/test/performance/dj38.sql b/src/tsp/test/performance/dj38.sql
new file mode 100644
index 0000000..f57d953
--- /dev/null
+++ b/src/tsp/test/performance/dj38.sql
@@ -0,0 +1,84 @@
+\i setup.sql
+
+SELECT plan(39);
+SET client_min_messages TO WARNING;
+
+-- http://www.math.uwaterloo.ca/tsp/world/dj38.tsp
+-- http://www.math.uwaterloo.ca/tsp/world/countries.html
+
+-- NAME: dj38
+-- COMMENT : 38 locations in Djibouti
+-- COMMENT : Derived from National Imagery and Mapping Agency data
+-- COMMENT : This file is a corrected version of dj89, where duplications
+-- COMMENT:  have been removed.  Thanks to Jay Muthuswamy and others for
+-- COMMENT:  requesting data sets without duplications.
+-- TYPE: TSP
+-- DIMENSION: 38
+-- EDGE_WEIGHT_TYPE: EUC_2D
+-- NODE_COORD_SECTION
+
+-- best 6656
+
+CREATE TABLE dj38 (id BIGINT, x FLOAT, y FLOAT, the_geom geometry);
+CREATE TEMP TABLE dj38 (id BIGINT, x FLOAT, y FLOAT, the_geom geometry);
+COPY dj38 (id, x, y) FROM stdin WITH DELIMITER ' ';
+1 11003.611100 42102.500000
+2 11108.611100 42373.888900
+3 11133.333300 42885.833300
+4 11155.833300 42712.500000
+5 11183.333300 42933.333300
+6 11297.500000 42853.333300
+7 11310.277800 42929.444400
+8 11416.666700 42983.333300
+9 11423.888900 43000.277800
+10 11438.333300 42057.222200
+11 11461.111100 43252.777800
+12 11485.555600 43187.222200
+13 11503.055600 42855.277800
+14 11511.388900 42106.388900
+15 11522.222200 42841.944400
+16 11569.444400 43136.666700
+17 11583.333300 43150.000000
+18 11595.000000 43148.055600
+19 11600.000000 43150.000000
+20 11690.555600 42686.666700
+21 11715.833300 41836.111100
+22 11751.111100 42814.444400
+23 11770.277800 42651.944400
+24 11785.277800 42884.444400
+25 11822.777800 42673.611100
+26 11846.944400 42660.555600
+27 11963.055600 43290.555600
+28 11973.055600 43026.111100
+29 12058.333300 42195.555600
+30 12149.444400 42477.500000
+31 12286.944400 43355.555600
+32 12300.000000 42433.333300
+33 12355.833300 43156.388900
+34 12363.333300 43189.166700
+35 12372.777800 42711.388900
+36 12386.666700 43334.722200
+37 12421.666700 42895.555600
+38 12645.000000 42973.333300
+\.
+
+
+UPDATE dj38 SET the_geom = ST_makePoint(x,y);
+
+CREATE OR REPLACE FUNCTION test_performance(upper_bound FLOAT)
+RETURNS SETOF TEXT AS
+$BODY$
+BEGIN
+    FOR i IN 1..39 LOOP
+        RETURN query SELECT is((SELECT agg_cost < 6656 * upper_bound  FROM pgr_eucledianTSP('select * FROM dj38', i, randomize := false) WHERE seq = 39),
+            't',
+            'i= ' || i || ' upper_bound = ' || upper_bound);
+    END LOOP;
+END;
+$BODY$ LANGUAGE plpgsql;
+
+select test_performance(1.1);
+
+SELECT finish();
+ROLLBACK;
+
diff --git a/src/tsp/test/performance/qa194.sql b/src/tsp/test/performance/qa194.sql
new file mode 100644
index 0000000..9078383
--- /dev/null
+++ b/src/tsp/test/performance/qa194.sql
@@ -0,0 +1,239 @@
+\i setup.sql
+
+SELECT plan(39);
+SET client_min_messages TO WARNING;
+
+
+-- http://www.math.uwaterloo.ca/tsp/world/qa194.tsp
+
+-- NAME : qa194
+-- COMMENT : 194 locations in Qatar
+-- COMMENT : Derived from National Imagery and Mapping Agency data
+-- TYPE : TSP
+-- DIMENSION : 194
+-- EDGE_WEIGHT_TYPE : EUC_2D
+-- NODE_COORD_SECTION
+-- OPTIMAL 9352
+
+
+
+CREATE TABLE qa194 (id BIGINT, x FLOAT, y FLOAT, the_geom geometry);
+COPY qa194 (id, x, y) FROM stdin WITH DELIMITER ' ';
+1 24748.3333 50840.0000
+2 24758.8889 51211.9444
+3 24827.2222 51394.7222
+4 24904.4444 51175.0000
+5 24996.1111 51548.8889
+6 25010.0000 51039.4444
+7 25030.8333 51275.2778
+8 25067.7778 51077.5000
+9 25100.0000 51516.6667
+10 25103.3333 51521.6667
+11 25121.9444 51218.3333
+12 25150.8333 51537.7778
+13 25158.3333 51163.6111
+14 25162.2222 51220.8333
+15 25167.7778 51606.9444
+16 25168.8889 51086.3889
+17 25173.8889 51269.4444
+18 25210.8333 51394.1667
+19 25211.3889 51619.1667
+20 25214.1667 50807.2222
+21 25214.4444 51378.8889
+22 25223.3333 51451.6667
+23 25224.1667 51174.4444
+24 25233.3333 51333.3333
+25 25234.1667 51203.0556
+26 25235.5556 51330.0000
+27 25235.5556 51495.5556
+28 25242.7778 51428.8889
+29 25243.0556 51452.5000
+30 25252.5000 51559.1667
+31 25253.8889 51535.2778
+32 25253.8889 51549.7222
+33 25256.9444 51398.8889
+34 25263.6111 51516.3889
+35 25265.8333 51545.2778
+36 25266.6667 50969.1667
+37 25266.6667 51483.3333
+38 25270.5556 51532.7778
+39 25270.8333 51505.8333
+40 25270.8333 51523.0556
+41 25275.8333 51533.6111
+42 25277.2222 51547.7778
+43 25278.3333 51525.5556
+44 25278.3333 51541.3889
+45 25279.1667 51445.5556
+46 25281.1111 51535.0000
+47 25281.3889 51512.5000
+48 25283.3333 51533.3333
+49 25283.6111 51546.6667
+50 25284.7222 51555.2778
+51 25286.1111 51504.1667
+52 25286.1111 51534.1667
+53 25286.6667 51533.3333
+54 25287.5000 51537.7778
+55 25288.0556 51546.6667
+56 25290.8333 51528.3333
+57 25291.9444 51424.4444
+58 25292.5000 51520.8333
+59 25298.6111 51001.6667
+60 25300.8333 51394.4444
+61 25306.9444 51507.7778
+62 25311.9444 51003.0556
+63 25313.8889 50883.3333
+64 25315.2778 51438.6111
+65 25316.6667 50766.6667
+66 25320.5556 51495.5556
+67 25322.5000 51507.7778
+68 25325.2778 51470.0000
+69 25326.6667 51350.2778
+70 25337.5000 51425.0000
+71 25339.1667 51173.3333
+72 25340.5556 51293.6111
+73 25341.9444 51507.5000
+74 25358.8889 51333.6111
+75 25363.6111 51281.1111
+76 25368.6111 51226.3889
+77 25374.4444 51436.6667
+78 25377.7778 51294.7222
+79 25396.9444 51422.5000
+80 25400.0000 51183.3333
+81 25400.0000 51425.0000
+82 25404.7222 51073.0556
+83 25416.9444 51403.8889
+84 25416.9444 51457.7778
+85 25419.4444 50793.6111
+86 25429.7222 50785.8333
+87 25433.3333 51220.0000
+88 25440.8333 51378.0556
+89 25444.4444 50958.3333
+90 25451.3889 50925.0000
+91 25459.1667 51316.6667
+92 25469.7222 51397.5000
+93 25478.0556 51362.5000
+94 25480.5556 50938.8889
+95 25483.3333 51383.3333
+96 25490.5556 51373.6111
+97 25492.2222 51400.2778
+98 25495.0000 50846.6667
+99 25495.0000 50965.2778
+100 25497.5000 51485.2778
+101 25500.8333 50980.5556
+102 25510.5556 51242.2222
+103 25531.9444 51304.4444
+104 25533.3333 50977.2222
+105 25538.8889 51408.3333
+106 25545.8333 51387.5000
+107 25549.7222 51431.9444
+108 25550.0000 51433.3333
+109 25560.2778 51158.6111
+110 25566.9444 51484.7222
+111 25567.5000 50958.8889
+112 25574.7222 51486.3889
+113 25585.5556 51151.3889
+114 25609.4444 51092.2222
+115 25610.2778 51475.2778
+116 25622.5000 51454.4444
+117 25645.8333 51450.0000
+118 25650.0000 51372.2222
+119 25666.9444 51174.4444
+120 25683.8889 51505.8333
+121 25686.3889 51468.8889
+122 25696.1111 51260.8333
+123 25700.8333 51584.7222
+124 25708.3333 51591.6667
+125 25716.6667 51050.0000
+126 25717.5000 51057.7778
+127 25723.0556 51004.1667
+128 25734.7222 51547.5000
+129 25751.1111 51449.1667
+130 25751.9444 50920.8333
+131 25758.3333 51395.8333
+132 25765.2778 51019.7222
+133 25772.2222 51483.3333
+134 25775.8333 51023.0556
+135 25779.1667 51449.7222
+136 25793.3333 51409.4444
+137 25808.3333 51060.5556
+138 25816.6667 51133.3333
+139 25823.6111 51152.5000
+140 25826.6667 51043.8889
+141 25829.7222 51245.2778
+142 25833.3333 51072.2222
+143 25839.1667 51465.2778
+144 25847.7778 51205.8333
+145 25850.0000 51033.3333
+146 25856.6667 51083.3333
+147 25857.5000 51298.8889
+148 25857.5000 51441.3889
+149 25866.6667 51066.6667
+150 25867.7778 51205.5556
+151 25871.9444 51354.7222
+152 25872.5000 51258.3333
+153 25880.8333 51221.3889
+154 25883.0556 51185.2778
+155 25888.0556 51386.3889
+156 25900.0000 51000.0000
+157 25904.1667 51201.6667
+158 25928.3333 51337.5000
+159 25937.5000 51313.3333
+160 25944.7222 51456.3889
+161 25950.0000 51066.6667
+162 25951.6667 51349.7222
+163 25957.7778 51075.2778
+164 25958.3333 51099.4444
+165 25966.6667 51283.3333
+166 25983.3333 51400.0000
+167 25983.6111 51328.0556
+168 26000.2778 51294.4444
+169 26008.6111 51083.6111
+170 26016.6667 51333.3333
+171 26021.6667 51366.9444
+172 26033.3333 51116.6667
+173 26033.3333 51166.6667
+174 26033.6111 51163.8889
+175 26033.6111 51200.2778
+176 26048.8889 51056.9444
+177 26050.0000 51250.0000
+178 26050.2778 51297.5000
+179 26050.5556 51135.8333
+180 26055.0000 51316.1111
+181 26067.2222 51258.6111
+182 26074.7222 51083.6111
+183 26076.6667 51166.9444
+184 26077.2222 51222.2222
+185 26078.0556 51361.6667
+186 26083.6111 51147.2222
+187 26099.7222 51161.1111
+188 26108.0556 51244.7222
+189 26116.6667 51216.6667
+190 26123.6111 51169.1667
+191 26123.6111 51222.7778
+192 26133.3333 51216.6667
+193 26133.3333 51300.0000
+194 26150.2778 51108.0556
+\.
+
+
+UPDATE qa194 SET the_geom = ST_makePoint(x,y);
+
+CREATE OR REPLACE FUNCTION test_performance(upper_bound FLOAT)
+RETURNS SETOF TEXT AS
+$BODY$
+BEGIN
+    FOR i IN 1..194 BY 5 LOOP
+        RETURN query SELECT is((SELECT agg_cost < 9352 * upper_bound  FROM pgr_eucledianTSP('select * FROM qa194', i, tries_per_temperature:= 1, randomize := false) WHERE seq = 195),
+            't',
+            'i= ' || i || ' upper_bound = ' || upper_bound);
+    END LOOP;
+END;
+$BODY$ LANGUAGE plpgsql;
+
+select test_performance(1.4);
+
+SELECT finish();
+ROLLBACK;
+
+
+
diff --git a/src/tsp/test/performance/wi29.sql b/src/tsp/test/performance/wi29.sql
new file mode 100644
index 0000000..1c36aa0
--- /dev/null
+++ b/src/tsp/test/performance/wi29.sql
@@ -0,0 +1,71 @@
+\i setup.sql
+
+SELECT plan(29);
+SET client_min_messages TO WARNING;
+
+-- http://www.math.uwaterloo.ca/tsp/world/wi29.tsp
+-- http://www.math.uwaterloo.ca/tsp/world/countries.html
+
+-- NAME : wi29
+-- COMMENT : 29 locations in Western Sahara
+-- COMMENT : Derived FROM National Imagery and Mapping Agency data
+-- TYPE : TSP
+-- DIMENSION : 29
+-- EDGE_WEIGHT_TYPE : EUC_2D
+-- NODE_COORD_SECTION
+
+-- best 27603
+
+CREATE TEMP TABLE wi29 (id BIGINT, x FLOAT, y FLOAT, the_geom geometry);
+COPY wi29 (id, x, y) FROM stdin WITH DELIMITER ' ';
+1 20833.3333 17100.0000
+2 20900.0000 17066.6667
+3 21300.0000 13016.6667
+4 21600.0000 14150.0000
+5 21600.0000 14966.6667
+6 21600.0000 16500.0000
+7 22183.3333 13133.3333
+8 22583.3333 14300.0000
+9 22683.3333 12716.6667
+10 23616.6667 15866.6667
+11 23700.0000 15933.3333
+12 23883.3333 14533.3333
+13 24166.6667 13250.0000
+14 25149.1667 12365.8333
+15 26133.3333 14500.0000
+16 26150.0000 10550.0000
+17 26283.3333 12766.6667
+18 26433.3333 13433.3333
+19 26550.0000 13850.0000
+20 26733.3333 11683.3333
+21 27026.1111 13051.9444
+22 27096.1111 13415.8333
+23 27153.6111 13203.3333
+24 27166.6667 9833.3333
+25 27233.3333 10450.0000
+26 27233.3333 11783.3333
+27 27266.6667 10383.3333
+28 27433.3333 12400.0000
+29 27462.5000 12992.2222
+\.
+
+
+UPDATE wi29 SET the_geom = ST_makePoint(x,y);
+
+CREATE OR REPLACE FUNCTION test_performance(upper_bound FLOAT)
+RETURNS SETOF TEXT AS
+$BODY$
+BEGIN
+    FOR i IN 1..29 LOOP
+        RETURN query SELECT is((SELECT agg_cost < 27603 * upper_bound  FROM pgr_eucledianTSP('select * FROM wi29', i, randomize := false) WHERE seq = 30),
+            't',
+            'i= ' || i || ' upper_bound = ' || upper_bound);
+    END LOOP;
+END;
+$BODY$ LANGUAGE plpgsql;
+
+select test_performance(1.065);
+
+SELECT finish();
+ROLLBACK;
+
diff --git a/src/tsp/test/pgtap/pgr_TSP_types_check.sql b/src/tsp/test/pgtap/pgr_TSP_types_check.sql
new file mode 100644
index 0000000..0b19163
--- /dev/null
+++ b/src/tsp/test/pgtap/pgr_TSP_types_check.sql
@@ -0,0 +1,213 @@
+
+\i setup.sql
+
+SELECT plan(28);
+SET client_min_messages TO WARNING;
+
+SELECT has_function('pgr_tsp');
+SELECT has_function('pgr_tsp', ARRAY[
+    'text', 'bigint', 'bigint',
+    'double precision',
+    'integer', 'integer', 'integer',
+    'double precision',
+    'double precision',
+    'double precision',
+    'boolean'
+    ]);
+SELECT function_returns('pgr_tsp', ARRAY[
+    'text', 'bigint', 'bigint',
+    'double precision',
+    'integer', 'integer', 'integer',
+    'double precision',
+    'double precision',
+    'double precision',
+    'boolean'
+    ], 'setof record');
+
+PREPARE parameters AS
+SELECT array[
+'matrix_row_sql',
+'start_id','end_id','max_processing_time',
+'tries_per_temperature',
+'max_changes_per_temperature',
+'max_consecutive_non_changes',
+'initial_temperature',
+'final_temperature',
+'cooling_factor',
+'randomize',
+'seq',
+'node',
+'cost',
+'agg_cost'];
+
+SELECT set_has(
+    $$SELECT proargnames FROM pg_proc WHERE proname = 'pgr_tsp'$$,
+    'parameters');
+
+
+
+CREATE TEMP TABLE matrixrows AS
+SELECT * FROM pgr_dijkstraCostMatrix(
+    $$SELECT id, source, target, cost, reverse_cost FROM edge_table$$,
+    (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE ID < 14),
+    directed:= false
+);
+
+CREATE OR REPLACE FUNCTION test_anyInteger(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+        FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+    END IF;
+    start_sql = start_sql || p || ', ';
+END LOOP;
+end_sql = ' FROM matrixrows $$, randomize := false)';
+
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION test_anyNumerical(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+        FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+    END IF;
+    start_sql = start_sql || p || ', ';
+END LOOP;
+end_sql = ' FROM matrixrows $$, randomize := false)';
+
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+SELECT test_anyInteger('pgr_tsp',
+    ARRAY['start_vid', 'end_vid', 'agg_cost'],
+    'start_vid');
+SELECT test_anyInteger('pgr_tsp',
+    ARRAY['start_vid', 'end_vid', 'agg_cost'],
+    'end_vid');
+SELECT test_anyNumerical('pgr_tsp',
+    ARRAY['start_vid', 'end_vid', 'agg_cost'],
+    'agg_cost');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        max_processing_time := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: max_processing_time >= 0',
+    'SHOULD throw because max_processing_time has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        tries_per_temperature := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: tries_per_temperature >= 0',
+    'SHOULD throw because tries_per_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        max_changes_per_temperature := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: max_changes_per_temperature > 0',
+    'SHOULD throw because max_changes_per_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        max_consecutive_non_changes := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: max_consecutive_non_changes > 0',
+    'SHOULD throw because max_consecutive_non_changes has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        cooling_factor := 0,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: 0 < cooling_factor < 1',
+    'SHOULD throw because cooling_factor has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        cooling_factor := 1,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: 0 < cooling_factor < 1',
+    'SHOULD throw because cooling_factor has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        initial_temperature := 0,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: initial_temperature > final_temperature',
+    'SHOULD throw because initial_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        final_temperature := 101,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: initial_temperature > final_temperature',
+    'SHOULD throw because final_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_TSP('SELECT start_vid, end_vid, agg_cost FROM matrixrows',
+        final_temperature := 0,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: final_temperature > 0',
+    'SHOULD throw because final_temperature has illegal value');
+
+/*
+initial_temperature FLOAT DEFAULT 100,
+final_temperature FLOAT DEFAULT 0.1,
+ */
+
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/tsp/test/pgtap/pgr_eucledianTSP_types_check.sql b/src/tsp/test/pgtap/pgr_eucledianTSP_types_check.sql
new file mode 100644
index 0000000..5194d75
--- /dev/null
+++ b/src/tsp/test/pgtap/pgr_eucledianTSP_types_check.sql
@@ -0,0 +1,210 @@
+
+\i setup.sql
+
+SELECT plan(28);
+SET client_min_messages TO WARNING;
+
+SELECT has_function('pgr_euclediantsp');
+SELECT has_function('pgr_euclediantsp', ARRAY[
+    'text', 'bigint', 'bigint',
+    'double precision',
+    'integer', 'integer', 'integer',
+    'double precision',
+    'double precision',
+    'double precision',
+    'boolean'
+    ]);
+SELECT function_returns('pgr_euclediantsp', ARRAY[
+    'text', 'bigint', 'bigint',
+    'double precision',
+    'integer', 'integer', 'integer',
+    'double precision',
+    'double precision',
+    'double precision',
+    'boolean'
+    ], 'setof record');
+
+PREPARE parameters AS
+SELECT array[
+'coordinates_sql',
+'start_id','end_id','max_processing_time',
+'tries_per_temperature',
+'max_changes_per_temperature',
+'max_consecutive_non_changes',
+'initial_temperature',
+'final_temperature',
+'cooling_factor',
+'randomize',
+'seq',
+'node',
+'cost',
+'agg_cost'];
+
+SELECT set_eq(
+    $$SELECT proargnames FROM pg_proc WHERE proname = 'pgr_euclediantsp'$$,
+    'parameters');
+
+
+
+CREATE TEMP TABLE coords AS
+SELECT id, ST_X(the_geom) AS x, ST_Y(the_geom) AS y
+FROM edge_table_vertices_pgr;
+
+CREATE OR REPLACE FUNCTION test_anyInteger(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+        FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+    END IF;
+    start_sql = start_sql || p || ', ';
+END LOOP;
+end_sql = ' FROM coords $$, randomize := false)';
+
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT throws_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION test_anyNumerical(fn TEXT, params TEXT[], parameter TEXT) 
+RETURNS SETOF TEXT AS
+$BODY$
+DECLARE
+start_sql TEXT;
+end_sql TEXT;
+query TEXT;
+p TEXT;
+BEGIN
+    start_sql = 'select * from ' || fn || '($$ SELECT ';
+        FOREACH  p IN ARRAY params LOOP
+        IF p = parameter THEN CONTINUE;
+    END IF;
+    start_sql = start_sql || p || ', ';
+END LOOP;
+end_sql = ' FROM coords $$, randomize := false)';
+
+    query := start_sql || parameter || '::SMALLINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::INTEGER ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::BIGINT ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::REAL ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+
+    query := start_sql || parameter || '::FLOAT8 ' || end_sql;
+    RETURN query SELECT lives_ok(query);
+END;
+$BODY$ LANGUAGE plpgsql;
+
+SELECT test_anyInteger('pgr_euclediantsp',
+    ARRAY['id', 'x', 'y'],
+    'id');
+SELECT test_anyNumerical('pgr_euclediantsp',
+    ARRAY['id', 'x', 'y'],
+    'x');
+SELECT test_anyNumerical('pgr_euclediantsp',
+    ARRAY['id', 'x', 'y'],
+    'y');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        max_processing_time := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: max_processing_time >= 0',
+    'SHOULD throw because max_processing_time has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        tries_per_temperature := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: tries_per_temperature >= 0',
+    'SHOULD throw because tries_per_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        max_changes_per_temperature := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: max_changes_per_temperature > 0',
+    'SHOULD throw because max_changes_per_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        max_consecutive_non_changes := -4,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: max_consecutive_non_changes > 0',
+    'SHOULD throw because max_consecutive_non_changes has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        cooling_factor := 0,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: 0 < cooling_factor < 1',
+    'SHOULD throw because cooling_factor has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        cooling_factor := 1,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: 0 < cooling_factor < 1',
+    'SHOULD throw because cooling_factor has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        initial_temperature := 0,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: initial_temperature > final_temperature',
+    'SHOULD throw because initial_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        final_temperature := 101,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: initial_temperature > final_temperature',
+    'SHOULD throw because final_temperature has illegal value');
+
+SELECT throws_ok($$
+    SELECT * FROM pgr_eucledianTSP('SELECT id, x, y FROM coords',
+        final_temperature := 0,
+        randomize := false)$$,
+    'XX000',
+    'Condition not met: final_temperature > 0',
+    'SHOULD throw because final_temperature has illegal value');
+
+/*
+initial_temperature FLOAT DEFAULT 100,
+final_temperature FLOAT DEFAULT 0.1,
+ */
+
+
+SELECT finish();
+ROLLBACK;
diff --git a/src/tsp/test/test.conf b/src/tsp/test/test.conf
index d50f65d..714c533 100644
--- a/src/tsp/test/test.conf
+++ b/src/tsp/test/test.conf
@@ -2,16 +2,31 @@
 
 %main::tests = (
     'any' => {
-        'comment' => 'TSP test for any versions.',
-        'data' => ['tsp-any-00.data','tsp.data'],
+        'comment' => 'newTSP',
+        'data' => [],
         'tests' => [qw(
-            tsp-any
-            tsp-any-00
-            tsp-any-01
-            tsp-any-03
-            tsp-any-04
-            tsp-any-05)]
-        },
+            doc-pgr_eucledianTSP
+            tsp-v2-0
+            )],
+        'linux' => [qw(
+            doc-pgr_TSP
+            doc-tsp
+            )],
+        'macos' => [qw(
+            doc-pgr_TSP-mac
+            doc-tsp-mac
+            )],
+        'windows' => [qw(
+            doc-pgr_TSP-windows
+            doc-tsp-windows
+            )],
+        'documentation' => [qw(
+            doc-tsp
+            doc-pgr_TSP
+            doc-pgr_eucledianTSP
+            )]
+    },
+    #wi29-tsp qa194-tsp
 #    'vpg-vpgis' => {}, # for version specific tests
 #    '8-1' => {},       # for pg 8.x and postgis 1.x
 #    '9.2-2.1' => {},   # for pg 9.2 and postgis 2.1
diff --git a/src/tsp/test/tsp-any-00.data b/src/tsp/test/tsp-any-00.data
deleted file mode 100644
index af6ffd1..0000000
--- a/src/tsp/test/tsp-any-00.data
+++ /dev/null
@@ -1,32 +0,0 @@
-drop table if exists tsp_00 cascade;
-create table tsp_00 (
-source_id serial not null primary key,
-x float,
-y float);
-
-insert into tsp_00 (x,y) values
-(1,7),
-(1,4),
-(3,8),
-(1,2),
-(3,5),
-(5,8),
-(1,1),
-(2,1),
-(3,2),
-(4.5,3),
-(7,7),
-(3,1),
-(3,3),
-(4.5,5),
-(3,4),
-(4.5,4),
-(7,4),
-(5,1),
-(4.5,2),
-(7,2),
-(7,1),
-(4.5,1);
-
-
-
diff --git a/src/tsp/test/tsp-any-00.result b/src/tsp/test/tsp-any-00.result
deleted file mode 100644
index d1547d3..0000000
--- a/src/tsp/test/tsp-any-00.result
+++ /dev/null
@@ -1 +0,0 @@
-32.4721
diff --git a/src/tsp/test/tsp-any-00.test.sql b/src/tsp/test/tsp-any-00.test.sql
deleted file mode 100644
index c015300..0000000
--- a/src/tsp/test/tsp-any-00.test.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-select round(sum(cost)::numeric, 4) as cost from pgr_tsp('select source_id as id, x, y from tsp_00 where source_id in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)', 1);
diff --git a/src/tsp/test/tsp-any-01.result b/src/tsp/test/tsp-any-01.result
deleted file mode 100644
index cf022c0..0000000
--- a/src/tsp/test/tsp-any-01.result
+++ /dev/null
@@ -1 +0,0 @@
-23.4706
diff --git a/src/tsp/test/tsp-any-01.test.sql b/src/tsp/test/tsp-any-01.test.sql
deleted file mode 100644
index 7f6ff54..0000000
--- a/src/tsp/test/tsp-any-01.test.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-select round(sum(cost)::numeric, 4) as cost from pgr_tsp('select source_id as id, x, y from tsp_00 where source_id<12 order by source_id', 6);
diff --git a/src/tsp/test/tsp-any-03.test.sql b/src/tsp/test/tsp-any-03.test.sql
deleted file mode 100644
index 0959b41..0000000
--- a/src/tsp/test/tsp-any-03.test.sql
+++ /dev/null
@@ -1,62 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,1);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,2);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,3);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,4);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,0);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,2);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,3);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,4);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,0);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,1);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,3);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,4);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,0);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,1);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,2);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,4);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,0);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,1);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,2);
-\echo '----------------------------------'
-select * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,3);
-\echo '----------------------------------'
diff --git a/src/tsp/test/tsp-any-04.result b/src/tsp/test/tsp-any-04.result
deleted file mode 100644
index 0529a17..0000000
--- a/src/tsp/test/tsp-any-04.result
+++ /dev/null
@@ -1,11 +0,0 @@
-0|5|6|2.24
-1|10|11|4.12
-2|2|3|2.24
-3|0|1|3.00
-4|1|2|2.00
-5|3|4|1.00
-6|6|7|1.00
-7|7|8|1.41
-8|8|9|1.80
-9|9|10|2.50
-10|4|5|3.61
diff --git a/src/tsp/test/tsp-any-04.test.sql b/src/tsp/test/tsp-any-04.test.sql
deleted file mode 100644
index a0504dc..0000000
--- a/src/tsp/test/tsp-any-04.test.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-select seq, id1, id2, round(cost::numeric, 2) as cost from pgr_tsp('select source_id as id, x, y from tsp_00 where source_id<12 order by source_id', 6, 5);
diff --git a/src/tsp/test/tsp-any-05.result b/src/tsp/test/tsp-any-05.result
deleted file mode 100644
index 5c53264..0000000
--- a/src/tsp/test/tsp-any-05.result
+++ /dev/null
@@ -1,34 +0,0 @@
-----------------------------------1(in ints)
-OK
-----------------------------------1(in tenths)
-OK
-----------------------------------1-0
-0|1
-1|2
-2|3
-3|0
-----------------------------------1-2
-0|1
-1|0
-2|3
-3|2
-----------------------------------1-3
-0|1
-1|2
-2|0
-3|3
-----------------------------------0-1
-0|0
-1|3
-2|2
-3|1
-----------------------------------2-1
-0|2
-1|3
-2|0
-3|1
-----------------------------------3-1
-0|3
-1|0
-2|2
-3|1
diff --git a/src/tsp/test/tsp-any-05.test.sql b/src/tsp/test/tsp-any-05.test.sql
deleted file mode 100644
index 847561b..0000000
--- a/src/tsp/test/tsp-any-05.test.sql
+++ /dev/null
@@ -1,39 +0,0 @@
-/*PGR-GNU*****************************************************************
-
-Copyright (c) 2015 pgRouting developers
-Mail: project at pgrouting.org
-
-------
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-********************************************************************PGR-GNU*/
-\echo '----------------------------------1(in ints)'
-select case when r=array[1,2,3,0] then 'OK' when r=array[1,0,3,2] then 'OK' else 'FAIL' end from (select array_agg(id) as r from (SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1)) as a) as b;
-\echo '----------------------------------1(in tenths)'
-select case when r=array[1,2,3,0] then 'OK' when r=array[1,0,3,2] then 'OK' else 'FAIL' end from (select array_agg(id) as r from (SELECT seq, id FROM pgr_tsp('{{0,.1,.2,.3},{.1,0,.4,.5},{.2,.4,0,.6},{.3,.5,.6,0}}'::float8[],1)) as a) as b;
-\echo '----------------------------------1-0'
-SELECT seq, id FROM pgr_tsp('{{0,1,3,3},{1,0,2,2},{3,2,0,2},{3,2,2,0}}'::float8[],1,0);
-\echo '----------------------------------1-2'
-SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1,2);
-\echo '----------------------------------1-3'
-SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1,3);
-\echo '----------------------------------0-1'
-SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],0,1);
-\echo '----------------------------------2-1'
-SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],2,1);
-\echo '----------------------------------3-1'
-SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],3,1);
-
diff --git a/src/tsp/test/tsp-any.result b/src/tsp/test/tsp-any.result
deleted file mode 100644
index 793c011..0000000
--- a/src/tsp/test/tsp-any.result
+++ /dev/null
@@ -1,7 +0,0 @@
-15.4787
-OK
-0|1
-1|0
-2|3
-3|2
-11.3137
diff --git a/src/tsp/test/tsp-any.test.sql b/src/tsp/test/tsp-any.test.sql
deleted file mode 100644
index c1dbe09..0000000
--- a/src/tsp/test/tsp-any.test.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-BEGIN;
---------------------------------------------------------------------------------
---              PGR_pgr_tsp
---------------------------------------------------------------------------------
-
-
-
-SELECT round(sum(cost)::numeric, 4) as cost
-FROM pgr_tsp('SELECT id, x, y FROM vertex_table ORDER BY id', 6, 5);
-select case when r=array[1,2,3,0] then 'OK' when r=array[1,0,3,2] then 'OK' else 'FAIL' end from (select array_agg(id) as r from (SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1)) as a) as b;
-SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1,2);
-SELECT round(sum(cost)::numeric, 4) as cost
-FROM pgr_tsp('SELECT id::integer, st_x(the_geom) as x,st_x(the_geom) as y FROM edge_table_vertices_pgr  ORDER BY id', 6, 5);
-ROLLBACK;
diff --git a/src/tsp/test/tsp-any-03.result b/src/tsp/test/tsp-v2-0.result
similarity index 54%
rename from src/tsp/test/tsp-any-03.result
rename to src/tsp/test/tsp-v2-0.result
index a09e0ba..d8ea61c 100644
--- a/src/tsp/test/tsp-any-03.result
+++ b/src/tsp/test/tsp-v2-0.result
@@ -1,3 +1,16 @@
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+15.4787
+OK
+0|1
+1|0
+2|3
+3|2
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+11.3137
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+32.4721
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+23.4706
 0|0
 1|2
 2|4
@@ -118,3 +131,49 @@
 3|1
 4|3
 ----------------------------------
+NOTICE:  Deprecated Signature pgr_tsp(sql, integer, integer)
+0|6|6|2.24
+1|11|11|4.12
+2|3|3|2.24
+3|1|1|3.00
+4|2|2|2.00
+5|4|4|1.00
+6|7|7|1.00
+7|8|8|1.41
+8|9|9|1.80
+9|10|10|2.50
+10|5|5|3.61
+----------------------------------1(in ints)
+OK
+----------------------------------1(in tenths)
+OK
+----------------------------------1-0
+0|1
+1|2
+2|3
+3|0
+----------------------------------1-2
+0|1
+1|0
+2|3
+3|2
+----------------------------------1-3
+0|1
+1|2
+2|0
+3|3
+----------------------------------0-1
+0|0
+1|3
+2|2
+3|1
+----------------------------------2-1
+0|2
+1|3
+2|0
+3|1
+----------------------------------3-1
+0|3
+1|0
+2|2
+3|1
diff --git a/src/tsp/test/tsp-v2-0.test.sql b/src/tsp/test/tsp-v2-0.test.sql
new file mode 100644
index 0000000..7f8e035
--- /dev/null
+++ b/src/tsp/test/tsp-v2-0.test.sql
@@ -0,0 +1,137 @@
+
+/*PGR-GNU*****************************************************************
+
+Copyright (c) 2015 pgRouting developers
+Mail: project at pgrouting.org
+
+------
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ ********************************************************************PGR-GNU*/
+
+--------------------------------------------------------------------------------
+--              PGR_pgr_tsp
+--------------------------------------------------------------------------------
+BEGIN;
+
+CREATE TEMP TABLE vertex_table (
+    id serial,
+    x double precision,
+    y double precision
+);
+
+INSERT INTO vertex_table VALUES
+(1,2,0), (2,2,1), (3,3,1), (4,4,1), (5,0,2), (6,1,2), (7,2,2),
+(8,3,2), (9,4,2), (10,2,3), (11,3,3), (12,4,3), (13,2,4);
+
+CREATE table tsp_00 (
+    source_id serial not null primary key,
+    x float,
+    y float);
+
+insert into tsp_00 (x,y) values
+(1,7),
+(1,4),
+(3,8),
+(1,2),
+(3,5),
+(5,8),
+(1,1),
+(2,1),
+(3,2),
+(4.5,3),
+(7,7),
+(3,1),
+(3,3),
+(4.5,5),
+(3,4),
+(4.5,4),
+(7,4),
+(5,1),
+(4.5,2),
+(7,2),
+(7,1),
+(4.5,1);
+
+
+
+SELECT round(sum(cost)::numeric, 4) as cost
+FROM pgr_tsp('SELECT id, x, y FROM vertex_table ORDER BY id', 6, 5);
+SELECT case when r=array[1,2,3,0] then 'OK' when r=array[1,0,3,2] then 'OK' else 'FAIL' end from (SELECT array_agg(id) as r from (SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1)) as a) as b;
+SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1,2);
+SELECT round(sum(cost)::numeric, 4) as cost
+FROM pgr_tsp('SELECT id::integer, st_x(the_geom) as x,st_x(the_geom) as y FROM edge_table_vertices_pgr  ORDER BY id', 6, 5);
+SELECT round(sum(cost)::numeric, 4) as cost from pgr_tsp('SELECT source_id as id, x, y from tsp_00 where source_id in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)', 1);
+SELECT round(sum(cost)::numeric, 4) as cost from pgr_tsp('SELECT source_id as id, x, y from tsp_00 where source_id<12 order by source_id', 6);
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,1);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,2);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,3);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],0,4);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,0);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,2);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,3);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],1,4);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,0);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,1);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,3);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],2,4);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,0);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,1);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,2);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],3,4);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,0);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,1);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,2);
+\echo '----------------------------------'
+SELECT * from pgr_tsp('{{0,1,2,3,4},{1,0,3,2,1},{2,3,0,4,2},{3,2,4,0,3},{4,1,2,3,0}}'::float8[],4,3);
+\echo '----------------------------------'
+SELECT seq, id1, id2, round(cost::numeric, 2) as cost from pgr_tsp('SELECT source_id as id, x, y from tsp_00 where source_id<12 order by source_id', 6, 5);
+\echo '----------------------------------1(in ints)'
+SELECT case when r=array[1,2,3,0] then 'OK' when r=array[1,0,3,2] then 'OK' else 'FAIL' end from (SELECT array_agg(id) as r from (SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1)) as a) as b;
+\echo '----------------------------------1(in tenths)'
+SELECT case when r=array[1,2,3,0] then 'OK' when r=array[1,0,3,2] then 'OK' else 'FAIL' end from (SELECT array_agg(id) as r from (SELECT seq, id FROM pgr_tsp('{{0,.1,.2,.3},{.1,0,.4,.5},{.2,.4,0,.6},{.3,.5,.6,0}}'::float8[],1)) as a) as b;
+\echo '----------------------------------1-0'
+SELECT seq, id FROM pgr_tsp('{{0,1,3,3},{1,0,2,2},{3,2,0,2},{3,2,2,0}}'::float8[],1,0);
+\echo '----------------------------------1-2'
+SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1,2);
+\echo '----------------------------------1-3'
+SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1,3);
+\echo '----------------------------------0-1'
+SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],0,1);
+\echo '----------------------------------2-1'
+SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],2,1);
+\echo '----------------------------------3-1'
+SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],3,1);
+
+ROLLBACK;
diff --git a/src/tsp/test/tsp.data b/src/tsp/test/tsp.data
deleted file mode 100644
index e67ae80..0000000
--- a/src/tsp/test/tsp.data
+++ /dev/null
@@ -1,12 +0,0 @@
-
-DROP TABLE IF EXISTS vertex_table;
-CREATE TABLE vertex_table (
-    id serial,
-    x double precision,
-    y double precision
-);
-
-INSERT INTO vertex_table VALUES
-(1,2,0), (2,2,1), (3,3,1), (4,4,1), (5,0,2), (6,1,2), (7,2,2),
-(8,3,2), (9,4,2), (10,2,3), (11,3,3), (12,4,3), (13,2,4);
-
diff --git a/src/vrp_basic/CMakeLists.txt b/src/vrp_basic/CMakeLists.txt
deleted file mode 100644
index a9219b9..0000000
--- a/src/vrp_basic/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-set(PACKAGE_SQL_FILES "")
-add_subdirectory(sql)
-set(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-
-subdirs(doc src test)
-
diff --git a/src/vrp_basic/doc/pgr_vrpOneDepot.rst b/src/vrp_basic/doc/pgr_vrpOneDepot.rst
index a1c8cea..6278605 100644
--- a/src/vrp_basic/doc/pgr_vrpOneDepot.rst
+++ b/src/vrp_basic/doc/pgr_vrpOneDepot.rst
@@ -9,12 +9,16 @@
 
 .. _pgr_vrp_basic:
 
-pgr_vrpOneDepot 
+
+pgr_vrpOneDepot - Proposed
 ===============================================================================
 
-No documentation available from the original developer
 
-.. warning:: this function is experimental and there is no assurance that it will work
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+No documentation available from the original developer
 
 * :ref:`type_cost_result`
 * http://en.wikipedia.org/wiki/Vehicle_routing_problem
diff --git a/src/vrp_basic/src/Orders.txt b/src/vrp_basic/src/Orders.txt
deleted file mode 100644
index f4b621a..0000000
--- a/src/vrp_basic/src/Orders.txt
+++ /dev/null
@@ -1,102 +0,0 @@
- CUST_NO.   XCOORD.    YCOORD.    DEMAND   READY_TIME   DUE_Time   SERVICE_TIME
-    1      40.00      50.00       0.00       0.00     240.00       0.00
-    2      25.00      85.00      20.00     145.00     175.00      10.00
-    3      22.00      75.00      30.00      50.00      80.00      10.00
-    4      22.00      85.00      10.00     109.00     139.00      10.00
-    5      20.00      80.00      40.00     141.00     171.00      10.00
-    6      20.00      85.00      20.00      41.00      71.00      10.00
-    7      18.00      75.00      20.00      95.00     125.00      10.00
-    8      15.00      75.00      20.00      79.00     109.00      10.00
-    9      15.00      80.00      10.00      91.00     121.00      10.00
-   10      10.00      35.00      20.00      91.00     121.00      10.00
-   11      10.00      40.00      30.00     119.00     149.00      10.00
-   12       8.00      40.00      40.00      59.00      89.00      10.00
-   13       8.00      45.00      20.00      64.00      94.00      10.00
-   14       5.00      35.00      10.00     142.00     172.00      10.00
-   15       5.00      45.00      10.00      35.00      65.00      10.00
-   16       2.00      40.00      20.00      58.00      88.00      10.00
-   17       0.00      40.00      20.00      72.00     102.00      10.00
-   18       0.00      45.00      20.00     149.00     179.00      10.00
-   19      44.00       5.00      20.00      87.00     117.00      10.00
-   20      42.00      10.00      40.00      72.00     102.00      10.00
-   21      42.00      15.00      10.00     122.00     152.00      10.00
-   22      40.00       5.00      10.00      67.00      97.00      10.00
-   23      40.00      15.00      40.00      92.00     122.00      10.00
-   24      38.00       5.00      30.00      65.00      95.00      10.00
-   25      38.00      15.00      10.00     148.00     178.00      10.00
-   26      35.00       5.00      20.00     154.00     184.00      10.00
-   27      95.00      30.00      30.00     115.00     145.00      10.00
-   28      95.00      35.00      20.00      62.00      92.00      10.00
-   29      92.00      30.00      10.00      62.00      92.00      10.00
-   30      90.00      35.00      10.00      67.00      97.00      10.00
-   31      88.00      30.00      10.00      74.00     104.00      10.00
-   32      88.00      35.00      20.00      61.00      91.00      10.00
-   33      87.00      30.00      10.00     131.00     161.00      10.00
-   34      85.00      25.00      10.00      51.00      81.00      10.00
-   35      85.00      35.00      30.00     111.00     141.00      10.00
-   36      67.00      85.00      20.00     139.00     169.00      10.00
-   37      65.00      85.00      40.00      43.00      73.00      10.00
-   38      65.00      82.00      10.00     124.00     154.00      10.00
-   39      62.00      80.00      30.00      75.00     105.00      10.00
-   40      60.00      80.00      10.00      37.00      67.00      10.00
-   41      60.00      85.00      30.00      85.00     115.00      10.00
-   42      58.00      75.00      20.00      92.00     122.00      10.00
-   43      55.00      80.00      10.00      33.00      63.00      10.00
-   44      55.00      85.00      20.00     128.00     158.00      10.00
-   45      55.00      82.00      10.00      64.00      94.00      10.00
-   46      20.00      82.00      10.00      37.00      67.00      10.00
-   47      18.00      80.00      10.00     113.00     143.00      10.00
-   48       2.00      45.00      10.00      45.00      75.00      10.00
-   49      42.00       5.00      10.00     151.00     181.00      10.00
-   50      42.00      12.00      10.00     104.00     134.00      10.00
-   51      72.00      35.00      30.00     116.00     146.00      10.00
-   52      55.00      20.00      19.00      83.00     113.00      10.00
-   53      25.00      30.00       3.00      52.00      82.00      10.00
-   54      20.00      50.00       5.00      91.00     121.00      10.00
-   55      55.00      60.00      16.00     139.00     169.00      10.00
-   56      30.00      60.00      16.00     140.00     170.00      10.00
-   57      50.00      35.00      19.00     130.00     160.00      10.00
-   58      30.00      25.00      23.00      96.00     126.00      10.00
-   59      15.00      10.00      20.00     152.00     182.00      10.00
-   60      10.00      20.00      19.00      42.00      72.00      10.00
-   61      15.00      60.00      17.00     155.00     185.00      10.00
-   62      45.00      65.00       9.00      66.00      96.00      10.00
-   63      65.00      35.00       3.00      52.00      82.00      10.00
-   64      65.00      20.00       6.00      39.00      69.00      10.00
-   65      45.00      30.00      17.00      53.00      83.00      10.00
-   66      35.00      40.00      16.00      11.00      41.00      10.00
-   67      41.00      37.00      16.00     133.00     163.00      10.00
-   68      64.00      42.00       9.00      70.00     100.00      10.00
-   69      40.00      60.00      21.00     144.00     174.00      10.00
-   70      31.00      52.00      27.00      41.00      71.00      10.00
-   71      35.00      69.00      23.00     180.00     210.00      10.00
-   72      65.00      55.00      14.00      65.00      95.00      10.00
-   73      63.00      65.00       8.00      30.00      60.00      10.00
-   74       2.00      60.00       5.00      77.00     107.00      10.00
-   75      20.00      20.00       8.00     141.00     171.00      10.00
-   76       5.00       5.00      16.00      74.00     104.00      10.00
-   77      60.00      12.00      31.00      75.00     105.00      10.00
-   78      23.00       3.00       7.00     150.00     180.00      10.00
-   79       8.00      56.00      27.00      90.00     120.00      10.00
-   80       6.00      68.00      30.00      89.00     119.00      10.00
-   81      47.00      47.00      13.00     192.00     222.00      10.00
-   82      49.00      58.00      10.00      86.00     116.00      10.00
-   83      27.00      43.00       9.00      42.00      72.00      10.00
-   84      37.00      31.00      14.00      35.00      65.00      10.00
-   85      57.00      29.00      18.00      96.00     126.00      10.00
-   86      63.00      23.00       2.00      87.00     117.00      10.00
-   87      21.00      24.00      28.00      87.00     117.00      10.00
-   88      12.00      24.00      13.00      90.00     120.00      10.00
-   89      24.00      58.00      19.00      67.00      97.00      10.00
-   90      67.00       5.00      25.00     144.00     174.00      10.00
-   91      37.00      47.00       6.00      86.00     116.00      10.00
-   92      49.00      42.00      13.00     167.00     197.00      10.00
-   93      53.00      43.00      14.00      14.00      44.00      10.00
-   94      61.00      52.00       3.00     178.00     208.00      10.00
-   95      57.00      48.00      23.00      95.00     125.00      10.00
-   96      56.00      37.00       6.00      34.00      64.00      10.00
-   97      55.00      54.00      26.00     132.00     162.00      10.00
-   98       4.00      18.00      35.00     120.00     150.00      10.00
-   99      26.00      52.00       9.00      46.00      76.00      10.00
-  100      26.00      35.00      15.00      77.00     107.00      10.00
-  101      31.00      67.00       3.00     180.00     210.00      10.00
\ No newline at end of file
diff --git a/src/vrp_basic/src/Tester.cpp b/src/vrp_basic/src/Tester.cpp
index a3bb228..9dcf18a 100644
--- a/src/vrp_basic/src/Tester.cpp
+++ b/src/vrp_basic/src/Tester.cpp
@@ -21,6 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#include <string>
+#include <vector>
 #include "VRP_Solver.h"
 #include "Utils.h"
 
@@ -29,240 +31,220 @@ char buff[1005];
 CVRPSolver solver;
 
 // Load orders from the order file. The first order represents the depot.
-// TODO: file names are hard coded, it should be changed to commandline argument.
-void loadOrders()
-{
-	FILE *fp = fopen("Orders.txt", "rt");
-	if(fp == NULL)
-	{
-		fprintf(stderr, "Order file not found!\n");
-	}
-	bool bGotDepot = false;
-	// OrderId XCord YCord Demand StartTime EndTime ServiceTime
-	while(fgets(buff, 1000, fp))
-	{
-		if(strlen(buff) == 0)
-			break;
-		StringTokenizer tokenizer;
-		tokenizer.parse(buff, " \t");
-		StringVector vecToken;
-		tokenizer.getTokens(vecToken);
-
-		if(vecToken.size() != 7)
-			continue;
-
-		if(!isdigit(vecToken[0][0]))
-			continue;
-		
-		if (!bGotDepot)
-		{
-			// This order represents Deopot
-			CDepotInfo depot;
-			int id = atoi(vecToken[0].c_str());
-			depot.setDepotId(id);
-
-			Point pt;
-
-			pt.X = atof(vecToken[1].c_str());
-			pt.Y = atof(vecToken[2].c_str());
-
-			depot.setDepotLocation(pt);
-
-			int openTime = atoi(vecToken[4].c_str());
-			depot.setOpenTime(openTime);
-
-			int closeTime = atoi(vecToken[5].c_str());
-			depot.setCloseTime(closeTime);
-
-			solver.addDepot(depot);
-			bGotDepot = true;
-		}
-		else
-		{
-			// This is an order
-			COrderInfo order;
-			int id = atoi(vecToken[0].c_str());
-			order.setOrderId(id);
-
-			Point pt;
-
-			pt.X = atof(vecToken[1].c_str());
-			pt.Y = atof(vecToken[2].c_str());
-
-			order.setOrderLocation(pt);
-
-			int demand = atoi(vecToken[3].c_str());
-			order.setOrderUnit(demand);
-
-			int openTime = atoi(vecToken[4].c_str());
-			order.setOpenTime(openTime);
-
-			int closeTime = atoi(vecToken[5].c_str());
-			order.setCloseTime(closeTime);
-
-			int serviceTime = atoi(vecToken[6].c_str());
-			order.setServiceTime(serviceTime);
-
-			solver.addOrder(order);
-		}
-	}
-	fclose(fp);
+// TODO(someone) : file names are hard coded, it should be changed to commandline argument.
+void loadOrders() {
+    FILE *fp = fopen("Orders.txt", "rt");
+    if (fp == NULL) {
+        fprintf(stderr, "Order file not found!\n");
+    }
+    bool bGotDepot = false;
+    // OrderId XCord YCord Demand StartTime EndTime ServiceTime
+    while (fgets(buff, 1000, fp)) {
+        if (strlen(buff) == 0)
+            break;
+        StringTokenizer tokenizer;
+        tokenizer.parse(buff, " \t");
+        StringVector vecToken;
+        tokenizer.getTokens(vecToken);
+
+        if (vecToken.size() != 7)
+            continue;
+
+        if (!isdigit(vecToken[0][0]))
+            continue;
+
+        if (!bGotDepot) {
+            // This order represents Deopot
+            CDepotInfo depot;
+            int id = atoi(vecToken[0].c_str());
+            depot.setDepotId(id);
+
+            Point pt;
+
+            pt.X = atof(vecToken[1].c_str());
+            pt.Y = atof(vecToken[2].c_str());
+
+            depot.setDepotLocation(pt);
+
+            int openTime = atoi(vecToken[4].c_str());
+            depot.setOpenTime(openTime);
+
+            int closeTime = atoi(vecToken[5].c_str());
+            depot.setCloseTime(closeTime);
+
+            solver.addDepot(depot);
+            bGotDepot = true;
+        } else {
+            // This is an order
+            COrderInfo order;
+            int id = atoi(vecToken[0].c_str());
+            order.setOrderId(id);
+
+            Point pt;
+
+            pt.X = atof(vecToken[1].c_str());
+            pt.Y = atof(vecToken[2].c_str());
+
+            order.setOrderLocation(pt);
+
+            int demand = atoi(vecToken[3].c_str());
+            order.setOrderUnit(demand);
+
+            int openTime = atoi(vecToken[4].c_str());
+            order.setOpenTime(openTime);
+
+            int closeTime = atoi(vecToken[5].c_str());
+            order.setCloseTime(closeTime);
+
+            int serviceTime = atoi(vecToken[6].c_str());
+            order.setServiceTime(serviceTime);
+
+            solver.addOrder(order);
+        }
+    }
+    fclose(fp);
 }
 
 // Load vehicles from vehicle file.
-// TODO: file names are hard coded, it should be changed to commandline argument.
-
-void loadVehicles()
-{
-	FILE *fp = fopen("Vehicles.txt", "rt");
-
-	if(fp == NULL)
-	{
-		fprintf(stderr, "Vehicle file not found!\n");
-	}
-	// VehicleId Capacity 
-	// In terms of cost all the vehicle will have default cost of 1 for the first version
-	while(fgets(buff, 1000, fp))
-	{
-		if(strlen(buff) == 0)
-			break;
-		StringTokenizer tokenizer;
-		tokenizer.parse(buff, " \t");
-		StringVector vecToken;
-		tokenizer.getTokens(vecToken);
-
-		if(vecToken.size() != 2)
-			continue;
-
-		if(!isdigit(vecToken[0][0]))
-			continue;
-
-		CVehicleInfo vehicle;
-
-		int id = atoi(vecToken[0].c_str());
-		vehicle.setId(id);
-		
-		int capcity = atoi(vecToken[1].c_str());
-		vehicle.setCapacity(capcity);
-
-		vehicle.setCostPerKM(1);
-
-		solver.addVehicle(vehicle);
-	}
-	fclose(fp);
+// TODO(someone) : file names are hard coded, it should be changed to commandline argument.
+
+void loadVehicles() {
+    FILE *fp = fopen("Vehicles.txt", "rt");
+
+    if (fp == NULL) {
+        fprintf(stderr, "Vehicle file not found!\n");
+    }
+    // VehicleId Capacity
+    // In terms of cost all the vehicle will have default cost of 1 for the first version
+    while (fgets(buff, 1000, fp)) {
+        if (strlen(buff) == 0)
+            break;
+        StringTokenizer tokenizer;
+        tokenizer.parse(buff, " \t");
+        StringVector vecToken;
+        tokenizer.getTokens(vecToken);
+
+        if (vecToken.size() != 2)
+            continue;
+
+        if (!isdigit(vecToken[0][0]))
+            continue;
+
+        CVehicleInfo vehicle;
+
+        int id = atoi(vecToken[0].c_str());
+        vehicle.setId(id);
+
+        int capcity = atoi(vecToken[1].c_str());
+        vehicle.setCapacity(capcity);
+
+        vehicle.setCostPerKM(1);
+
+        solver.addVehicle(vehicle);
+    }
+    fclose(fp);
 }
 
 // Load the cost matrix
-// TODO: file names are hard coded, it should be changed to commandline argument.
-void loadDistanceMatrix()
-{
-	FILE *fp = fopen("Distance.txt", "rt");
-	if(fp == NULL)
-	{
-		fprintf(stderr, "Cost file not found!\n");
-		return;
-	}
-
-	// From To Cost
-	while(fgets(buff, 1000, fp))
-	{
-		if(strlen(buff) == 0)
-			break;
-		StringTokenizer tokenizer;
-		tokenizer.parse(buff, " \t");
-		StringVector vecToken;
-		tokenizer.getTokens(vecToken);
-
-		if(vecToken.size() != 3)
-			continue;
-
-		if(!isdigit(vecToken[0][0]))
-			continue;
-
-		int fromId = atoi(vecToken[0].c_str());
-		int toId = atoi(vecToken[1].c_str());
-		CostPack cpack;
-		cpack.cost = cpack.distance = atof(vecToken[2].c_str());
-		cpack.traveltime = cpack.cost;
-		
-		if(fromId == 1)
-			solver.addDepotToOrderCost(fromId, toId, cpack);
-		else if(toId == 1)
-			solver.addOrderToDepotCost(fromId, toId, cpack);
-		else
-			solver.addOrderToOrderCost(fromId, toId, cpack);
-	}
-	fclose(fp);		
+// TODO(someone) : file names are hard coded, it should be changed to commandline argument.
+void loadDistanceMatrix() {
+    FILE *fp = fopen("Distance.txt", "rt");
+    if (fp == NULL) {
+        fprintf(stderr, "Cost file not found!\n");
+        return;
+    }
+
+    // From To Cost
+    while (fgets(buff, 1000, fp)) {
+        if (strlen(buff) == 0)
+            break;
+        StringTokenizer tokenizer;
+        tokenizer.parse(buff, " \t");
+        StringVector vecToken;
+        tokenizer.getTokens(vecToken);
+
+        if (vecToken.size() != 3)
+            continue;
+
+        if (!isdigit(vecToken[0][0]))
+            continue;
+
+        int fromId = atoi(vecToken[0].c_str());
+        int toId = atoi(vecToken[1].c_str());
+        CostPack cpack;
+        cpack.cost = cpack.distance = atof(vecToken[2].c_str());
+        cpack.traveltime = cpack.cost;
+
+        if (fromId == 1)
+            solver.addDepotToOrderCost(fromId, toId, cpack);
+        else if (toId == 1)
+            solver.addOrderToDepotCost(fromId, toId, cpack);
+        else
+            solver.addOrderToOrderCost(fromId, toId, cpack);
+    }
+    fclose(fp);
 }
 
 // Print the solution to a file.
-// TODO: Currently prints on a fixed file. Later the file name will be taken as a command line argument
-
-bool print_solution(std::string strError)
-{
-	FILE *fp = fopen("result.txt", "wt");
-	if(fp == NULL)
-	{
-		strError = "Could not open file";
-		return false;
-	}
-	CSolutionInfo solution;
-	bool bOK = solver.getSolution(solution, strError);
-	if(bOK == false)
-		return false;
-
-	int totalRoute = solution.getTourInfoVector().size();
-	CTourInfo ctour;
-
-	fprintf(fp, "Total Number of Route: %d\n", totalRoute);
-	fprintf(fp, "Total Cost: %.3lf\n", solution.getTotalCost());
-	fprintf(fp, "Total Distance: %.3lf\n", solution.getTotalDistance());
-	fprintf(fp, "Total TravelTime: %.3lf\n", solution.getTotalTravelTime());
-
-	for(int i = 0; i < totalRoute; i++)
-	{
-		ctour = solution.getTour(i);
-		fprintf(fp, "Route No. %d: \n", i + 1);
-		fprintf(fp, "Vehicle Id: %d\n", ctour.getVehicleId());
-		fprintf(fp, "Starting Depot Id: %d\n", ctour.getStartDepot());
-		fprintf(fp, "End Depot Id: %d\n", ctour.getEndDepot());
-
-		std::vector<int> vecOrder = ctour.getOrderVector();
-		int totalOrder = vecOrder.size();
-		fprintf(fp, "Visited Order Ids: ");
-		for(int j = 0; j < totalOrder; j++)
-		{
-			if(j > 0)
-				fprintf(fp, " ");
-			fprintf(fp, "%d", vecOrder[j]);
-			if(j < totalOrder - 1)
-				fprintf(fp, ",");
-		}
-		fprintf(fp, "\n");
-	}
-
-	fclose(fp);
-	return true;
+// TODO(someone) : Currently prints on a fixed file. Later the file name will be taken as a command line argument
+
+bool print_solution(std::string strError) {
+    FILE *fp = fopen("result.txt", "wt");
+    if (fp == NULL) {
+        strError = "Could not open file";
+        return false;
+    }
+    CSolutionInfo solution;
+    bool bOK = solver.getSolution(solution, strError);
+    if (bOK == false)
+        return false;
+
+    int totalRoute = solution.getTourInfoVector().size();
+    CTourInfo ctour;
+
+    fprintf(fp, "Total Number of Route: %d\n", totalRoute);
+    fprintf(fp, "Total Cost: %.3lf\n", solution.getTotalCost());
+    fprintf(fp, "Total Distance: %.3lf\n", solution.getTotalDistance());
+    fprintf(fp, "Total TravelTime: %.3lf\n", solution.getTotalTravelTime());
+
+    for (int i = 0; i < totalRoute; i++) {
+        ctour = solution.getTour(i);
+        fprintf(fp, "Route No. %d: \n", i + 1);
+        fprintf(fp, "Vehicle Id: %d\n", ctour.getVehicleId());
+        fprintf(fp, "Starting Depot Id: %d\n", ctour.getStartDepot());
+        fprintf(fp, "End Depot Id: %d\n", ctour.getEndDepot());
+
+        std::vector<int> vecOrder = ctour.getOrderVector();
+        int totalOrder = vecOrder.size();
+        fprintf(fp, "Visited Order Ids: ");
+        for (int j = 0; j < totalOrder; j++) {
+            if (j > 0)
+                fprintf(fp, " ");
+            fprintf(fp, "%d", vecOrder[j]);
+            if (j < totalOrder - 1)
+                fprintf(fp, ", ");
+        }
+        fprintf(fp, "\n");
+    }
+
+    fclose(fp);
+    return true;
 }
 
-int main()
-{
-	loadOrders();
-	loadVehicles();
-	loadDistanceMatrix();
-	
-	std::string strError;
-	bool bIsOK = solver.solveVRP(strError);
-	
-	if(!bIsOK)
-	{
-		fprintf(stderr, "Error Occurred: %s\n", strError.c_str());
-	}
-	else
-	{
-		print_solution(strError);
-	}
-
-
-	return 0;
+int main() {
+    loadOrders();
+    loadVehicles();
+    loadDistanceMatrix();
+
+    std::string strError;
+    bool bIsOK = solver.solveVRP(strError);
+
+    if (!bIsOK) {
+        fprintf(stderr, "Error Occurred: %s\n", strError.c_str());
+    } else {
+        print_solution(strError);
+    }
+
+
+    return 0;
 }
diff --git a/src/vrp_basic/src/Utils.h b/src/vrp_basic/src/Utils.h
index d6ddf0f..3a72340 100644
--- a/src/vrp_basic/src/Utils.h
+++ b/src/vrp_basic/src/Utils.h
@@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 */
 
-#ifndef UTILS_H
-#define UTILS_H
+#ifndef SRC_VRP_BASIC_SRC_UTILS_H_
+#define SRC_VRP_BASIC_SRC_UTILS_H_
 
 #include <string>
 #include <map>
@@ -34,97 +34,79 @@ typedef std::vector<int> IntVector;
 typedef std::vector<double> DoubleVector;
 typedef std::vector<std::string> StringVector;
 
-class tokenizer
-{
+class tokenizer {
     std::string s, delim;
     std::string::size_type pos;
 
-public:
-
-    tokenizer( std::string xs, std::string xdelim ) : s(xs), delim(xdelim)
-    {
-        pos = s.find_first_not_of( delim );
+ public:
+    tokenizer(std::string xs, std::string xdelim) : s(xs), delim(xdelim) {
+        pos = s.find_first_not_of(delim);
     }
 
-    bool has_more_tokens()
-    {
+    bool has_more_tokens() {
         return pos != std::string::npos;
     }
 
-    std::string next_token()
-    {
-        std::string::size_type end_pos = s.find_first_of( delim, pos );
-        std::string token = s.substr( pos, end_pos-pos );
-        pos = s.find_first_not_of( delim, end_pos );
+    std::string next_token() {
+        std::string::size_type end_pos = s.find_first_of(delim, pos);
+        std::string token = s.substr(pos, end_pos-pos);
+        pos = s.find_first_not_of(delim, end_pos);
         return token;
     }
 };
 
-class StringOperation
-{
-
-public:
+class StringOperation {
+ public:
+     static std::string TRIMWHITESPACE(std::string strInput) {
+         std::string strOut = strInput;
+         std::string strWht = " \f\n\r\t\v";
 
-	static std::string TRIMWHITESPACE(std::string strInput)
-	{
-		std::string strOut = strInput;
-		std::string strWht = " \f\n\r\t\v";	
-
-		strOut.erase(0,strOut.find_first_not_of(strWht));
-		strOut.erase(strOut.find_last_not_of(strWht) + 1);
-		return strOut;
-	};
+         strOut.erase(0, strOut.find_first_not_of(strWht));
+         strOut.erase(strOut.find_last_not_of(strWht) + 1);
+         return strOut;
+     };
 };
 
-class StringTokenizer
-{
-public:
-	StringTokenizer()
-	{
-		reset();
-	}
-
-	void reset()
-	{
-		vecTokens.clear();
-		strInput = "";
-	}
-
-	bool parse(std::string strInput, std::string chDelim)
-	{
-        tokenizer t( strInput, chDelim );
-		while(t.has_more_tokens())
-		{
-			vecTokens.push_back(t.next_token());
-		}
-		return true;
-	}
-
-	size_t getTokenCount() 
-	{
-		return vecTokens.size();
-	}
-
-	bool getToken(std::string& strToken, long iTokenIndex)
-	{
-		long lTokenCount = vecTokens.size();
-		if(iTokenIndex < 0 || iTokenIndex < lTokenCount)
-		{
-			strToken = vecTokens[iTokenIndex];
-			return true;
-		}
-		return false;
-	}
-
-	bool getTokens(StringVector& vecTokensRef)
-	{
-		vecTokensRef = vecTokens;
-		return true;
-	}
-
-private:
-	std::string strInput;
-	StringVector vecTokens;
-
+class StringTokenizer {
+ public:
+     StringTokenizer() {
+         reset();
+     }
+
+     void reset() {
+         vecTokens.clear();
+         strInput = "";
+     }
+
+     bool parse(std::string strInput, std::string chDelim) {
+         tokenizer t(strInput, chDelim);
+         while (t.has_more_tokens()) {
+             vecTokens.push_back(t.next_token());
+         }
+         return true;
+     }
+
+     size_t getTokenCount() {
+         return vecTokens.size();
+     }
+
+     bool getToken(std::string& strToken, int64_t iTokenIndex) {
+         int64_t lTokenCount = vecTokens.size();
+         if (iTokenIndex < 0 ||  iTokenIndex < lTokenCount) {
+             strToken = vecTokens[iTokenIndex];
+             return true;
+         }
+         return false;
+     }
+
+     bool getTokens(StringVector& vecTokensRef) {
+         vecTokensRef = vecTokens;
+         return true;
+     }
+
+ private:
+     std::string strInput;
+     StringVector vecTokens;
 };
 
+#endif  // SRC_VRP_BASIC_SRC_UTILS_H_
diff --git a/src/vrp_basic/src/VRP.c b/src/vrp_basic/src/VRP.c
index 12279f0..1e9f4fb 100644
--- a/src/vrp_basic/src/VRP.c
+++ b/src/vrp_basic/src/VRP.c
@@ -21,7 +21,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include "VRP.h"
+#include "./VRP.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <search.h>
+#include <string.h>
+// #include <math.h>
 
 #include "postgres.h"
 #include "executor/spi.h"
@@ -30,887 +35,830 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #if PGSQL_VERSION > 92
 #include "access/htup_details.h"
 #endif
+#include "fmgr.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <search.h>
-
-#include "string.h"
-#include "math.h"
 
-#include "fmgr.h"
 
 
+#include "./../../common/src/pgr_types.h"
 
 #undef qsort
 
-//-------------------------------------------------------------------------
+// -------------------------------------------------------------------------
 
 /*
  * Define this to have profiling enabled
  */
-//#define PROFILE
+// #define PROFILE
 
 #ifdef PROFILE
 #include <sys/time.h>
 
 struct timeval prof_astar, prof_store, prof_extract, prof_total;
-long proftime[5];
-long profipts1, profipts2, profopts;
+int64_t proftime[5];
+int64_t profipts1, profipts2, profopts;
 
 #define profstart(x) do { gettimeofday(&x, NULL); } while (0);
 #define profstop(n, x) do { struct timeval _profstop;   \
-        long _proftime;                         \
-        gettimeofday(&_profstop, NULL);                         \
-        _proftime = ( _profstop.tv_sec*1000000+_profstop.tv_usec) -     \
-                ( x.tv_sec*1000000+x.tv_usec); \
-        elog(NOTICE, \
-                "PRF(%s) %lu (%f ms)", \
-                (n), \
-             _proftime, _proftime / 1000.0);    \
-        } while (0);
+    int64_t _proftime;                         \
+    gettimeofday(&_profstop, NULL);                         \
+    _proftime = (_profstop.tv_sec*1000000+_profstop.tv_usec) -     \
+    (x.tv_sec*1000000+x.tv_usec); \
+    elog(NOTICE, \
+            "PRF(%s) %lu (%f ms)", \
+            (n), \
+            _proftime, _proftime / 1000.0);    \
+} while (0);
 
 #else
 
 #define profstart(x) do { } while (0);
 #define profstop(n, x) do { } while (0);
 
-#endif // PROFILE
+#endif  //   PROFILE
 
 
-// ------------------------------------------------------------------------
+//  ------------------------------------------------------------------------
 
-Datum vrp(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum vrp(PG_FUNCTION_ARGS);
 
 #undef DEBUG
-//#define DEBUG 1
+// #define DEBUG 1
 #include "../../common/src/debug_macro.h"
 
 
-// The number of tuples to fetch from the SPI cursor at each iteration
+//  The number of tuples to fetch from the SPI cursor at each iteration
 #define TUPLIMIT 1000
 
 #ifndef PG_MODULE_MAGIC
 PG_MODULE_MAGIC;
 #endif
 
-typedef struct vehicle_columns
-{
-	int vehicle_id;
-	int capacity;
-	
+typedef struct vehicle_columns {
+    int vehicle_id;
+    int capacity;
 } vehicle_columns_t;
 
-typedef struct order_columns
-{
-	int id;
-	int order_unit;
-	int open_time;
-	int close_time;
-	int service_time;
+typedef struct order_columns {
+    int id;
+    int order_unit;
+    int open_time;
+    int close_time;
+    int service_time;
 
-	int x;
-	int y;
+    int x;
+    int y;
 } order_columns_t;
 
-typedef struct distance_columns
-{
-	int src_id;
-	int dest_id;
-	int cost;
-	int distance;
-	int traveltime;
+typedef struct distance_columns {
+    int src_id;
+    int dest_id;
+    int cost;
+    int distance;
+    int traveltime;
 } distance_columns_t;
 
 
-//float DISTANCE[MAX_TOWNS][MAX_TOWNS];
-//float x[MAX_TOWNS],y[MAX_TOWNS];
+// float DISTANCE[MAX_TOWNS][MAX_TOWNS];
+// float x[MAX_TOWNS], y[MAX_TOWNS];
 
 static char *
-text2char(text *in)
-{
-	char *out = (char*)palloc(VARSIZE(in));
+text2char(text *in) {
+    char *out = (char*)palloc(VARSIZE(in));
 
-	memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
-	out[VARSIZE(in) - VARHDRSZ] = '\0';
-	return out;
+    memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
+    out[VARSIZE(in) - VARHDRSZ] = '\0';
+    return out;
 }
 
 static int
-finish(int *code)
-{
-	*code = SPI_finish();
-	if (*code  != SPI_OK_FINISH )
-	{
-		elog(ERROR,"couldn't disconnect from SPI");
-		return -1 ;
-	}
-	return 0;
+finish(int *code) {
+    *code = SPI_finish();
+    if (*code != SPI_OK_FINISH) {
+        elog(ERROR, "couldn't disconnect from SPI");
+        return -1;
+    }
+    return 0;
 }
 
 
 
 static int
-fetch_distance_columns(SPITupleTable *tuptable, distance_columns_t *distance_columns)
-{
-	PGR_DBG("Fetching distance");
-
-	distance_columns->src_id = SPI_fnumber(SPI_tuptable->tupdesc, "src_id");
-	distance_columns->dest_id = SPI_fnumber(SPI_tuptable->tupdesc, "dest_id");
-	distance_columns->cost = SPI_fnumber(SPI_tuptable->tupdesc, "cost");
-	distance_columns->distance = SPI_fnumber(SPI_tuptable->tupdesc, "distance");  
-	distance_columns->traveltime = SPI_fnumber(SPI_tuptable->tupdesc, "traveltime");
-	if (distance_columns->src_id == SPI_ERROR_NOATTRIBUTE ||
-		distance_columns->dest_id == SPI_ERROR_NOATTRIBUTE ||
-		distance_columns->cost == SPI_ERROR_NOATTRIBUTE ||
-		distance_columns->distance == SPI_ERROR_NOATTRIBUTE ||
-		distance_columns->traveltime == SPI_ERROR_NOATTRIBUTE) 
-	{
-		elog(ERROR, "Error, query must return columns "
-			"'src_id', 'dest_id', 'cost', 'distance' and 'traveltime'");
-		return -1;
-	}
-
-	return 0;
+fetch_distance_columns(SPITupleTable *tuptable, distance_columns_t *distance_columns) {
+    PGR_DBG("Fetching distance");
+
+    distance_columns->src_id = SPI_fnumber(SPI_tuptable->tupdesc, "src_id");
+    distance_columns->dest_id = SPI_fnumber(SPI_tuptable->tupdesc, "dest_id");
+    distance_columns->cost = SPI_fnumber(SPI_tuptable->tupdesc, "cost");
+    distance_columns->distance = SPI_fnumber(SPI_tuptable->tupdesc, "distance");
+    distance_columns->traveltime = SPI_fnumber(SPI_tuptable->tupdesc, "traveltime");
+    if (distance_columns->src_id == SPI_ERROR_NOATTRIBUTE ||
+            distance_columns->dest_id == SPI_ERROR_NOATTRIBUTE ||
+            distance_columns->cost == SPI_ERROR_NOATTRIBUTE ||
+            distance_columns->distance == SPI_ERROR_NOATTRIBUTE ||
+            distance_columns->traveltime == SPI_ERROR_NOATTRIBUTE) {
+        elog(ERROR, "Error, query must return columns "
+                "'src_id', 'dest_id', 'cost', 'distance' and 'traveltime'");
+        return -1;
+    }
+
+    return 0;
 }
 
 
 static void
-fetch_distance(HeapTuple *tuple, TupleDesc *tupdesc, 
-			   distance_columns_t *distance_columns, vrp_cost_element_t *dist, size_t t)
-{
-	Datum binval;
-	bool isnull;
+fetch_distance(HeapTuple *tuple, TupleDesc *tupdesc,
+        distance_columns_t *distance_columns, vrp_cost_element_t *dist, size_t t) {
+    Datum binval;
+    bool isnull;
 
-	PGR_DBG("fetch_distance: src_id col:%i", distance_columns->src_id);
+    PGR_DBG("fetch_distance: src_id col:%i", distance_columns->src_id);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->src_id, &isnull);
+    binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->src_id, &isnull);
 
     PGR_DBG("back from SPI_getbinval for src_id");
-    PGR_DBG("binval=%i", binval);
+    //  PGR_DBG("binval = %i", binval);
 
-	if (isnull)
-		elog(ERROR, "src_id contains a null value");
+    if (isnull)
+        elog(ERROR, "src_id contains a null value");
 
-	dist->src_id = DatumGetInt32(binval);
+    dist->src_id = DatumGetInt32(binval);
 
     PGR_DBG("back from DatumGetInt32");
-	PGR_DBG("src_id=%i", dist->src_id);
+    PGR_DBG("src_id = %i", dist->src_id);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->dest_id, &isnull);
-	if (isnull)
-		elog(ERROR, "dest_id contains a null value");
+    binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->dest_id, &isnull);
+    if (isnull)
+        elog(ERROR, "dest_id contains a null value");
 
-	dist->dest_id = DatumGetInt32(binval);
+    dist->dest_id = DatumGetInt32(binval);
 
-	PGR_DBG("dest_id=%i", dist->dest_id);
+    PGR_DBG("dest_id = %i", dist->dest_id);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->cost, &isnull);
+    binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->cost, &isnull);
 
-	if (isnull)
-		elog(ERROR, "cost contains a null value");
+    if (isnull)
+        elog(ERROR, "cost contains a null value");
 
-	dist->cost = DatumGetFloat8(binval);
+    dist->cost = DatumGetFloat8(binval);
 
-	PGR_DBG("cost=%lf", dist->cost);
+    PGR_DBG("cost = %lf", dist->cost);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->distance, &isnull);
-	if (isnull)
-		elog(ERROR, "distance contains a null value");
+    binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->distance, &isnull);
+    if (isnull)
+        elog(ERROR, "distance contains a null value");
 
-	dist->distance = DatumGetFloat8(binval);
+    dist->distance = DatumGetFloat8(binval);
 
-	PGR_DBG("distance=%lf", dist->distance);
+    PGR_DBG("distance = %lf", dist->distance);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->traveltime, &isnull);
+    binval = SPI_getbinval(*tuple, *tupdesc, distance_columns->traveltime, &isnull);
 
-	if (isnull)
-		elog(ERROR, "traveltime contains a null value");
+    if (isnull)
+        elog(ERROR, "traveltime contains a null value");
 
-	dist->traveltime = DatumGetFloat8(binval);
+    dist->traveltime = DatumGetFloat8(binval);
 
-	PGR_DBG("traveltime=%lf", dist->traveltime);
+    PGR_DBG("traveltime = %lf", dist->traveltime);
 
-	//PGR_DBG("dist[%i][%i] = %f\n", from_point, to_point, value);
+    // PGR_DBG("dist[%i][%i] = %f\n", from_point, to_point, value);
 
-	
-	//PGR_DBG("dist[%i(%i:%i)][%i(%i:%i)] = %f\n", from, from_order, from_point, to, to_order, to_point, *(dist + (num_rows * from) + to));
 
+    // PGR_DBG("dist[%i(%i:%i)][%i(%i:%i)] = %f\n", from, from_order, from_point, to, to_order, to_point, *(dist + (num_rows * from) + to));
 }
 
 static int
-fetch_order_columns(SPITupleTable *tuptable, order_columns_t *order_columns)
-{
-	PGR_DBG("Fetching order");
-
-	//order_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
-	order_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
-	order_columns->order_unit = SPI_fnumber(SPI_tuptable->tupdesc, "order_unit");
-	order_columns->open_time = SPI_fnumber(SPI_tuptable->tupdesc, "open_time");
-	order_columns->close_time = SPI_fnumber(SPI_tuptable->tupdesc, "close_time");
-	order_columns->service_time = SPI_fnumber(SPI_tuptable->tupdesc, "service_time");
-	order_columns->x = SPI_fnumber(SPI_tuptable->tupdesc, "x");
-	order_columns->y = SPI_fnumber(SPI_tuptable->tupdesc, "y");  
-	if (//order_columns->id == SPI_ERROR_NOATTRIBUTE ||
-		order_columns->id == SPI_ERROR_NOATTRIBUTE ||
-		order_columns->open_time == SPI_ERROR_NOATTRIBUTE ||
-		order_columns->order_unit == SPI_ERROR_NOATTRIBUTE ||
-		order_columns->close_time == SPI_ERROR_NOATTRIBUTE ||
-		order_columns->service_time == SPI_ERROR_NOATTRIBUTE ||
-		order_columns->x == SPI_ERROR_NOATTRIBUTE ||
-		order_columns->y == SPI_ERROR_NOATTRIBUTE
-		)
-	{
-		//      elog(ERROR, "Error, query must return columns "
-		//           "'id', 'order_id', 'pu_time', 'do_time', 'pu_time_window', 'do_time_window', 'from_x', 'to_x', 'from_y', 'to_y' and 'size'");
-		elog(ERROR, "Error, query must return columns "
-			//"'id', 
-			"'id', 'order_unit', 'open_time', 'close_time', 'service_time', 'x', 'y'");
-		return -1;
-	}
-
-	return 0;
+fetch_order_columns(SPITupleTable *tuptable, order_columns_t *order_columns) {
+    PGR_DBG("Fetching order");
+
+    // order_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
+    order_columns->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
+    order_columns->order_unit = SPI_fnumber(SPI_tuptable->tupdesc, "order_unit");
+    order_columns->open_time = SPI_fnumber(SPI_tuptable->tupdesc, "open_time");
+    order_columns->close_time = SPI_fnumber(SPI_tuptable->tupdesc, "close_time");
+    order_columns->service_time = SPI_fnumber(SPI_tuptable->tupdesc, "service_time");
+    order_columns->x = SPI_fnumber(SPI_tuptable->tupdesc, "x");
+    order_columns->y = SPI_fnumber(SPI_tuptable->tupdesc, "y");
+    if (  // order_columns->id == SPI_ERROR_NOATTRIBUTE ||
+            order_columns->id == SPI_ERROR_NOATTRIBUTE ||
+            order_columns->open_time == SPI_ERROR_NOATTRIBUTE ||
+            order_columns->order_unit == SPI_ERROR_NOATTRIBUTE ||
+            order_columns->close_time == SPI_ERROR_NOATTRIBUTE ||
+            order_columns->service_time == SPI_ERROR_NOATTRIBUTE ||
+            order_columns->x == SPI_ERROR_NOATTRIBUTE ||
+            order_columns->y == SPI_ERROR_NOATTRIBUTE
+       ) {
+        //       elog(ERROR, "Error, query must return columns "
+        //            "'id', 'order_id', 'pu_time', 'do_time', 'pu_time_window', 'do_time_window', 'from_x', 'to_x', 'from_y', 'to_y' and 'size'");
+        elog(ERROR, "Error, query must return columns "
+                // "'id',
+                "'id', 'order_unit', 'open_time', 'close_time', 'service_time', 'x', 'y'");
+        return -1;
+    }
+
+    return 0;
 }
 
 static void
 fetch_order(HeapTuple *tuple, TupleDesc *tupdesc,
-			order_columns_t *order_columns, vrp_orders_t *order, size_t t)
-{
-	Datum binval;
-	bool isnull;
-
-	PGR_DBG("inside fetch_order\n");
+        order_columns_t *order_columns, vrp_orders_t *order, size_t t) {
+    Datum binval;
+    bool isnull;
 
-	//binval = SPI_getbinval(*tuple, *tupdesc, order_columns->id, &isnull);
-	//
-	//  PGR_DBG("got binval\n");
-	//
-	//if (isnull)
-	//  elog(ERROR, "id contains a null value");
-	//
-	//order->id = DatumGetInt32(binval);
-	order->id = (int)t + 1;
+    PGR_DBG("inside fetch_order\n");
 
-	PGR_DBG("id = %i\n", order->id);
+    // binval = SPI_getbinval(*tuple, *tupdesc, order_columns->id, &isnull);
+    //
+    //  PGR_DBG("got binval\n");
+    //
+    // if (isnull)
+    //  elog(ERROR, "id contains a null value");
+    //
+    // order->id = DatumGetInt32(binval);
+    order->id = (int)t + 1;
 
-	binval = SPI_getbinval(*tuple, *tupdesc, order_columns->id, &isnull);
-	if (isnull)
-		elog(ERROR, "order_id contains a null value");
+    PGR_DBG("id = %i\n", order->id);
 
-	order->id = DatumGetInt32(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, order_columns->id, &isnull);
+    if (isnull)
+        elog(ERROR, "order_id contains a null value");
 
-	PGR_DBG("order_id = %i\n", order->id);  
+    order->id = DatumGetInt32(binval);
 
+    PGR_DBG("order_id = %i\n", order->id);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, order_columns->order_unit, &isnull);
-	if (isnull)
-		elog(ERROR, "order_unit contains a null value");
 
-	order->order_unit = DatumGetInt32(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, order_columns->order_unit, &isnull);
+    if (isnull)
+        elog(ERROR, "order_unit contains a null value");
 
-	PGR_DBG("order_unit = %i\n", order->order_unit);
+    order->order_unit = DatumGetInt32(binval);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, order_columns->open_time, &isnull);
-	if (isnull)
-		elog(ERROR, "open_time contains a null value");
+    PGR_DBG("order_unit = %i\n", order->order_unit);
 
-	order->open_time = DatumGetInt32(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, order_columns->open_time, &isnull);
+    if (isnull)
+        elog(ERROR, "open_time contains a null value");
 
-	PGR_DBG("open_time = %i\n", order->open_time);
+    order->open_time = DatumGetInt32(binval);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, order_columns->close_time, &isnull);
-	if (isnull)
-		elog(ERROR, "close_time contains a null value");
+    PGR_DBG("open_time = %i\n", order->open_time);
 
-	order->close_time = DatumGetInt32(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, order_columns->close_time, &isnull);
+    if (isnull)
+        elog(ERROR, "close_time contains a null value");
 
-	PGR_DBG("close_time = %d\n", order->close_time);
+    order->close_time = DatumGetInt32(binval);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, order_columns->service_time, &isnull);
-	if (isnull)
-		elog(ERROR, "service_time contains a null value");
+    PGR_DBG("close_time = %d\n", order->close_time);
 
-	order->service_time = DatumGetInt32(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, order_columns->service_time, &isnull);
+    if (isnull)
+        elog(ERROR, "service_time contains a null value");
 
-	PGR_DBG("service_time = %d\n", order->service_time);
+    order->service_time = DatumGetInt32(binval);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, order_columns->x, &isnull);
-	if (isnull)
-		elog(ERROR, "x contains a null value");
+    PGR_DBG("service_time = %d\n", order->service_time);
 
-	order->x = DatumGetFloat8(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, order_columns->x, &isnull);
+    if (isnull)
+        elog(ERROR, "x contains a null value");
 
-	PGR_DBG("x = %f\n", order->x);
+    order->x = DatumGetFloat8(binval);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, order_columns->y, &isnull);
-	if (isnull)
-		elog(ERROR, "y contains a null value");
+    PGR_DBG("x = %f\n", order->x);
 
-	order->y = DatumGetFloat8(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, order_columns->y, &isnull);
+    if (isnull)
+        elog(ERROR, "y contains a null value");
 
-	PGR_DBG("doUT = %f\n", order->y);
+    order->y = DatumGetFloat8(binval);
 
+    PGR_DBG("doUT = %f\n", order->y);
 }
 
 static int
-fetch_vehicle_columns(SPITupleTable *tuptable, vehicle_columns_t *vehicle_columns)
-{
-	PGR_DBG("Fetching order");
-
-	vehicle_columns->vehicle_id = SPI_fnumber(SPI_tuptable->tupdesc, "vehicle_id");
-	vehicle_columns->capacity = SPI_fnumber(SPI_tuptable->tupdesc, "capacity");
-	
-	if (vehicle_columns->vehicle_id == SPI_ERROR_NOATTRIBUTE ||
-		vehicle_columns->capacity == SPI_ERROR_NOATTRIBUTE
-		)
-	{
-		elog(ERROR, "Error, query must return columns "
-			"'id' and 'capacity'");
-		return -1;
-	}
-
-	return 0;
+fetch_vehicle_columns(SPITupleTable *tuptable, vehicle_columns_t *vehicle_columns) {
+    PGR_DBG("Fetching order");
+
+    vehicle_columns->vehicle_id = SPI_fnumber(SPI_tuptable->tupdesc, "vehicle_id");
+    vehicle_columns->capacity = SPI_fnumber(SPI_tuptable->tupdesc, "capacity");
+
+    if (vehicle_columns->vehicle_id == SPI_ERROR_NOATTRIBUTE ||
+            vehicle_columns->capacity == SPI_ERROR_NOATTRIBUTE) {
+        elog(ERROR, "Error, query must return columns "
+                "'id' and 'capacity'");
+        return -1;
+    }
+
+    return 0;
 }
 
 static void
 fetch_vehicle(HeapTuple *tuple, TupleDesc *tupdesc,
-			  vehicle_columns_t *vehicle_columns, vrp_vehicles_t *vehicle, size_t t)
-{
-	Datum binval;
-	bool isnull;
+        vehicle_columns_t *vehicle_columns, vrp_vehicles_t *vehicle, size_t t) {
+    Datum binval;
+    bool isnull;
 
-	PGR_DBG("inside fetch_vehicle\n");
+    PGR_DBG("inside fetch_vehicle\n");
 
-	//binval = SPI_getbinval(*tuple, *tupdesc, vehicle_columns->id, &isnull);
-	//PGR_DBG("Got id\n");
-	//
-	//if (isnull)
-	//  elog(ERROR, "id contains a null value");
-	//
-	//vehicle->id = DatumGetInt32(binval);
+    // binval = SPI_getbinval(*tuple, *tupdesc, vehicle_columns->id, &isnull);
+    // PGR_DBG("Got id\n");
+    //
+    // if (isnull)
+    //  elog(ERROR, "id contains a null value");
+    //
+    // vehicle->id = DatumGetInt32(binval);
 
-	
-	binval = SPI_getbinval(*tuple, *tupdesc, vehicle_columns->vehicle_id, &isnull);
-	PGR_DBG("Got vehicle_id\n");
 
-	if (isnull)
-		elog(ERROR, "vehicle_id contains a null value");
+    binval = SPI_getbinval(*tuple, *tupdesc, vehicle_columns->vehicle_id, &isnull);
+    PGR_DBG("Got vehicle_id\n");
 
-	vehicle->id = DatumGetInt32(binval);
+    if (isnull)
+        elog(ERROR, "vehicle_id contains a null value");
 
-	PGR_DBG("vehicle_id = %i\n", vehicle->id);
+    vehicle->id = DatumGetInt32(binval);
 
-	binval = SPI_getbinval(*tuple, *tupdesc, vehicle_columns->capacity, &isnull);
-	if (isnull)
-		elog(ERROR, "capacity contains a null value");
+    PGR_DBG("vehicle_id = %i\n", vehicle->id);
 
-	vehicle->capacity = DatumGetInt32(binval);
+    binval = SPI_getbinval(*tuple, *tupdesc, vehicle_columns->capacity, &isnull);
+    if (isnull)
+        elog(ERROR, "capacity contains a null value");
 
-	PGR_DBG("capacity = %f\n", vehicle->capacity);
+    vehicle->capacity = DatumGetInt32(binval);
 
+    PGR_DBG("capacity = %d\n", vehicle->capacity);
 }
 
-static int conn(int *SPIcode)
-{
-	int res = 0;
+static int conn(int *SPIcode) {
+    int res = 0;
 
-	*SPIcode = SPI_connect();
+    *SPIcode = SPI_connect();
 
-	if (*SPIcode  != SPI_OK_CONNECT)
-	{
-		elog(ERROR, "vrp: couldn't open a connection to SPI");
-		res = -1;
-	}
+    if (*SPIcode != SPI_OK_CONNECT) {
+        elog(ERROR, "vrp: couldn't open a connection to SPI");
+        res = -1;
+    }
 
-	return res;	
+    return res;
 }
 
-static int prepare_query(Portal *SPIportal, char* sql)
-{
-	int res = 0;
+static int prepare_query(Portal *SPIportal, char* sql) {
+    int res = 0;
 
-	void* SPIplan = SPI_prepare(sql, 0, NULL);
+    void* SPIplan = SPI_prepare(sql, 0, NULL);
 
-	if (SPIplan  == NULL)
-	{
-		elog(ERROR, "vrp: couldn't create query plan via SPI");
-		res = -1;
-	}
+    if (SPIplan == NULL) {
+        elog(ERROR, "vrp: couldn't create query plan via SPI");
+        res = -1;
+    }
 
-	if ((*SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL)
-	{
-		elog(ERROR, "vrp: SPI_cursor_open('%s') returns NULL", sql);
-		res = -1;
-	}
+    if ((*SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) {
+        elog(ERROR, "vrp: SPI_cursor_open('%s') returns NULL", sql);
+        res = -1;
+    }
 
-	return res;
+    return res;
 }
 
 static int solve_vrp(char* orders_sql, char* vehicles_sql,
-					  char* dist_sql,
-					  int depot,
-					  vrp_result_element_t** path, size_t *path_count)
-{
-	int SPIcode;
+        char* dist_sql,
+        int depot,
+        vrp_result_element_t** path, size_t *path_count) {
+    int SPIcode;
 
-	Portal SPIportal_o; 
-	Portal SPIportal_v; 
-	Portal SPIportal_d; 
-	// Portal SPIportal_p;
+    Portal SPIportal_o;
+    Portal SPIportal_v;
+    Portal SPIportal_d;
+    //  Portal SPIportal_p;
 
-	bool moredata = TRUE;
-	size_t ntuples;
+    bool moredata = TRUE;
+    size_t ntuples;
 
     size_t order_num;
     size_t vehicle_num;
     size_t dist_num;
 
-	vrp_vehicles_t *vehicles=NULL;
-	vehicle_columns_t vehicle_columns = {.vehicle_id = -1, .capacity = -1};
+    vrp_vehicles_t *vehicles = NULL;
+    vehicle_columns_t vehicle_columns = {.vehicle_id = -1, .capacity = -1};
 
-	vrp_orders_t *orders=NULL;
-	order_columns_t order_columns = {.id = -1, .order_unit = -1, .open_time = -1, .close_time = -1, .service_time = -1, .x = -1, .y = -1};
+    vrp_orders_t *orders = NULL;
+    order_columns_t order_columns = {.id = -1, .order_unit = -1, .open_time = -1, .close_time = -1, .service_time = -1, .x = -1, .y = -1};
 
-	vrp_cost_element_t *costs=NULL;
-	distance_columns_t distance_columns = {.src_id = -1, .dest_id = -1, .cost = -1, .distance = -1,	.traveltime = -1};
+    vrp_cost_element_t *costs = NULL;
+    distance_columns_t distance_columns = {.src_id = -1, .dest_id = -1, .cost = -1, .distance = -1, .traveltime = -1};
 
-	char *err_msg = NULL;
-	int ret = -1;
+    char *err_msg = NULL;
+    int ret = -1;
 
-	// int   z = 0;
+    //  int   z = 0;
 
-	// int    tt, cc;
-	// double dx, dy;
-	// float  fit=0.0;
+    //  int    tt, cc;
+    //  double dx, dy;
+    //  float fit = 0.0;
 
-	int prep = -1, con = -1;
+    int prep = -1, con = -1;
 
-	//int total_tuples = 0;
-	order_num = 0;
-	vehicle_num = 0;
+    // int total_tuples = 0;
+    order_num = 0;
+    vehicle_num = 0;
 
-	PGR_DBG("start solve_vrp\n");
+    PGR_DBG("start solve_vrp\n");
 
-	//vrp_orders_t depot_ord = {id:0, order_id:depot, from:depot_point, to:depot_point};
-	//orders = palloc(1 * sizeof(vrp_orders_t));
-	//orders[0] = depot_ord;
+    // vrp_orders_t depot_ord = {id:0, order_id:depot, from:depot_point, to:depot_point};
+    // orders = palloc(1 * sizeof(vrp_orders_t));
+    // orders[0] = depot_ord;
 
-	con = conn(&SPIcode);
+    con = conn(&SPIcode);
 
-	if (con < 0)
-		return ret;
+    if (con < 0)
+        return ret;
 
 
-	// Fetching orders
+    //  Fetching orders
 
     PGR_DBG("calling prepare_query for orders_sql");
 
-	prep = prepare_query(&SPIportal_o, orders_sql);
+    prep = prepare_query(&SPIportal_o, orders_sql);
 
-	if (prep < 0)
-		return ret;
+    if (prep < 0)
+        return ret;
 
-	PGR_DBG("Query: %s\n",orders_sql);
-	PGR_DBG("Query executed\n");
+    PGR_DBG("Query: %s\n", orders_sql);
+    PGR_DBG("Query executed\n");
 
-	PGR_DBG("Orders before: %i\n", order_num);
+    PGR_DBG("Orders before: %lu\n", order_num);
 
-	while (moredata == TRUE)  
-	{
-		SPI_cursor_fetch(SPIportal_o, TRUE, TUPLIMIT);
+    while (moredata == TRUE) {
+        SPI_cursor_fetch(SPIportal_o, TRUE, TUPLIMIT);
 
-		PGR_DBG("cursor fetched\n");
+        PGR_DBG("cursor fetched\n");
 
-		if (order_columns.id == -1)
-		{
-			if (fetch_order_columns(SPI_tuptable, &order_columns) == -1)
-				return finish(&SPIcode);
-		}
+        if (order_columns.id == -1) {
+            if (fetch_order_columns(SPI_tuptable, &order_columns) == -1)
+                return finish(&SPIcode);
+        }
 
-		ntuples = SPI_processed;
+        ntuples = SPI_processed;
 
-		order_num += ntuples;
+        order_num += ntuples;
 
-		PGR_DBG("Tuples: %i\n", order_num);
+        PGR_DBG("Tuples: %lu\n", order_num);
 
-		if (!orders)
-		  	orders = palloc(order_num * sizeof(vrp_orders_t));
-		else
-			orders = repalloc(orders, (order_num + 1) * sizeof(vrp_orders_t));
+        if (!orders)
+            orders = palloc(order_num * sizeof(vrp_orders_t));
+        else
+            orders = repalloc(orders, (order_num + 1) * sizeof(vrp_orders_t));
 
-		if (orders == NULL)
-		{
-			elog(ERROR, "Out of memory");
-			return finish(&SPIcode);
-		}
+        if (orders == NULL) {
+            elog(ERROR, "Out of memory");
+            return finish(&SPIcode);
+        }
 
-		if (ntuples > 0)
-		{
-			SPITupleTable *tuptable = SPI_tuptable;
-			TupleDesc tupdesc = SPI_tuptable->tupdesc;
+        if (ntuples > 0) {
+            SPITupleTable *tuptable = SPI_tuptable;
+            TupleDesc tupdesc = SPI_tuptable->tupdesc;
 
-			PGR_DBG("Got tuple desc\n");
+            PGR_DBG("Got tuple desc\n");
             size_t t;
-			for (t = 0; t < ntuples; t++)
-			{
-				HeapTuple tuple = tuptable->vals[t];
-				//PGR_DBG("Before order fetched [%i]\n", order_num - ntuples + t);
-				fetch_order(&tuple, &tupdesc, &order_columns,
-					&orders[order_num - ntuples + t], t);
-
-				//&orders[t+1], t);
-				PGR_DBG("Order fetched\n");
-			}
-
-			SPI_freetuptable(tuptable);
-		}
-		else
-		{
-			moredata = FALSE;
-		}
-	}// end of fetching orders
-	//finish(&SPIcode_o);
-/*
-	int o;
-	for(o=0; o<order_num+1;++o)
-	{
-		elog(NOTICE, "ORDERS[%i] = {id=%i, open=%i, close=%i, service=%i}", o, orders[o].id, orders[o].open_time, orders[o].close_time, orders[o].service_time);
-	}
-*/
-	PGR_DBG ("order_num = %i", order_num); 
+            for (t = 0; t < ntuples; t++) {
+                HeapTuple tuple = tuptable->vals[t];
+                // PGR_DBG("Before order fetched [%i]\n", order_num - ntuples + t);
+                fetch_order(&tuple, &tupdesc, &order_columns,
+                        &orders[order_num - ntuples + t], t);
+
+                // &orders[t+1], t);
+                PGR_DBG("Order fetched\n");
+            }
+
+            SPI_freetuptable(tuptable);
+        } else {
+            moredata = FALSE;
+        }
+    }  //  end of fetching orders
+    // finish(&SPIcode_o);
+    /*
+       int o;
+       for (o = 0; o<order_num+1;++o)
+       {
+       elog(NOTICE, "ORDERS[%i] = {id = %i, open = %i, close = %i, service = %i}", o, orders[o].id, orders[o].open_time, orders[o].close_time, orders[o].service_time);
+       }
+       */
+    PGR_DBG("order_num = %lu", order_num);
 
-	//qsort (orders, order_num+1, sizeof (vrp_orders_t), order_cmp);
+    // qsort (orders, order_num+1, sizeof (vrp_orders_t), order_cmp);
 
 
-	// Fetching vehicles
+    //  Fetching vehicles
 
-	moredata = TRUE;
-	prep = prepare_query(&SPIportal_v, vehicles_sql);
+    moredata = TRUE;
+    prep = prepare_query(&SPIportal_v, vehicles_sql);
 
-	if (prep < 0)
-		return ret;
+    if (prep < 0)
+        return ret;
 
-	PGR_DBG("Query: %s\n",vehicles_sql);
-	PGR_DBG("Query executed\n");
+    PGR_DBG("Query: %s\n", vehicles_sql);
+    PGR_DBG("Query executed\n");
 
 
-	while (moredata == TRUE)
-	{
-		SPI_cursor_fetch(SPIportal_v, TRUE, TUPLIMIT);
+    while (moredata == TRUE) {
+        SPI_cursor_fetch(SPIportal_v, TRUE, TUPLIMIT);
 
-		if (vehicle_columns.vehicle_id == -1)
-		{
-			if (fetch_vehicle_columns(SPI_tuptable, &vehicle_columns) == -1)
-				return finish(&SPIcode);
-		}
+        if (vehicle_columns.vehicle_id == -1) {
+            if (fetch_vehicle_columns(SPI_tuptable, &vehicle_columns) == -1)
+                return finish(&SPIcode);
+        }
 
 
-		ntuples = SPI_processed;
+        ntuples = SPI_processed;
 
-		vehicle_num += ntuples;
+        vehicle_num += ntuples;
 
-		PGR_DBG("Tuples: %i\n", vehicle_num);
+        PGR_DBG("Tuples: %lu\n", vehicle_num);
 
-		if (!vehicles)
-			vehicles = palloc(vehicle_num * sizeof(vrp_vehicles_t));
-		else
-			vehicles = repalloc(vehicles, vehicle_num * sizeof(vrp_vehicles_t));
+        if (!vehicles)
+            vehicles = palloc(vehicle_num * sizeof(vrp_vehicles_t));
+        else
+            vehicles = repalloc(vehicles, vehicle_num * sizeof(vrp_vehicles_t));
 
-		if (vehicles == NULL)
-		{
-			elog(ERROR, "Out of memory");
-			return finish(&SPIcode);
-		}
+        if (vehicles == NULL) {
+            elog(ERROR, "Out of memory");
+            return finish(&SPIcode);
+        }
 
-		if (ntuples > 0)
-		{
-			SPITupleTable *tuptable = SPI_tuptable;
-			TupleDesc tupdesc = SPI_tuptable->tupdesc;
+        if (ntuples > 0) {
+            SPITupleTable *tuptable = SPI_tuptable;
+            TupleDesc tupdesc = SPI_tuptable->tupdesc;
 
-			PGR_DBG("Got tuple desc\n");
+            PGR_DBG("Got tuple desc\n");
 
             size_t t;
-			for (t = 0; t < ntuples; t++)
-			{
-				HeapTuple tuple = tuptable->vals[t];
-				PGR_DBG("Before vehicle fetched\n");
-				fetch_vehicle(&tuple, &tupdesc, &vehicle_columns,
-					&vehicles[vehicle_num - ntuples + t], t);
-				PGR_DBG("Vehicle fetched\n");
-			}
-
-			SPI_freetuptable(tuptable);
-		}
-		else
-		{
-			moredata = FALSE;
-		}
-	}// end of fetching vehicles
-	//finish(&SPIcode_v);
-
-	//double dist[order_num*2+1][order_num*2+1];
-
-	// Fetching distances
-
-	dist_num = 0;
-	moredata = TRUE;
-	prep = prepare_query(&SPIportal_d, dist_sql);
-
-	if (prep < 0)
-		return ret;
-
-	PGR_DBG("Query: %s\n",dist_sql);
-	PGR_DBG("Query executed\n");
-
-	while (moredata == TRUE)
-	{
-		SPI_cursor_fetch(SPIportal_d, TRUE, TUPLIMIT);
-
-		if (distance_columns.src_id == -1)
-		{
-			if (fetch_distance_columns(SPI_tuptable, &distance_columns) == -1)
-				return finish(&SPIcode);
-		}
-
-		ntuples = SPI_processed;
-		dist_num += ntuples;
-
-		PGR_DBG("Tuples: %i\n", vehicle_num);
-
-		if (!costs)
-			costs = palloc(dist_num * sizeof(vrp_cost_element_t));
-		else
-			costs = repalloc(costs, dist_num * sizeof(vrp_cost_element_t));
-
-		if (costs == NULL)
-		{
-			elog(ERROR, "Out of memory");
-			return finish(&SPIcode);
-		}
-
-		if (ntuples > 0)
-		{
-			SPITupleTable *tuptable = SPI_tuptable;
-			TupleDesc tupdesc = SPI_tuptable->tupdesc;
-
-			PGR_DBG("Got tuple desc\n");
+            for (t = 0; t < ntuples; t++) {
+                HeapTuple tuple = tuptable->vals[t];
+                PGR_DBG("Before vehicle fetched\n");
+                fetch_vehicle(&tuple, &tupdesc, &vehicle_columns,
+                        &vehicles[vehicle_num - ntuples + t], t);
+                PGR_DBG("Vehicle fetched\n");
+            }
+
+            SPI_freetuptable(tuptable);
+        } else {
+            moredata = FALSE;
+        }
+    }  //  end of fetching vehicles
+    // finish(&SPIcode_v);
+
+    // double dist[order_num*2+1][order_num*2+1];
+
+    //  Fetching distances
+
+    dist_num = 0;
+    moredata = TRUE;
+    prep = prepare_query(&SPIportal_d, dist_sql);
+
+    if (prep < 0)
+        return ret;
+
+    PGR_DBG("Query: %s\n", dist_sql);
+    PGR_DBG("Query executed\n");
+
+    while (moredata == TRUE) {
+        SPI_cursor_fetch(SPIportal_d, TRUE, TUPLIMIT);
+
+        if (distance_columns.src_id == -1) {
+            if (fetch_distance_columns(SPI_tuptable, &distance_columns) == -1)
+                return finish(&SPIcode);
+        }
+
+        ntuples = SPI_processed;
+        dist_num += ntuples;
+
+        PGR_DBG("Tuples: %lu\n", vehicle_num);
+
+        if (!costs)
+            costs = palloc(dist_num * sizeof(vrp_cost_element_t));
+        else
+            costs = repalloc(costs, dist_num * sizeof(vrp_cost_element_t));
+
+        if (costs == NULL) {
+            elog(ERROR, "Out of memory");
+            return finish(&SPIcode);
+        }
+
+        if (ntuples > 0) {
+            SPITupleTable *tuptable = SPI_tuptable;
+            TupleDesc tupdesc = SPI_tuptable->tupdesc;
+
+            PGR_DBG("Got tuple desc\n");
             size_t t;
-			for (t = 0; t < ntuples; t++)
-			{
-				HeapTuple tuple = tuptable->vals[t];
-				PGR_DBG("Before distance fetched\n");
-				fetch_distance(&tuple, &tupdesc, &distance_columns,
-					&costs[dist_num - ntuples + t], t);
-				PGR_DBG("Distance fetched\n");
-			}
+            for (t = 0; t < ntuples; t++) {
+                HeapTuple tuple = tuptable->vals[t];
+                PGR_DBG("Before distance fetched\n");
+                fetch_distance(&tuple, &tupdesc, &distance_columns,
+                        &costs[dist_num - ntuples + t], t);
+                PGR_DBG("Distance fetched\n");
+            }
 
-			SPI_freetuptable(tuptable);
-		}
-		else
-		{
-			moredata = FALSE;
-		}
-	}// end of fetching distances
+            SPI_freetuptable(tuptable);
+        } else {
+            moredata = FALSE;
+        }
+    }  //  end of fetching distances
 
 
-	PGR_DBG("Calling vrp\n");
+    PGR_DBG("Calling vrp\n");
 
-	profstop("extract", prof_extract);
-	profstart(prof_vrp);
+    profstop("extract", prof_extract);
+    profstart(prof_vrp);
 
-	PGR_DBG("Total orders: %i\n", order_num);
-	PGR_DBG("Total vehicles: %i\n", vehicle_num);
+    PGR_DBG("Total orders: %lu\n", order_num);
+    PGR_DBG("Total vehicles: %lu\n", vehicle_num);
 
 
-	//qsort (orders, order_num+1, sizeof (vrp_orders_t), order_cmp_asc);
+    // qsort (orders, order_num+1, sizeof (vrp_orders_t), order_cmp_asc);
 
 
 #ifdef DEBUG
-	int o;
-	for(o=0; o<order_num+1;++o)
-	{
-		PGR_DBG("ORDERS[%i] = {id=%i, open=%i, close=%i, service=%i}", o, orders[o].id, orders[o].open_time, orders[o].close_time, orders[o].service_time);
-	}
+    int o;
+    for (o = 0; o < order_num + 1; ++o) {
+        PGR_DBG("ORDERS[%i] = {id = %i, open = %i, close = %i, service = %i}", o, orders[o].id, orders[o].open_time, orders[o].close_time, orders[o].service_time);
+    }
 #endif
-	
 
 
-	//itinerary = (vrp_result_element_t *)palloc(sizeof(vrp_result_element_t)*(order_num*2-1)*vehicle_num);
 
-	PGR_DBG("Calling vrp solver\n");
-    //elog(NOTICE, "Calling find_vrp_solution: vehicles: %i, orders: %i, dists: %i, depot: %i", vehicle_num, order_num, dist_num, depot);
+    // itinerary = (vrp_result_element_t *)palloc(sizeof(vrp_result_element_t)*(order_num*2-1)*vehicle_num);
 
-	ret = find_vrp_solution(vehicles, vehicle_num,
-		orders, order_num,
-		costs, dist_num,
-		depot,
-		path, path_count, &err_msg);
+    PGR_DBG("Calling vrp solver\n");
+    // elog(NOTICE, "Calling find_vrp_solution: vehicles: %i, orders: %i, dists: %i, depot: %i", vehicle_num, order_num, dist_num, depot);
 
-	//ret = -1;
-	//elog(NOTICE, "vrp solved! ret: %d, path_count: %d", ret, *path_count);
-	// int pp;
-/*
-	for(pp = 0; pp < *path_count; pp++)
-	{
-		elog(NOTICE, "Row: %d: %d %d %d %d %d", pp, (*path)[pp].order_id, (*path)[pp].order_pos, (*path)[pp].vehicle_id, (*path)[pp].arrival_time, (*path)[pp].depart_time);
-	}
-*/
-	PGR_DBG("vrp solved! ret: %d, path_count: %d", ret, path_count);
-	//PGR_DBG("Score: %f\n", fit);
-
-	profstop("vrp", prof_vrp);
-	profstart(prof_store);
-
-	PGR_DBG("Profile changed and ret is %i", ret);
-
-	if (ret < 0)
-	{
-		//elog(ERROR, "Error computing path: %s", err_msg);
-		ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), errmsg("Error computing path: %s", err_msg)));
-	} 
-
-	//pfree(vehicles);
-	//pfree(orders);
-	return finish(&SPIcode);    
+    ret = find_vrp_solution(vehicles, vehicle_num,
+            orders, order_num,
+            costs, dist_num,
+            depot,
+            path, path_count, &err_msg);
+
+    // ret = -1;
+    // elog(NOTICE, "vrp solved! ret: %d, path_count: %d", ret, *path_count);
+    //  int pp;
+    /*
+       for (pp = 0; pp < *path_count; pp++)
+       {
+       elog(NOTICE, "Row: %d: %d %d %d %d %d", pp, (*path)[pp].order_id, (*path)[pp].order_pos, (*path)[pp].vehicle_id, (*path)[pp].arrival_time, (*path)[pp].depart_time);
+       }
+       */
+    PGR_DBG("vrp solved! ret: %d, path_count: %lu", ret, *path_count);
+    // PGR_DBG("Score: %f\n", fit);
+
+    profstop("vrp", prof_vrp);
+    profstart(prof_store);
+
+    PGR_DBG("Profile changed and ret is %i", ret);
+
+    if (ret < 0) {
+        // elog(ERROR, "Error computing path: %s", err_msg);
+        ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), errmsg("Error computing path: %s", err_msg)));
+    }
+
+    // pfree(vehicles);
+    // pfree(orders);
+    return finish(&SPIcode);
 }
 
 PG_FUNCTION_INFO_V1(vrp);
-Datum
-vrp(PG_FUNCTION_ARGS)
-{
-	FuncCallContext     *funcctx;
-	uint32_t                  call_cntr;
-	uint32_t                  max_calls;
-	TupleDesc            tuple_desc;
-	vrp_result_element_t         *path;
+PGDLLEXPORT Datum
+vrp(PG_FUNCTION_ARGS) {
+    FuncCallContext     *funcctx;
+    uint32_t                  call_cntr;
+    uint32_t                  max_calls;
+    TupleDesc            tuple_desc;
+    vrp_result_element_t         *path;
 
-	/* stuff done only on the first call of the function */
-	if (SRF_IS_FIRSTCALL())
-	{
-		MemoryContext   oldcontext;
-		//int path_count;
-		// int ret=-1;
-		size_t path_count = 0;
+    /* stuff done only on the first call of the function */
+    if (SRF_IS_FIRSTCALL()) {
+        MemoryContext   oldcontext;
+        // int path_count;
+        //  int ret = -1;
+        size_t path_count = 0;
 
-		// XXX profiling messages are not thread safe
-		profstart(prof_total);
-		profstart(prof_extract);
+        //  XXX profiling messages are not thread safe
+        profstart(prof_total);
+        profstart(prof_extract);
 
-		/* create a function context for cross-call persistence */
-		funcctx = SRF_FIRSTCALL_INIT();
+        /* create a function context for cross-call persistence */
+        funcctx = SRF_FIRSTCALL_INIT();
 
-		/* switch to memory context appropriate for multiple function calls */
-		oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
+        /* switch to memory context appropriate for multiple function calls */
+        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
 
-		//path = (vrp_result_element_t *)palloc(sizeof(vrp_result_element_t)*(MAX_ORDERS-1)*2*MAX_VEHICLES);
+        // path = (vrp_result_element_t *)palloc(sizeof(vrp_result_element_t)*(MAX_ORDERS-1)*2*MAX_VEHICLES);
 
 
         PGR_DBG("Calling solve_vrp ...");
 
-		// ret =
-                solve_vrp(//text2char(PG_GETARG_TEXT_P(0)), // points sql
-			text2char(PG_GETARG_TEXT_P(0)),  // orders sql
-			text2char(PG_GETARG_TEXT_P(1)),  // vehicles sql
-			text2char(PG_GETARG_TEXT_P(2)),  // distances query
-			PG_GETARG_INT32(3),  // depot id
-			&path, &path_count);
-
-		PGR_DBG("Back from solve_vrp, path_count:%d", path_count);
-		//elog(NOTICE, "Back from solve_vrp, path_count:%d", path_count);
-        
+        //  ret =
+        solve_vrp(  // text2char(PG_GETARG_TEXT_P(0)),  //  points sql
+                text2char(PG_GETARG_TEXT_P(0)),  //   orders sql
+                text2char(PG_GETARG_TEXT_P(1)),  //   vehicles sql
+                text2char(PG_GETARG_TEXT_P(2)),  //   distances query
+                PG_GETARG_INT32(3),  //   depot id
+                &path, &path_count);
+
+        PGR_DBG("Back from solve_vrp, path_count:%lu", path_count);
+        // elog(NOTICE, "Back from solve_vrp, path_count:%d", path_count);
+
         /* total number of tuples to be returned */
-		//PGR_DBG("Counting tuples number\n");
-
-		funcctx->max_calls = (uint32_t)path_count;
-
-		funcctx->user_fctx = path;
-
-		/* Build a tuple descriptor for our result type */
-        	if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
-            		ereport(ERROR,
-                    	(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                     	errmsg("function returning record called in context "
-                            "that cannot accept type record")));
-
-        	funcctx->tuple_desc = BlessTupleDesc(tuple_desc);
-
-        	/*
-         	* generate attribute metadata needed later to produce tuples from raw
-         	* C strings
-         	*/
-        	//attinmeta = TupleDescGetAttInMetadata(tuple_desc);
-        	//funcctx->attinmeta = attinmeta;
-
-		MemoryContextSwitchTo(oldcontext);
-		//elog(NOTICE, "table formed");
-	}
-
-	/* stuff done on every call of the function */
-	funcctx = SRF_PERCALL_SETUP();
-
-	call_cntr = funcctx->call_cntr;
-	max_calls = funcctx->max_calls;
-	tuple_desc = funcctx->tuple_desc;
-
-	path = (vrp_result_element_t *)funcctx->user_fctx;
-
-	//elog(NOTICE, "Point 1");
-	//PGR_DBG("Trying to allocate some memory\n");
-	//PGR_DBG("call_cntr = %i, max_calls = %i\n", call_cntr, max_calls);
-
-	if (call_cntr < max_calls)    /* do when there is more left to send */
-	{
-		HeapTuple    tuple;
-		Datum        result;
-		Datum *values;
-		bool* nulls;
-
-		values = palloc(5 * sizeof(Datum));
-		nulls = palloc(5 * sizeof(bool));
-
-		values[0] = Int32GetDatum(path[call_cntr].order_id);   // order id
-		nulls[0] = false;
-		values[1] = Int32GetDatum(path[call_cntr].order_pos);  // order pos
-		nulls[1] = false;
-		values[2] = Int32GetDatum(path[call_cntr].vehicle_id); // vehicle id
-		nulls[2] = false;
-		values[3] = Int32GetDatum(path[call_cntr].arrival_time); // arrival time
-		nulls[3] = false;
-		//values[4] = TimeTzADTPGetDatum(&path[call_cntr].time);
-		values[4] = Int32GetDatum(path[call_cntr].depart_time);  // departure time
-		nulls[4] = false;
-
-		// PGR_DBG("Heap making\n");
-		//elog(NOTICE,"Result %d %d %d", call_cntr, path[call_cntr].order_id, max_calls);
-		tuple = heap_form_tuple(tuple_desc, values, nulls);
-
-		//PGR_DBG("Datum making\n");
-
-		/* make the tuple into a datum */
-		result = HeapTupleGetDatum(tuple);
-
-		//PGR_DBG("Trying to free some memory\n");
-
-		/* clean up */
-		pfree(values);
-		pfree(nulls);
-
-
-		SRF_RETURN_NEXT(funcctx, result);
-	}
-	else    /* do when there is no more left */
-	{
-		
-		PGR_DBG("Ending function\n");
-		profstop("store", prof_store);
-		profstop("total", prof_total);
-		PGR_DBG("Profiles stopped\n");
-
-		free(path);
-		
-		PGR_DBG("Itinerary cleared\n");
-
-		SRF_RETURN_DONE(funcctx);
-	}
+        // PGR_DBG("Counting tuples number\n");
+
+        funcctx->max_calls = (uint32_t)path_count;
+
+        funcctx->user_fctx = path;
+
+        /* Build a tuple descriptor for our result type */
+        if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
+            ereport(ERROR,
+                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                     errmsg("function returning record called in context "
+                         "that cannot accept type record")));
+
+        funcctx->tuple_desc = BlessTupleDesc(tuple_desc);
+
+        /*
+         * generate attribute metadata needed later to produce tuples from raw
+         * C strings
+         */
+        // attinmeta = TupleDescGetAttInMetadata(tuple_desc);
+        // funcctx->attinmeta = attinmeta;
+
+        MemoryContextSwitchTo(oldcontext);
+        // elog(NOTICE, "table formed");
+    }
+
+    /* stuff done on every call of the function */
+    funcctx = SRF_PERCALL_SETUP();
+
+    call_cntr = funcctx->call_cntr;
+    max_calls = funcctx->max_calls;
+    tuple_desc = funcctx->tuple_desc;
+
+    path = (vrp_result_element_t *)funcctx->user_fctx;
+
+    // elog(NOTICE, "Point 1");
+    // PGR_DBG("Trying to allocate some memory\n");
+    // PGR_DBG("call_cntr = %i, max_calls = %i\n", call_cntr, max_calls);
+
+    if (call_cntr < max_calls) {
+        /* do when there is more left to send */
+        HeapTuple    tuple;
+        Datum        result;
+        Datum *values;
+        char* nulls;
+
+        values = palloc(5 * sizeof(Datum));
+        nulls = palloc(5 * sizeof(char));
+
+        values[0] = Int32GetDatum(path[call_cntr].order_id);   //  order id
+        nulls[0] = ' ';
+        values[1] = Int32GetDatum(path[call_cntr].order_pos);  //   order pos
+        nulls[1] = ' ';
+        values[2] = Int32GetDatum(path[call_cntr].vehicle_id);  //   vehicle id
+        nulls[2] = ' ';
+        values[3] = Int32GetDatum(path[call_cntr].arrival_time);  //   arrival time
+        nulls[3] = ' ';
+        // values[4] = TimeTzADTPGetDatum(&path[call_cntr].time);
+        values[4] = Int32GetDatum(path[call_cntr].depart_time);  //   departure time
+        nulls[4] = ' ';
+
+        //  PGR_DBG("Heap making\n");
+        // elog(NOTICE, "Result %d %d %d", call_cntr, path[call_cntr].order_id, max_calls);
+        tuple = heap_form_tuple(tuple_desc, values, nulls);
+
+        // PGR_DBG("Datum making\n");
+
+        /* make the tuple into a datum */
+        result = HeapTupleGetDatum(tuple);
+
+        // PGR_DBG("Trying to free some memory\n");
+
+        /* clean up */
+        pfree(values);
+        pfree(nulls);
+
+
+        SRF_RETURN_NEXT(funcctx, result);
+    } else {
+        /* do when there is no more left */
+
+        PGR_DBG("Ending function\n");
+        profstop("store", prof_store);
+        profstop("total", prof_total);
+        PGR_DBG("Profiles stopped\n");
+
+        free(path);
+
+        PGR_DBG("Itinerary cleared\n");
+
+        SRF_RETURN_DONE(funcctx);
+    }
 }
diff --git a/src/vrp_basic/src/VRP.h b/src/vrp_basic/src/VRP.h
index b041f27..43c3153 100644
--- a/src/vrp_basic/src/VRP.h
+++ b/src/vrp_basic/src/VRP.h
@@ -21,51 +21,43 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef _VRP_H
-#define _VRP_H
+#ifndef SRC_VRP_BASIC_SRC_VRP_H_
+#define SRC_VRP_BASIC_SRC_VRP_H_
 
-#include "postgres.h"
+#include <stddef.h>
 
-
-typedef struct vrp_vehicles 
-{
-	int id;
-	int capacity;
-	
+typedef struct vrp_vehicles {
+    int id;
+    int capacity;
 } vrp_vehicles_t;
 
 
-typedef struct vrp_orders 
-{
-	int id;
-	int order_unit;
-	int open_time;
-	int close_time;
-	int service_time;
-	
-	float8 x;
-	float8 y;
-	
-} vrp_orders_t;
-
-typedef struct vrp_cost_element
-{
-	int src_id;
-	int dest_id;
-	double cost;
-	double distance;
-	double traveltime;
-
-}vrp_cost_element_t;
+typedef struct vrp_orders {
+    int id;
+    int order_unit;
+    int open_time;
+    int close_time;
+    int service_time;
 
+    double x;
+    double y;
+} vrp_orders_t;
 
-typedef struct vrp_result_element
-{
-	int order_id;
-	int order_pos;
-	int vehicle_id;
-	int arrival_time;
-	int depart_time;
+typedef struct vrp_cost_element {
+    int src_id;
+    int dest_id;
+    double cost;
+    double distance;
+    double traveltime;
+} vrp_cost_element_t;
+
+
+typedef struct vrp_result_element {
+    int order_id;
+    int order_pos;
+    int vehicle_id;
+    int arrival_time;
+    int depart_time;
 } vrp_result_element_t;
 
 
@@ -73,14 +65,14 @@ typedef struct vrp_result_element
 extern "C" {
 #endif
 
-int find_vrp_solution(vrp_vehicles_t *vehicles, size_t vehicle_count, 
-					  vrp_orders_t *orders, size_t order_count,
-					  vrp_cost_element_t *costmatrix, size_t cost_count,
-					  int depot_id,
-					  vrp_result_element_t **result, size_t *result_count, char **err_msg);
+int find_vrp_solution(vrp_vehicles_t *vehicles, size_t vehicle_count,
+        vrp_orders_t *orders, size_t order_count,
+        vrp_cost_element_t *costmatrix, size_t cost_count,
+        int depot_id,
+        vrp_result_element_t **result, size_t *result_count, char **err_msg);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif
+#endif  // SRC_VRP_BASIC_SRC_VRP_H_
diff --git a/src/vrp_basic/src/VRP_Solver.cpp b/src/vrp_basic/src/VRP_Solver.cpp
index aee3ed3..81f9a90 100644
--- a/src/vrp_basic/src/VRP_Solver.cpp
+++ b/src/vrp_basic/src/VRP_Solver.cpp
@@ -21,13 +21,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
+#include "./VRP_Solver.h"
 #include <algorithm>
-#include "VRP_Solver.h"
+#include <math.h>
+#include <utility>
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
 
 #undef PGR_LOGGER_ON
 #define PGR_LOGGER_LOC
@@ -36,1003 +42,855 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #define DOUBLE_MAX 1e50
 
-bool operator != (const CVehicleInfo& cur, const CVehicleInfo& that)
-{
-	return(cur.m_iVehicleId != that.m_iVehicleId);
+bool operator != (const CVehicleInfo& cur, const CVehicleInfo& that) {
+    return(cur.m_iVehicleId != that.m_iVehicleId);
 }
 
-bool operator== (const CTourInfo& cur, const CTourInfo& that)
-{
-	if(cur.m_vehicleInfo != that.m_vehicleInfo)
-		return false;
-	if(cur.m_viOrderIds.size() != that.m_viOrderIds.size())
-		return false;
-	auto tot = cur.m_viOrderIds.size();
-	for(size_t i = 0; i < tot; i++)
-	{
-		if(cur.m_viOrderIds[i] != that.m_viOrderIds[i])
-			return false;
-	}
-	return true;
+bool operator == (const CTourInfo& cur, const CTourInfo& that) {
+    if (cur.m_vehicleInfo != that.m_vehicleInfo)
+        return false;
+    if (cur.m_viOrderIds.size() != that.m_viOrderIds.size())
+        return false;
+    auto tot = cur.m_viOrderIds.size();
+    for (size_t i = 0; i < tot; i++) {
+        if (cur.m_viOrderIds[i] != that.m_viOrderIds[i])
+            return false;
+    }
+    return true;
 }
 
-bool operator == (const CMoveInfo& cur, const CMoveInfo& that)
-{
-	if(!(cur.m_vInitialTour == that.m_vInitialTour))
-		return false;
-	if(!(cur.m_vModifiedTour == that.m_vModifiedTour))
-		return false;
-	return true;
+bool operator == (const CMoveInfo& cur, const CMoveInfo& that) {
+    if (!(cur.m_vInitialTour == that.m_vInitialTour))
+        return false;
+    if (!(cur.m_vModifiedTour == that.m_vModifiedTour))
+        return false;
+    return true;
 }
 
 
 
-CVehicleInfo::CVehicleInfo()
-{
-	m_iCurrentLoad = 0;
+CVehicleInfo::CVehicleInfo() {
+    m_iCurrentLoad = 0;
 }
-CVehicleInfo::~CVehicleInfo()
-{
+CVehicleInfo::~CVehicleInfo() {
 }
 
-bool CVehicleInfo::loadUnit(int lUnit)
-{
-	if(m_iCurrentLoad + lUnit > m_iCapacity)
-		return false;
-	m_iCurrentLoad += lUnit;
-	return true;
+bool CVehicleInfo::loadUnit(int lUnit) {
+    if (m_iCurrentLoad + lUnit > m_iCapacity)
+        return false;
+    m_iCurrentLoad += lUnit;
+    return true;
 }
 
-COrderInfo::COrderInfo()
-{
-}
-COrderInfo::~COrderInfo()
-{
-}
+COrderInfo::COrderInfo() { }
+COrderInfo::~COrderInfo() { }
 
-CDepotInfo::CDepotInfo()
-{
-}
-CDepotInfo::~CDepotInfo()
-{
-}
+CDepotInfo::CDepotInfo() { }
+CDepotInfo::~CDepotInfo() { }
 
-CTourInfo::CTourInfo()
-{
-	m_dTotalCost = 0.0;
-	m_dTotalDistance = 0.0;
-	m_dTotalTraveltime = 0.0;
-}
-CTourInfo::~CTourInfo()
-{
+CTourInfo::CTourInfo() {
+    m_dTotalCost = 0.0;
+    m_dTotalDistance = 0.0;
+    m_dTotalTraveltime = 0.0;
 }
+CTourInfo::~CTourInfo() { }
 
-bool CTourInfo::insertOrder(int orderId, int pos)
-{
-	m_viOrderIds.insert(m_viOrderIds.begin() + pos, orderId);
-	return true;
+bool CTourInfo::insertOrder(int orderId, int pos) {
+    m_viOrderIds.insert(m_viOrderIds.begin() + pos, orderId);
+    return true;
 }
 
-int CTourInfo::getRemainingCapacity()
-{
-	return(m_vehicleInfo.getRemainingCapacity());
+int CTourInfo::getRemainingCapacity() {
+    return(m_vehicleInfo.getRemainingCapacity());
 }
 
-bool CTourInfo::removeOrder(int pos)
-{
-	m_viOrderIds.erase(m_viOrderIds.begin() + pos);
-	return true;
+bool CTourInfo::removeOrder(int pos) {
+    m_viOrderIds.erase(m_viOrderIds.begin() + pos);
+    return true;
 }
 
-void CTourInfo::updateCost(double cost, double distance, double travelTime)
-{
-	m_dTotalCost = cost;
-	m_dTotalDistance = distance;
-	m_dTotalTraveltime = travelTime;
+void CTourInfo::updateCost(double cost, double distance, double travelTime) {
+    m_dTotalCost = cost;
+    m_dTotalDistance = distance;
+    m_dTotalTraveltime = travelTime;
 }
 
-CSolutionInfo::CSolutionInfo()
-{
-}
-CSolutionInfo::~CSolutionInfo()
-{
-}
+CSolutionInfo::CSolutionInfo() { }
+CSolutionInfo::~CSolutionInfo() { }
 
-void CSolutionInfo::replaceTour(CTourInfo curTour)
-{
-	unsigned int i;
-	for(i = 0; i < m_vtourAll.size(); i++)
-	{
-		if(m_vtourAll[i].getVehicleId() == curTour.getVehicleId())
-		{
-			m_vtourAll[i] = curTour;
-			return;
-		}
-	}
-	return;
+void CSolutionInfo::replaceTour(CTourInfo curTour) {
+    unsigned int i;
+    for (i = 0; i < m_vtourAll.size(); i++) {
+        if (m_vtourAll[i].getVehicleId() == curTour.getVehicleId()) {
+            m_vtourAll[i] = curTour;
+            return;
+        }
+    }
+    return;
 }
 
-void CSolutionInfo::replaceTourAt(int index, CTourInfo curTour)
-{
-	if(index < 0 || (unsigned int) index >= m_vtourAll.size())
-		return;
-	m_vtourAll[index] = curTour;
+void CSolutionInfo::replaceTourAt(int index, CTourInfo curTour) {
+    if (index < 0 ||  (unsigned int) index >= m_vtourAll.size())
+        return;
+    m_vtourAll[index] = curTour;
 }
 
-bool CSolutionInfo::init(std::vector<int> vecOrder, int iTotalOrder, std::vector<int> vecVehicle)
-{
-	m_vUnservedOrderId = vecOrder;
-	m_iTotalOrders = iTotalOrder;
-	m_vUnusedVehicles =  vecVehicle;
-
-	m_vtourAll.clear();
-	m_iVehicleUsed = 0;
-	m_iOrdersServed = 0;
-	m_iTotalOrders = 0;
-	m_dTotalCost = 0;
-	m_dTotalDistance = 0;
-	m_dTotalTravelTime = 0;
-	return true;
-}
+bool CSolutionInfo::init(std::vector<int> vecOrder, int iTotalOrder, std::vector<int> vecVehicle) {
+    m_vUnservedOrderId = vecOrder;
+    m_iTotalOrders = iTotalOrder;
+    m_vUnusedVehicles = vecVehicle;
 
-bool CSolutionInfo::addTour(CTourInfo& tour)
-{
-	m_vtourAll.push_back(tour);
-	int vid = tour.getVehicleId();
-	std::vector<int>::iterator it;
-	it = std::find(m_vUnusedVehicles.begin(), m_vUnusedVehicles.end(), vid);
-	if(it != m_vUnusedVehicles.end())
-	{
-		m_vUnusedVehicles.erase(it);
-	}
-	m_iVehicleUsed++;
-	m_dTotalDistance += tour.getDistance();
-	m_dTotalTravelTime += tour.getTravelTime();
-	m_dTotalCost += tour.getCost();
-
-	std::vector<int> vecOrders = tour.getOrderVector();
-
-	m_iOrdersServed += static_cast<int>(vecOrders.size());
-
-	for(unsigned int i = 0; i < vecOrders.size(); i++)
-	{
-		int oid = vecOrders[i];
-		it = std::find(m_vUnservedOrderId.begin(), m_vUnservedOrderId.end(), oid);
-		if(it != m_vUnservedOrderId.end())
-		{
-			m_vUnservedOrderId.erase(it);
-		}
-	}
-
-	return true;
+    m_vtourAll.clear();
+    m_iVehicleUsed = 0;
+    m_iOrdersServed = 0;
+    m_iTotalOrders = 0;
+    m_dTotalCost = 0;
+    m_dTotalDistance = 0;
+    m_dTotalTravelTime = 0;
+    return true;
 }
 
-CMoveInfo::CMoveInfo()
-{
+bool CSolutionInfo::addTour(CTourInfo& tour) {
+    m_vtourAll.push_back(tour);
+    int vid = tour.getVehicleId();
+    std::vector<int>::iterator it;
+    it = std::find(m_vUnusedVehicles.begin(), m_vUnusedVehicles.end(), vid);
+    if (it != m_vUnusedVehicles.end()) {
+        m_vUnusedVehicles.erase(it);
+    }
+    m_iVehicleUsed++;
+    m_dTotalDistance += tour.getDistance();
+    m_dTotalTravelTime += tour.getTravelTime();
+    m_dTotalCost += tour.getCost();
 
-}
-CMoveInfo::~CMoveInfo()
-{
+    std::vector<int> vecOrders = tour.getOrderVector();
+
+    m_iOrdersServed += static_cast<int>(vecOrders.size());
+
+    for (unsigned int i = 0; i < vecOrders.size(); i++) {
+        int oid = vecOrders[i];
+        it = std::find(m_vUnservedOrderId.begin(), m_vUnservedOrderId.end(), oid);
+        if (it != m_vUnservedOrderId.end()) {
+            m_vUnservedOrderId.erase(it);
+        }
+    }
 
+    return true;
 }
 
-void CMoveInfo::setInitialTour(CTourInfo tourData)
-{
-	m_vInitialTour.clear();
-	m_vInitialTour.push_back(tourData);
+CMoveInfo::CMoveInfo() { }
+CMoveInfo::~CMoveInfo() { }
+
+void CMoveInfo::setInitialTour(CTourInfo tourData) {
+    m_vInitialTour.clear();
+    m_vInitialTour.push_back(tourData);
 }
 
-void CMoveInfo::setInitialTour(CTourInfo tourData1, CTourInfo tourData2)
-{
-	m_vInitialTour.clear();
-	m_vInitialTour.push_back(tourData1);
-	m_vInitialTour.push_back(tourData2);
+void CMoveInfo::setInitialTour(CTourInfo tourData1, CTourInfo tourData2) {
+    m_vInitialTour.clear();
+    m_vInitialTour.push_back(tourData1);
+    m_vInitialTour.push_back(tourData2);
 }
 
-void CMoveInfo::setModifiedTour(CTourInfo tourData)
-{
-	m_vModifiedTour.clear();
-	m_vModifiedTour.push_back(tourData);
+void CMoveInfo::setModifiedTour(CTourInfo tourData) {
+    m_vModifiedTour.clear();
+    m_vModifiedTour.push_back(tourData);
 }
 
-void CMoveInfo::setModifiedTour(CTourInfo tourData1, CTourInfo tourData2)
-{
-	m_vModifiedTour.clear();
-	m_vModifiedTour.push_back(tourData1);
-	m_vModifiedTour.push_back(tourData2);
+void CMoveInfo::setModifiedTour(CTourInfo tourData1, CTourInfo tourData2) {
+    m_vModifiedTour.clear();
+    m_vModifiedTour.push_back(tourData1);
+    m_vModifiedTour.push_back(tourData2);
 }
 
-void CMoveInfo::getInitialTour(CTourInfo &tourData)
-{
-	tourData = m_vInitialTour[0];
+void CMoveInfo::getInitialTour(CTourInfo &tourData) {
+    tourData = m_vInitialTour[0];
 }
 
-void CMoveInfo::getInitialTour(CTourInfo &tourData1, CTourInfo &tourData2)
-{
-	tourData1 = m_vInitialTour[0];
-	tourData2 = m_vInitialTour[1];
+void CMoveInfo::getInitialTour(CTourInfo &tourData1, CTourInfo &tourData2) {
+    tourData1 = m_vInitialTour[0];
+    tourData2 = m_vInitialTour[1];
 }
 
-bool CMoveInfo::getModifiedTourAt(int index, CTourInfo& tourInfo)
-{
-	if(index < 0 || (unsigned int) index >= m_vModifiedTour.size())
-		return false;
-	tourInfo = m_vModifiedTour[index];
-        return true;
+bool CMoveInfo::getModifiedTourAt(int index, CTourInfo& tourInfo) {
+    if (index < 0 ||  (unsigned int) index >= m_vModifiedTour.size())
+        return false;
+    tourInfo = m_vModifiedTour[index];
+    return true;
 }
 
 
 
-CVRPSolver::CVRPSolver()
-{
+CVRPSolver::CVRPSolver() {
     // set a seed for the random number generator
     // so it will generate consistent results for the same input
     // otherwise we can not test it :(
     srand(1726354);
 }
-CVRPSolver::~CVRPSolver()
-{
-}
-
-bool CVRPSolver::solveVRP(std::string& strError)
-{
-//	if(!m_bIsReadyToSolve)
-//	{
-//		strError = "Scenario is not ready to solve. Configure all parameter";
-//		return false;
-//	}
-	PGR_LOG("Inside Solve VRP");
-	std::vector<int> vecOrders, vecVehicles;
-	for(unsigned int i = 0; i < m_vOrderInfos.size(); i++)
-	{
-		vecOrders.push_back(m_vOrderInfos[i].getOrderId());
-	}
-
-	for(unsigned int i = 0; i < m_vVehicleInfos.size(); i++)
-	{
-		vecVehicles.push_back(m_vVehicleInfos[i].getId());
-	}
-	
-	m_solutionFinal.init(vecOrders, static_cast<int>(vecOrders.size()), vecVehicles);
-	PGR_LOG("After init solution");
-	int iAttemtCount = 0;
-	while(iAttemtCount < MAXIMUM_TRY)
-	{
-		bool bUpdateFound = false;
-		CSolutionInfo initialSolution = generateInitialSolution();
-		PGR_LOG("After Generate initial Solution");
-		iAttemtCount++;
-		bUpdateFound = updateFinalSolution(initialSolution);
-		PGR_LOG("After update final Solution");
-		bool bUpdateFound2 = tabuSearch(initialSolution);
-		PGR_LOG("After Tabu Search");
-		if((bUpdateFound == true) || (bUpdateFound2 == true))
-		{
-			iAttemtCount = 0;
-		}
-	}
-	m_bIsSolutionReady = true;
+CVRPSolver::~CVRPSolver() { }
+
+bool CVRPSolver::solveVRP(std::string& strError) {
+    // if (!m_bIsReadyToSolve)
+    // {
+    //      strError = "Scenario is not ready to solve. Configure all parameter";
+    //      return false;
+    // }
+    PGR_LOG("Inside Solve VRP");
+    std::vector<int> vecOrders, vecVehicles;
+    for (unsigned int i = 0; i < m_vOrderInfos.size(); i++) {
+        vecOrders.push_back(m_vOrderInfos[i].getOrderId());
+    }
+
+    for (unsigned int i = 0; i < m_vVehicleInfos.size(); i++) {
+        vecVehicles.push_back(m_vVehicleInfos[i].getId());
+    }
+
+    m_solutionFinal.init(vecOrders, static_cast<int>(vecOrders.size()), vecVehicles);
+    PGR_LOG("After init solution");
+    int iAttemptCount = 0;
+    while (iAttemptCount < MAXIMUM_TRY) {
+        bool bUpdateFound = false;
+        CSolutionInfo initialSolution = generateInitialSolution();
+        PGR_LOG("After Generate initial Solution");
+        iAttemptCount++;
+        bUpdateFound = updateFinalSolution(initialSolution);
+        PGR_LOG("After update final Solution");
+        bool bUpdateFound2 = tabuSearch(initialSolution);
+        PGR_LOG("After Tabu Search");
+        if ((bUpdateFound == true) ||  (bUpdateFound2 == true)) {
+            iAttemptCount = 0;
+        }
+    }
+    m_bIsSolutionReady = true;
     strError += " ";
-	return true;
-
+    return true;
+}
+
+CSolutionInfo CVRPSolver::generateInitialSolution() {
+    CSolutionInfo initialSolution;
+    PGR_LOG("Inside gen ini sol");
+    std::vector<int> vecOrders, vecVehicles;
+    for (unsigned int i = 0; i < m_vOrderInfos.size(); i++) {
+        vecOrders.push_back(m_vOrderInfos[i].getOrderId());
+    }
+
+    for (unsigned int i = 0; i < m_vVehicleInfos.size(); i++) {
+        vecVehicles.push_back(m_vVehicleInfos[i].getId());
+    }
+
+    initialSolution.init(vecOrders, static_cast<int>(vecOrders.size()), vecVehicles);
+
+    int iUnusedVehicles = static_cast<int>(initialSolution.getUnusedVehicleCount());
+    int iUnservedOrders = static_cast<int>(initialSolution.getUnservedOrderCount());  // m_viUnservedOrderIndex.size();
+    PGR_LOG("before while");
+    while (iUnusedVehicles &&  iUnservedOrders) {
+        CTourInfo curTour;
+
+        int vehicleIndex = rand() % iUnusedVehicles--;
+        int vehicleInd = m_mapVehicleIdToIndex[initialSolution.getUnusedVehicleAt(vehicleIndex)];
+        curTour.setVehicleInfo(m_vVehicleInfos[vehicleInd]);  // m_viUnusedVehicleIndex[vehicleIndex]
+        initialSolution.removeVehicle(vehicleIndex);
+
+        curTour.setStartDepot(m_vDepotInfos[0].getDepotId());
+        curTour.setEndDepot(m_vDepotInfos[0].getDepotId());
+
+        // use a random seed to start to tour. (we can use better approach in future)
+
+        bool insertAvailable = true;
+
+        while (insertAvailable) {
+            insertAvailable = false;
+            std::pair<int, int> PotentialInsert;  //  first = insert_index, second = removed_order_index;
+            std::pair<int, double> bestInsert = std::make_pair(-1, DOUBLE_MAX);  // first = order_insert_index, second = cost;
+
+            for (int i = 0; i < iUnservedOrders; ++i) {
+                int orderInd = m_mapOrderIdToIndex[initialSolution.getUnservedOrderAt(i)];
+                COrderInfo curOrder = m_vOrderInfos[orderInd];
+                std::pair<int, double> curInsert = getPotentialInsert(curTour, curOrder);
+
+                if (curInsert.second < bestInsert.second) {
+                    insertAvailable = true;
+                    bestInsert = curInsert;
+                    PotentialInsert = std::make_pair(curInsert.first, i);
+                }
+            }
+            if (insertAvailable) {
+                if (insertOrder(curTour, initialSolution.getUnservedOrderAt(PotentialInsert.second), PotentialInsert.first)) {
+                    iUnservedOrders--;
+                    initialSolution.removeOrder(PotentialInsert.second);
+                }
+            }
+        }
+
+        initialSolution.addTour(curTour);
+    }
+
+    return initialSolution;
+}
+
+bool CVRPSolver::updateFinalSolution(CSolutionInfo& curSolution) {
+    bool callUpdate = false;
+    if (curSolution.getOrderServed() > m_solutionFinal.getOrderServed()) {
+        callUpdate = true;
+    } else if (curSolution.getOrderServed() == m_solutionFinal.getOrderServed()) {
+        if (curSolution.getTotalCost() < m_solutionFinal.getTotalCost()) {
+            callUpdate = true;
+        } else if (curSolution.getTotalCost() == m_solutionFinal.getTotalCost()) {
+            if (curSolution.getTotalTravelTime() < m_solutionFinal.getTotalTravelTime()) {
+                callUpdate = true;
+            } else if (curSolution.getTotalTravelTime() == m_solutionFinal.getTotalTravelTime()) {
+                if (curSolution.getTotalDistance() < m_solutionFinal.getTotalDistance()) {
+                    callUpdate = true;
+                }
+            }
+        }
+    }
+    if (callUpdate) {
+        // m_iStepsSinceLastSolution = 0;
+        m_solutionFinal = curSolution;
+
+        // clear map and delete objects
+        // m_mpTabuCount.clear();
+        // for (std::map< CVRPTWMove*, int >::iterator it = m_mpMoveFrequency.begin();it!= m_mpMoveFrequency.end();++it)
+        // {
+        //  delete (*it).first;
+        // }
+        // m_mpMoveFrequency.clear();
+        return true;
+    }
+    return false;
+}
+
+std::pair<int, double> CVRPSolver::getPotentialInsert(CTourInfo& curTour, COrderInfo& curOrder) {
+    std::pair<int, double> bestInsert = std::make_pair(-1, DOUBLE_MAX);
+    if (curOrder.getOrderUnit() > curTour.getRemainingCapacity()) {
+        return bestInsert;
+    }
+    // check if ith position insert is fisible.
+    std::vector<int> vecOrderId = curTour.getOrderVector();
+    for (unsigned int i = 0; i <= vecOrderId.size(); ++i) {
+        CostPack costToOrder, costFromOrder;
+
+        if (!i) {
+            costToOrder = getDepotToOrderCost(curTour.getStartDepot(), curOrder.getOrderId());
+        } else {
+            costToOrder = getOrderToOrderCost(vecOrderId[i-1], curOrder.getOrderId());
+        }
+
+        double dArrivalTime = costToOrder.traveltime + curTour.getStartTime(i);
+
+        if (dArrivalTime > curOrder.getCloseTime()) {
+            continue;
+        }
+
+        if (i == vecOrderId.size()) {
+            costFromOrder = getOrderToDepotCost(curOrder.getOrderId(), curTour.getEndDepot());
+        } else {
+            costFromOrder = getOrderToOrderCost(curOrder.getOrderId(), vecOrderId[i]);
+        }
+
+        dArrivalTime += curOrder.getServiceTime() + costFromOrder.traveltime;
+
+        if (i < vecOrderId.size() &&  dArrivalTime > m_vOrderInfos[m_mapOrderIdToIndex[vecOrderId[i]]].getCloseTime()) {
+            continue;
+        }
+
+        CostPack totalCost = getCostForInsert(curTour, curOrder, i);
+
+        if (totalCost.cost < bestInsert.second) {
+            bestInsert = std::make_pair(i, totalCost.cost);
+        }
+    }
+    return bestInsert;
+}
+
+bool CVRPSolver::tabuSearch(CSolutionInfo& curSolution) {
+    m_bFoundOptimal = false;
+    updateFinalSolution(curSolution);
+
+    int numberOfSearch = 0;
+    m_iGeneratedSolutionCount = 0;
+    m_iStepsSinceLastSolution = 0;
+
+    while (numberOfSearch < TOTAL_NUMBER_OF_SEARCH) {
+        // applyBestMoveInCurrentSolution(curSolution, identifyPotentialMove(curSolution) );
+        insertUnservedOrders(curSolution);
+        // attemptFeasibleNodeExchange(curSolution);
+        attemptVehicleExchange(curSolution);
+        ++numberOfSearch;
+    }
+    return false;
+}
+
+void CVRPSolver::applyBestMoveInCurrentSolution(CSolutionInfo& curSolution, CMoveInfo& bestMove) {
+    ++m_iGeneratedSolutionCount;
+    ++m_iStepsSinceLastSolution;
+
+    updateTabuCount(bestMove);
+
+    int totalTour = static_cast<int>(bestMove.getModifiedTourCount());
+    for (int i = 0; i < totalTour; ++i) {
+        CTourInfo tourInfo;
+        bool bIsValid = bestMove.getModifiedTourAt(i, tourInfo);
+
+        if (bIsValid)
+            curSolution.replaceTour(tourInfo);
+    }
+    updateFinalSolution(curSolution);
+}
+
+void CVRPSolver::insertUnservedOrders(CSolutionInfo& curSolution) {
+    ++m_iGeneratedSolutionCount;
+    ++m_iStepsSinceLastSolution;
+    bool insertAvailable = true;
+    CMoveInfo curMove;
+    int totalUnservedOrder = static_cast<int>(m_vOrderInfos.size() - curSolution.getOrderServed());
+
+    while (insertAvailable &&  totalUnservedOrder > 0) {
+        int insertTourId = -1;
+        insertAvailable = false;
+        int totalTour = static_cast<int>(curSolution.getTourInfoVector().size());
+        std::pair<int, int> PotentialInsert;  //  first = insert_index, second = removed_customer_index;
+        std::pair<int, double> bestInsert = std::make_pair(-1, DOUBLE_MAX);  // first = customer_insert_index, second = cost;
+
+        for (int j = 0; j < totalTour; ++j) {
+            CTourInfo curTour = curSolution.getTour(j);
+            curMove.setInitialTour(curTour);
+
+            for (int i = 0; i < totalUnservedOrder; ++i) {
+                int ordIndex = m_mapOrderIdToIndex[curSolution.getUnservedOrderAt(i)];
+                COrderInfo curOrder = m_vOrderInfos[ordIndex];
+                std::pair<int, double> curInsert = getPotentialInsert(curTour, curOrder);
+
+                insertOrder(curTour, i, curInsert.first);
+                curMove.setModifiedTour(curTour);
+                curMove.getInitialTour(curTour);
+
+                // check if current move is tabu.
+                if (isTabuMove(curMove)) {
+                    continue;
+                }
+
+                if (curInsert.second < bestInsert.second) {
+                    insertTourId = j;
+                    insertAvailable = true;
+                    bestInsert = curInsert;
+                    PotentialInsert = std::make_pair(curInsert.first, i);
+                }
+            }
+        }
+        if (insertAvailable) {
+            totalUnservedOrder--;
+            curMove.setInitialTour(curSolution.getTour(insertTourId));
+
+            addOrderAtTour(curSolution, insertTourId,
+                    PotentialInsert.first,
+                    PotentialInsert.second);
+
+            curMove.setModifiedTour(curSolution.getTour(insertTourId));
+            this->updateTabuCount(curMove);
+            this->updateFinalSolution(curSolution);  // this->evaluateCurrentSolution();
+        }
+    }
+}
+
+bool CVRPSolver::addDepot(CDepotInfo depotInfo) {
+    int id = depotInfo.getDepotId();
+    if (m_mapDepotIdToIndex.find(id) != m_mapDepotIdToIndex.end())
+        return false;
+    m_mapDepotIdToIndex.insert(std::make_pair(id, m_vDepotInfos.size()));
+    m_vDepotInfos.push_back(depotInfo);
+
+    return true;
+}
+
+bool CVRPSolver::addOrder(COrderInfo orderInfo) {
+    int id = orderInfo.getOrderId();
+    if (m_mapOrderIdToIndex.find(id) != m_mapOrderIdToIndex.end()) {
+        return false;
+    }
+    int index = static_cast<int>(m_vOrderInfos.size());
+    m_mapOrderIdToIndex.insert(std::make_pair(id, index));
+    m_vOrderInfos.push_back(orderInfo);
+    m_viUnservedOrderIndex.push_back(index);
+    return true;
+}
+
+bool CVRPSolver::addVehicle(CVehicleInfo vehicleInfo) {
+    int id = vehicleInfo.getId();
+    if (m_mapVehicleIdToIndex.find(id) != m_mapVehicleIdToIndex.end()) {
+        return false;
+    }
+    int index = static_cast<int>(m_vVehicleInfos.size());
+    m_mapVehicleIdToIndex.insert(std::make_pair(id, index));
+    m_vVehicleInfos.push_back(vehicleInfo);
+    m_viUnusedVehicleIndex.push_back(index);
+    return true;
+}
+
+bool CVRPSolver::addDepotToOrderCost(int depotId, int orderId, CostPack cost) {
+    PII depo_order = std::make_pair(depotId, orderId);
+    if (m_mapDepotToOrderrCost.find(depo_order) != m_mapDepotToOrderrCost.end()) {
+        return false;
+    }
+    m_mapDepotToOrderrCost.insert(make_pair(depo_order, cost));
+    return true;
+}
+
+bool CVRPSolver::addOrderToDepotCost(int depotId, int orderId, CostPack cost) {
+    PII depo_order = std::make_pair(orderId, depotId);
+    if (m_mapOrderToDepotCost.find(depo_order) != m_mapOrderToDepotCost.end()) {
+        return false;
+    }
+    m_mapOrderToDepotCost.insert(std::make_pair(depo_order, cost));
+    return true;
+}
+
+bool CVRPSolver::addOrderToOrderCost(int firstOrder, int secondOrder, CostPack cost) {
+    PII order_order = std::make_pair(firstOrder, secondOrder);
+    if (m_mapOrderToOrderCost.find(order_order) != m_mapOrderToOrderCost.end()) {
+        return false;
+    }
+    m_mapOrderToOrderCost.insert(std::make_pair(order_order, cost));
+    return true;
+}
+
+bool CVRPSolver::getSolution(CSolutionInfo& solution, std::string& strError) {
+    if (m_bIsSolutionReady == true) {
+        solution = m_solutionFinal;
+        return true;
+    } else {
+        bool ret = solveVRP(strError);
+        if (ret == true) {
+            solution = m_solutionFinal;
+            return true;
+        }
+        return false;
+    }
 }
 
-CSolutionInfo CVRPSolver::generateInitialSolution()
-{
-	CSolutionInfo initialSolution;
-	PGR_LOG("Inside gen ini sol");
-	std::vector<int> vecOrders, vecVehicles;
-	for(unsigned int i = 0; i < m_vOrderInfos.size(); i++)
-	{
-		vecOrders.push_back(m_vOrderInfos[i].getOrderId());
-	}
-
-	for(unsigned int i = 0; i < m_vVehicleInfos.size(); i++)
-	{
-		vecVehicles.push_back(m_vVehicleInfos[i].getId());
-	}
-
-	initialSolution.init(vecOrders, static_cast<int>(vecOrders.size()), vecVehicles);
-
-	int iUnusedVehicles = static_cast<int>(initialSolution.getUnusedVehicleCount());
-	int iUnservedOrders = static_cast<int>(initialSolution.getUnservedOrderCount());//m_viUnservedOrderIndex.size();
-	PGR_LOG("before while");
-	while( iUnusedVehicles && iUnservedOrders )
-	{
-		CTourInfo curTour;
-
-		int vehicleIndex = rand() % iUnusedVehicles--;
-		int vehicleInd = m_mapVehicleIdToIndex[initialSolution.getUnusedVehicleAt(vehicleIndex)];
-		curTour.setVehicleInfo(m_vVehicleInfos[vehicleInd]);//m_viUnusedVehicleIndex[vehicleIndex]
-		initialSolution.removeVehicle(vehicleIndex);
-		
-		curTour.setStartDepot(m_vDepotInfos[0].getDepotId());
-		curTour.setEndDepot(m_vDepotInfos[0].getDepotId());
-		
-		//use a random seed to start to tour. (we can use better approach in future)
-		
-		bool insertAvailable = true;
-
-		while( insertAvailable )
-		{
-			insertAvailable = false;
-			std::pair<int,int> PotentialInsert; // first = insert_index, second = removed_order_index;
-			std::pair<int,double> bestInsert = std::make_pair(-1,DOUBLE_MAX);//first = order_insert_index, second = cost;
-
-			for(int i = 0;i<iUnservedOrders;++i)
-			{
-				int orderInd = m_mapOrderIdToIndex[initialSolution.getUnservedOrderAt(i)];
-				COrderInfo curOrder = m_vOrderInfos[orderInd];
-				std::pair<int,double> curInsert = getPotentialInsert(curTour, curOrder);
-
-				if( curInsert.second < bestInsert.second )
-				{
-					insertAvailable = true;
-					bestInsert = curInsert;
-					PotentialInsert = std::make_pair(curInsert.first,i);
-				}
-			}
-			if( insertAvailable )
-			{
-				if(insertOrder(curTour, initialSolution.getUnservedOrderAt(PotentialInsert.second), PotentialInsert.first))
-				{
-					iUnservedOrders--;
-					initialSolution.removeOrder(PotentialInsert.second);
-				}
-			}
-		}
-
-		initialSolution.addTour(curTour);
-	}
-
-	return initialSolution;
-}
+CostPack CVRPSolver::getDepotToOrderCost(int depotId, int orderId) {
+    PII depo_order = std::make_pair(depotId, orderId);
 
-bool CVRPSolver::updateFinalSolution(CSolutionInfo& curSolution)
-{
-	bool callUpdate = false;
-	if ( curSolution.getOrderServed() > m_solutionFinal.getOrderServed() )
-	{
-		callUpdate = true;
-	}
-	else if ( curSolution.getOrderServed() == m_solutionFinal.getOrderServed() )
-	{
-		if ( curSolution.getTotalCost() < m_solutionFinal.getTotalCost() )
-		{
-			callUpdate = true;
-		}
-		else if (curSolution.getTotalCost() == m_solutionFinal.getTotalCost() )
-		{
-			if ( curSolution.getTotalTravelTime() < m_solutionFinal.getTotalTravelTime() )
-			{
-				callUpdate = true;
-			}
-			else if ( curSolution.getTotalTravelTime() == m_solutionFinal.getTotalTravelTime()  )
-			{
-				if ( curSolution.getTotalDistance() < m_solutionFinal.getTotalDistance()  )
-				{
-					callUpdate = true;
-				}
-			}
-		}
-	}
-	if (callUpdate)
-	{
-		//m_iStepsSinceLastSolution = 0;
-		m_solutionFinal = curSolution;
-
-		//clear map and delete objects
-		//m_mpTabuCount.clear();
-		//for (std::map< CVRPTWMove*,int >::iterator it = m_mpMoveFrequency.begin();it!=m_mpMoveFrequency.end();++it)
-		//{
-		//	delete (*it).first;
-		//}
-		//m_mpMoveFrequency.clear();
-		return true;
-	}
-	return false;
+    if (m_mapDepotToOrderrCost.find(depo_order) != m_mapDepotToOrderrCost.end()) {
+        return(m_mapDepotToOrderrCost[depo_order]);
+    }
+    CostPack ret;
+    ret.cost = ret.distance = ret.traveltime = 1e15;
+    return ret;
 }
 
-std::pair<int,double> CVRPSolver::getPotentialInsert(CTourInfo& curTour, COrderInfo& curOrder)
-{
-	std::pair<int,double> bestInsert = std::make_pair(-1,DOUBLE_MAX);
-	if( curOrder.getOrderUnit() > curTour.getRemainingCapacity() )
-	{
-		return bestInsert;
-	}
-	//check if ith position insert is fisible.
-	std::vector<int> vecOrderId = curTour.getOrderVector();
-	for(unsigned int i = 0; i <= vecOrderId.size();++i)
-	{
-		CostPack costToOrder, costFromOrder;
-		
-		if(!i)
-		{
-			costToOrder = getDepotToOrderCost( curTour.getStartDepot(), curOrder.getOrderId());
-		}
-		else costToOrder = getOrderToOrderCost( vecOrderId[i-1], curOrder.getOrderId());
-
-		double dArrivalTime = costToOrder.traveltime + curTour.getStartTime(i);
-
-		if( dArrivalTime > curOrder.getCloseTime() )
-		{
-			continue;
-		}
-
-		if (i == vecOrderId.size())
-		{
-			costFromOrder = getOrderToDepotCost( curOrder.getOrderId(), curTour.getEndDepot() );
-		}
-		else costFromOrder = getOrderToOrderCost( curOrder.getOrderId(), vecOrderId[i] );
-
-		dArrivalTime += curOrder.getServiceTime() + costFromOrder.traveltime;
-
-		if( i < vecOrderId.size() && dArrivalTime > m_vOrderInfos[m_mapOrderIdToIndex[vecOrderId[i]]].getCloseTime())
-		{
-			continue;
-		}
-
-		CostPack totalCost = getCostForInsert(curTour, curOrder, i);
-
-		
-		if( totalCost.cost < bestInsert.second )
-		{
-			bestInsert = std::make_pair(i,totalCost.cost);
-		}
-	}
-	return bestInsert;
-}
+CostPack CVRPSolver::getOrderToOrderCost(int orderId1, int orderId2) {
+    PII order_order = std::make_pair(orderId1, orderId2);
 
-bool CVRPSolver::tabuSearch(CSolutionInfo& curSolution)
-{
-	m_bFoundOptimal = false;
-	updateFinalSolution(curSolution);
-
-	int numberOfSearch = 0;
-	m_iGeneratedSolutionCount = 0;
-	m_iStepsSinceLastSolution = 0;
-
-	while( numberOfSearch < TOTAL_NUMBER_OF_SEARCH )
-	{
-		//applyBestMoveInCurrentSolution(curSolution, identifyPotentialMove(curSolution) );	
-		insertUnservedOrders(curSolution);
-		//attemptFeasibleNodeExchange(curSolution);
-		attempVehicleExchange(curSolution);
-		++numberOfSearch;
-	}
-	return false;
+    if (m_mapOrderToOrderCost.find(order_order) != m_mapOrderToOrderCost.end()) {
+        return(m_mapOrderToOrderCost[order_order]);
+    }
+    CostPack ret;
+    ret.cost = ret.distance = ret.traveltime = 1e15;
+    return ret;
 }
 
-void CVRPSolver::applyBestMoveInCurrentSolution(CSolutionInfo& curSolution, CMoveInfo& bestMove)
-{
-	++m_iGeneratedSolutionCount;
-	++m_iStepsSinceLastSolution;
 
-	updateTabuCount(bestMove);
+CostPack CVRPSolver::getOrderToDepotCost(int depotId, int orderId) {
+    PII depo_order = std::make_pair(orderId, depotId);
 
-	int totalTour = static_cast<int>(bestMove.getModifiedTourCount());
-	for(int i = 0;i<totalTour;++i)
-	{
-		CTourInfo tourInfo;
-		bool bIsValid = bestMove.getModifiedTourAt(i, tourInfo);
-
-		if(bIsValid)
-			curSolution.replaceTour(tourInfo);
-	}
-	updateFinalSolution(curSolution);
-	
+    if (m_mapOrderToDepotCost.find(depo_order) != m_mapOrderToDepotCost.end()) {
+        return(m_mapOrderToDepotCost[depo_order]);
+    }
+    CostPack ret;
+    ret.cost = ret.distance = ret.traveltime = 1e15;
+    return ret;
 }
 
-void CVRPSolver::insertUnservedOrders(CSolutionInfo& curSolution)
-{
-	++m_iGeneratedSolutionCount;
-	++m_iStepsSinceLastSolution;
-	bool insertAvailable = true;
-	CMoveInfo curMove;
-	int totalUnservedOrder = static_cast<int>(m_vOrderInfos.size() - curSolution.getOrderServed());
-
-	while( insertAvailable && totalUnservedOrder > 0 )
-	{
-		int insertTourId = -1;
-		insertAvailable = false;
-		int totalTour = static_cast<int>(curSolution.getTourInfoVector().size());
-		std::pair<int,int> PotentialInsert; // first = insert_index, second = removed_customer_index;
-		std::pair<int,double> bestInsert = std::make_pair(-1,DOUBLE_MAX);//first = customer_insert_index, second = cost;
-
-		for(int j = 0;j<totalTour;++j)
-		{
-			CTourInfo curTour = curSolution.getTour(j);
-			curMove.setInitialTour(curTour);
-
-			for(int i = 0;i<totalUnservedOrder;++i)
-			{
-				int ordIndex = m_mapOrderIdToIndex[curSolution.getUnservedOrderAt(i)];
-				COrderInfo curOrder = m_vOrderInfos[ordIndex];
-				std::pair<int,double> curInsert = getPotentialInsert(curTour, curOrder);
-
-				insertOrder(curTour, i,curInsert.first);
-				curMove.setModifiedTour(curTour);
-				curMove.getInitialTour(curTour);
-
-				//check if current move is tabu.
-				if( isTabuMove(curMove) )
-				{
-					continue;
-				}
-
-				if( curInsert.second < bestInsert.second )
-				{
-					insertTourId = j;
-					insertAvailable = true;
-					bestInsert = curInsert;
-					PotentialInsert = std::make_pair(curInsert.first,i);
-				}
-			}
-		}
-		if( insertAvailable )
-		{
-			totalUnservedOrder--;
-			curMove.setInitialTour(curSolution.getTour(insertTourId));
-
-			addOrderAtTour(curSolution, insertTourId,
-				PotentialInsert.first,
-				PotentialInsert.second);
-
-			curMove.setModifiedTour(curSolution.getTour(insertTourId));
-			this->updateTabuCount(curMove);
-			this->updateFinalSolution(curSolution);//this->evaluateCurrentSolution();
-		}
-	}
-	
-}
+bool CVRPSolver::insertOrder(CTourInfo& tourInfo, int orderId, int pos) {
+    if (pos < 0 ||  (unsigned int) pos > tourInfo.getOrderVector().size())
+        return false;
 
-bool CVRPSolver::addDepot(CDepotInfo depotInfo)
-{
-	int id = depotInfo.getDepotId();
-	if(m_mapDepotIdToIndex.find(id) != m_mapDepotIdToIndex.end())
-		return false;
-	m_mapDepotIdToIndex.insert(std::make_pair(id, m_vDepotInfos.size()));
-	m_vDepotInfos.push_back(depotInfo);
-	
-	return true;
-}
+    int orderIndex = m_mapOrderIdToIndex[orderId];
+    if (!tourInfo.getVehicleInfo().loadUnit(m_vOrderInfos[orderIndex].getOrderUnit()))
+        return false;
+    tourInfo.insertOrder(orderId, pos);
 
-bool CVRPSolver::addOrder(COrderInfo orderInfo)
-{
-	int id = orderInfo.getOrderId();
-	if(m_mapOrderIdToIndex.find(id) != m_mapOrderIdToIndex.end())
-	{
-		return false;
-	}
-	int index = static_cast<int>(m_vOrderInfos.size());
-	m_mapOrderIdToIndex.insert(std::make_pair(id, index));
-	m_vOrderInfos.push_back(orderInfo);
-	m_viUnservedOrderIndex.push_back(index);
-	return true;
-}
+    if (!updateTourCosts(tourInfo)) {
+        tourInfo.removeOrder(pos);
+        return false;
+    }
 
-bool CVRPSolver::addVehicle(CVehicleInfo vehicleInfo)
-{
-	int id = vehicleInfo.getId();
-	if(m_mapVehicleIdToIndex.find(id) != m_mapVehicleIdToIndex.end())
-	{
-		return false;
-	}
-	int index = static_cast<int>(m_vVehicleInfos.size());
-	m_mapVehicleIdToIndex.insert(std::make_pair(id, index));
-	m_vVehicleInfos.push_back(vehicleInfo);
-	m_viUnusedVehicleIndex.push_back(index);
-	return true;
+    return true;
 }
 
-bool CVRPSolver::addDepotToOrderCost(int depotId, int orderId, CostPack cost)
-{
-	PII depo_order = std::make_pair(depotId, orderId);
-	if(m_mapDepotToOrderrCost.find(depo_order) != m_mapDepotToOrderrCost.end())
-	{
-		return false;
-	}
-	m_mapDepotToOrderrCost.insert(make_pair(depo_order, cost));
-	return true;
-}
+bool CVRPSolver::updateTourCosts(CTourInfo& tourInfo) {
+    std::vector<int> vecOrderId = tourInfo.getOrderVector();
+    std::vector<int> vecStartTimes;
 
-bool CVRPSolver::addOrderToDepotCost(int depotId, int orderId, CostPack cost)
-{
-	PII depo_order = std::make_pair(orderId, depotId);
-	if(m_mapOrderToDepotCost.find(depo_order) != m_mapOrderToDepotCost.end())
-	{
-		return false;
-	}
-	m_mapOrderToDepotCost.insert(std::make_pair(depo_order, cost));
-	return true;
-}
+    double dCost, dDistance, dTravelTime;
+    dCost = dDistance = dTravelTime = 0.0;
 
-bool CVRPSolver::addOrderToOrderCost(int firstOrder, int secondOrder, CostPack cost)
-{
-	PII order_order = std::make_pair(firstOrder, secondOrder);
-	if(m_mapOrderToOrderCost.find(order_order) != m_mapOrderToOrderCost.end())
-	{
-		return false;
-	}
-	m_mapOrderToOrderCost.insert(std::make_pair(order_order, cost));
-	return true;
-}
+    CostPack cPack = getDepotToOrderCost(tourInfo.getStartDepot(), vecOrderId[0]);
 
-bool CVRPSolver::getSolution(CSolutionInfo& solution, std::string& strError)
-{
-	if(m_bIsSolutionReady == true)
-	{
-		solution = m_solutionFinal;
-		return true;
-	}
-	else
-	{
-		bool ret = solveVRP(strError);
-		if(ret == true)
-		{
-			solution = m_solutionFinal;
-			return true;
-		}
-		return false;
-	}
-}
+    dCost += cPack.cost;
+    dDistance += cPack.distance;
 
-CostPack CVRPSolver::getDepotToOrderCost(int depotId, int orderId)
-{
-	PII depo_order = std::make_pair(depotId, orderId);
-
-	if(m_mapDepotToOrderrCost.find(depo_order) != m_mapDepotToOrderrCost.end())
-	{
-		return(m_mapDepotToOrderrCost[depo_order]);
-	}
-	CostPack ret;
-	ret.cost = ret.distance = ret.traveltime = 1e15;
-	return ret;
-}
+    int ind = m_mapOrderIdToIndex[vecOrderId[0]];
+    vecStartTimes.push_back(0);
 
-CostPack CVRPSolver::getOrderToOrderCost(int orderId1, int orderId2)
-{
-	PII order_order = std::make_pair(orderId1, orderId2);
-
-	if(m_mapOrderToOrderCost.find(order_order) != m_mapOrderToOrderCost.end())
-	{
-		return(m_mapOrderToOrderCost[order_order]);
-	}
-	CostPack ret;
-	ret.cost = ret.distance = ret.traveltime = 1e15;
-	return ret;
-}
+    if (dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
+        return false;
 
+    dTravelTime = (std::max)(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(),
+            static_cast<double>(m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime()));
+    vecStartTimes.push_back(static_cast<int>(ceil(dTravelTime)));
 
-CostPack CVRPSolver::getOrderToDepotCost(int depotId, int orderId)
-{
-	PII depo_order = std::make_pair(orderId, depotId);
+    unsigned int i;
+    for (i = 1; i < vecOrderId.size(); i++) {
+        cPack = getOrderToOrderCost(vecOrderId[i - 1], vecOrderId[i]);
+        dCost += cPack.cost;
+        dDistance += cPack.distance;
 
-	if(m_mapOrderToDepotCost.find(depo_order) != m_mapOrderToDepotCost.end())
-	{
-		return(m_mapOrderToDepotCost[depo_order]);
-	}
-	CostPack ret;
-	ret.cost = ret.distance = ret.traveltime = 1e15;
-	return ret;
-}
+        ind = m_mapOrderIdToIndex[vecOrderId[i]];
 
-bool CVRPSolver::insertOrder(CTourInfo& tourInfo, int orderId, int pos)
-{
-	if(pos < 0 || (unsigned int) pos > tourInfo.getOrderVector().size())
-		return false;
-
-	int orderIndex = m_mapOrderIdToIndex[orderId];
-	if(!tourInfo.getVehicleInfo().loadUnit(m_vOrderInfos[orderIndex].getOrderUnit()))
-		return false;
-	tourInfo.insertOrder(orderId, pos);
-		
-	if(!updateTourCosts(tourInfo))
-	{
-		tourInfo.removeOrder(pos);
-		return false;
-	}
-
-	return true;
-}
+        if (dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
+            return false;
 
-bool CVRPSolver::updateTourCosts(CTourInfo& tourInfo)
-{
-	std::vector<int> vecOrderId = tourInfo.getOrderVector();
-	std::vector<int> vecStartTimes;
+        dTravelTime = (std::max)(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(),
+                static_cast<double>(m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime()));
 
-	double dCost, dDistance, dTravelTime;
-	dCost = dDistance = dTravelTime = 0.0;
+        vecStartTimes.push_back(static_cast<int>(ceil(dTravelTime)));
+    }
 
-	CostPack cPack = getDepotToOrderCost(tourInfo.getStartDepot(), vecOrderId[0]);
+    cPack = getOrderToDepotCost(vecOrderId[i - 1], tourInfo.getEndDepot());
+    dCost += cPack.cost;
+    dDistance += cPack.distance;
 
-	dCost += cPack.cost;
-	dDistance += cPack.distance;
+    dTravelTime += cPack.traveltime;
 
-	int ind = m_mapOrderIdToIndex[vecOrderId[0]];
-	vecStartTimes.push_back(0);
+    vecStartTimes.push_back(static_cast<int>(ceil(dTravelTime)));
+    ind = m_mapDepotIdToIndex[tourInfo.getEndDepot()];
+    if (dTravelTime > m_vDepotInfos[ind].getCloseTime())
+        return false;
 
-	if(dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
-		return false;
+    tourInfo.updateCost(dCost, dDistance, dTravelTime);
 
-	dTravelTime = max(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(), 
-						m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime());
-	vecStartTimes.push_back(static_cast<int>(ceil(dTravelTime)));
+    tourInfo.setStartTime(vecStartTimes);
 
-	unsigned int i;
-	for(i = 1; i < vecOrderId.size(); i++)
-	{
-		cPack = getOrderToOrderCost(vecOrderId[i - 1], vecOrderId[i]);
-		dCost += cPack.cost;
-		dDistance += cPack.distance;
+    return true;
+}
 
-		ind = m_mapOrderIdToIndex[vecOrderId[i]];
+bool CVRPSolver::addOrderAtTour(CSolutionInfo &solutionInfo, int tourIndex, int insertIndex, int orderIndex) {
+    return(insertOrder(solutionInfo.getTour(tourIndex), m_vOrderInfos[orderIndex].getOrderId(), insertIndex));
+}
 
-		if(dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
-			return false;
+CostPack CVRPSolver::getCostForInsert(CTourInfo& curTour, COrderInfo& curOrder, int pos) {
+    std::vector<int> vecOrderId = curTour.getOrderVector();
 
-		dTravelTime = max(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(), 
-			m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime());
+    vecOrderId.insert(vecOrderId.begin() + pos, curOrder.getOrderId());
+    double dCost, dDistance, dTravelTime;
+    dCost = dDistance = dTravelTime = 0.0;
+    CostPack costRet;
 
-	    vecStartTimes.push_back(static_cast<int>(ceil(dTravelTime)));
-	
-	}
-	
-	cPack = getOrderToDepotCost(vecOrderId[i - 1], tourInfo.getEndDepot());
-	dCost += cPack.cost;
-	dDistance += cPack.distance;
+    costRet.cost = INF;
+    costRet.distance = INF;
+    costRet.traveltime = INF;
 
-	dTravelTime += cPack.traveltime;
+    CostPack cPack = getDepotToOrderCost(curTour.getStartDepot(), vecOrderId[0]);
 
-	vecStartTimes.push_back(static_cast<int>(ceil(dTravelTime)));
-	ind = m_mapDepotIdToIndex[tourInfo.getEndDepot()];
-	if(dTravelTime > m_vDepotInfos[ind].getCloseTime())
-		return false;
+    dCost += cPack.cost;
+    dDistance += cPack.distance;
 
-	tourInfo.updateCost(dCost, dDistance, dTravelTime);
+    int ind = m_mapOrderIdToIndex[vecOrderId[0]];
 
-	tourInfo.setStartTime(vecStartTimes);
+    if (dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
+        return costRet;
 
-	return true;
-}
+    dTravelTime = (std::max)(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(),
+            static_cast<double>(m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime()));
 
-bool CVRPSolver::addOrderAtTour(CSolutionInfo &solutionInfo, int tourIndex, int insertIndex, int orderIndex)
-{
-	return(insertOrder(solutionInfo.getTour(tourIndex), m_vOrderInfos[orderIndex].getOrderId(), insertIndex));
-}
+    unsigned int i;
+    for (i = 1; i < vecOrderId.size(); i++) {
+        cPack = getOrderToOrderCost(vecOrderId[i - 1], vecOrderId[i]);
+        dCost += cPack.cost;
+        dDistance += cPack.distance;
 
-CostPack CVRPSolver::getCostForInsert(CTourInfo& curTour, COrderInfo& curOrder, int pos)
-{
-	std::vector<int> vecOrderId = curTour.getOrderVector();
-	
-	vecOrderId.insert(vecOrderId.begin() + pos, curOrder.getOrderId());
-	double dCost, dDistance, dTravelTime;
-	dCost = dDistance = dTravelTime = 0.0;
-	CostPack costRet;
+        ind = m_mapOrderIdToIndex[vecOrderId[i]];
 
-	costRet.cost = INF;
-	costRet.distance = INF;
-	costRet.traveltime = INF;
+        if (dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
+            return costRet;
 
-	CostPack cPack = getDepotToOrderCost(curTour.getStartDepot(), vecOrderId[0]);
+        dTravelTime = (std::max)(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(),
+                static_cast<double>(m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime()));
+    }
 
-	dCost += cPack.cost;
-	dDistance += cPack.distance;
+    cPack = getOrderToDepotCost(vecOrderId[i - 1], curTour.getEndDepot());
+    dCost += cPack.cost;
+    dDistance += cPack.distance;
 
-	int ind = m_mapOrderIdToIndex[vecOrderId[0]];
+    dTravelTime += cPack.traveltime;
 
-	if(dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
-		return costRet;
+    ind = m_mapDepotIdToIndex[curTour.getEndDepot()];
+    if (dTravelTime > m_vDepotInfos[ind].getCloseTime())
+        return costRet;
 
-	dTravelTime = max(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(), 
-		m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime());
+    costRet.cost = dCost - curTour.getCost();
+    costRet.distance = dDistance - curTour.getDistance();
+    costRet.traveltime = dTravelTime - curTour.getTravelTime();
 
-	unsigned int i;
-	for(i = 1; i < vecOrderId.size(); i++)
-	{
-		cPack = getOrderToOrderCost(vecOrderId[i - 1], vecOrderId[i]);
-		dCost += cPack.cost;
-		dDistance += cPack.distance;
+    return costRet;
+}
 
-		ind = m_mapOrderIdToIndex[vecOrderId[i]];
+void CVRPSolver::attemptVehicleExchange(CSolutionInfo& solutionInfo) {
+    ++m_iGeneratedSolutionCount;
+    ++m_iStepsSinceLastSolution;
+    CMoveInfo curMove;
+    CMoveInfo bestMove;
 
-		if(dTravelTime + cPack.traveltime > m_vOrderInfos[ind].getCloseTime())
-			return costRet;
+    int bestFreeCapacity = 0;
+    std::pair<int, int> bestSwapIndex;
+    int totalTour = static_cast<int>(solutionInfo.getTourCount());
 
-		dTravelTime = max(dTravelTime + cPack.traveltime + m_vOrderInfos[ind].getServiceTime(), 
-			m_vOrderInfos[ind].getOpenTime() + m_vOrderInfos[ind].getServiceTime());
+    for (int i = 0; i < totalTour; ++i) {
+        CTourInfo firstTour = solutionInfo.getTour(i);
+        int firstTourLoad = firstTour.getVehicleInfo().getCurrentLoad();
+        int firstVehicleCapacity = firstTour.getVehicleInfo().getCapacity();
 
-	}
+        for (int j = i + 1; j < totalTour; ++j) {
+            CTourInfo secondTour = solutionInfo.getTour(j);
+            curMove.setInitialTour(firstTour, secondTour);
 
-	cPack = getOrderToDepotCost(vecOrderId[i - 1], curTour.getEndDepot());
-	dCost += cPack.cost;
-	dDistance += cPack.distance;
+            int FirstTourRemainingCapacity = firstVehicleCapacity - secondTour.getVehicleInfo().getCurrentLoad();
 
-	dTravelTime += cPack.traveltime;
+            int SecondTourRemainingCapacity = secondTour.getVehicleInfo().getCapacity() - firstTourLoad;
 
-	ind = m_mapDepotIdToIndex[curTour.getEndDepot()];
-	if(dTravelTime > m_vDepotInfos[ind].getCloseTime())
-		return costRet;
+            // int prevFreeCapacity = max(secondTour.getRemainingCapacity(), firstTour.getRemainingCapacity() );
 
-	costRet.cost = dCost - curTour.getCost();
-	costRet.distance = dDistance - curTour.getDistance();
-	costRet.traveltime = dTravelTime - curTour.getTravelTime();
+            int curFreeCapacity = (std::max)(FirstTourRemainingCapacity, SecondTourRemainingCapacity);
 
-	return costRet;
-}
+            if ((FirstTourRemainingCapacity > 0) &&  (SecondTourRemainingCapacity > 0) &&
+                    // curFreeCapacity > curFreeCapacity autological compare evaluates to false (error on MAC)
+                    (curFreeCapacity > bestFreeCapacity)) {
+                CVehicleInfo tempVehicle = m_vVehicleInfos[firstTour.getVehicleId()];
+                firstTour.setVehicleInfo(m_vVehicleInfos[secondTour.getVehicleId()]);
+                secondTour.setVehicleInfo(tempVehicle);
 
-void CVRPSolver::attempVehicleExchange(CSolutionInfo& solutionInfo)
-{
-	++m_iGeneratedSolutionCount;
-	++m_iStepsSinceLastSolution;
-	CMoveInfo curMove; 
-	CMoveInfo bestMove;
-
-	int bestFreeCapacity = 0;
-	std::pair<int,int> bestSwapIndex;
-	int totalTour = static_cast<int>(solutionInfo.getTourCount());
-
-	for (int i = 0;i<totalTour;++i)
-	{
-		CTourInfo firstTour = solutionInfo.getTour(i);
-		int firstTourLoad = firstTour.getVehicleInfo().getCurrentLoad();
-		int firstVehicleCapacity = firstTour.getVehicleInfo().getCapacity();
-
-		for (int j = i+1;j<totalTour;++j)
-		{
-			CTourInfo secondTour = solutionInfo.getTour(j);
-			curMove.setInitialTour(firstTour,secondTour);
-
-			int FirstTourRemainingCapacity = firstVehicleCapacity - secondTour.getVehicleInfo().getCurrentLoad();
-
-			int SecondTourRemainingCapacity = secondTour.getVehicleInfo().getCapacity() - firstTourLoad;
-
-			// int prevFreeCapacity = max( secondTour.getRemainingCapacity(), firstTour.getRemainingCapacity() );
-
-			int curFreeCapacity = max(FirstTourRemainingCapacity,SecondTourRemainingCapacity);
-
-			if ( (FirstTourRemainingCapacity > 0) && (SecondTourRemainingCapacity > 0) && 
-				// curFreeCapacity > curFreeCapacity  autological compare evaluates to false (error on MAC)
-                              (curFreeCapacity > bestFreeCapacity) )
-			{
-
-				CVehicleInfo tempVehicle = m_vVehicleInfos[firstTour.getVehicleId()];
-				firstTour.setVehicleInfo(m_vVehicleInfos[secondTour.getVehicleId()] );
-				secondTour.setVehicleInfo( tempVehicle );
-
-				curMove.setModifiedTour(firstTour, secondTour);
-
-				if (!isTabuMove(curMove))
-				{
-					bestMove = curMove;
-					bestFreeCapacity = curFreeCapacity;
-					bestSwapIndex = std::make_pair(i,j);
-				}
-
-				curMove.getInitialTour(firstTour,secondTour);
-			}
-		}
-	}
-	if (bestFreeCapacity > 0)
-	{
-		CTourInfo tempTour;
-		bestMove.getModifiedTourAt(0, tempTour);
-		solutionInfo.replaceTourAt(bestSwapIndex.first, tempTour);
-		bestMove.getModifiedTourAt(1, tempTour);
-		solutionInfo.replaceTourAt(bestSwapIndex.second, tempTour);
-		updateTabuCount(bestMove);
-		updateFinalSolution(solutionInfo);
-	}
-	
-}
-/*
-void CVRPSolver::attemptFeasibleNodeExchange(CSolutionInfo& solutionInfo)
-{
-	++m_iGeneratedSolutionCount;
-	++m_iStepsSinceLastSolution;
-	CMoveInfo bestMove, curMove;
-
-	int totalTour = solutionInfo.getTourCount();
-	
-	for (int i = 0;i<totalTour;++i)
-	{
-		CTourInfo curTour = solutionInfo.getTour(i);
-		std::vector<int> vecOrderId = curTour.getOrderVector();
-		curMove.setInitialTour(curTour);
-		int totalCustomer = curTour.getServedOrderCount();
-		std::pair<int,int> bestSwapIndex;
-		double lowestCost = DOUBLE_MAX;
-
-		for (int j = 0;j<totalCustomer;++j)
-		{
-			for (int k = j+1;k<totalCustomer;++k)
-			{
-				COrderInfo firstCustomer = m_vOrderInfos[m_mapOrderIdToIndex[vecOrderId[j]]];
-				COrderInfo secondCustomer = m_vOrderInfos[m_mapOrderIdToIndex[vecOrderId[k]]];
-
-				if ( curTour->isFeasibleReplace(j,pSecondCustomer) && pCurTour->isFeasibleReplace(k,pFirstCustomer) )
-				{
-					pCurTour->removeCustomer(j,false);
-					pCurTour->addCustomer(pSecondCustomer,j);
-
-					pCurTour->removeCustomer(k,false);
-					pCurTour->addCustomer(pFirstCustomer,k);
-
-					pCurMove->setModifiedTour(pCurTour);
-					if (isTabuMove(pCurMove))
-					{
-						pCurMove->getInitialTour(pCurTour);
-						continue;
-					}
-
-					double curTourCost = pCurTour->getTourData()->calcCost(pCurTour->getAssignedVehicle());
-					if ( curTourCost < lowestCost )
-					{
-						*pBestMove = *pCurMove;
-						lowestCost = curTourCost;
-						bestSwapIndex = std::make_pair(j,k);
-					}
-					pCurMove->getInitialTour(pCurTour);
-				}
-			}
-		}
-
-		if (lowestCost!=DOUBLE_MAX)
-		{
-			m_pCurrentSolution->replaceTourAt(i,pBestMove->getModifiedTourAt(0));
-			this->updateTabuCount(pBestMove);
-			this->evaluateCurrentSolution();
-		}
-	}
-	delete pCurMove;
-	delete pBestMove;
+                curMove.setModifiedTour(firstTour, secondTour);
+
+                if (!isTabuMove(curMove)) {
+                    bestMove = curMove;
+                    bestFreeCapacity = curFreeCapacity;
+                    bestSwapIndex = std::make_pair(i, j);
+                }
+
+                curMove.getInitialTour(firstTour, secondTour);
+            }
+        }
+    }
+    if (bestFreeCapacity > 0) {
+        CTourInfo tempTour;
+        bestMove.getModifiedTourAt(0, tempTour);
+        solutionInfo.replaceTourAt(bestSwapIndex.first, tempTour);
+        bestMove.getModifiedTourAt(1, tempTour);
+        solutionInfo.replaceTourAt(bestSwapIndex.second, tempTour);
+        updateTabuCount(bestMove);
+        updateFinalSolution(solutionInfo);
+    }
+}
+#if 0
+void CVRPSolver::attemptFeasibleNodeExchange(CSolutionInfo& solutionInfo) {
+    ++m_iGeneratedSolutionCount;
+    ++m_iStepsSinceLastSolution;
+    CMoveInfo bestMove, curMove;
+
+    int totalTour = solutionInfo.getTourCount();
+
+    for (int i = 0; i < totalTour; ++i) {
+        CTourInfo curTour = solutionInfo.getTour(i);
+        std::vector<int> vecOrderId = curTour.getOrderVector();
+        curMove.setInitialTour(curTour);
+        int totalCustomer = curTour.getServedOrderCount();
+        std::pair<int, int> bestSwapIndex;
+        double lowestCost = DOUBLE_MAX;
+
+        for (int j = 0; j < totalCustomer; ++j) {
+            for (int k = j + 1; k < totalCustomer; ++k) {
+                COrderInfo firstCustomer = m_vOrderInfos[m_mapOrderIdToIndex[vecOrderId[j]]];
+                COrderInfo secondCustomer = m_vOrderInfos[m_mapOrderIdToIndex[vecOrderId[k]]];
+
+                if (curTour->isFeasibleReplace(j, pSecondCustomer) &&  pCurTour->isFeasibleReplace(k, pFirstCustomer)) {
+                    pCurTour->removeCustomer(j, false);
+                    pCurTour->addCustomer(pSecondCustomer, j);
+
+                    pCurTour->removeCustomer(k, false);
+                    pCurTour->addCustomer(pFirstCustomer, k);
+
+                    pCurMove->setModifiedTour(pCurTour);
+                    if (isTabuMove(pCurMove)) {
+                        pCurMove->getInitialTour(pCurTour);
+                        continue;
+                    }
+
+                    double curTourCost = pCurTour->getTourData()->calcCost(pCurTour->getAssignedVehicle());
+                    if (curTourCost < lowestCost) {
+                        *pBestMove = *pCurMove;
+                        lowestCost = curTourCost;
+                        bestSwapIndex = std::make_pair(j, k);
+                    }
+                    pCurMove->getInitialTour(pCurTour);
+                }
+            }
+        }
+
+        if (lowestCost!= DOUBLE_MAX) {
+            m_pCurrentSolution->replaceTourAt(i, pBestMove->getModifiedTourAt(0));
+            this->updateTabuCount(pBestMove);
+            this->evaluateCurrentSolution();
+        }
+    }
+    delete pCurMove;
+    delete pBestMove;
 }
-*/
-
-void CVRPSolver::updateTabuCount(CMoveInfo& bestMove)
-{
-	m_veMoves.push_back(bestMove);
-	/*
-	bestMove.reverseMove();
-	CMoveInfo curMove;
-
-	std::map< CMoveInfo,int >::iterator mpIt = m_mapMoveFrequency.find(bestMove);
-
-	if (mpIt == m_mapMoveFrequency.end())
-	{
-		curMove = bestMove;
-	}
-	else curMove = (*mpIt).first;
-
-	m_mapMoveFrequency[curMove]++;
-
-	if( m_mapMoveFrequency[curMove] >= MAXIMUM_MOVE_FREQUENCY )
-	{
-		CMoveInfo tmpMove;
-		std::set<CMoveInfo>::iterator sIt = m_sTabuList.find(curMove);
-
-		CMoveInfo tmpMove2;
-		if ( sIt == m_sTabuList.end() )
-		{
-			tmpMove2 = curMove;
-		}
-		else tmpMove2 = (*sIt);
-		m_sTabuList.insert(tmpMove2);
-	}
-	m_mapTabuCount[curMove] = std::make_pair(m_iGeneratedSolutionCount,m_iStepsSinceLastSolution);
-	bestMove.reverseMove();
-	*/
+#endif
+
+void CVRPSolver::updateTabuCount(CMoveInfo& bestMove) {
+    m_veMoves.push_back(bestMove);
+#if 0
+    bestMove.reverseMove();
+    CMoveInfo curMove;
+
+    std::map< CMoveInfo, int >::iterator mpIt = m_mapMoveFrequency.find(bestMove);
+
+    if (mpIt == m_mapMoveFrequency.end()) {
+        curMove = bestMove;
+    } else {
+        curMove = (*mpIt).first;
+    }
+
+    m_mapMoveFrequency[curMove]++;
+
+    if (m_mapMoveFrequency[curMove] >= MAXIMUM_MOVE_FREQUENCY) {
+        CMoveInfo tmpMove;
+        std::set<CMoveInfo>::iterator sIt = m_sTabuList.find(curMove);
+
+        CMoveInfo tmpMove2;
+        if (sIt == m_sTabuList.end()) {
+            tmpMove2 = curMove;
+        } else {
+            tmpMove2 = (*sIt);
+        }
+        m_sTabuList.insert(tmpMove2);
+    }
+    m_mapTabuCount[curMove] = std::make_pair(m_iGeneratedSolutionCount, m_iStepsSinceLastSolution);
+    bestMove.reverseMove();
+    */
+#endif
 }
 
-bool CVRPSolver::isTabuMove(CMoveInfo& curMove)
-{
-	size_t i, tot = m_veMoves.size();
-	for(i = 0; i < tot; i++)
-	{
-		if(curMove == m_veMoves[i])
-			return true;
-	}
-	return false;
+bool CVRPSolver::isTabuMove(CMoveInfo& curMove) {
+    size_t i, tot = m_veMoves.size();
+    for (i = 0; i < tot; i++) {
+        if (curMove == m_veMoves[i])
+            return true;
+    }
+    return false;
 }
 
 
diff --git a/src/vrp_basic/src/VRP_Solver.h b/src/vrp_basic/src/VRP_Solver.h
index 8fa3d8a..2aa487e 100644
--- a/src/vrp_basic/src/VRP_Solver.h
+++ b/src/vrp_basic/src/VRP_Solver.h
@@ -21,15 +21,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef VRPSOLVER_H
-#define VRPSOLVER_H
+#ifndef SRC_VRP_BASIC_SRC_VRP_SOLVER_H_
+#define SRC_VRP_BASIC_SRC_VRP_SOLVER_H_
 
+#pragma once
+
+#include <cstdlib>
 #include <vector>
 #include <map>
 #include <utility>
 #include <string>
 #include <math.h>
-#include <stdlib.h>
 
 #define MAXIMUM_TRY 15
 #define TOTAL_NUMBER_OF_SEARCH 15
@@ -39,385 +41,374 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 typedef std::pair<int, int> PII;
 
-#define max(a,b) ((a)>(b))?(a):(b)
-
-// Structure for Point, Geo coordinates can be represented with it
-typedef struct
-{
+//  Structure for Point, Geo coordinates can be represented with it
+typedef struct {
   double X, Y;
 }Point;
 
-// Structure to keep cost, distance and traveltime. If distance/ traveltime is missing, there may be a negative flag
-typedef struct
-{
-	double cost, distance, traveltime;
+//  Structure to keep cost, distance and traveltime. If distance/ traveltime is missing, there may be a negative flag
+typedef struct {
+    double cost, distance, traveltime;
 }CostPack;
 
 
-// Class for holding vehicle information which consist of capacity, and cost_per_km
-// For first version we will use homogeneous cost
-class CVehicleInfo
-{
-public:
-	CVehicleInfo();
-	~CVehicleInfo();
+//  Class for holding vehicle information which consist of capacity, and cost_per_km
+//  For first version we will use homogeneous cost
+class CVehicleInfo {
+ public:
+     CVehicleInfo();
+     ~CVehicleInfo();
+
+     bool init();
+
+     bool loadUnit(int lUnit);
+     bool unloadUnit(int lUnit);
+     int getRemainingCapacity() {return (m_iCapacity - m_iCurrentLoad);}
 
-	bool init();
+     int getCurrentLoad() {return m_iCurrentLoad;}
 
-	bool loadUnit(int lUnit);
-	bool unloadUnit(int lUnit);
-	int getRemainingCapacity(){return (m_iCapacity - m_iCurrentLoad);}
+     int getCapacity() {return m_iCapacity;}
+     void setCapacity(int capacity) {m_iCapacity = capacity;}
 
-	int getCurrentLoad(){return m_iCurrentLoad;}
-	
-	int getCapacity(){return m_iCapacity;}
-	void setCapacity(int capacity){m_iCapacity = capacity;}
+     int getId() {return (this->m_iVehicleId);}
+     void setId(int id) {m_iVehicleId = id;}
 
-	int getId(){return (this->m_iVehicleId);}
-	void setId(int id){m_iVehicleId = id;}
+     double getCostPerKM() {return m_dCostPerKM;}
+     void setCostPerKM(double cost) {m_dCostPerKM = cost;}
 
-	double getCostPerKM(){return m_dCostPerKM;}
-	void setCostPerKM(double cost){m_dCostPerKM = cost;}
+     friend bool operator != (const CVehicleInfo& cur, const CVehicleInfo& that);
 
-	friend bool operator != (const CVehicleInfo& cur, const CVehicleInfo& that);
-	
-	
-	//CVehicleInfo( CVehicleInfo const& );
-	//CVehicleInfo& operator = (const CVehicleInfo& vehicleInfo);
 
-private:
-	int m_iCapacity;
-	int m_iCurrentLoad;
-	int m_iVehicleId;
-	double m_dCostPerKM;
-	
+     // CVehicleInfo( CVehicleInfo const& );
+     // CVehicleInfo& operator = (const CVehicleInfo& vehicleInfo);
+
+ private:
+     int m_iCapacity;
+     int m_iCurrentLoad;
+     int m_iVehicleId;
+     double m_dCostPerKM;
 };
 
 
 
-// Class to represent Orders. Each order is consist of open_time, close_time and sevice_time, its location and number of units ordered.
-class COrderInfo
-{
-public:
-	COrderInfo();
-	~COrderInfo();
+//  Class to represent Orders. Each order is consist of open_time, close_time and sevice_time, its location and number of units ordered.
+class COrderInfo {
+ public:
+     COrderInfo();
+     ~COrderInfo();
+
+     int getOpenTime() {return m_iOrderOpenTime;}
+     void setOpenTime(int openTime) {m_iOrderOpenTime = openTime;}
 
-	int getOpenTime(){return m_iOrderOpenTime;}
-	void setOpenTime(int openTime){m_iOrderOpenTime = openTime;}
+     int getCloseTime() {return m_iOrderCloseTime;}
+     void setCloseTime(int closeTime) {m_iOrderCloseTime = closeTime;}
 
-	int getCloseTime(){return m_iOrderCloseTime;}
-	void setCloseTime(int closeTime){m_iOrderCloseTime = closeTime;}
+     int getServiceTime() {return m_iOrderServiceTime;}
+     void setServiceTime(int serviceTime) {m_iOrderServiceTime = serviceTime;}
 
-	int getServiceTime(){return m_iOrderServiceTime;}
-	void setServiceTime(int serviceTime){m_iOrderServiceTime = serviceTime;}
+     int getOrderUnit() {return m_iOrderUnitCount;}
+     void setOrderUnit(int orderUnit) {m_iOrderUnitCount = orderUnit;}
 
-	int getOrderUnit(){return m_iOrderUnitCount;}
-	void setOrderUnit(int orderUnit){m_iOrderUnitCount = orderUnit;}
+     Point getOrderLocation() {return m_ptOrderLocation;}
+     void setOrderLocation(Point location) {m_ptOrderLocation = location;}
 
-	Point getOrderLocation(){return m_ptOrderLocation;}
-	void setOrderLocation(Point location){m_ptOrderLocation = location;}
+     int getOrderId() {return m_iOrderId; }
+     void setOrderId(int orderId) {m_iOrderId = orderId;}
 
-	int getOrderId(){return m_iOrderId;	}
-	void setOrderId(int orderId){m_iOrderId = orderId;}
 
+     // COrderInfo( COrderInfo const& );
+     // COrderInfo& operator = (const COrderInfo& solution);
 
-	//COrderInfo( COrderInfo const& );
-	//COrderInfo& operator = (const COrderInfo& solution);
+ private:
+     int m_iOrderOpenTime;
+     int m_iOrderCloseTime;
+     int m_iOrderServiceTime;
+     int m_iOrderUnitCount;
+     int m_iOrderId;
 
-private:
-	int m_iOrderOpenTime;
-	int m_iOrderCloseTime;
-	int m_iOrderServiceTime;
-	int m_iOrderUnitCount;
-	int m_iOrderId;
-	
-	Point m_ptOrderLocation; 
+     Point m_ptOrderLocation;
 };
 
 
-// Class to represent Depot information. Each depot will have it's Open_Time and Close_Time. The Depot that will open earliest will have open time 0
-// and all other time will be normalized with respect to it. For the first version there will be only one depot
-class CDepotInfo
-{
-public:
-	CDepotInfo();
-	~CDepotInfo();
+//  Class to represent Depot information. Each depot will have it's Open_Time and Close_Time. The Depot that will open earliest will have open time 0
+//  and all other time will be normalized with respect to it. For the first version there will be only one depot
+class CDepotInfo {
+ public:
+     CDepotInfo();
+     ~CDepotInfo();
 
-	int getOpenTime(){return m_iDepotOpenTime;}
-	void setOpenTime(int openTime){m_iDepotOpenTime = openTime;}
+     int getOpenTime() {return m_iDepotOpenTime;}
+     void setOpenTime(int openTime) {m_iDepotOpenTime = openTime;}
 
-	int getCloseTime(){return m_iDepotCloseTime;}
-	void setCloseTime(int closeTime){m_iDepotCloseTime = closeTime;}
+     int getCloseTime() {return m_iDepotCloseTime;}
+     void setCloseTime(int closeTime) {m_iDepotCloseTime = closeTime;}
 
-	int getDepotId(){return m_iDepotId;}
-	void setDepotId(int id){m_iDepotId = id;}
+     int getDepotId() {return m_iDepotId;}
+     void setDepotId(int id) {m_iDepotId = id;}
 
-	Point getDepotLocation(){return m_ptDepotLocation;}
-	void setDepotLocation(Point location){m_ptDepotLocation = location;}
-	
-	//CDepotInfo( CDepotInfo const& );
-	//CDepotInfo& operator = (const CDepotInfo& solution);
+     Point getDepotLocation() {return m_ptDepotLocation;}
+     void setDepotLocation(Point location) {m_ptDepotLocation = location;}
 
-private:
-	int m_iDepotOpenTime;
-	int m_iDepotCloseTime;
-	
-	int m_iDepotId;
+     // CDepotInfo( CDepotInfo const& );
+     // CDepotInfo& operator = (const CDepotInfo& solution);
 
-	Point m_ptDepotLocation;
-};
+ private:
+     int m_iDepotOpenTime;
+     int m_iDepotCloseTime;
+
+     int m_iDepotId;
 
-// Class to represent information of a Tour. A Tour starts from a depot and ends in a depot. On the way it serves several orders. 
-// Each Tour has a vehicle ID and the list of Orders it serves in appropriate order. It also has the total Distance, Cost and Time assciated.
-class CTourInfo
-{
-public:
-	CTourInfo();
-	~CTourInfo();
-	
-	void init();
-
-	int getRemainingCapacity();
-	
-	int getVehicleId(){return m_vehicleInfo.getId();}
-
-	CVehicleInfo& getVehicleInfo(){return m_vehicleInfo;}
-	void setVehicleInfo(CVehicleInfo vehicleInfo){m_vehicleInfo = vehicleInfo;}
-	
-	int getStartDepot(){return m_iStartDepotId;}
-	void setStartDepot(int depotId){m_iStartDepotId = depotId;}
-	
-	int getEndDepot(){return m_iEndDepotId;}
-	void setEndDepot(int depotId){m_iEndDepotId = depotId;}
-
-	size_t getServedOrderCount(){return m_viOrderIds.size();}
-
-	void updateCost(double cost, double distance, double travelTime);
-
-	void setStartTime(std::vector<int> vStartTime){m_viStartTime = vStartTime;}
-
-
-	bool insertOrder(int orderId, int pos);
-	bool removeOrder(int pos);
-	
-
-	double getDistance(){return m_dTotalDistance;}
-
-	double getCost(){return m_dTotalCost;}
-
-	double getTravelTime(){return m_dTotalTraveltime;}
-	
-	std::vector<int> getOrderVector(){return m_viOrderIds;}
-
-	int getStartTime(int pos){if( (unsigned int) pos >= m_viStartTime.size()) return 0; 
-								else return m_viStartTime[pos];}
-
-	friend bool operator== (const CTourInfo& cur, const CTourInfo& that);
-	
-
-	//bool operator != (const CTourInfo& that)
-	//{
-	//	return(!(*this == that));
-	//}
-	
-	//CTourInfo( CTourInfo const& );
-	//CTourInfo& operator = (const CTourInfo& solution);
-	
-
-private:
-	CVehicleInfo m_vehicleInfo;
-	int m_iStartDepotId;
-	int m_iEndDepotId;
-	int m_iOrdersServed;
-	std::vector<int> m_viOrderIds;
-	std::vector<int> m_viStartTime;
-	double m_dTotalCost;
-	double m_dTotalDistance;
-	double m_dTotalTraveltime;
+     Point m_ptDepotLocation;
 };
 
+//  Class to represent information of a Tour. A Tour starts from a depot and ends in a depot. On the way it serves several orders.
+//  Each Tour has a vehicle ID and the list of Orders it serves in appropriate order. It also has the total Distance, Cost and Time assciated.
+class CTourInfo {
+ public:
+     CTourInfo();
+     ~CTourInfo();
+
+     void init();
+
+     int getRemainingCapacity();
+
+     int getVehicleId() {return m_vehicleInfo.getId();}
+
+     CVehicleInfo& getVehicleInfo() {return m_vehicleInfo;}
+     void setVehicleInfo(CVehicleInfo vehicleInfo) {m_vehicleInfo = vehicleInfo;}
+
+     int getStartDepot() {return m_iStartDepotId;}
+     void setStartDepot(int depotId) {m_iStartDepotId = depotId;}
+
+     int getEndDepot() {return m_iEndDepotId;}
+     void setEndDepot(int depotId) {m_iEndDepotId = depotId;}
+
+     size_t getServedOrderCount() {return m_viOrderIds.size();}
+
+     void updateCost(double cost, double distance, double travelTime);
 
+     void setStartTime(std::vector<int> vStartTime) {m_viStartTime = vStartTime;}
 
-// This class will represent a solution of a VRP problem. A solution will be consist of multiple tour. 
-// It also contains the number of vehicle used, number of orders served and total cost, distance and traveltime.
-class CSolutionInfo
-{
-public:
-	CSolutionInfo();
-	~CSolutionInfo();
-	
-	int getVehicleUsed(){return m_iVehicleUsed;}
-	int getOrderServed(){return m_iOrdersServed;}
-	//int getVehicleUsed(){return m_iVehicleUsed;}
-	
-	bool addTour(CTourInfo& tour);
-	CTourInfo& getTour(int pos){return m_vtourAll[pos];}
-
-	size_t getTourCount(){return (m_vtourAll.size());}
-
-	size_t getUnservedOrderCount(){return m_vUnservedOrderId.size();}
-	size_t getUnusedVehicleCount(){return m_vUnusedVehicles.size();}
-
-	int getUnusedVehicleAt(int pos){return m_vUnusedVehicles[pos];}
-
-	void removeVehicle(int pos){m_vUnusedVehicles.erase(m_vUnusedVehicles.begin() + pos);}
-	void removeOrder(int pos){m_vUnservedOrderId.erase(m_vUnservedOrderId.begin() + pos);}
-	
-	double getTotalCost(){return m_dTotalCost;}
-	double getTotalDistance(){return m_dTotalDistance;}
-	double getTotalTravelTime(){return m_dTotalTravelTime;}
-	int getUnservedOrderAt(int pos){return m_vUnservedOrderId[pos];}
-	//void addOrderAtTour(int tourIndex, int insertIndex, int orderIndex);
-
-	void replaceTourAt(int index, CTourInfo curTour);
-	void replaceTour(CTourInfo curTour);
-
-	bool init(std::vector<int> vecOrder, int iTotalOrder, std::vector<int> vecVehicle);
-	
-	std::vector<CTourInfo> getTourInfoVector(){return m_vtourAll;}
-	
-	//CTourInfo( CTourInfo const& );
-	//CTourInfo& operator = (const CTourInfo& solution);
-	
-private:
-	std::vector<CTourInfo> m_vtourAll;
-	std::vector<int> m_vUnservedOrderId;
-	std::vector<int> m_vUnusedVehicles;
-	int m_iVehicleUsed;
-	int m_iOrdersServed;
-	int m_iTotalOrders;
-	double m_dTotalCost;
-	double m_dTotalDistance;
-	double m_dTotalTravelTime;
+
+     bool insertOrder(int orderId, int pos);
+     bool removeOrder(int pos);
+
+
+     double getDistance() {return m_dTotalDistance;}
+
+     double getCost() {return m_dTotalCost;}
+
+     double getTravelTime() {return m_dTotalTraveltime;}
+
+     std::vector<int> getOrderVector() {return m_viOrderIds;}
+
+     int getStartTime(int pos) {
+         if ((unsigned int) pos >= m_viStartTime.size())
+             return 0;
+         else
+             return m_viStartTime[pos];
+     }
+
+     friend bool operator == (const CTourInfo& cur, const CTourInfo& that);
+
+
+     // bool operator != (const CTourInfo& that)
+     //  {
+     //  return(!(*this == that));
+     // }
+
+     // CTourInfo( CTourInfo const& );
+     // CTourInfo& operator = (const CTourInfo& solution);
+
+
+ private:
+     CVehicleInfo m_vehicleInfo;
+     int m_iStartDepotId;
+     int m_iEndDepotId;
+     int m_iOrdersServed;
+     std::vector<int> m_viOrderIds;
+     std::vector<int> m_viStartTime;
+     double m_dTotalCost;
+     double m_dTotalDistance;
+     double m_dTotalTraveltime;
 };
 
-class CMoveInfo
-{
-public:
 
-	CMoveInfo();
-	~CMoveInfo();
 
-	bool isBetter( CMoveInfo *pVRPMove );
+//  This class will represent a solution of a VRP problem. A solution will be consist of multiple tour.
+//  It also contains the number of vehicle used, number of orders served and total cost, distance and traveltime.
+class CSolutionInfo {
+ public:
+     CSolutionInfo();
+     ~CSolutionInfo();
+
+     int getVehicleUsed() {return m_iVehicleUsed;}
+     int getOrderServed() {return m_iOrdersServed;}
+     // int getVehicleUsed() {return m_iVehicleUsed;}
+
+     bool addTour(CTourInfo& tour);
+     CTourInfo& getTour(int pos) {return m_vtourAll[pos];}
 
-	void reverseMove();
-	void setInitialTour(CTourInfo pTourData);
-	void setInitialTour(CTourInfo pTourData1, CTourInfo pTourData2);
-	void setModifiedTour(CTourInfo pTourData);
-	void setModifiedTour(CTourInfo pTourData1, CTourInfo pTourData2);
+     size_t getTourCount() {return (m_vtourAll.size());}
 
-	bool getModifiedTourAt(int index, CTourInfo& tourInfo);
-	size_t getModifiedTourCount() const { return m_vModifiedTour.size();}
-	double getModifiedTourCost() const;
-	void getInitialTour(CTourInfo &TourData);
-	void getInitialTour(CTourInfo &TourData1, CTourInfo &TourData2);
+     size_t getUnservedOrderCount() {return m_vUnservedOrderId.size();}
+     size_t getUnusedVehicleCount() {return m_vUnusedVehicles.size();}
 
-	friend bool operator == (const CMoveInfo& cur, const CMoveInfo& that);
-	
+     int getUnusedVehicleAt(int pos) {return m_vUnusedVehicles[pos];}
 
-	//bool operator != (const CMoveInfo& that)
-	//{
-	//	return(!(*this == that));
-	//}
+     void removeVehicle(int pos) {m_vUnusedVehicles.erase(m_vUnusedVehicles.begin() + pos);}
+     void removeOrder(int pos) {m_vUnservedOrderId.erase(m_vUnservedOrderId.begin() + pos);}
 
-	//CMoveInfo( CMoveInfo const& );
-	//CMoveInfo& operator = (const CMoveInfo& solution);
+     double getTotalCost() {return m_dTotalCost;}
+     double getTotalDistance() {return m_dTotalDistance;}
+     double getTotalTravelTime() {return m_dTotalTravelTime;}
+     int getUnservedOrderAt(int pos) {return m_vUnservedOrderId[pos];}
+     // void addOrderAtTour(int tourIndex, int insertIndex, int orderIndex);
 
-private:
+     void replaceTourAt(int index, CTourInfo curTour);
+     void replaceTour(CTourInfo curTour);
 
-	void clearInitialTour();
-	void clearModifiedTour();
+     bool init(std::vector<int> vecOrder, int iTotalOrder, std::vector<int> vecVehicle);
 
-	std::vector<CTourInfo> m_vInitialTour;
-	std::vector<CTourInfo> m_vModifiedTour;
+     std::vector<CTourInfo> getTourInfoVector() {return m_vtourAll;}
+
+     // CTourInfo( CTourInfo const& );
+     // CTourInfo& operator = (const CTourInfo& solution);
+
+ private:
+     std::vector<CTourInfo> m_vtourAll;
+     std::vector<int> m_vUnservedOrderId;
+     std::vector<int> m_vUnusedVehicles;
+     int m_iVehicleUsed;
+     int m_iOrdersServed;
+     int m_iTotalOrders;
+     double m_dTotalCost;
+     double m_dTotalDistance;
+     double m_dTotalTravelTime;
+};
+
+class CMoveInfo {
+ public:
+     CMoveInfo();
+     ~CMoveInfo();
+
+     bool isBetter(CMoveInfo *pVRPMove);
+
+     void reverseMove();
+     void setInitialTour(CTourInfo pTourData);
+     void setInitialTour(CTourInfo pTourData1, CTourInfo pTourData2);
+     void setModifiedTour(CTourInfo pTourData);
+     void setModifiedTour(CTourInfo pTourData1, CTourInfo pTourData2);
+
+     bool getModifiedTourAt(int index, CTourInfo& tourInfo);
+     size_t getModifiedTourCount() const { return m_vModifiedTour.size();}
+     double getModifiedTourCost() const;
+     void getInitialTour(CTourInfo &TourData);
+     void getInitialTour(CTourInfo &TourData1, CTourInfo &TourData2);
+
+     friend bool operator == (const CMoveInfo& cur, const CMoveInfo& that);
+
+
+     // bool operator != (const CMoveInfo& that)
+     //  {
+     //  return(!(*this == that));
+     // }
+
+     // CMoveInfo( CMoveInfo const& );
+     // CMoveInfo& operator = (const CMoveInfo& solution);
+
+ private:
+     void clearInitialTour();
+     void clearModifiedTour();
+
+     std::vector<CTourInfo> m_vInitialTour;
+     std::vector<CTourInfo> m_vModifiedTour;
 };
 
 
 
 
-// This is the main class that will solve the VRP problem. It will use the previous classes to represent the problem and the solution.
-// It will also have pre generated point to point distance/ cost/ traveltime information in maps.
-class CVRPSolver
-{
-public:
-	CVRPSolver();
-	~CVRPSolver();
-	
-	bool init();
-	
-	bool addDepot(CDepotInfo depotInfo);
-	bool addOrder(COrderInfo orderInfo);
-	bool addVehicle(CVehicleInfo vehicleInfo);
-	
-	CostPack getOrderToOrderCost(int firstOrder, int secondOrder);
-	CostPack getDepotToOrderCost(int depotId, int orderId);
-	CostPack getOrderToDepotCost(int depotId, int orderId);
-	
-	bool addOrderToOrderCost(int firstOrder, int secondOrder, CostPack cost);
-	bool addDepotToOrderCost(int depotId, int orderId, CostPack cost);
-	bool addOrderToDepotCost(int depotId, int orderId, CostPack cost);
-
-	void removeVehicle(int vehicleIndex)
-	{m_viUnusedVehicleIndex.erase(m_viUnusedVehicleIndex.begin() + vehicleIndex, m_viUnusedVehicleIndex.begin() + vehicleIndex+1);}
-	
-	void removeOrder(int orderIndex)
-	{m_viUnservedOrderIndex.erase(m_viUnservedOrderIndex.begin() + orderIndex, m_viUnservedOrderIndex.begin() + orderIndex + 1);}
-	
-	bool solveVRP(std::string& strError);
-	
-	bool getSolution(CSolutionInfo& solution, std::string& strError);
-	CSolutionInfo generateInitialSolution();
-	bool updateFinalSolution(CSolutionInfo& solutionInfo);
-	std::pair<int,double> getPotentialInsert(CTourInfo& curTour, COrderInfo& curOrder);
-	CostPack getCostForInsert(CTourInfo& curTour, COrderInfo& curOrder, int pos);
-	bool tabuSearch(CSolutionInfo& solutionInfo);
-	int getServiceTime(int order_id){return (m_vOrderInfos[m_mapOrderIdToIndex[order_id]].getServiceTime());}
-
-	bool insertOrder(CTourInfo& tourInfo, int orderId, int pos);
-	void applyBestMoveInCurrentSolution(CSolutionInfo& solutionInfo, CMoveInfo& bestMove );
-	void insertUnservedOrders(CSolutionInfo& solutionInfo);
-	//void attemptFeasibleNodeExchange(CSolutionInfo& solutionInfo);
-	void attempVehicleExchange(CSolutionInfo& solutionInfo);
-	//CMoveInfo identifyPotentialMove();
-	void updateTabuCount(CMoveInfo& bestMove);
-
-	bool isTabuMove(CMoveInfo& curMove);
-	bool updateTourCosts(CTourInfo& tourInfo);
-	bool addOrderAtTour(CSolutionInfo& solutionInfo, int tourIndex, int insertIndex, int orderIndex);
-	
-
-private:
-	bool m_bIsReadyToSolve;
-	std::vector<CVehicleInfo> m_vVehicleInfos;
-	std::vector<COrderInfo> m_vOrderInfos;
-	std::vector<CDepotInfo> m_vDepotInfos;
-	
-	std::map<int, int> m_mapOrderIdToIndex;
-	std::map<int, int> m_mapVehicleIdToIndex;
-	std::map<int, int> m_mapDepotIdToIndex;
-	
-	std::map<std::pair<int, int>, CostPack> m_mapOrderToOrderCost;
-	std::map<std::pair<int, int>, CostPack> m_mapDepotToOrderrCost;
-	std::map<std::pair<int, int>, CostPack> m_mapOrderToDepotCost;
-
-	/*
-	std::map<CMoveInfo, int> m_mapMoveFrequency;
-	std::map<CMoveInfo, std::pair<int, int> > m_mapTabuCount;
-	std::set<CMoveInfo> m_sTabuList;
-	*/
-
-	std::vector<CMoveInfo> m_veMoves;
-	
-	bool m_bIsSolutionReady;
-	CSolutionInfo m_solutionFinal;
-
-private:
-	std::vector<int> m_viUnservedOrderIndex;
-	std::vector<int> m_viUnusedVehicleIndex;
-	int m_iGeneratedSolutionCount;
-	int m_iStepsSinceLastSolution;
-	bool m_bFoundOptimal;
-		
+//  This is the main class that will solve the VRP problem. It will use the previous classes to represent the problem and the solution.
+//  It will also have pre generated point to point distance/ cost/ traveltime information in maps.
+class CVRPSolver {
+ public:
+     CVRPSolver();
+     ~CVRPSolver();
+
+     bool init();
+
+     bool addDepot(CDepotInfo depotInfo);
+     bool addOrder(COrderInfo orderInfo);
+     bool addVehicle(CVehicleInfo vehicleInfo);
+
+     CostPack getOrderToOrderCost(int firstOrder, int secondOrder);
+     CostPack getDepotToOrderCost(int depotId, int orderId);
+     CostPack getOrderToDepotCost(int depotId, int orderId);
+
+     bool addOrderToOrderCost(int firstOrder, int secondOrder, CostPack cost);
+     bool addDepotToOrderCost(int depotId, int orderId, CostPack cost);
+     bool addOrderToDepotCost(int depotId, int orderId, CostPack cost);
+
+     void removeVehicle(int vehicleIndex)
+     {m_viUnusedVehicleIndex.erase(m_viUnusedVehicleIndex.begin() + vehicleIndex, m_viUnusedVehicleIndex.begin() + vehicleIndex+1);}
+
+     void removeOrder(int orderIndex)
+     {m_viUnservedOrderIndex.erase(m_viUnservedOrderIndex.begin() + orderIndex, m_viUnservedOrderIndex.begin() + orderIndex + 1);}
+
+     bool solveVRP(std::string& strError);
+
+     bool getSolution(CSolutionInfo& solution, std::string& strError);
+     CSolutionInfo generateInitialSolution();
+     bool updateFinalSolution(CSolutionInfo& solutionInfo);
+     std::pair<int, double> getPotentialInsert(CTourInfo& curTour, COrderInfo& curOrder);
+     CostPack getCostForInsert(CTourInfo& curTour, COrderInfo& curOrder, int pos);
+     bool tabuSearch(CSolutionInfo& solutionInfo);
+     int getServiceTime(int order_id) {return (m_vOrderInfos[m_mapOrderIdToIndex[order_id]].getServiceTime());}
+
+     bool insertOrder(CTourInfo& tourInfo, int orderId, int pos);
+     void applyBestMoveInCurrentSolution(CSolutionInfo& solutionInfo, CMoveInfo& bestMove);
+     void insertUnservedOrders(CSolutionInfo& solutionInfo);
+     // void attemptFeasibleNodeExchange(CSolutionInfo& solutionInfo);
+     void attemptVehicleExchange(CSolutionInfo& solutionInfo);
+     // CMoveInfo identifyPotentialMove();
+     void updateTabuCount(CMoveInfo& bestMove);
+
+     bool isTabuMove(CMoveInfo& curMove);
+     bool updateTourCosts(CTourInfo& tourInfo);
+     bool addOrderAtTour(CSolutionInfo& solutionInfo, int tourIndex, int insertIndex, int orderIndex);
+
+
+ private:
+     bool m_bIsReadyToSolve;
+     std::vector<CVehicleInfo> m_vVehicleInfos;
+     std::vector<COrderInfo> m_vOrderInfos;
+     std::vector<CDepotInfo> m_vDepotInfos;
+
+     std::map<int, int> m_mapOrderIdToIndex;
+     std::map<int, int> m_mapVehicleIdToIndex;
+     std::map<int, int> m_mapDepotIdToIndex;
+
+     std::map<std::pair<int, int>, CostPack> m_mapOrderToOrderCost;
+     std::map<std::pair<int, int>, CostPack> m_mapDepotToOrderrCost;
+     std::map<std::pair<int, int>, CostPack> m_mapOrderToDepotCost;
+
+     /*
+        std::map<CMoveInfo, int> m_mapMoveFrequency;
+        std::map<CMoveInfo, std::pair<int, int> > m_mapTabuCount;
+        std::set<CMoveInfo> m_sTabuList;
+        */
+
+     std::vector<CMoveInfo> m_veMoves;
+
+     bool m_bIsSolutionReady;
+     CSolutionInfo m_solutionFinal;
+
+ private:
+     std::vector<int> m_viUnservedOrderIndex;
+     std::vector<int> m_viUnusedVehicleIndex;
+     int m_iGeneratedSolutionCount;
+     int m_iStepsSinceLastSolution;
+     bool m_bFoundOptimal;
 };
 
-#endif
+#endif  // SRC_VRP_BASIC_SRC_VRP_SOLVER_H_
diff --git a/src/vrp_basic/src/VRP_core.cpp b/src/vrp_basic/src/VRP_core.cpp
index aec0c35..397a811 100644
--- a/src/vrp_basic/src/VRP_core.cpp
+++ b/src/vrp_basic/src/VRP_core.cpp
@@ -21,13 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
 #include "VRP.h"
 #include "VRP_Solver.h"
+#include <vector>
+#include <string>
 #include <exception>
 
 #undef PGR_LOGGER_ON
@@ -37,205 +39,187 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 CVRPSolver solver;
 
-void loadOrders(vrp_orders_t *orders, int order_count, int depotId)
-{
-	int i;
-    PGR_LOGF("%s: %d\n", "Depot ID", id)
-	for(i = 0; i < order_count; i++)
-	{
-		int id = orders[i].id;
-        PGR_LOGF("%s: %d\n", "Order ID", id)
-		if (id == depotId)
-		{
-			PGR_LOG("Got depot");
-			// This order represents Deopot
-			CDepotInfo depot;
-			
-			depot.setDepotId(id);
+void loadOrders(vrp_orders_t *orders, int order_count, int depotId) {
+    int i;
+    PGR_LOGF("%s: %d\n", "Depot ID", id);
+    for (i = 0; i < order_count; i++) {
+        int id = orders[i].id;
+        PGR_LOGF("%s: %d\n", "Order ID", id);
+        if (id == depotId) {
+            PGR_LOG("Got depot");
+            // This order represents Deopot
+            CDepotInfo depot;
 
-			Point pt;
+            depot.setDepotId(id);
 
-			pt.X = orders[i].x;
-			pt.Y = orders[i].y;
+            Point pt;
 
-			depot.setDepotLocation(pt);
+            pt.X = orders[i].x;
+            pt.Y = orders[i].y;
 
-			int openTime = orders[i].open_time;
-			depot.setOpenTime(openTime);
+            depot.setDepotLocation(pt);
 
-			int closeTime = orders[i].close_time;
-			depot.setCloseTime(closeTime);
+            int openTime = orders[i].open_time;
+            depot.setOpenTime(openTime);
 
-			solver.addDepot(depot);
-			
-		}
-		else
-		{
-			// This is an order
-			COrderInfo order;
-			
-			order.setOrderId(id);
+            int closeTime = orders[i].close_time;
+            depot.setCloseTime(closeTime);
 
-			Point pt;
+            solver.addDepot(depot);
 
-			pt.X = orders[i].x;
-			pt.Y = orders[i].y;
+        } else {
+            // This is an order
+            COrderInfo order;
 
-			order.setOrderLocation(pt);
+            order.setOrderId(id);
 
-			int demand = orders[i].order_unit;
-			order.setOrderUnit(demand);
+            Point pt;
 
-			int openTime = orders[i].open_time;
-			order.setOpenTime(openTime);
+            pt.X = orders[i].x;
+            pt.Y = orders[i].y;
 
-			int closeTime = orders[i].close_time;
-			order.setCloseTime(closeTime);
+            order.setOrderLocation(pt);
 
-			int serviceTime = orders[i].service_time;
-			order.setServiceTime(serviceTime);
+            int demand = orders[i].order_unit;
+            order.setOrderUnit(demand);
 
-			solver.addOrder(order);
-		}
-	}
-	
+            int openTime = orders[i].open_time;
+            order.setOpenTime(openTime);
+
+            int closeTime = orders[i].close_time;
+            order.setCloseTime(closeTime);
+
+            int serviceTime = orders[i].service_time;
+            order.setServiceTime(serviceTime);
+
+            solver.addOrder(order);
+        }
+    }
 }
 
-void loadVehicles(vrp_vehicles_t *vehicles, int vehicle_count)
-{
-	int i;
-	for(i = 0; i < vehicle_count; i++)
-	{
-		CVehicleInfo vehicle;
+void loadVehicles(vrp_vehicles_t *vehicles, int vehicle_count) {
+    int i;
+    for (i = 0; i < vehicle_count; i++) {
+        CVehicleInfo vehicle;
 
-		int id = vehicles[i].id;
-		vehicle.setId(id);
+        int id = vehicles[i].id;
+        vehicle.setId(id);
 
-		int capcity = vehicles[i].capacity;
-		vehicle.setCapacity(capcity);
+        int capcity = vehicles[i].capacity;
+        vehicle.setCapacity(capcity);
 
-		vehicle.setCostPerKM(1);
+        vehicle.setCostPerKM(1);
 
-		solver.addVehicle(vehicle);
-	}
-	
+        solver.addVehicle(vehicle);
+    }
 }
 
-void loadDistanceMatrix(vrp_cost_element_t *costmatrix, int cost_count, int depotId)
-{
-	int i;
-	for(i = 0; i < cost_count; i++)
-	{
-		int fromId = costmatrix[i].src_id;
-		int toId = costmatrix[i].dest_id;
-		CostPack cpack;
-		cpack.cost = costmatrix[i].cost;
-		cpack.distance = costmatrix[i].distance; 
-		cpack.traveltime = costmatrix[i].traveltime;
-
-		if(fromId == depotId)
-			solver.addDepotToOrderCost(fromId, toId, cpack);
-		else if(toId == depotId)
-			solver.addOrderToDepotCost(fromId, toId, cpack);
-		else
-			solver.addOrderToOrderCost(fromId, toId, cpack);
-	}
-	
+void loadDistanceMatrix(vrp_cost_element_t *costmatrix, int cost_count, int depotId) {
+    int i;
+    for (i = 0; i < cost_count; i++) {
+        int fromId = costmatrix[i].src_id;
+        int toId = costmatrix[i].dest_id;
+        CostPack cpack;
+        cpack.cost = costmatrix[i].cost;
+        cpack.distance = costmatrix[i].distance;
+        cpack.traveltime = costmatrix[i].traveltime;
+
+        if (fromId == depotId)
+            solver.addDepotToOrderCost(fromId, toId, cpack);
+        else if (toId == depotId)
+            solver.addOrderToDepotCost(fromId, toId, cpack);
+        else
+            solver.addOrderToOrderCost(fromId, toId, cpack);
+    }
 }
 
 
 int find_vrp_solution(vrp_vehicles_t *vehicles, size_t vehicle_count,
-					  vrp_orders_t *orders, size_t order_count,
-					  vrp_cost_element_t *costmatrix, size_t cost_count,
-					  int depot_id,
-					  vrp_result_element_t **results, size_t *result_count, char **err_msg)
-{
-	int res;
-	
-	std::string strError;
-	try {
-		PGR_LOG("Before load order");
-		loadOrders(orders, static_cast<int>(order_count), depot_id);
-		PGR_LOG("After load order");
-		loadVehicles(vehicles, static_cast<int>(vehicle_count));
-		PGR_LOG("After load vehicles");
-		loadDistanceMatrix(costmatrix, static_cast<int>(cost_count), depot_id);
-		PGR_LOG("After load distance matrix");
-		res = solver.solveVRP(strError);
-		PGR_LOG("After VRP Solve");
-	
-	}
-	catch(std::exception& e) {
-		*err_msg = (char *) e.what();
-		return -1;
-	}
-	catch(...) {
-		*err_msg = (char *) "Caught unknown exception!";
-		return -1;
-	}
-
-	
-	if (res < 0)
-		return res;
-	else
-	{
-		try {
-		CSolutionInfo solution;
-		CTourInfo ctour;
-		// bool bOK =
+                      vrp_orders_t *orders, size_t order_count,
+                      vrp_cost_element_t *costmatrix, size_t cost_count,
+                      int depot_id,
+                      vrp_result_element_t **results, size_t *result_count, char **err_msg) {
+    int res;
+
+    std::string strError;
+    try {
+        PGR_LOG("Before load order");
+        loadOrders(orders, static_cast<int>(order_count), depot_id);
+        PGR_LOG("After load order");
+        loadVehicles(vehicles, static_cast<int>(vehicle_count));
+        PGR_LOG("After load vehicles");
+        loadDistanceMatrix(costmatrix, static_cast<int>(cost_count), depot_id);
+        PGR_LOG("After load distance matrix");
+        res = solver.solveVRP(strError);
+        PGR_LOG("After VRP Solve");
+    }
+    catch(std::exception& e) {
+        *err_msg = (char *) e.what();
+        return -1;
+    }
+    catch(...) {
+        *err_msg = (char *) "Caught unknown exception!";
+        return -1;
+    }
+
+
+    if (res < 0) {
+        return res;
+    } else {
+        try {
+        CSolutionInfo solution;
+        CTourInfo ctour;
+        // bool bOK =
                 solver.getSolution(solution, strError);
-		auto totalRoute = solution.getTourInfoVector().size();
-		size_t totRows = 0;
-		for(size_t i = 0; i < totalRoute; i++)
-		{
-			totRows += (solution.getTour(static_cast<int>(i)).getServedOrderCount() + 2);
-		}
-		*results = (vrp_result_element_t *) malloc(totRows * sizeof(vrp_result_element_t));
-		*result_count = totRows;
-		int cnt = 0;
-		for(size_t i = 0; i < totalRoute; i++)
-		{
-			ctour = solution.getTour(static_cast<int>(i));
-			std::vector<int> vecOrder = ctour.getOrderVector();
-			auto totalOrder = vecOrder.size();
-
-			// For start depot
-			(*results)[cnt].order_id = ctour.getStartDepot();
-			(*results)[cnt].order_pos = 0;
-			(*results)[cnt].vehicle_id = ctour.getVehicleId();
-			(*results)[cnt].arrival_time = -1;
-			(*results)[cnt].depart_time = ctour.getStartTime(0);
-			cnt++;
-			
-			// For each order
-			for(size_t j = 0; j < totalOrder; j++)
-			{
-				(*results)[cnt].order_id = vecOrder[j];
-				(*results)[cnt].order_pos = static_cast<int>(j) + 1;
-				(*results)[cnt].vehicle_id = ctour.getVehicleId();
-				(*results)[cnt].depart_time = ctour.getStartTime(static_cast<int>(j) + 1);
-				(*results)[cnt].arrival_time = ctour.getStartTime(static_cast<int>(j) + 1) - solver.getServiceTime(vecOrder[j]);
-				cnt++;
-			}
-			
-			// For return depot
-			(*results)[cnt].order_id = ctour.getEndDepot();
-			(*results)[cnt].order_pos = static_cast<int>(totalOrder) + 1;
-			(*results)[cnt].vehicle_id = ctour.getVehicleId();
-			(*results)[cnt].arrival_time = ctour.getStartTime(static_cast<int>(totalOrder) + 1);
-			(*results)[cnt].depart_time = -1;
-			cnt++;
-		}
-		}
-		catch(std::exception& e) {
-		*err_msg = (char *) e.what();
-		return -1;
-		}
-		catch(...) {
-		*err_msg = (char *) "Caught unknown exception!";
-		return -1;
-		}
-	}
-	return EXIT_SUCCESS;
+        auto totalRoute = solution.getTourInfoVector().size();
+        size_t totRows = 0;
+        for (size_t i = 0; i < totalRoute; i++) {
+            totRows += (solution.getTour(static_cast<int>(i)).getServedOrderCount() + 2);
+        }
+        *results = (vrp_result_element_t *) malloc(totRows * sizeof(vrp_result_element_t));
+        *result_count = totRows;
+        int cnt = 0;
+        for (size_t i = 0; i < totalRoute; i++) {
+            ctour = solution.getTour(static_cast<int>(i));
+            std::vector<int> vecOrder = ctour.getOrderVector();
+            auto totalOrder = vecOrder.size();
+
+            // For start depot
+            (*results)[cnt].order_id = ctour.getStartDepot();
+            (*results)[cnt].order_pos = 0;
+            (*results)[cnt].vehicle_id = ctour.getVehicleId();
+            (*results)[cnt].arrival_time = -1;
+            (*results)[cnt].depart_time = ctour.getStartTime(0);
+            cnt++;
+
+            // For each order
+            for (size_t j = 0; j < totalOrder; j++) {
+                (*results)[cnt].order_id = vecOrder[j];
+                (*results)[cnt].order_pos = static_cast<int>(j) + 1;
+                (*results)[cnt].vehicle_id = ctour.getVehicleId();
+                (*results)[cnt].depart_time = ctour.getStartTime(static_cast<int>(j) + 1);
+                (*results)[cnt].arrival_time = ctour.getStartTime(static_cast<int>(j) + 1) - solver.getServiceTime(vecOrder[j]);
+                cnt++;
+            }
+
+            // For return depot
+            (*results)[cnt].order_id = ctour.getEndDepot();
+            (*results)[cnt].order_pos = static_cast<int>(totalOrder) + 1;
+            (*results)[cnt].vehicle_id = ctour.getVehicleId();
+            (*results)[cnt].arrival_time = ctour.getStartTime(static_cast<int>(totalOrder) + 1);
+            (*results)[cnt].depart_time = -1;
+            cnt++;
+        }
+        }
+        catch(std::exception& e) {
+        *err_msg = (char *) e.what();
+        return -1;
+        }
+        catch(...) {
+        *err_msg = (char *) "Caught unknown exception!";
+        return -1;
+        }
+    }
+    return EXIT_SUCCESS;
 }
 
diff --git a/src/vrp_basic/src/Vehicles.txt b/src/vrp_basic/src/Vehicles.txt
deleted file mode 100644
index 04aa1c2..0000000
--- a/src/vrp_basic/src/Vehicles.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-V_d	Capacity
-1	200
-2	200
-3	200
-4	200
-5	200
-6	200
-7	200
-8	200
-9	200
-10	200
-11	200
-12	200
-13	200
-14	200
-15	200
-16	200
-17	200
-18	200
-19	200
-20	200
diff --git a/src/vrppdtw/CMakeLists.txt b/src/vrppdtw/CMakeLists.txt
deleted file mode 100644
index 302fdcd..0000000
--- a/src/vrppdtw/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(PACKAGE_SQL_FILES "")
-ADD_SUBDIRECTORY(sql)
-SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-SUBDIRS(doc src test)
-
diff --git a/src/vrppdtw/doc/CMakeLists.txt b/src/vrppdtw/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/vrppdtw/doc/doc-gsoc_vrppdtw.queries b/src/vrppdtw/doc/doc-gsoc_vrppdtw.queries
new file mode 100644
index 0000000..db1864d
--- /dev/null
+++ b/src/vrppdtw/doc/doc-gsoc_vrppdtw.queries
@@ -0,0 +1,76 @@
+--q1
+SELECT DISTINCT(id1) FROM pgr_gsoc_vrppdtw(
+    'SELECT * FROM customer ORDER BY id', 25, 200)
+ORDER BY id1;
+ id1 
+-----
+   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+(9 rows)
+
+--q2
+SELECT count(*) FROM pgr_gsoc_vrppdtw(
+    'SELECT * FROM customer ORDER BY id', 25, 200);
+ count 
+-------
+   114
+(1 row)
+
+--q3
+SELECT * FROM pgr_gsoc_vrppdtw(
+    'SELECT * FROM customer ORDER BY id', 25, 200)
+    WHERE id1 in (1, 5, 9);
+ seq | id1 | id2 |       cost       
+-----+-----+-----+------------------
+   1 |   1 |   0 |                0
+   2 |   1 |   5 | 105.132745950422
+   3 |   1 |   3 | 196.132745950422
+   4 |   1 |   7 | 288.132745950422
+   5 |   1 |   8 | 380.961173075168
+   6 |   1 |  10 | 474.566724350632
+   7 |   1 |  11 | 567.566724350632
+   8 |   1 |   9 |   660.7290020108
+   9 |   1 |   6 |   752.9650699883
+  10 |   1 |   4 |   845.2011379658
+  11 |   1 |   2 | 938.806689241264
+  12 |   1 |   1 | 1030.80668924126
+  13 |   1 |  75 | 1123.80668924126
+  14 |   1 |   0 | 1139.61807754211
+  51 |   5 |   0 |                0
+  52 |   5 |  43 | 106.552945357247
+  53 |   5 |  42 | 199.552945357247
+  54 |   5 |  41 | 291.552945357247
+  55 |   5 |  40 | 383.552945357247
+  56 |   5 |  44 | 476.552945357247
+  57 |   5 |  46 | 569.381372481993
+  58 |   5 |  45 | 661.381372481993
+  59 |   5 |  48 | 753.381372481993
+  60 |   5 |  51 | 756.381372481993
+  61 |   5 | 101 | 846.381372481993
+  62 |   5 |  50 | 938.617440459493
+  63 |   5 |  52 | 1031.77971811966
+  64 |   5 |  49 | 1124.77971811966
+  65 |   5 |  47 | 1216.77971811966
+  66 |   5 |   0 | 1234.80747449698
+ 103 |   9 |   0 |                0
+ 104 |   9 |  90 | 110.615528128088
+ 105 |   9 |  87 | 205.615528128088
+ 106 |   9 |  86 | 296.615528128088
+ 107 |   9 |  83 | 392.615528128088
+ 108 |   9 |  82 | 485.615528128088
+ 109 |   9 |  84 | 581.446480022934
+ 110 |   9 |  85 |  674.27490714768
+ 111 |   9 |  88 |  767.27490714768
+ 112 |   9 |  89 | 860.103334272426
+ 113 |   9 |  91 |  953.70888554789
+ 114 |   9 |   0 | 976.069565322888
+(42 rows)
+
+--q4
diff --git a/src/vrppdtw/doc/index.rst b/src/vrppdtw/doc/index.rst
deleted file mode 100755
index 1ab2a25..0000000
--- a/src/vrppdtw/doc/index.rst
+++ /dev/null
@@ -1,84 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share  
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-.. _pgr_gsocvrppdtw:
-
-pgr_gsoc_vrppdtw
-===============================================================================
-
-.. index:: 
-	single: pgr_gsoc_vrppdtw(text,integer,integer)
-
-Name
--------------------------------------------------------------------------------
-
-``pgr_gsoc_vrppdtw`` — Returns optimized  solution
-
-
-Synopsis
--------------------------------------------------------------------------------
-
-Vehicle Routing Problem with Pickup and Delivery (VRPPD): A number of goods need to be moved from certain pickup locations to other delivery locations. The goal is to find optimal routes for a fleet of vehicles to visit the pickup and drop-off locations.
-
-.. code-block:: sql
-
-	 pgr_gsoc_vrppdtw(text sql, integer , integer;
-
-
-Description
--------------------------------------------------------------------------------
-
-:sql: a SQL query, which should return a set of rows with the following columns:
-
-	.. code-block:: sql
-
-		select * from pgr_gsoc_vrppdtw(
-                                                'select * from customer order by id'::text, 25,200
-                                                                );
-                                                                                                 
-                                                                                                               
-
-Returns set of :ref:`type_cost_result`:
-
-:seq:   row sequence
-:rid:   route ID
-:nid:   node ID (``-1`` for the last row)
-:cost:  cost to traverse to ``seq``
-
-Examples
--------------------------------------------------------------------------------
-
-
-.. code-block:: sql
-
-	
-                SELECT  * from pgr_gsoc_vrppdtw(
-                                                'select * from customer order by id'::text, 25,200
-                                                                );
-                                                                                                 
-                                                                                                 
-
-
-	 seq | rid  | nid  | cost 
-	-----+------+------+------
-	   0 |    7 |    8 |    1
-	   1 |    8 |    9 |    1
-	   2 |    9 |   15 |    1
-	   3 |   12 |   -1 |    0
-           . |   .  |   .  |    .  
-           . |   .  |   .  |    .
- 
-
-
-
-See Also
--------------------------------------------------------------------------------
-
-* :ref:`type_cost_result`
-* http://en.wikipedia.org/wiki/Vehicle_routing_problem
diff --git a/src/vrppdtw/doc/pgr_gsoc_vrppdtw.rst b/src/vrppdtw/doc/pgr_gsoc_vrppdtw.rst
new file mode 100644
index 0000000..2d83daa
--- /dev/null
+++ b/src/vrppdtw/doc/pgr_gsoc_vrppdtw.rst
@@ -0,0 +1,134 @@
+.. 
+   ****************************************************************************
+    pgRouting Manual
+    Copyright(c) pgRouting Contributors
+
+    This documentation is licensed under a Creative Commons Attribution-Share  
+    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
+   ****************************************************************************
+
+.. _pgr_gsocvrppdtw:
+
+pgr_gsoc_vrppdtw - Proposed
+===============================================================================
+
+
+Name
+-------------------------------------------------------------------------------
+
+``pgr_gsoc_vrppdtw`` — Returns a solution for `Pick and Delivery` with `time windows` Vehicle Routing Problem
+
+.. include:: ../../proposed.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
+
+Signature Summary
+-----------------
+
+     
+.. code-block:: none
+
+    pgr_gsoc_vrppdtw(sql, vehicle_num, capacity)
+    RETURNS SET OF pgr_costResult[]:
+
+Signatures
+-----------
+
+.. index:: 
+    single: gsoc_vrppdtw(Complete Signature) - proposed
+
+
+Complete signature
+...................
+
+.. code-block:: none
+
+    pgr_gsoc_vrppdtw(sql, vehicle_num, capacity)
+    Returns set of pgr_costResult[]:
+
+
+.. rubric:: Example: Show the id1
+
+.. literalinclude:: ../doc/doc-gsoc_vrppdtw.queries
+   :start-after: --q1
+   :end-before: --q2
+
+
+Description of the Signatures
+-------------------------------
+
+Description of the sql query
+.........................................................................................
+
+================  ===================   =================================================
+Column            Type                  Description
+================  ===================   =================================================
+**id**            ``ANY-INTEGER``       Identifier of the customer.
+
+                                        - A value of ``0`` identifies the starting location
+
+**x**             ``ANY-NUMERICAL``     ``X`` coordinate of the location.
+**y**             ``ANY-NUMERICAL``     ``Y`` coordinate of the location.
+**demand**        ``ANY-NUMERICAL``     How much is added / removed from the vehicle.
+
+                                        - Negative value is a delivery,
+                                        - Positive value is a pickup,
+
+**openTime**      ``ANY-NUMERICAL``     The time relative to 0, when the customer opens.
+**closeTime**     ``ANY-NUMERICAL``     The time relative to 0, when the customer closes.
+**serviceTime**   ``ANY-NUMERICAL``     The duration of the loading / unloading.
+**pickup_id**     ``ANY-INTEGER``       Value used when the current customer is a Delivery to find the corresponding Pickup
+**deliver_id**    ``ANY-INTEGER``       Value used when the current customer is a Pickup to find the corresponding Delivery
+================  ===================   =================================================
+
+Description of the parameters of the signatures
+.........................................................................................
+
+================== ===========  =================================================
+Column             Type            Description
+================== ===========  =================================================
+**sql**            ``TEXT``     SQL query as described above.
+**vehicle_num**    ``INTEGER``  Maximum number of vehicles in the result. (currently is ignored)
+**capacity**       ``INTEGER``  Capacity of the vehicle.
+================== ===========  =================================================
+
+Description of the result
+.........................................................................................
+
+RETURNS SET OF pgr_costResult[]:
+
+================== =========== =================================================
+Column             Type            Description
+================== =========== =================================================
+**seq**            ``INTEGER`` Sequential value starting from **1**.
+**id1**            ``INTEGER`` Current vehicle identifier.
+**id2**            ``INTEGER`` Customer identifier.
+**cost**           ``FLOAT``   Previous ``cost`` plus `travel time` plus `wait time` plus `service time`.
+                                - when ``id2 = 0`` for the second time for the same ``id1``, then has the total time for the current ``id1``
+================== =========== =================================================
+
+
+
+Examples
+-------------------------------------------------------------------------------
+
+.. rubric:: Example: Total number of rows returned
+
+.. literalinclude:: ../doc/doc-gsoc_vrppdtw.queries
+   :start-after: --q2
+   :end-before: --q3
+
+.. rubric:: Example: Results for only id1 values: 1, 5, and 9
+
+.. literalinclude:: ../doc/doc-gsoc_vrppdtw.queries
+   :start-after: --q3
+   :end-before: --q4
+
+
+See Also
+-------------------------------------------------------------------------------
+
+* The examples use :ref:`pickDeliverData`
+* current implementation is a wrapper of :ref:`pgr_pickDeliver`
+* http://en.wikipedia.org/wiki/Vehicle_routing_problem
diff --git a/src/vrppdtw/sql/CMakeLists.txt b/src/vrppdtw/sql/CMakeLists.txt
index 0ad253c..f0746f5 100644
--- a/src/vrppdtw/sql/CMakeLists.txt
+++ b/src/vrppdtw/sql/CMakeLists.txt
@@ -1,8 +1,7 @@
 # Append in local scope
 LIST(APPEND PACKAGE_SQL_FILES
-    ${CMAKE_CURRENT_SOURCE_DIR}/routing_vrppdtw.sql
+    ${CMAKE_CURRENT_SOURCE_DIR}/gsoc_vrppdtw.sql
 )
 
 # set in parent scope
 SET(PACKAGE_SQL_FILES "${PACKAGE_SQL_FILES}" PARENT_SCOPE)
-
diff --git a/src/vrppdtw/sql/gsoc_vrppdtw.sql b/src/vrppdtw/sql/gsoc_vrppdtw.sql
new file mode 100644
index 0000000..43d12b1
--- /dev/null
+++ b/src/vrppdtw/sql/gsoc_vrppdtw.sql
@@ -0,0 +1,19 @@
+CREATE OR REPLACE FUNCTION pgr_gsoc_vrppdtw(
+    sql text,
+    vehicle_num INTEGER,
+    capacity INTEGER
+)
+RETURNS SETOF pgr_costresult AS
+$BODY$
+DECLARE
+has_reverse BOOLEAN;
+customers_sql TEXT;
+BEGIN
+    RETURN query
+         SELECT a.seq, vehicle_id::INTEGER AS id1, stop_id::INTEGER AS id2, departure_time AS cost
+        FROM _pgr_pickDeliver($1, $2, $3, 1, 30) AS a WHERE vehicle_id != -1;
+END
+$BODY$
+LANGUAGE plpgsql VOLATILE
+COST 100
+ROWS 1000;
diff --git a/src/vrppdtw/sql/routing_vrppdtw.sql b/src/vrppdtw/sql/routing_vrppdtw.sql
deleted file mode 100644
index 8ff857e..0000000
--- a/src/vrppdtw/sql/routing_vrppdtw.sql
+++ /dev/null
@@ -1,41 +0,0 @@
-/*PGR
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
------------------------------------------------------------------------
--- Core function for vrp with sigle depot computation
--- See README for description
------------------------------------------------------------------------
---
---
-create or replace function pgr_gsoc_vrppdtw(
-                sql text,
-                vehicle_num integer,
-                capacity integer,
-                OUT seq integer,
-                OUT rid integer,
-                OUT nid integer,
-                OUT cost integer
-                )
-returns setof record as
-'$libdir/${PGROUTING_LIBRARY_NAME}', 'vrppdtw'
-LANGUAGE c VOLATILE STRICT;
-
-
diff --git a/src/vrppdtw/src/CMakeLists.txt b/src/vrppdtw/src/CMakeLists.txt
deleted file mode 100644
index a67c349..0000000
--- a/src/vrppdtw/src/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-add_library(vrppdtw OBJECT
-    pdp.h
-    pdp.c
-    Route.h
-    Solution.h
-    pdp_solver.cpp )
diff --git a/src/vrppdtw/src/Route.h b/src/vrppdtw/src/Route.h
deleted file mode 100644
index 89b5e82..0000000
--- a/src/vrppdtw/src/Route.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/*PGR
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-
-#ifndef _ROUTE_H
-#define _ROUTE_H
-
-#include <vector>
-#include <map>
-#include <queue>
-#include <string>
-#include <stdlib.h>
-#include <iostream>
-#include <algorithm>
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#include <set>
-
-class Route
-{
-        public:
-                int twv;
-                int cv;
-                int dis;
-                int path[1200];
-                int order[1200];
-                int path_length;
-                Route()
-                {
-                        twv=0;
-                        cv=0;
-                        dis=0;
-                        path_length=0;
-                        for(int i=0;i<1000;i++)
-                        {
-                                path[i]=0;
-                                order[i]=0;
-                        }
-                }
-                State append(customer *c, Pickup p, depot d,int CustomerLength, int PickupLength, State S);
-                void update(customer *c,depot d);
-                double cost();
-                int HillClimbing(customer *c,depot d,Pickup p);
-                int insertOrder(customer *c,depot d,Pickup p);
-                void remove(State S);
-                // void print();
-                int RemoveOrder(Pickup p);
-};
-
-
-
-int  Route::RemoveOrder(Pickup p){
-        int flag=0;
-        // printf("Remove Order with Pid=%d  Did=%d\n",p.Pid,p.Did);
-        for(int i=0;i<path_length;i++)
-        {
-                if(path[i]==p.Pid || path[i]==p.Did)
-                {
-                        flag=1;
-                        path[i]=0;
-                        order[i]=0;
-                }
-        }
-        int new_path[path_length+1],new_length=0,new_order[path_length+1];
-        if(flag==1)
-        {
-                //copy 
-                for(int i=0;i<path_length;i++)
-                {
-                        if(path[i]!=0)
-                        {
-                                 // printf("path[%d]=%d \n",new_length,path[i]);
-                                new_path[new_length]=path[i];
-                                new_order[new_length]=order[i];
-                                new_length++;
-                        }
-                }
-                //Reverse Copy
-                for(int i=0;i<new_length;i++)
-                {
-                        path[i]=new_path[i];
-                        order[i]=new_order[i];
-                }
-                path_length=new_length;
-                return 1;
-        }
-        else
-        {
-                return 0;
-        }
-}
-State  Route::append(customer *c, Pickup p, depot d, int CustomerLength, int PickupLength, State S){
-
-        //Save State;
-        S.twv=twv;
-        S.cv=cv;
-        S.dis=dis;
-        S.path_length=path_length;
-        for(int i=0;i<path_length;i++)
-        {
-                S.path[i]=path[i];
-                S.order[i]=order[i];
-        }
-
-        // Insert Order 
-        path[path_length]=p.Pid;
-        order[path_length]=p.id;
-        path[path_length+1]=p.Did;
-        order[path_length+1]=p.id;
-        path_length+=2;
-
-        return S;
-}
-void Route::update(customer *c, depot d)
-{
-        dis=0,twv=0,cv=0;
-        int load=0;
-        for(int i=-1;i<path_length;i++)
-        {
-                //depot to first customer
-                if(i==-1)
-                {
-                        dis+=sqrt(((d.x-c[path[i+1]].x)*(d.x-c[path[i+1]].x))+((d.y-c[path[i+1]].y)*(d.y-c[path[i+1]].y)));
-                        if(dis<c[path[i+1]].Etime)
-                        {
-                                dis=c[path[i+1]].Etime;
-                        }
-                        else if(dis>c[path[i+1]].Ltime)
-                        {
-                                twv+=1;
-                        }
-                        dis+=c[path[i+1]].Stime;
-                        load+=c[path[i+1]].demand;
-                }
-                //Last cusotmer to depot 
-                if(i==path_length-1)
-                {
-                        dis+=sqrt(((d.x-c[path[i]].x)*(d.x-c[path[i]].x))+((d.y-c[path[i]].y)*(d.y-c[path[i]].y)));
-                        if(dis>d.Ltime)
-                        {
-                                twv+=1;
-                        }
-                }
-                //Middle customers
-                if(i>=0 && i< path_length-1)
-                {
-                        dis+=sqrt(((c[path[i]].x-c[path[i+1]].x)*(c[path[i]].x-c[path[i+1]].x))+((c[path[i]].y-c[path[i+1]].y)*(c[path[i]].y-c[path[i+1]].y)));
-                        if(dis<c[path[i+1]].Etime)
-                        {
-                                dis=c[path[i+1]].Etime;
-                        }
-                        else if(dis>c[path[i+1]].Ltime)
-                        {
-                                twv+=1;
-                        }
-                        dis+=c[path[i+1]].Stime;
-                        load+=c[path[i+1]].demand;
-                }
-
-                if(load>200 || load<0)
-                {
-                        cv+=1;
-                }
-        }
-        return;
-}
-double Route::cost()
-{
-        return (0.3*dis)+(0.5*twv)+(0.2*cv);
-}
-int Route::insertOrder(customer *c, depot d, Pickup p)
-{
-        // double cost1=0,cost2=0;
-        twv=0,cv=0,dis=0;
-        int swap=0;
-        update(c,d);
-        if(twv==0 && cv==0 && dis<d.Ltime)        
-                return 0;
-
-        for(int i=0;i<path_length;i++)
-        {
-                for(int j=0;j<path_length;j++)
-                {
-                        if((c[path[i]].Ltime > c[path[j]].Ltime) ){
-                                //Swap Path
-                                swap=path[i];
-                                path[i]=path[j];
-                                path[j]=swap;
-                                //Swap order
-                                swap=order[i];
-                                order[i]=order[j];
-                                order[j]=swap;
-
-                        }
-                }
-        }
-        //After complete sort
-        int *temp=NULL;
-            int *tempo=NULL;
-            temp= (int *)malloc(1000*sizeof(int));
-            tempo= (int *)malloc(1000*sizeof(int));
-        for(int i=0;i<path_length;i++)
-        {
-                temp[i]=path[path_length-i-1];
-                tempo[i]=order[path_length-i-1];
-        }
-        for(int i=0;i<path_length;i++)
-        {
-                path[i]=temp[i];
-                order[i]=tempo[i];
-        }
-
-        twv=0,cv=0,dis=0;
-        update(c,d);        
-         // print(); 
-        if(twv>0 || cv>0 || dis> d.Ltime)
-        { 
-                return 1;
-        }
-        return 0;
-}
-
-int Route::HillClimbing(customer *c, depot d, Pickup p)
-{
-        double cost1=0,cost2=0;
-        twv=0,cv=0,dis=0;
-        int swap=0;
-        update(c,d);
-        cost1=cost();
-        if(twv==0 && cv==0 && dis<d.Ltime)        
-                return 0;
-
-        for(int i=0;i<path_length;i++){
-                for(int j=0;j<path_length;j++){
-                        int swap_flag=0,count_flag=0;
-                        if((c[path[i]].Ltime > c[path[j]].Ltime) &&  (count_flag==0) ){
-                                swap_flag=1;
-                                count_flag=1;
-                                //Swap Path
-                                swap=path[i];
-                                path[i]=path[j];
-                                path[j]=swap;
-                                //Swap order
-                                swap=order[i];
-                                order[i]=order[j];
-                                order[j]=swap;
-
-                        }
-                        update(c,d);
-                        cost2=cost();
-                        if(cost2>cost1){
-                                if(swap_flag==1){
-                                        //Swap Path
-                                        swap=path[i];
-                                        path[i]=path[j];
-                                        path[j]=swap;
-                                        //Swap order
-                                        swap=order[i];
-                                        order[i]=order[j];
-                                        order[j]=swap;
-                                        //     update(c,d);
-                                }
-                        }
-                }
-        }
-        //After complete sort
-        int *temp=NULL;
-            int *tempo=NULL;
-            temp= (int *)malloc(1000*sizeof(int));
-            tempo= (int *)malloc(1000*sizeof(int));
-        for(int i=0;i<path_length;i++)
-        {
-                temp[i]=path[path_length-i-1];
-                tempo[i]=order[path_length-i-1];
-        }
-        for(int i=0;i<path_length;i++)
-        {
-                path[i]=temp[i];
-                order[i]=tempo[i];
-        }
-
-
-        update(c,d);
-        if(twv>0 || cv>0 || dis> d.Ltime)
-        { 
-                return 1;
-        }
-        return 0;
-}
-
-
-#if 0
-void Route::print(){
-        printf("%d ",dis);
-        printf("%d ",twv);
-        printf("%d ",cv);
-        printf("%lf ",cost());
-        printf("[");
-        for(int i=0;i<path_length;i++)
-        {
-                printf("%d ",path[i]);
-        }
-        printf("] ");
-        printf("[");
-        for(int i=0;i<path_length;i++)
-        {
-                printf("%d ",order[i]);
-        }
-        printf("] \n");
-        return;
-
-}
-#endif
-
-void Route::remove( State S){
-        twv=S.twv;
-        cv=S.cv;
-        dis=S.dis;
-        path_length=S.path_length;
-        for(int i=0;i<path_length;i++)
-        {
-                path[i]=S.path[i];
-                order[i]=S.order[i];
-        }
-        return;
-}
-
-
-#endif
diff --git a/src/vrppdtw/src/Solution.h b/src/vrppdtw/src/Solution.h
deleted file mode 100644
index e8690ae..0000000
--- a/src/vrppdtw/src/Solution.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*PGR
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-#ifndef  _SOLUTION_H
-#define _SOLUTION_H
-
-#include <vector>
-#include <map>
-#include <queue>
-#include <string>
-#include <stdlib.h>
-#include <iostream>
-#include <algorithm>
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#include <set>
-
-#include "./Route.h"
-
-class Solution{
-        public:
-                Solution(){
-                        route_length=0,cost_total=0,twv_total=0,cv_total=0,dis_total=0;
-                }
-                //Variables
-                int twv_total;
-                int cv_total;
-                int dis_total;
-                double cost_total;
-                std::vector<Route> r;
-                int route_length;
-                //Methods
-                void dump();
-                double getCost();
-                Solution getBestofNeighborhood(Solution S, customer *c, depot d, Pickup *p,int CustomerLength, int PickupLength);
-                void UpdateSol();
-
-};
-class Neighborhoods{
-        public:
-                Neighborhoods(){}
-                Solution BestSPI(Solution S, customer *c, depot d, Pickup *p, int CustomerLength, int PickupLength);                
-};
-
-
-
-void Solution::UpdateSol()
-{
-        cost_total=0,twv_total=0,cv_total=0,dis_total=0;
-        int routes_del=0;
-        for(int i=0;i<route_length;i++)
-        {
-                twv_total+=r[i].twv;
-                dis_total+=r[i].dis;
-                cv_total+=r[i].cv;
-                cost_total+=r[i].cost();
-                if(r[i].path_length==0)
-                {
-                        routes_del++;
-                        r.erase(r.begin()+i);   
-                }
-        }
-        route_length=route_length-routes_del;
-        return;
-}
-
-
-//Methods in Solution
-
-#if 0
-void Solution::dump(){
-        printf("Routes Length=%d   ",route_length);
-        printf("Total Cost=%lf   ",cost_total);
-        printf("Total Distance=%d   \n",dis_total);
-        printf("Routes \n");
-        for(int i=0;i<route_length;i++)
-        {
-                printf("Route::%d  ",i);
-                printf("TWV=%d  CV=%d DIS=%d [ ",r[i].twv,r[i].cv,r[i].dis);
-                for(int j=0;j<r[i].path_length;j++)
-                {
-                        printf("%d ",r[i].path[j]);
-                }
-                printf("]\n");
-        }
-        return;
-}
-#endif
-
-double Solution::getCost(){
-        cost_total=0;
-        for(unsigned int i=0;i<r.size();i++)
-        {
-                cost_total+=r[i].cost();
-        }
-        return cost_total;
-}
-
-Solution Solution::getBestofNeighborhood(Solution S, customer *c, depot d, Pickup *p,  int CustomerLength, int PickupLength){
-        //    printf("twv_total=%lf\n",S.cost_total);
-        Neighborhoods N;
-        Solution S1;
-        S1=N.BestSPI(S,c,d,p,CustomerLength,PickupLength);
-        return S1;
-}
-
-
-
-Solution Neighborhoods::BestSPI(Solution S, customer *c, depot d, Pickup *p,  int CustomerLength, int PickupLength){
-        Solution CurrSol,BestSol,TempSol;
-        CurrSol=BestSol=S;
-        Pickup *OrderRequests=NULL;
-        OrderRequests= (Pickup *)malloc(2000*sizeof(Pickup));
-        int Ro_flag,Hc_flag;
-        State TempState;
-        //Copy Order requests from pickup's
-        for(int order=1;order<=PickupLength;order++)
-        {
-                OrderRequests[order]=p[order];
-        }
-
-        //Main SPI
-        for(int order=1;order<=PickupLength;order++)
-        {
-                //Order Find and Remove it! 
-                for(unsigned int route_remove=0;route_remove<CurrSol.r.size();route_remove++)
-                {                                
-                        Ro_flag=CurrSol.r[route_remove].RemoveOrder(OrderRequests[order]);
-                        TempSol=CurrSol;
-                        if(Ro_flag==1)
-                        {
-                                //Insert, Total Cost, (if it is more copy back the solution) ,  (else store best=temp, checked=2, break )          
-                                for(unsigned int route=0;route<CurrSol.r.size();route++)
-                                {
-                                        TempState=CurrSol.r[route].append(c,OrderRequests[order],d,CustomerLength, PickupLength,TempState);
-                                        Hc_flag=CurrSol.r[route].insertOrder(c,d,OrderRequests[order]);
-                                        // Hc flag tells us about insertion
-                                        if(Hc_flag==0)
-                                        {
-                                                if(CurrSol.r[route].cost() <= BestSol.r[route].cost())
-                                                {
-                                                        CurrSol.UpdateSol();
-                                                        BestSol=CurrSol;
-                                                }
-                                        }
-                                        TempSol.UpdateSol();
-                                        CurrSol=TempSol;
-                                        //   CurrSol = BestSol;
-                                }        
-                                BestSol.UpdateSol();
-                                CurrSol = BestSol;
-                                break;
-                        }
-                        else
-                        {
-                                continue;
-                        }
-                }
-        }
-        BestSol.UpdateSol();
-        return BestSol;
-}
-
-
-
-#endif 
diff --git a/src/vrppdtw/src/pdp.c b/src/vrppdtw/src/pdp.c
deleted file mode 100644
index a205d16..0000000
--- a/src/vrppdtw/src/pdp.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/*PGR
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-#include "./postgres.h"
-#include "executor/spi.h"
-#include "funcapi.h"
-#include "catalog/pg_type.h"
-#if PGSQL_VERSION > 92
-#include "access/htup_details.h"
-#endif
-
-#include "fmgr.h"
-#include "./pdp.h"
-
-
-Datum vrppdtw(PG_FUNCTION_ARGS);
-
-
-#undef DEBUG
-//#define DEBUG 1
-
-#ifdef DEBUG
-#define DBG(format, arg...)                     \
-        elog(NOTICE, format , ## arg)
-#else
-#define DBG(format, arg...) do { ; } while (0)
-#endif
-
-// The number of tuples to fetch from the SPI cursor at each iteration
-#define TUPLIMIT 1000
-
-#ifndef PG_MODULE_MAGIC
-PG_MODULE_MAGIC;
-#endif
-
-
-
-static char *text2char(text *in)
-{
-        char *out = (char*)palloc(VARSIZE(in));
-
-        memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
-        out[VARSIZE(in) - VARHDRSZ] = '\0';
-        return out;
-}
-
- static int
-  finish(int code, int ret)
-         {
-                    code = SPI_finish();
-                       if (code  != SPI_OK_FINISH ) {
-                                    elog(ERROR,"couldn't disconnect from SPI");
-                                         return -1 ;
-                                            }
-                          return ret;
-                           }
- 
-
-typedef struct Customer_type{
-        int id;
-        int x;
-        int y;
-        int demand;
-        int Etime;
-        int Ltime;
-        int Stime;
-        int Pindex;
-        int Dindex;
-}customer_t;
-
-
-
-#if 0
-static int conn(int *SPIcode)
-{
-        int res = 0;
-
-        *SPIcode = SPI_connect();
-
-        if (*SPIcode  != SPI_OK_CONNECT)
-        {
-                elog(ERROR, "vrppdtw: couldn't open a connection to SPI");
-                res = -1;
-        }
-
-        return res;
-}
-
-static int prepare_query(Portal *SPIportal, char* sql)
-{
-        int res = 0;
-
-        void* SPIplan = SPI_prepare(sql, 0, NULL);
-
-        if (SPIplan  == NULL)
-        {
-                elog(ERROR, "vrppdtw: couldn't create query plan via SPI");
-                res = -1;
-        }
-
-        if ((*SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL)
-        {
-                elog(ERROR, "vrppdtw: SPI_cursor_open('%s') returns NULL", sql);
-                res = -1;
-        }
-
-        return res;
-}
-#endif
-
-static int fetch_customer_columns(SPITupleTable *tuptable, customer_t *c , int vehicle_count , int capacity)
-{
-        DBG("Customer Data");
-
-        c->id = SPI_fnumber(SPI_tuptable->tupdesc, "id");
-        DBG(" id done ");
-        c->x = SPI_fnumber(SPI_tuptable->tupdesc, "x");
-        DBG("x done");
-        c->y = SPI_fnumber(SPI_tuptable->tupdesc, "y");
-        DBG("y done");
-        c->demand = SPI_fnumber(SPI_tuptable->tupdesc, "demand");
-        DBG("demand done");
-        c->Etime = SPI_fnumber(SPI_tuptable->tupdesc, "etime");
-        DBG("etime done");
-        c->Ltime = SPI_fnumber(SPI_tuptable->tupdesc, "ltime");
-        DBG("ltime done");
-        c->Stime = SPI_fnumber(SPI_tuptable->tupdesc, "stime");
-        DBG("stime done");
-        c->Pindex = SPI_fnumber(SPI_tuptable->tupdesc, "pindex");
-        DBG("pindex done");
-        c->Dindex = SPI_fnumber(SPI_tuptable->tupdesc, "dindex");
-        DBG("dindex done");
-        if (c->id == SPI_ERROR_NOATTRIBUTE ||
-                        c->x == SPI_ERROR_NOATTRIBUTE ||
-                        c->y == SPI_ERROR_NOATTRIBUTE ||
-                        c->demand == SPI_ERROR_NOATTRIBUTE ||
-                        c->Ltime == SPI_ERROR_NOATTRIBUTE ||
-                        c->Stime == SPI_ERROR_NOATTRIBUTE ||
-                        c->Pindex == SPI_ERROR_NOATTRIBUTE ||
-                        c->Dindex == SPI_ERROR_NOATTRIBUTE ||
-                        c->Etime == SPI_ERROR_NOATTRIBUTE)
-        {
-                elog(ERROR, "Error, query must return columns "
-                                "'id', 'x','y','demand', 'Etime',  'Ltime', 'Stime', 'Pindex',  and 'Dindex'");
-                return -1;
-        }
-
-        DBG("Returned from here  ");
-        return 0;
-}
-
-
-static void fetch_customer(HeapTuple *tuple, TupleDesc *tupdesc, customer_t *c_all, customer *c_single)
-{
-        Datum binval;
-        bool isnull;
-        DBG("Hey baby in fetch_customer");
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->id, &isnull);
-        DBG("fetching first thing");
-        if (isnull) elog(ERROR, "id contains a null value");
-        c_single->id = DatumGetInt32(binval);
-        DBG("id =  %d", c_single->id);
-
-
-        DBG("fetching second  thing");
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->x, &isnull);
-        if (isnull) 
-                elog(ERROR, "x contains a null value");
-        c_single->x = DatumGetInt32(binval);
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->y, &isnull);
-        if (isnull) elog(ERROR, "y contains a null value");
-        c_single->y = DatumGetInt32(binval);
-
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->demand, &isnull);
-        if (isnull) elog(ERROR, "demand contains a null value");
-        c_single->demand = DatumGetInt32(binval);
-
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->Etime, &isnull);
-        if (isnull) elog(ERROR, "Etime contains a null value");
-        c_single->Etime = DatumGetInt32(binval);
-
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->Ltime, &isnull);
-        if (isnull) elog(ERROR, "Ltime contains a null value");
-        c_single->Ltime = DatumGetInt32(binval);
-
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->Stime, &isnull);
-        if (isnull) elog(ERROR, "Stime contains a null value");
-        c_single->Stime = DatumGetInt32(binval);
-
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->Pindex, &isnull);
-        if (isnull) elog(ERROR, "pindex contains a null value");
-        c_single->Pindex = DatumGetInt32(binval);
-
-        binval = SPI_getbinval(*tuple, *tupdesc, c_all->Dindex, &isnull);
-        if (isnull) elog(ERROR, "dindex contains a null value");
-        c_single->Dindex = DatumGetInt32(binval);
-
-        return;
-}
-
-
-
-
-//Note:: edge_colums = total , //ly customer_t = total ....
-
-static int compute_shortest_path(char* sql, int  vehicle_count, int capacity , path_element **results, int *length_results_struct) 
-{
-
-        int SPIcode;
-        void *SPIplan;
-        Portal SPIportal;
-        bool moredata = TRUE;
-        int ntuples;
-        customer *customer_single=NULL;
-        int total_tuples = 0;
-        customer_t customer_all = {.id= -1, .x=-1, .y=-1 , .demand=-1 , .Etime=-1, .Ltime=-1 , .Stime=-1 , .Pindex=-1 , .Dindex=-1 };   // write this 
-
-        char *err_msg;
-        int ret = -1;
-        // register int z;
-
-        DBG("start shortest_path\n");
-
-        SPIcode = SPI_connect();
-        if (SPIcode  != SPI_OK_CONNECT) {
-                elog(ERROR, "shortest_path: couldn't open a connection to SPI");
-                return -1;
-        }
-
-        SPIplan = SPI_prepare(sql, 0, NULL);
-        if (SPIplan  == NULL) {
-                elog(ERROR, "shortest_path: couldn't create query plan via SPI");
-                return -1;
-        }
-
-        if ((SPIportal = SPI_cursor_open(NULL, SPIplan, NULL, NULL, true)) == NULL) {
-                elog(ERROR, "shortest_path: SPI_cursor_open('%s') returns NULL", sql);
-                return -1;
-        }
-
-        while (moredata == TRUE) {
-                SPI_cursor_fetch(SPIportal, TRUE, TUPLIMIT);
-
-                DBG("Checking ");
-
-                if (customer_all.id == -1) {
-                        if (fetch_customer_columns(SPI_tuptable, &customer_all,vehicle_count, capacity) == -1)
-                        {
-                               return finish(SPIcode, ret);
-                        }
-                        DBG("Here I am ");
-                }
-
-                ntuples = SPI_processed;
-                total_tuples += ntuples;
-                DBG("Calculated total_tuples  ntuples=%d   total_tuples =%d ", ntuples, total_tuples);
-                
-                   if (customer_single==NULL)
-                   customer_single = palloc(total_tuples * sizeof(customer));
-                   else
-                   customer_single = repalloc(customer_single, total_tuples * sizeof(customer));
-
-
-                DBG("Error here ");
-                    if (customer_single == NULL) {
-                                 elog(ERROR, "Out of memory");
-                                          return finish(SPIcode, ret);
-                                           }
-
-
-
-                if (ntuples > 0) {
-                        DBG("Check here ");
-                        int t;
-                        SPITupleTable *tuptable = SPI_tuptable;
-                        TupleDesc tupdesc = SPI_tuptable->tupdesc;
-
-                        for (t = 0; t < ntuples; t++) {
-                                DBG("In for loop ");
-                                HeapTuple tuple = tuptable->vals[t];
-                                DBG("Manikanta ");
-                                fetch_customer(&tuple, &tupdesc, &customer_all , &customer_single[total_tuples - ntuples + t]);
-                                DBG("After Function call");
-                        }
-                        SPI_freetuptable(tuptable);
-                } 
-                else {
-                        moredata = FALSE;
-                }
-        }
-
-        int k;
-        for(k=0;k<total_tuples;k++)
-        {
-                DBG("%d     %d     %d     %d     %d     %d     %d     %d     %d" , customer_single[k].id, customer_single[k].x , customer_single[k].y , customer_single[k].demand , customer_single[k].Etime ,customer_single[k].Ltime ,customer_single[k].Stime, customer_single[k].Pindex,  customer_single[k].Dindex);
-        }
-
-        DBG("Calling Solver Instance\n");
-
-
-        ret = Solver(customer_single, total_tuples, vehicle_count, capacity , &err_msg,results, length_results_struct);
-
-        if (ret < -2) {
-                //elog(ERROR, "Error computing path: %s", err_msg);
-                ereport(ERROR, (errcode(ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED), 
-                                        errmsg("Error computing path: %s", err_msg)));
-        } 
-
-
-        DBG("*length_results_count  = %i\n", *length_results_struct);
-
-        DBG("ret = %i\n", ret);
-
-
-
-
-        int vb;
-        for(vb=1;vb<*length_results_struct;vb++)
-        {
-                DBG("results[%d].seq=%d  ",vb, (*results)[vb].seq);
-                DBG("results[%d].rid=%d  ",vb, (*results)[vb].rid);
-                DBG("results[%d].nid=%d \n",vb, (*results)[vb].nid);
-        }
-
-        pfree(customer_single);
-        DBG("Working till here ");
-        return finish(SPIcode, ret);
-
-}
-
-
-
-PG_FUNCTION_INFO_V1(vrppdtw);
-        Datum
-vrppdtw(PG_FUNCTION_ARGS)
-{
-        FuncCallContext     *funcctx;
-        int                  call_cntr;
-        int                  max_calls;
-        TupleDesc            tuple_desc;
-        path_element     *results = 0;
-
-
-        /* stuff done only on the first call of the function */
-
-        if (SRF_IS_FIRSTCALL())
-
-        {
-                MemoryContext   oldcontext;
-                // int ret;
-                int length_results_struct = 0;
-
-
-
-
-                /* create a function context for cross-call persistence */
-
-                funcctx = SRF_FIRSTCALL_INIT();
-
-
-
-                /* switch to memory context appropriate for multiple function calls */
-
-                oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-
-
-                results = (path_element *)palloc(sizeof(path_element)*((length_results_struct)+1));
-
-                DBG("Calling compute_shortes_path");
-
-
-
-                // ret =
-                compute_shortest_path(
-
-                                text2char(PG_GETARG_TEXT_P(0)),  // customers sql
-
-                                PG_GETARG_INT32(1),  // vehicles  count
-
-                                PG_GETARG_INT32(2),  // capacity count
-
-                                &results, &length_results_struct
-                                );
-
-                DBG("Back from solve_vrp, length_results: %d", length_results_struct);
-
-                /* total number of tuples to be returned */
-                funcctx->max_calls = length_results_struct;
-                funcctx->user_fctx = results;
-
-                /* Build a tuple descriptor for our result type */
-                if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
-                        ereport(ERROR,
-                                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                         errmsg("function returning record called in context "
-                                                 "that cannot accept type record")));
-
-                funcctx->tuple_desc = BlessTupleDesc(tuple_desc);
-
-                MemoryContextSwitchTo(oldcontext);
-        }
-
-        /* stuff done on every call of the function */
-        funcctx = SRF_PERCALL_SETUP();
-
-        call_cntr = funcctx->call_cntr;
-        max_calls = funcctx->max_calls;
-        tuple_desc = funcctx->tuple_desc;
-        results = (path_element *) funcctx->user_fctx;
-
-        /* do when there is more left to send */
-        if (call_cntr < max_calls) {
-                HeapTuple    tuple;
-                Datum        result;
-                Datum *values;
-                bool* nulls;
-
-                DBG("Till hereee ");
-                values = palloc(4 * sizeof(Datum));
-                nulls = palloc(4 * sizeof(bool));
-
-                values[0] = Int32GetDatum(results[call_cntr].seq);
-                nulls[0] = false;
-                values[1] = Int32GetDatum(results[call_cntr].rid);
-                nulls[1] = false;
-                values[2] = Int32GetDatum(results[call_cntr].nid);
-                nulls[2] = false;
-                values[3] = Int32GetDatum(results[call_cntr].cost);
-                nulls[3] = false;
-                tuple = heap_form_tuple(tuple_desc, values, nulls);
-
-                /* make the tuple into a datum */
-                result = HeapTupleGetDatum(tuple);
-
-                /* clean up (this is not really necessary) */
-                pfree(values);
-                pfree(nulls);
-
-                SRF_RETURN_NEXT(funcctx, result);
-        }
-        /* do when there is no more left */
-        else {
-                DBG("Ending function\n");
-
-                free(results);
-                DBG("Itinerary cleared\n");
-
-
-                SRF_RETURN_DONE(funcctx);
-        }
-
-
-}
diff --git a/src/vrppdtw/src/pdp.h b/src/vrppdtw/src/pdp.h
deleted file mode 100644
index 4180f23..0000000
--- a/src/vrppdtw/src/pdp.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*PGR
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-#include<stdio.h>
-#include<stdlib.h>
-#include<math.h>
-#include "postgres.h"
-
-#ifndef _PDP_H
-#define _PDP_H
-
-
-// Structures and variables which help us in storing the data
-
-typedef struct Depot{
-        int id;
-        int x;
-        int y;
-        int demand;
-        int Etime;
-        int Ltime;
-        int Stime;
-        int Pindex;
-        int Dindex;
-}depot;
-
-
-
-typedef struct Customer{
-        int id;
-        int x;
-        int y;
-        int demand;
-        int Etime;
-        int Ltime;
-        int Stime;
-        int Pindex;
-        int Dindex;
-        double Ddist;
-        int P;
-        int D;
-}customer;
-
-
-typedef struct Pickup{
-        int id;
-        int Pid;
-        double Ddist;
-        int Did;
-        int checked;
-}pickup; 
-
-
-
-typedef struct Vehicle{
-        int capacity;
-        int used_vehicles;
-        int given_vehicles;
-        int speed;
-        int cost;
-}VehicleInfo;
-
-
-// A module which calculates distance 
-double CalculateDistance(int x1,int y1,int x2,int y2)
-{
-        return sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
-}
-
-/*
-// DEPOT:  With id=0
-depot ScanDepot(depot d)
-{
-
-scanf("%d",&d.id);
-scanf("%d",&d.x);
-scanf("%d",&d.y);
-scanf("%d",&d.demand);
-scanf("%d",&d.Etime);
-scanf("%d",&d.Ltime);
-scanf("%d",&d.Stime);
-scanf("%d",&d.Pindex);
-scanf("%d",&d.Dindex);
-return d;
-}
-
-// CUSTOMER: WITH id>=1
-customer ScanCustomer(int id,customer c,depot d)
-{
-c.id=id;
-scanf("%d",&c.x);
-scanf("%d",&c.y);
-scanf("%d",&c.demand);
-scanf("%d",&c.Etime);
-scanf("%d",&c.Ltime);
-scanf("%d",&c.Stime);
-scanf("%d",&c.Pindex);
-scanf("%d",&c.Dindex);
-if(c.Pindex==0)
-{ 
-c.P=1;
-c.D=0;
-}  
-else if(c.Dindex==0)
-{
-c.D=1;
-c.P=0;
-}
-c.Ddist=CalculateDistance(c.x,c.y,d.x,d.y);
-return c;
-}
-
-
-//VEHICLE: First Line contains vehicle data
-VehicleInfo ScanVehicle(VehicleInfo Vehicle)
-{
-scanf("%d",&Vehicle.given_vehicles);
-scanf("%d",&Vehicle.capacity);
-scanf("%d",&Vehicle.speed);
-Vehicle.used_vehicles=0;
-return Vehicle;
-
-}
-
-
- */
-
-
-// Part of code: It is used to save some variables and helps if we need to revisit previous state.
-typedef struct statesave{
-        int twv;
-        int cv;
-        int dis;
-        //       vector<int> path;
-        //      vector<int> order;
-        int path[1000];
-        int order[1000];
-        int path_length;
-}State;
-
-
-typedef struct PathElement {
-         int seq;
-         int rid;
-         int nid;
-         int nseq;
-         int cost;
-} path_element;
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-int Solver(customer *c, int total_tuples, int vehicle_count, int capacity , char **msg, path_element **results, int *length_results);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
-#endif
-
-
-
-
-
-
-
-
-
-
diff --git a/src/vrppdtw/src/pdp_solver.cpp b/src/vrppdtw/src/pdp_solver.cpp
deleted file mode 100644
index e154607..0000000
--- a/src/vrppdtw/src/pdp_solver.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-/*PGR
-
-Copyright (c) 2014 Manikata Kondeti
-mani.iiit123 at gmail.com
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-/*                                 
-
- *****list of files in this dir*******
- pdp.cpp  --> Main solver
- pdp.h    ---> Structures defined in this header file
- Solution.h  -----> It contains the Solution Class and Code related to Neighborhoods  
- Route.h     -----> Explains all about Route Class.
- pdp.c --->  Contains all the details on pgRouting integration.
-
- The main problem is in two steps. 1.)Getting the initial solutiion and 2.)Optimizing it.
-
- 1.) "Initial solution":
- A few heuristics are applied to find a feasible initial solution. Sequential Construction and Hill climbing. More implementation details are found here:: https://github.com/pgRouting/pgrouting/wiki/VRP-Pickup-Delivery-Problem 
-
- 2.) "Optimizing the Solution":
- A reactive tabu search is applied on the initial solution to get a feasible optimized solution. TabuSearch comes under local search methods. We have three neighborhoods 
-                       i) Single Paired Insertion  
-                       ii) Swapping pairs between routes  
-                       iii)Within Route Insertion. 
-                        Tabu attributes plays an important role in giving the best solution(it includes TabuLength, A vector containing feasible solutions and a counter for number of solutions). 
-                        Reactive part discussed in the paper is to modify TabuLength based on the solution cycle. 
-
- */
-#ifdef __MINGW32__
-#include <winsock2.h>
-#include <windows.h>
-#endif
-
-
-#include <vector>
-#include <map>
-#include <queue>
-#include <string>
-#include <stdlib.h>
-#include <iostream>
-#include <algorithm>
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#include <set>
-//Headers Include
-#include "./pdp.h"
-#include "./Solution.h"
-#include "./Route.h"
-
-
-int PickupLength=0;
-
-//Depot 
-depot d;
-//Vehicle
-//Customer Data
-customer *c=NULL;
-pickup *p=NULL;
-int len=0;
-
-int CustomerLength;
-
-
-std::vector<Solution> T;
-
-Route *r=NULL;
-//Definitions for a few functions 
-int TabuSearch();
-//Vector containing solutions
-
-//Initial Solution
-Solution S0;
-
-void result_struct();
-int Solver(customer *c1,int total_tuples, int VehicleLength, int capacity , char **msg, path_element **results, int *length_results_struct)
-{
-        CustomerLength= total_tuples-1;
-
-        c = (customer *)malloc((CustomerLength+5)*sizeof(customer));
-        p = (pickup *)malloc((CustomerLength+5)*sizeof(pickup));
-        r = (Route *)malloc((CustomerLength+5)*sizeof(Route));
-VehicleInfo Vehicle;
-        //Depot Data
-        d.id = c1[0].id;
-        d.x = c1[0].x;
-        d.y = c1[0].y;
-        d.demand = c1[0].demand;
-        d.Etime = c1[0].Etime;
-        d.Ltime = c1[0].Ltime;
-        d.Stime = c1[0].Stime;
-        d.Pindex = c1[0].Pindex;
-        d.Dindex = c1[0].Dindex;
-
-
-        //Customer Data 
-        for(int i=1;i<=CustomerLength;i++)
-        {
-                c[i].id = c1[i].id;
-                c[i].x = c1[i].x;
-                c[i].y = c1[i].y;
-                c[i].Etime = c1[i].Etime;
-                c[i].demand = c1[i].demand;
-                c[i].Ltime = c1[i].Ltime;
-                c[i].Stime = c1[i].Stime;
-                c[i].Pindex = c1[i].Pindex;
-                c[i].Dindex = c1[i].Dindex;
-                c[i].Ddist= CalculateDistance(c[i].x, c[i].y ,d.x, d.y);                        
-                if(c[i].Pindex==0){
-                        c[i].P=1;
-                        c[i].D=0;
-                }
-                if(c[i].Dindex==0){
-                        c[i].D=1;
-                        c[i].P=0;
-                }
-        }
-
-        //Vehicle Data 
-                  
-         Vehicle.given_vehicles =  VehicleLength;
-         Vehicle.capacity = capacity;
-         Vehicle.speed = 1;
-         Vehicle.used_vehicles=0;
-
-      
-
-
-        //From customers put aside all the pickup's;
-        for(int i=1;i<=CustomerLength;i++){
-                if(c[i].P==1){
-                        PickupLength+=1;
-                        p[PickupLength].id=PickupLength;
-                        p[PickupLength].Did=c[i].Dindex;
-                        p[PickupLength].Ddist=c[i].Ddist;
-                        p[PickupLength].Pid=c[i].id;
-                }
-        }
-        // printf("Pickup Length=%d \n",PickupLength);
-
-        //Sort Pickup's
-        int swap;
-        double swap1;
-        for(int i=1;i<=PickupLength;i++)
-        {
-                for(int j=1;j<=PickupLength-i;j++){
-                        if(p[j].Ddist>p[j+1].Ddist){
-                                swap1=p[j].Ddist;
-                                p[j].Ddist=p[j+1].Ddist;
-                                p[j+1].Ddist=swap1;
-                                swap=p[j].Did;
-                                p[j].Did=p[j+1].Did;
-                                p[j+1].Did=swap;
-                                swap=p[j].Pid;
-                                p[j].Pid=p[j+1].Pid;
-                                p[j+1].Pid=swap;
-                                swap=p[j].id;
-                                p[j].id=p[j+1].id;
-                                p[j+1].id=swap;
-                        }
-                }
-                p[i].checked=0;
-        }
-
-
-        for(int i=1;i<=PickupLength;i++)
-        {
-                //          DBG("PickupID[%d]=%lf\n",p[i].id,p[i].Ddist);
-        }
-
-        // int flag_complete=0;
-        int checked=0;
-        //Sequential Construction 
-        for(int v=1;v<110;v++){
-                for(int i=PickupLength;i>=1;i--){
-                        if(p[i].checked!=1){
-                                State S;
-                                S=r[v].append(c,p[i],d,CustomerLength,PickupLength,S);
-                                int flag=r[v].HillClimbing(c,d,p[i]);
-                                if(flag==1){
-                                        //Remove 
-                                        p[i].checked=0;
-                                        r[v].remove(S);
-                                }
-                                else{
-                                        p[i].checked=1;
-                                        checked+=1;
-                                }
-                        }
-                        //Requests complete
-                }
-                Vehicle.used_vehicles=v;
-                if(checked==PickupLength)
-                {
-                        v=9999;
-                }
-        }
-     //   *length_results_struct = d.Ltime;
-        int sum=0,rts=0;
-
-        for(int i=1;i<=Vehicle.used_vehicles;i++){
-                // printf("%d, ",i);
-                // r[i].print();
-                sum+=r[i].dis;
-                if(r[i].dis!=0){
-                        rts+=1;
-                }
-                Vehicle.cost=sum;
-        }
-        // printf("Sum=%d  Routes=%d  Vehicle.used_vehicles=%d\n",sum,rts,Vehicle.used_vehicles);
-
-        //Storing Initial Solution (S0 is the Initial Solution)
-        for(int i=1;i<=Vehicle.used_vehicles;i++)
-        {
-                S0.cost_total+=r[i].cost();
-                S0.dis_total+=r[i].dis;
-                S0.twv_total+=r[i].twv;
-                S0.cv_total+=r[i].cv;
-        }
-        S0.route_length=Vehicle.used_vehicles;
-        for(int i=1;i<=Vehicle.used_vehicles;i++)
-        {
-                S0.r.push_back(r[i]);
-        }
-        // printf("Size  =>>  S0.r.size=%ld\n", S0.r.size());
-
- 
-       //Starting Neighborhoods
-        // printf("\nNeighborhoods From now\n");
-        int sol_count=TabuSearch();
-
- //Copying back the results 
- // path_element->results , path_length   {  we need to send (results, length_results) backk ; 
-        int nodes_count;
-        nodes_count= CustomerLength;
-        *results = (path_element *) malloc(sizeof(path_element) * (nodes_count + 5*VehicleLength));
-        int length_results=0;
-
- 
-
-        int *cost, *cost_nodes;
-        cost = (int *)malloc(1000*sizeof(int));
-        cost_nodes = (int *)malloc(1000*sizeof(int));
-        //Cost Calculation 
-
-        int copy_length=0;
-        // TAKE AN ARRAY EMBED EVERYTHING 
-        for(int itr_route=0;itr_route<T[sol_count].route_length;itr_route++)
-        {
-                cost[copy_length]=d.id;
-                copy_length++;
-                for(int itr_node=0;itr_node<T[sol_count].r[itr_route].path_length;itr_node++)
-                {
-                cost[copy_length]=T[sol_count].r[itr_route].path[itr_node];
-                copy_length++;
-                }
-                cost[copy_length]=d.id;
-                copy_length++;
-        }
-
-        copy_length-=1;
-        int temp_dis=0;
-        for(int i=0;i<copy_length;i++)
-        {                
-                if(i==0)
-                {
-                        cost_nodes[0]=0;
-                        temp_dis=0;
-                }
-                else 
-                {
-                //Depot to first node 
-                if(cost[i-1]==d.id && cost[i]!=d.id )
-                 {
-                         temp_dis=0;
-                        temp_dis+=sqrt(((c[cost[i]].x-d.x)*(c[cost[i]].x-d.x))+((c[cost[i]].y-d.y)*(c[cost[i]].y-d.y)));
-                        if(temp_dis < c[cost[i]].Etime)
-                        {
-                                        temp_dis=c[cost[i]].Etime;
-                        }
-
-                        cost_nodes[i]=temp_dis;
-                }
-
-                //Between nodes 
-                else if(cost[i-1]!=d.id && cost[i]!=d.id)
-                {
-                        temp_dis+=sqrt(((c[cost[i]].x-c[cost[i-1]].x)*(c[cost[i]].x-c[cost[i-1]].x))+((c[cost[i]].y-c[cost[i-1]].y)*(c[cost[i]].y-c    [cost[i-1]].y)));
-                        
-                         if(temp_dis < c[cost[i]].Etime)
-                                  {
-                                          temp_dis=c[cost[i]].Etime;
-                                  }
-                        
-                        temp_dis+=c[cost[i-1]].Stime;
-                        cost_nodes[i]=temp_dis;
-                }
-                else if(cost[i]==d.id && cost[i-1]!=d.id)
-                {
-                        temp_dis+=sqrt(((d.x-c[cost[i-1]].x)*(d.x-c[cost[i-1]].x))+((d.y-c[cost[i-1]].y)*(d.y-c[cost[i-1]].y)));
-                        cost_nodes[i]=temp_dis;
-                        temp_dis=0;
-                }
-                else if(cost[i]==d.id && cost[i-1]==d.id)
-                {
-                        cost_nodes[i]=0;
-                        temp_dis=0;
-                }
-                }
-                //Last node to deopt  
-        }
-
-        //Done cost calculation 
-
-
-        for(int itr_route=0; itr_route<T[sol_count].route_length; itr_route++)
-        {
-               (*results)[length_results].seq = length_results;
-                (*results)[length_results].rid = itr_route+1;
-                (*results)[length_results].nid = d.id;
-                (*results)[length_results].cost = cost_nodes[length_results];
-                length_results++;
-                
-                //Loop for path elements.
-                for(int itr_node=0;itr_node < T[sol_count].r[itr_route].path_length;itr_node++)
-                {
-                (*results)[length_results].seq = length_results;
-                (*results)[length_results].rid = itr_route+1;
-                (*results)[length_results].nid = T[sol_count].r[itr_route].path[itr_node];
-                (*results)[length_results].cost = cost_nodes[length_results];
-                length_results++;
-                }
-
-                (*results)[length_results].seq = length_results;
-                (*results)[length_results].rid = itr_route+1;
-                (*results)[length_results].nid = d.id;
-                (*results)[length_results].cost = cost_nodes[length_results];
-                length_results++;
-                
-        }
-
-       *length_results_struct = length_results;
-        free(c);
-        free(p);
-        free(r);
-
-//Copying is done till here
-
-        return 0;
-}
-int n=0,maxItr=30;
-
-
-
-/* TABU search helps us to store the solutions after every different move. The overview of TABU search will be a list containing list of solutions*/
-
-int TabuSearch()
-{
-        // printf("TABU Called\n");
-        Solution S,SBest;
-        double CBest;
-        //Pseudo Code
-        /*
-
-         **********Before*********
-         int n=0; //Counter     
-
-         Create Tabu List  Vector of Solutions  std::vector<Solution> T;
-
-         **********After**********
-         Solution S,S0,SBest;  //S0 is initial 
-         S=S0;
-         Double CBest,SBest;
-         CBest = S.getCost();
-         SBest = S0;
-         n=0; //Counter
-         while(1)
-         {
-         S = S.getBextofNeighborhood();
-         if(S==NULL)
-         break;
-         if(S.getCost() < CBest){
-         SBest = S;
-         CBest = S.getCost();
-         }
-         T.push_back(S);
-         n++;
-         if(n>maxItr)
-         break;
-         }
-
-         */
-
-        S=S0;
-        CBest = S.getCost();
-        SBest = S0;
-        T.clear();
-        T.push_back(S0);
-        while(1)
-        {
-                S = S.getBestofNeighborhood(S,c,d,p,CustomerLength,PickupLength);
-                if(S.getCost()==0)
-                        break;
-                if (S.getCost() < CBest){
-                        SBest = S;
-                        CBest = S.getCost();
-                        T.push_back(S);
-                }   
-                else if(S.getCost() == CBest )
-                {
-                        // printf("\n****************Repeated Solution****************\n");
-                        int k= ((12)*maxItr)/100;
-                        maxItr = maxItr-k;
-                        // printf("Maxitr after repeating %d k =%d\n",maxItr,k);
-                }
-                n++;
-                if (n > maxItr)
-                        break;
-        }
-#if 0
-        printf("Size of Tabu=%ld &&& n=%d  maxItr=%d\n",T.size(),n,maxItr);
-        for(unsigned int itr=0;itr<T.size();itr++)
-        {
-                T[itr].dump();
-        }
-#endif
-        return T.size()-1;
-}
-
diff --git a/src/vrppdtw/test/CMakeLists.txt b/src/vrppdtw/test/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/vrppdtw/test/doc-gsoc_vrppdtw.result b/src/vrppdtw/test/doc-gsoc_vrppdtw.result
new file mode 100644
index 0000000..bbf03a6
--- /dev/null
+++ b/src/vrppdtw/test/doc-gsoc_vrppdtw.result
@@ -0,0 +1,56 @@
+--q1
+1
+2
+3
+4
+5
+6
+7
+8
+9
+--q2
+114
+--q3
+1|1|0|0
+2|1|5|105.132745950422
+3|1|3|196.132745950422
+4|1|7|288.132745950422
+5|1|8|380.961173075168
+6|1|10|474.566724350632
+7|1|11|567.566724350632
+8|1|9|660.7290020108
+9|1|6|752.9650699883
+10|1|4|845.2011379658
+11|1|2|938.806689241264
+12|1|1|1030.80668924126
+13|1|75|1123.80668924126
+14|1|0|1139.61807754211
+51|5|0|0
+52|5|43|106.552945357247
+53|5|42|199.552945357247
+54|5|41|291.552945357247
+55|5|40|383.552945357247
+56|5|44|476.552945357247
+57|5|46|569.381372481993
+58|5|45|661.381372481993
+59|5|48|753.381372481993
+60|5|51|756.381372481993
+61|5|101|846.381372481993
+62|5|50|938.617440459493
+63|5|52|1031.77971811966
+64|5|49|1124.77971811966
+65|5|47|1216.77971811966
+66|5|0|1234.80747449698
+103|9|0|0
+104|9|90|110.615528128088
+105|9|87|205.615528128088
+106|9|86|296.615528128088
+107|9|83|392.615528128088
+108|9|82|485.615528128088
+109|9|84|581.446480022934
+110|9|85|674.27490714768
+111|9|88|767.27490714768
+112|9|89|860.103334272426
+113|9|91|953.70888554789
+114|9|0|976.069565322888
+--q4
diff --git a/src/vrppdtw/test/doc-gsoc_vrppdtw.test.sql b/src/vrppdtw/test/doc-gsoc_vrppdtw.test.sql
new file mode 100644
index 0000000..e130c44
--- /dev/null
+++ b/src/vrppdtw/test/doc-gsoc_vrppdtw.test.sql
@@ -0,0 +1,14 @@
+
+\echo --q1
+SELECT DISTINCT(id1) FROM pgr_gsoc_vrppdtw(
+    'SELECT * FROM customer ORDER BY id', 25, 200)
+ORDER BY id1;
+\echo --q2
+SELECT count(*) FROM pgr_gsoc_vrppdtw(
+    'SELECT * FROM customer ORDER BY id', 25, 200);
+\echo --q3
+SELECT * FROM pgr_gsoc_vrppdtw(
+    'SELECT * FROM customer ORDER BY id', 25, 200)
+    WHERE id1 in (1, 5, 9);
+\echo --q4
+
diff --git a/src/vrppdtw/test/pdp-any-01.result b/src/vrppdtw/test/pdp-any-01.result
deleted file mode 100644
index a50f605..0000000
--- a/src/vrppdtw/test/pdp-any-01.result
+++ /dev/null
@@ -1,146 +0,0 @@
-0|1|0|0
-1|1|71|293
-2|1|77|664
-3|1|79|758
-4|1|80|859
-5|1|49|1091
-6|1|47|1183
-7|1|0|1201
-8|2|0|0
-9|2|78|109
-10|2|104|109
-11|2|36|755
-12|2|105|755
-13|2|51|870
-14|2|101|870
-15|2|50|962
-16|2|52|1055
-17|2|0|1076
-18|3|0|0
-19|3|76|203
-20|3|73|568
-21|3|6|723
-22|3|2|915
-23|3|0|935
-24|4|0|0
-25|4|54|186
-26|4|56|475
-27|4|60|652
-28|4|59|752
-29|4|66|916
-30|4|69|1008
-31|4|0|1023
-32|5|0|0
-33|5|53|286
-34|5|58|561
-35|5|23|822
-36|5|103|822
-37|5|0|835
-38|6|0|0
-39|6|5|15
-40|6|7|260
-41|6|38|569
-42|6|34|841
-43|6|0|873
-44|7|0|0
-45|7|81|47
-46|7|25|259
-47|7|27|351
-48|7|70|516
-49|7|100|737
-50|7|99|833
-51|7|0|866
-52|8|0|0
-53|8|42|68
-54|8|63|261
-55|8|40|369
-56|8|74|477
-57|8|45|631
-58|8|48|723
-59|8|0|746
-60|9|0|0
-61|9|43|16
-62|9|41|256
-63|9|97|651
-64|9|106|651
-65|9|0|691
-66|10|0|0
-67|10|98|30
-68|10|96|185
-69|10|95|286
-70|10|94|379
-71|10|0|419
-72|11|0|0
-73|11|18|179
-74|11|92|458
-75|11|93|565
-76|11|12|742
-77|11|0|780
-78|12|0|0
-79|12|57|35
-80|12|55|185
-81|12|82|459
-82|12|84|554
-83|12|85|646
-84|12|89|827
-85|12|0|851
-86|13|0|0
-87|13|33|87
-88|13|35|373
-89|13|37|473
-90|13|30|586
-91|13|39|698
-92|13|21|1004
-93|13|0|1014
-94|14|0|0
-95|14|32|31
-96|14|31|290
-97|14|64|722
-98|14|102|722
-99|14|0|743
-100|15|0|0
-101|15|13|30
-102|15|17|189
-103|15|19|368
-104|15|15|474
-105|15|11|582
-106|15|9|675
-107|15|4|817
-108|15|1|1002
-109|15|0|1020
-110|16|0|0
-111|16|86|173
-112|16|29|448
-113|16|16|573
-114|16|14|665
-115|16|26|785
-116|16|91|926
-117|16|0|948
-118|17|0|0
-119|17|87|85
-120|17|83|355
-121|17|28|636
-122|17|22|902
-123|17|0|914
-124|18|0|0
-125|18|90|20
-126|18|65|166
-127|18|72|540
-128|18|88|735
-129|18|0|761
-130|19|0|0
-131|19|20|10
-132|19|24|155
-133|19|8|345
-134|19|10|447
-135|19|0|463
-136|20|0|0
-137|20|67|12
-138|20|3|155
-139|20|62|352
-140|20|44|460
-141|20|46|552
-142|20|61|662
-143|20|68|824
-144|20|75|1087
-145|20|0|0
diff --git a/src/vrppdtw/test/pdp-any-01.test.sql b/src/vrppdtw/test/pdp-any-01.test.sql
deleted file mode 100644
index 8f8dc19..0000000
--- a/src/vrppdtw/test/pdp-any-01.test.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-select * from pgr_gsoc_vrppdtw(
-                'select * from customer order by id'::text, 25,200
-                );
diff --git a/src/vrppdtw/test/pdp-any-02.result b/src/vrppdtw/test/pdp-any-02.result
new file mode 100644
index 0000000..9c67f81
--- /dev/null
+++ b/src/vrppdtw/test/pdp-any-02.result
@@ -0,0 +1,114 @@
+1|1|0|0
+2|1|5|105.132745950422
+3|1|3|196.132745950422
+4|1|7|288.132745950422
+5|1|8|380.961173075168
+6|1|10|474.566724350632
+7|1|11|567.566724350632
+8|1|9|660.7290020108
+9|1|6|752.9650699883
+10|1|4|845.2011379658
+11|1|2|938.806689241264
+12|1|1|1030.80668924126
+13|1|75|1123.80668924126
+14|1|0|1139.61807754211
+15|2|0|0
+16|2|13|120.805843601499
+17|2|17|214.805843601499
+18|2|18|307.805843601499
+19|2|19|402.805843601499
+20|2|15|497.805843601499
+21|2|16|592.805843601499
+22|2|14|684.805843601499
+23|2|12|777.805843601499
+24|2|0|815.884709130818
+25|3|0|0
+26|3|20|100
+27|3|24|195
+28|3|25|287
+29|3|27|379
+30|3|29|472.605551275464
+31|3|30|567.605551275464
+32|3|28|660.605551275464
+33|3|26|752.605551275464
+34|3|23|755.605551275464
+35|3|103|845.605551275464
+36|3|22|938.605551275464
+37|3|21|1030.60555127546
+38|3|0|1040.80359030265
+39|4|0|0
+40|4|32|121.622776601684
+41|4|33|213.622776601684
+42|4|31|309.007941408818
+43|4|35|404.007941408818
+44|4|37|499.838893303664
+45|4|38|591.838893303664
+46|4|39|686.838893303664
+47|4|36|691.838893303664
+48|4|105|781.838893303664
+49|4|34|874.838893303664
+50|4|0|907.227162785067
+51|5|0|0
+52|5|43|106.552945357247
+53|5|42|199.552945357247
+54|5|41|291.552945357247
+55|5|40|383.552945357247
+56|5|44|476.552945357247
+57|5|46|569.381372481993
+58|5|45|661.381372481993
+59|5|48|753.381372481993
+60|5|51|756.381372481993
+61|5|101|846.381372481993
+62|5|50|938.617440459493
+63|5|52|1031.77971811966
+64|5|49|1124.77971811966
+65|5|47|1216.77971811966
+66|5|0|1234.80747449698
+67|6|0|0
+68|6|57|125
+69|6|55|217
+70|6|54|312
+71|6|53|407.385164807135
+72|6|56|501.385164807135
+73|6|58|593.385164807135
+74|6|60|686.385164807135
+75|6|59|786.825471316045
+76|6|0|821.882567601961
+77|7|0|0
+78|7|67|102.206555615734
+79|7|65|193.206555615734
+80|7|63|285.206555615734
+81|7|62|380.206555615734
+82|7|74|473.206555615734
+83|7|72|568.206555615734
+84|7|61|661.206555615734
+85|7|64|663.206555615734
+86|7|102|753.206555615734
+87|7|68|846.206555615734
+88|7|66|941.591720422868
+89|7|69|1033.59172042287
+90|7|0|1049.40310872371
+91|8|0|0
+92|8|81|137.434164902526
+93|8|78|140.434164902526
+94|8|104|230.434164902526
+95|8|76|322.434164902526
+96|8|71|417.434164902526
+97|8|70|512.434164902526
+98|8|73|605.434164902526
+99|8|77|699.434164902526
+100|8|79|790.434164902526
+101|8|80|885.81932970966
+102|8|0|937.297480414595
+103|9|0|0
+104|9|90|110.615528128088
+105|9|87|205.615528128088
+106|9|86|296.615528128088
+107|9|83|392.615528128088
+108|9|82|485.615528128088
+109|9|84|581.446480022934
+110|9|85|674.27490714768
+111|9|88|767.27490714768
+112|9|89|860.103334272426
+113|9|91|953.70888554789
+114|9|0|976.069565322888
diff --git a/src/vrppdtw/test/pdp-any-02.test.sql b/src/vrppdtw/test/pdp-any-02.test.sql
new file mode 100644
index 0000000..88be2da
--- /dev/null
+++ b/src/vrppdtw/test/pdp-any-02.test.sql
@@ -0,0 +1,3 @@
+select * from pgr_gsoc_vrppdtw(
+    'select * from customer order by id'::text, 25, 200
+);
diff --git a/src/vrppdtw/test/test.conf b/src/vrppdtw/test/test.conf
index c4d9a93..936e410 100644
--- a/src/vrppdtw/test/test.conf
+++ b/src/vrppdtw/test/test.conf
@@ -1,17 +1,26 @@
 #!/usr/bin/perl -w
 
 %main::tests = (
-                    'any' => {
-                            'comment' => 'VRPPDTW: test for any versions.',
-                                    'data' => ['pdp-any-00.data'],
-                                            'tests' => [qw(pdp-any-01)]
-                                                    },
+    'any' => {
+        'comment' => 'Function test for any versions.',
+        'data' => ['../../pickDeliver/test/pickDeliver.data'],
+        'tests' => [qw(
+            doc-gsoc_vrppdtw
+            pdp-any-02
+            )],
+        'documentation' => [qw(
+            doc-gsoc_vrppdtw
+            )],
+
+#put here the ones that you are not testing (just a place holder)
+        'nottesting' => [qw(
+            )]
+    },
+# I don't know what this are for or how to use them.
+#  TODO ask Steve 
 #    'vpg-vpgis' => {}, # for version specific tests
 #    '8-1' => {},       # for pg 8.x and postgis 1.x
 #    '9.2-2.1' => {},   # for pg 9.2 and postgis 2.1
-               );
+);
 
 1;
-                                                                                                                                           
-                                                                                                                                           
-
diff --git a/src/withPoints/doc/CMakeLists.txt b/src/withPoints/doc/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/withPoints/doc/pgr_withPoints.rst b/src/withPoints/doc/pgr_withPoints.rst
index e1e0fb9..28311d9 100644
--- a/src/withPoints/doc/pgr_withPoints.rst
+++ b/src/withPoints/doc/pgr_withPoints.rst
@@ -9,7 +9,7 @@
 
 .. _pgr_withPoints:
 
-pgr_withPoints
+pgr_withPoints - Proposed
 ===============================================================================
 
 
@@ -18,9 +18,10 @@ Name
 
 ``pgr_withPoints`` - Returns the shortest path in a graph with additional temporary vertices.
 
-.. note::  This is a proposed function for version 2.3.
 
-     - Is not officially in the version 2.2 release.
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
 
 
 .. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
@@ -61,7 +62,7 @@ The main Characteristics are:
     - start_vid ascending
     - end_vid ascending
 
-  - Runing time: :math:`O(|start\_vids|∗(V \log V + E))`
+  - Running time: :math:`O(|start\_vids|∗(V \log V + E))`
 
 
 Signature Summary
@@ -78,13 +79,13 @@ Signature Summary
 
 
 Signatures
-==========
+-------------------
 
 .. index::
-    single: withPoints(edges_sql, points_sql, start_vid, end_vid) -- proposed
+    single: withPoints(Minimal Use) - Proposed
 
-Minimal signature
------------------
+Minimal Use
+.....................................................................
 
 The minimal signature:
     - Is for a **directed** graph.
@@ -104,10 +105,10 @@ The minimal signature:
    :end-before: --e2
 
 .. index::
-    single: withPoints(edges_sql, points_sql, start_vid, end_vid, directed, driving_side, details) -- proposed
+    single: withPoints(One to One) - Proposed
 
 One to One
-----------
+.....................................................................
 
 
 .. code-block:: none
@@ -123,12 +124,13 @@ One to One
    :start-after: --e2
    :end-before: --e3
 
+
+
 .. index::
-    single: withPoints(edges_sql, points_sql, start_vid, end_vids, directed, driving_side, details) -- proposed
+    single: withPoints(One to Many) - Proposed
 
 One to Many
------------
-
+.....................................................................
 
 .. code-block:: none
 
@@ -143,12 +145,13 @@ One to Many
    :start-after: --e3
    :end-before: --e4
 
+
+
 .. index::
-    single: withPoints(edges_sql, points_sql, start_vids, end_vid, directed, driving_side, details) -- proposed
+    single: withPoints(Many to One) - Proposed
 
 Many to One
------------
-
+.....................................................................
 
 .. code-block:: none
 
@@ -164,10 +167,10 @@ Many to One
    :end-before: --e5
 
 .. index::
-    single: withPoints(edges_sql, points_sql, start_vids, end_vids, directed, driving_side, details) -- proposed
+    single: withPoints(Many to Many) - Proposed
 
 Many to Many
-------------
+.....................................................................
 
 
 .. code-block:: none
@@ -187,24 +190,29 @@ Many to Many
 
 
 Description of the Signatures
-=============================
+---------------------------------
 
 ..
     description of the sql queries
 
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
 
-.. include:: withPoints_queries.txt 
+.. include:: ../../common/src/points_input.h
+    :start-after: points_sql_start
+    :end-before: points_sql_end
 
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+.....................................................................
 
 
 ================ ====================== =================================================
 Parameter        Type                   Description
 ================ ====================== =================================================
-**edges_sql**    ``TEXT``               Edges SQL query as decribed above.
-**points_sql**   ``TEXT``               Points SQL query as decribed above.
+**edges_sql**    ``TEXT``               Edges SQL query as described above.
+**points_sql**   ``TEXT``               Points SQL query as described above.
 **start_vid**    ``ANY-INTEGER``        Starting vertex identifier. When negative: is a point's pid.
 **end_vid**      ``ANY-INTEGER``        Ending vertex identifier. When negative: is a point's pid.
 **start_vids**   ``ARRAY[ANY-INTEGER]`` Array of identifiers of starting vertices. When negative: is a point's pid.
@@ -221,7 +229,7 @@ Parameter        Type                   Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+.....................................................................
 
 Returns set of ``(seq, [path_seq,] [start_vid,] [end_vid,] node, edge, cost, agg_cost)``
 
diff --git a/src/withPoints/doc/pgr_withPointsCost.rst b/src/withPoints/doc/pgr_withPointsCost.rst
index 49ebffb..4f1a37b 100644
--- a/src/withPoints/doc/pgr_withPointsCost.rst
+++ b/src/withPoints/doc/pgr_withPointsCost.rst
@@ -9,7 +9,7 @@
 
 .. _pgr_withPointsCost:
 
-pgr_withPointsCost
+pgr_withPointsCost - Proposed
 ===============================================================================
 
 
@@ -18,9 +18,10 @@ Name
 
 ``pgr_withPointsCost`` - Calculates the shortest path and returns only the aggregate cost of the shortest path(s) found, for the combination of points given.
 
-.. note::  This is a proposed function for version 2.3.
 
-     - Is not officially in the version 2.2 release.
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
 
 
 .. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
@@ -86,17 +87,17 @@ Signature Summary
     pgr_withPointsCost(edges_sql, points_sql, start_vids, end_vids, directed, driving_side)
     RETURNS SET OF (start_vid, end_vid, agg_cost)
 
-.. note:: There is no **details** flag, unlike the other members of the family of functions.  
+.. note:: There is no **details** flag, unlike the other members of the withPoints family of functions.  
 
 
 Signatures
-==========
+------------
 
 .. index::
-    single: withPointsCost(edges_sql, points_sql, start_pid, end_pid) -- proposed
+    single: withPointsCost(Minimal Use) - proposed
 
-Minimal Usage
------------------
+Minimal Use
+.........................................
 
 The minimal signature:
     - Is for a **directed** graph.
@@ -115,10 +116,10 @@ The minimal signature:
    :end-before: --e2
 
 .. index::
-    single: withPointsCost(edges_sql, points_sql, start_pid, end_pid, directed, driving_side) -- proposed
+    single: withPointsCost(One To One) - proposed
 
 One to One
-----------
+.........................................
 
 
 .. code-block:: none
@@ -134,11 +135,12 @@ One to One
    :start-after: --e2
    :end-before: --e3
 
+
 .. index::
-    single: withPointsCost(edges_sql, points_sql, start_pid, end_pids, directed, driving_side) -- proposed
+    single: withPointsCost(One To Many) - proposed
 
 One to Many
------------
+.........................................
 
 
 .. code-block:: none
@@ -154,12 +156,12 @@ One to Many
    :start-after: --e3
    :end-before: --e4
 
-.. index::
-    single: withPointsCost(edges_sql, points_sql, start_pids, end_pid, directed, driving_side) -- proposed
 
+.. index::
+    single: withPointsCost(Many To One) - proposed
 
 Many to One
------------
+.........................................
 
 .. code-block:: none
 
@@ -175,11 +177,10 @@ Many to One
    :end-before: --e5
 
 .. index::
-    single: withPointsCost(edges_sql, points_sql, start_vids, end_vids, directed, driving_side)
-
+    single: withPointsCost(Many To Many) - proposed
 
 Many to Many
-------------
+.........................................
 
 .. code-block:: none
 
@@ -198,24 +199,29 @@ Many to Many
 
 
 Description of the Signatures
-=============================
+---------------------------------
 
 ..
     description of the sql queries
 
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
 
-.. include:: withPoints_queries.txt 
+.. include:: ../../common/src/points_input.h
+    :start-after: points_sql_start
+    :end-before: points_sql_end
 
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+.................................................
 
 
 ================ ====================== =================================================
 Parameter        Type                   Description
 ================ ====================== =================================================
-**edges_sql**    ``TEXT``               Edges SQL query as decribed above.
-**points_sql**   ``TEXT``               Points SQL query as decribed above.
+**edges_sql**    ``TEXT``               Edges SQL query as described above.
+**points_sql**   ``TEXT``               Points SQL query as described above.
 **start_vid**    ``ANY-INTEGER``        Starting vertex identifier. When negative: is a point's pid.
 **end_vid**      ``ANY-INTEGER``        Ending vertex identifier. When negative: is a point's pid.
 **start_vids**   ``ARRAY[ANY-INTEGER]`` Array of identifiers of starting vertices. When negative: is a point's pid.
@@ -230,7 +236,7 @@ Parameter        Type                   Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+.................................................
 
 Returns set of ``(start_vid, end_vid, agg_cost)``
 
diff --git a/src/withPoints/doc/pgr_withPointsDD.rst b/src/withPoints/doc/pgr_withPointsDD.rst
index d4802d2..49f5916 100644
--- a/src/withPoints/doc/pgr_withPointsDD.rst
+++ b/src/withPoints/doc/pgr_withPointsDD.rst
@@ -9,7 +9,7 @@
 
 .. _pgr_withPointsDD:
 
-pgr_withPointsDD
+pgr_withPointsDD - Proposed
 ===============================================================================
 
 
@@ -18,9 +18,10 @@ Name
 
 ``pgr_withPointsDD`` - Returns the driving distance from a starting point.
 
-.. note::  This is a proposed function for version 2.3.
 
-     - Is not officially in the version 2.2 release.
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
 
 
 .. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
@@ -48,13 +49,13 @@ Signature Summary
     RETURNS SET OF (seq, node, edge, cost, agg_cost)
 
 Signatures
-==========
+------------
 
 .. index::
-    single: withPointsDD(edges_sql, points_sql, start_vid, distance) -- proposed
+    single: withPointsDD(Minimal Use) - proposed
 
-Minimal signature
------------------
+Minimal Use
+..................................
 
 The minimal signature:
     - Is for a **directed** graph.
@@ -75,10 +76,10 @@ The minimal signature:
    :end-before: --q2
 
 .. index::
-    single: withPointsDD(edges_sql, points_sql, start_vid, distance, directed, driving_side, details) -- proposed
+    single: withPointsDD(Single Start Vertex) - proposed
 
 Driving distance from a single point
-------------------------------------
+..............................................
 
 Finds the driving distance depending on the optional parameters setup.
 
@@ -95,10 +96,10 @@ Finds the driving distance depending on the optional parameters setup.
    :end-before: --q3
 
 .. index::
-    single: withPointsDD(edges_sql, points_sql, start_vid, distance, directed, driving_side, details, equicost) -- proposed
+    single: withPointsDD(Multiple Starting Vertices) - proposed
 
 Driving distance from many starting points
-------------------------------------------
+..................................................
 
 Finds the driving distance depending on the optional parameters setup.
 
@@ -112,25 +113,30 @@ Finds the driving distance depending on the optional parameters setup.
 
 
 Description of the Signatures
-=============================
-
+----------------------------------
 
 ..
     description of the sql queries
 
 
-.. include:: withPoints_queries.txt 
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
+
+.. include:: ../../common/src/points_input.h
+    :start-after: points_sql_start
+    :end-before: points_sql_end
 
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+........................................................
 
 
 ================ ================= =================================================
 Parameter        Type              Description
 ================ ================= =================================================
-**edges_sql**    ``TEXT``          Edges SQL query as decribed above.
-**points_sql**   ``TEXT``          Points SQL query as decribed above.
+**edges_sql**    ``TEXT``          Edges SQL query as described above.
+**points_sql**   ``TEXT``          Points SQL query as described above.
 **start_vid**    ``ANY-INTEGER``   Starting point id
 **distance**     ``ANY-NUMERICAL`` Distance from the start_pid
 **directed**     ``BOOLEAN``       (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
@@ -146,7 +152,7 @@ Parameter        Type              Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+........................................................
 
 Returns set of ``(seq, node, edge, cost, agg_cost)``
 
diff --git a/src/withPoints/doc/pgr_withPointsKSP.rst b/src/withPoints/doc/pgr_withPointsKSP.rst
index 8aa9b7f..a449715 100644
--- a/src/withPoints/doc/pgr_withPointsKSP.rst
+++ b/src/withPoints/doc/pgr_withPointsKSP.rst
@@ -9,7 +9,7 @@
 
 .. _pgr_withPointsKSP:
 
-pgr_withPointsKSP
+pgr_withPointsKSP - Proposed
 ===============================================================================
 
 
@@ -18,10 +18,10 @@ Name
 
 ``pgr_withPointsKSP`` - Find the K shortest paths using Yen's algorithm.
 
-.. note::  This is a proposed function for version 2.3.
-
-     - Is not officially in the version 2.2 release.
 
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
 
 .. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
    :target: http://www.boost.org/libs/graph
@@ -45,13 +45,13 @@ Signature Summary
     RETURNS SET OF (seq, path_id, path_seq, node, edge, cost, agg_cost)
 
 Signatures
-==========
+-----------
 
 .. index::
-    single: withPointsKSP(edges_sql, points_sql, start_pid, end_pid, K) -- proposed
+    single: withPointsKSP(Minimal Signature) - Proposed
 
 Minimal Usage
------------------
+....................................
 
 The minimal usage:
     - Is for a **directed** graph.
@@ -72,10 +72,10 @@ The minimal usage:
    :end-before: --q2
 
 .. index::
-    single: withPointsKSP(edges_sql, points_sql, start_pid, end_pid, K, directed, heap_paths, driving_side, details) -- proposed
+    single: withPointsKSP(Complete Signature) - Proposed
 
 Complete Signature
-------------------------------------
+....................................
 
 Finds the K shortest paths depending on the optional parameters setup.
 
@@ -93,25 +93,31 @@ Finds the K shortest paths depending on the optional parameters setup.
    :end-before: --q3
 
 Description of the Signatures
-=============================
+-------------------------------
 
 
 ..
     description of the sql queries
 
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
+
+.. include:: ../../common/src/points_input.h
+    :start-after: points_sql_start
+    :end-before: points_sql_end
 
-.. include:: withPoints_queries.txt 
 
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+..............................................................
 
 
 ================ ================= =================================================
 Parameter        Type              Description
 ================ ================= =================================================
-**edges_sql**    ``TEXT``          Edges SQL query as decribed above.
-**points_sql**   ``TEXT``          Points SQL query as decribed above.
+**edges_sql**    ``TEXT``          Edges SQL query as described above.
+**points_sql**   ``TEXT``          Points SQL query as described above.
 **start_pid**    ``ANY-INTEGER``   Starting point id.
 **end_pid**      ``ANY-INTEGER``   Ending point id.
 **K**            ``INTEGER``       Number of shortest paths.
@@ -128,7 +134,7 @@ Parameter        Type              Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+..............................................................
 
 Returns set of ``(seq, path_id, path_seq, node, edge, cost, agg_cost)``
 
@@ -136,7 +142,7 @@ Returns set of ``(seq, path_id, path_seq, node, edge, cost, agg_cost)``
 Column           Type              Description
 ============ =========== =================================================
 **seq**      ``INTEGER`` Row sequence.
-**path_seq** ``INTEGER`` Relative position in the path of node and edge. Has value 1 for the begining of a path.
+**path_seq** ``INTEGER`` Relative position in the path of node and edge. Has value 1 for the beginning of a path.
 **path_id**  ``INTEGER``  Path identifier. The ordering of the paths: For two paths i, j if i < j then agg_cost(i) <= agg_cost(j).
 **node**     ``BIGINT``  Identifier of the node in the path. Negative values are the identifiers of a point.
 **edge**     ``BIGINT``  Identifier of the edge used to go from ``node`` to the next node in the path sequence. 
diff --git a/src/withPoints/doc/pgr_withPointsVia.rst b/src/withPoints/doc/pgr_withPointsVia.rst
index dc959ac..4ad9fea 100644
--- a/src/withPoints/doc/pgr_withPointsVia.rst
+++ b/src/withPoints/doc/pgr_withPointsVia.rst
@@ -9,18 +9,20 @@
 
 .. _pgr_withPointsVia:
 
-pgr_withPointsVia
+pgr_withPointsVia - Proposed
 ===============================================================================
 
 
 Name
 -------------------------------------------------------------------------------
 
-``pgr_withPointsVia`` - Returns the driving distance from a starting point.
+``pgr_withPointsVia`` - Get a path using the vertices/points indicated
 
-.. note::  This is a proposed function for version 2.3.
 
-     - Is not officially in the version 2.2 release.
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
+
 
 
 .. figure:: ../../../doc/src/introduction/images/boost-inside.jpeg
@@ -47,13 +49,13 @@ Signature Summary
     RETURNS SET OF (seq, node, edge, cost, agg_cost)
 
 Signatures
-==========
+-----------------
 
 .. index::
 	single: withPointsVia(edges_sql, points_sql, start_pid, distance) -- proposed
 
 Minimal signature
------------------
+...................................................
 
 The minimal signature:
     - Is for a **directed** graph.
@@ -76,7 +78,7 @@ The minimal signature:
 	single: withPointsVia(edges_sql, points_sql, start_pid, distance, directed, driving_side, details) -- proposed
 
 Driving distance from a single point
-------------------------------------
+...................................................
 
 Finds the driving distance depending on the optional parameters setup.
 
@@ -94,25 +96,31 @@ Finds the driving distance depending on the optional parameters setup.
    :end-before: --q3
 
 Description of the Signatures
-=============================
+---------------------------------------------------
 
 
 ..
     description of the sql queries
 
+.. include:: ../../common/src/edges_input.h
+    :start-after: basic_edges_sql_start
+    :end-before: basic_edges_sql_end
+
+.. include:: ../../common/src/points_input.h
+    :start-after: points_sql_start
+    :end-before: points_sql_end
 
-.. include:: withPoints_queries.txt 
 
 
 Description of the parameters of the signatures
--------------------------------------------------------------------------------
+...................................................
 
 
 ================ ================= =================================================
 Parameter        Type              Description
 ================ ================= =================================================
-**edges_sql**    ``TEXT``          Edges SQL query as decribed above.
-**points_sql**   ``TEXT``          Points SQL query as decribed above.
+**edges_sql**    ``TEXT``          Edges SQL query as described above.
+**points_sql**   ``TEXT``          Points SQL query as described above.
 **start_pid**    ``ANY-INTEGER``   Starting point id.
 **distance**     ``ANY_NUMERICAL`` Distance from the start_pid
 **directed**     ``BOOLEAN``       (optional). When ``false`` the graph is considered as Undirected. Default is ``true`` which considers the graph as Directed.
@@ -127,7 +135,7 @@ Parameter        Type              Description
 
 
 Description of the return values
--------------------------------------------------------------------------------
+...................................................
 
 Returns set of ``(seq, node, edge, cost, agg_cost)``
 
@@ -167,7 +175,6 @@ The examples in this section use the following :ref:`fig1`
 
 
 
-The queries use the :ref:`sampledata` network.
 
 
 
@@ -182,6 +189,7 @@ See Also
 * :ref:`pgr_drivingDistance` - Driving distance using dijkstra.
 * :ref:`pgr_alphashape` - Alpha shape computation.
 * :ref:`pgr_points_as_polygon` - Polygon around set of points.
+* The queries use the :ref:`sampledata` network.
 
 .. rubric:: Indices and tables
 
diff --git a/src/withPoints/doc/withPoints.rst b/src/withPoints/doc/withPoints.rst
index 9879bd1..3aa5489 100644
--- a/src/withPoints/doc/withPoints.rst
+++ b/src/withPoints/doc/withPoints.rst
@@ -17,19 +17,26 @@ When points are also given as input:
 
     - :ref:`pgr_withPoints` - Route from/to points anywhere on the graph.
     - :ref:`pgr_withPointsCost` - Costs of the shortest paths.
+    - :ref:`pgr_withPointsCostMatrix` - Costs of the shortest paths.
     - :ref:`pgr_withPointsKSP` - K shortest paths.
     - :ref:`pgr_withPointsDD` - Driving distance.
 
-.. note:: The numbering of the points are handled with negative sign.
+.. toctree::
+    :hidden: 
 
-          - Original point identifiers are to be positive.
-          - Transformation to negative is done internally.
-          - For results for involving vertices identifiers 
+    ./pgr_withPoints
+    ./pgr_withPointsCost
+    ../../costMatrix/doc/pgr_withPointsCostMatrix
+    ./pgr_withPointsKSP
+    ./pgr_withPointsDD
+
+
+
+.. include:: ../../proposedNext.rst
+   :start-after: begin-warning
+   :end-before: end-warning
 
-            - positive sign is a vertex of the original grpah
-            - negative sign is a point of the temporary points
 
-          The reason for doing this is to avoid confusion when there is a vertex with the same number as identifier as the points identifier.
 
 
 Images
@@ -95,7 +102,18 @@ In all this functions we have to take care of as many aspects as possible:
 - Some points are:
 
   - Permanent, for example the set of points of clients stored in a table in the data base
-  - Temporal, for example points given thru a web application
+  - Temporal, for example points given through a web application
+
+- The numbering of the points are handled with negative sign.
+
+  - Original point identifiers are to be positive.
+  - Transformation to negative is done internally.
+  - For results for involving vertices identifiers 
+
+    - positive sign is a vertex of the original grpah
+    - negative sign is a point of the temporary points
+
+The reason for doing this is to avoid confusion when there is a vertex with the same number as identifier as the points identifier.
 
 Graph & edges
 ----------------
@@ -164,12 +182,3 @@ From third image above:
     - (15, 9,-1, 3) edge from vertex 9 to point 1 has cost 3
     - (15, -1,12, 7) edge from point 1 to vertex 12 has cost 7
 
-.. toctree::
-    :hidden: 
-
-    ./pgr_withPoints
-    ./pgr_withPointsCost
-    ./pgr_withPointsKSP
-    ./pgr_withPointsDD
-
-
diff --git a/src/withPoints/doc/withPoints_queries.txt b/src/withPoints/doc/withPoints_queries.txt
deleted file mode 100644
index 5f7886c..0000000
--- a/src/withPoints/doc/withPoints_queries.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-.. 
-   ****************************************************************************
-    pgRouting Manual
-    Copyright(c) pgRouting Contributors
-
-    This documentation is licensed under a Creative Commons Attribution-Share
-    Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
-   ****************************************************************************
-
-
-Description of the Edges SQL query
--------------------------------------------------------------------------------
-
-:edges_sql: an SQL query, which should return a set of rows with the following columns:
-
-================  ===================   =================================================
-Column            Type                  Description
-================  ===================   =================================================
-**id**            ``ANY-INTEGER``       Identifier of the edge.
-**source**        ``ANY-INTEGER``       Identifier of the first end point vertex of the edge.
-**target**        ``ANY-INTEGER``       Identifier of the second end point vertex of the edge.
-**cost**          ``ANY-NUMERICAL``     Weight of the edge `(source, target)`, If negative: edge `(source, target)` does not exist, therefore it's not part of the graph.
-**reverse_cost**  ``ANY-NUMERICAL``     (optional) Weight of the edge `(target, source)`, If negative: edge `(target, source)` does not exist, therefore it's not part of the graph.
-================  ===================   =================================================
-
-
-Description of the Points SQL query
--------------------------------------------------------------------------------
-
-:points_sql: an SQL query, which should return a set of rows with the following columns:
-
-============ ================= =================================================
-Column            Type              Description
-============ ================= =================================================
-**pid**      ``ANY-INTEGER``   (optional) Identifier of the point.
-                                 - Can not be NULL. 
-                                 - If column not present, a sequential identifier will be given automatically.
-
-**edge_id**  ``ANY-INTEGER``   Identifier of the "closest" edge to the point.
-**fraction** ``ANY-NUMERICAL`` Value in <0,1> that indicates the relative postition from the first end point of the edge.
-**side**     ``CHAR``          (optional) Value in ['b', 'r', 'l', NULL] indicating if the point is:
-                                 - In the right, left of the edge or
-                                 - If it doesn't matter with 'b' or NULL.
-                                 - If column not present 'b' is considered.
-============ ================= =================================================
-
-Where:
-
-:ANY-INTEGER: smallint, int, bigint
-:ANY-NUMERICAL: smallint, int, bigint, real, float
-
diff --git a/src/withPoints/src/get_new_queries.cpp b/src/withPoints/src/get_new_queries.cpp
index 5424878..4065fe4 100644
--- a/src/withPoints/src/get_new_queries.cpp
+++ b/src/withPoints/src/get_new_queries.cpp
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#include <sstream>
 #include "string.h"
+#include <sstream>
 #include "./get_new_queries.h"
 
 
@@ -38,18 +38,17 @@ get_new_queries(
         char *points_sql,
         char **edges_of_points_query,
         char **edges_no_points_query) {
-
     std::ostringstream edges_of_points_sql;
     std::ostringstream edges_no_points_sql;
 
     edges_of_points_sql << "WITH "
-        << " edges AS (" << edges_sql << "),"
+        << " edges AS (" << edges_sql << "), "
         << " points AS (" << points_sql << ")"
         << " SELECT DISTINCT edges.* FROM edges JOIN points ON (id = edge_id)";
     *edges_of_points_query = strdup(edges_of_points_sql.str().c_str());
 
     edges_no_points_sql << "WITH "
-        << " edges AS (" << edges_sql << "),"
+        << " edges AS (" << edges_sql << "), "
         << " points AS (" << points_sql << ")"
         << " SELECT edges.* FROM edges WHERE NOT EXISTS (SELECT edge_id FROM points WHERE id = edge_id)";
     *edges_no_points_query = strdup(edges_no_points_sql.str().c_str());
diff --git a/src/withPoints/src/get_new_queries.h b/src/withPoints/src/get_new_queries.h
index 147c05e..6d5f9dd 100644
--- a/src/withPoints/src/get_new_queries.h
+++ b/src/withPoints/src/get_new_queries.h
@@ -4,9 +4,9 @@ File: get_new_queries.h
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -25,6 +25,8 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
+#ifndef SRC_WITHPOINTS_SRC_GET_NEW_QUERIES_H_
+#define SRC_WITHPOINTS_SRC_GET_NEW_QUERIES_H_
 
 #pragma once
 
@@ -34,7 +36,7 @@ extern "C" {
 
     void get_new_queries(
             char *edges_sql,
-            char *points_sql, 
+            char *points_sql,
             char **edges_of_points_query,
             char **edges_no_points_query);
 
@@ -43,3 +45,4 @@ extern "C" {
 }
 #endif
 
+#endif  // SRC_WITHPOINTS_SRC_GET_NEW_QUERIES_H_
diff --git a/src/withPoints/src/many_to_many_withPoints.c b/src/withPoints/src/many_to_many_withPoints.c
index f697ab8..22607f5 100644
--- a/src/withPoints/src/many_to_many_withPoints.c
+++ b/src/withPoints/src/many_to_many_withPoints.c
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -36,7 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "access/htup_details.h"
 #endif
 
-//#define DEBUG
 
 #include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
@@ -49,13 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./get_new_queries.h"
 #include "./many_to_many_withPoints_driver.h"
 
-PG_FUNCTION_INFO_V1(many_to_many_withPoints);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-many_to_many_withPoints(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum many_to_many_withPoints(PG_FUNCTION_ARGS);
 
 
 /*******************************************************************************/
@@ -79,8 +72,6 @@ process(
         General_path_element_t **result_tuples,
         size_t *result_count) {
 
-    driving_side[0] = tolower(driving_side[0]);
-
     pgr_SPI_connect();
 
     Point_on_edge_t *points = NULL;
@@ -98,17 +89,17 @@ process(
 
     pgr_edge_t *edges_of_points = NULL;
     size_t total_edges_of_points = 0;
-    pgr_get_data_5_columns(edges_of_points_query, &edges_of_points, &total_edges_of_points);
+    pgr_get_edges(edges_of_points_query, &edges_of_points, &total_edges_of_points);
 
 
     pgr_edge_t *edges = NULL;
     size_t total_edges = 0;
-    pgr_get_data_5_columns(edges_no_points_query, &edges, &total_edges);
+    pgr_get_edges(edges_no_points_query, &edges, &total_edges);
 
     free(edges_of_points_query);
     free(edges_no_points_query);
 
-    if ( (total_edges + total_edges_of_points) == 0) {
+    if ((total_edges + total_edges_of_points) == 0) {
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
@@ -116,9 +107,10 @@ process(
     }
 
     char *err_msg = NULL;
+    char *log_msg = NULL;
     clock_t start_t = clock();
-    int  errcode = do_pgr_many_to_many_withPoints(
-            edges,  total_edges,
+    do_pgr_many_to_many_withPoints(
+            edges, total_edges,
             points, total_points,
             edges_of_points, total_edges_of_points,
             start_pidsArr, size_start_pidsArr,
@@ -130,31 +122,27 @@ process(
             result_tuples,
             result_count,
             &err_msg);
-    time_msg(" processing withPoints many to many", start_t, clock());
+    time_msg("Processing withPoints many to many", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
-
-    free(err_msg);
-    pfree(edges);
+    PGR_DBG("LOG: %s\n", err_msg);
+    if (log_msg) free(log_msg);
 
-    pgr_SPI_finish();
-
-    
-    if (errcode)  {
+    if (err_msg) {
         free(start_pidsArr);
         free(end_pidsArr);
-        pgr_send_error(errcode);
+        free(*result_tuples);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
     }
+    pfree(edges);
+    pgr_SPI_finish();
 }
 
 /*                                                                             */
 /*******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(many_to_many_withPoints);
 PGDLLEXPORT Datum
-#endif
 many_to_many_withPoints(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
@@ -164,7 +152,7 @@ many_to_many_withPoints(PG_FUNCTION_ARGS) {
     /*******************************************************************************/
     /*                          MODIFY AS NEEDED                                   */
     /*                                                                             */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                             */
     /*******************************************************************************/
@@ -253,7 +241,7 @@ many_to_many_withPoints(PG_FUNCTION_ARGS) {
         nulls = palloc(8 * sizeof(bool));
 
         size_t i;
-        for(i = 0; i < 8; ++i) {
+        for (i = 0; i < 8; ++i) {
             nulls[i] = false;
         }
 
diff --git a/src/withPoints/src/many_to_many_withPoints_driver.cpp b/src/withPoints/src/many_to_many_withPoints_driver.cpp
index 2dfadb0..2a35349 100644
--- a/src/withPoints/src/many_to_many_withPoints_driver.cpp
+++ b/src/withPoints/src/many_to_many_withPoints_driver.cpp
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
@@ -36,20 +36,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #include <sstream>
 #include <deque>
+#include <algorithm>
+#include <set>
 #include <vector>
 #include <cassert>
 
-// #define DEBUG
 
 #include "./pgr_dijkstra.hpp"
 #include "./pgr_withPoints.hpp"
 #include "./many_to_many_withPoints_driver.h"
-
-extern "C" {
 #include "./../../common/src/pgr_types.h"
-}
-
-#include "./../../common/src/memory_func.hpp"
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_alloc.hpp"
 
 
 // CREATE OR REPLACE FUNCTION pgr_withPoint(
@@ -61,15 +59,15 @@ extern "C" {
 
 int
 do_pgr_many_to_many_withPoints(
-        pgr_edge_t  *edges,
+        pgr_edge_t *edges,
         size_t total_edges,
-        Point_on_edge_t  *points_p,
+        Point_on_edge_t *points_p,
         size_t total_points,
-        pgr_edge_t  *edges_of_points,
+        pgr_edge_t *edges_of_points,
         size_t total_edges_of_points,
-        int64_t  *start_pidsArr,
+        int64_t *start_pidsArr,
         size_t size_start_pidsArr,
-        int64_t  *end_pidsArr,
+        int64_t *end_pidsArr,
         size_t size_end_pidsArr,
 
         char driving_side,
@@ -78,7 +76,7 @@ do_pgr_many_to_many_withPoints(
         bool only_cost,
         General_path_element_t **return_tuples,
         size_t *return_count,
-        char ** err_msg){
+        char ** err_msg) {
     std::ostringstream log;
     try {
         std::vector< Point_on_edge_t >
@@ -131,46 +129,45 @@ do_pgr_many_to_many_withPoints(
         }
 #endif
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_edges;
 
         std::deque< Path > paths;
 
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(edges, total_edges);
             digraph.graph_insert_data(new_edges);
             pgr_dijkstra(digraph, paths, start_vertices, end_vertices, only_cost);
         } else {
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(edges, total_edges);
             undigraph.graph_insert_data(new_edges);
             pgr_dijkstra(undigraph, paths, start_vertices, end_vertices, only_cost);
         }
 
 #if 0
-        for (auto &path :paths) {
+        for (auto &path : paths) {
             adjust_pids(points, path);
         }
 #endif
         if (!details) {
-            for (auto &path :paths) {
+            for (auto &path : paths) {
                 eliminate_details(path, edges_to_modify);
             }
         }
 
         /*
-         *  order paths based on the start_pid, end_pid
+         * order paths based on the start_pid, end_pid
          */
         std::sort(paths.begin(), paths.end(),
-                [](const Path &a,const  Path &b)
+                [](const Path &a, const Path &b)
                 -> bool {
                 if (b.start_id() != a.start_id()) {
                 return a.start_id() < b.start_id();
                 }
-                return a.end_id() < b.end_id();  
+                return a.end_id() < b.end_id();
                 });
 
         size_t count(0);
@@ -186,25 +183,28 @@ do_pgr_many_to_many_withPoints(
             return 0;
         }
 
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         log << "Converting a set of paths into the tuples\n";
         (*return_count) = (collapse_paths(return_tuples, paths));
 
-#ifndef DEBUG
-        {
-            std::ostringstream log;
-            log << "OK";
-            *err_msg = strdup(log.str().c_str());
-        }
-#else
-        *err_msg = strdup(log.str().c_str());
-#endif
         return 0;
-    } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        log << except.what() << "\n";
+        *err_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        log << "Caught unknown exception!\n";
         *err_msg = strdup(log.str().c_str());
-        return 1000;
     }
-    return 0;
+
+    return 1000;
 }
 
diff --git a/src/withPoints/src/many_to_many_withPoints_driver.h b/src/withPoints/src/many_to_many_withPoints_driver.h
index a9ee9b3..c419749 100644
--- a/src/withPoints/src/many_to_many_withPoints_driver.h
+++ b/src/withPoints/src/many_to_many_withPoints_driver.h
@@ -4,9 +4,9 @@ File: many_to_many_withPoints_driver.h
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_WITHPOINTS_SRC_MANY_TO_MANY_WITHPOINTS_DRIVER_H_
+#define SRC_WITHPOINTS_SRC_MANY_TO_MANY_WITHPOINTS_DRIVER_H_
+
 #pragma once
 
 #include "./../../common/src/pgr_types.h"
@@ -34,26 +37,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-//  CREATE OR REPLACE FUNCTION pgr_withPoint(
-//  edges_sql TEXT,
-//  points_sql TEXT,
-//  start_pid ANYARRAY,
-//  end_pid BIGINT,
-//  directed BOOLEAN DEFAULT true,
+// CREATE OR REPLACE FUNCTION pgr_withPoint(
+// edges_sql TEXT,
+// points_sql TEXT,
+// start_pid ANYARRAY,
+// end_pid BIGINT,
+// directed BOOLEAN DEFAULT true,
     int do_pgr_many_to_many_withPoints(
-            pgr_edge_t  *edges,
+            pgr_edge_t *edges,
             size_t total_edges,
 
-            Point_on_edge_t  *points,
+            Point_on_edge_t *points,
             size_t total_points,
 
-            pgr_edge_t  *edges_of_points,
+            pgr_edge_t *edges_of_points,
             size_t total_edges_of_points,
 
-            int64_t  *start_pidsArr,
+            int64_t *start_pidsArr,
             size_t size_start_pidsArr,
 
-            int64_t  *end_pidsArr,
+            int64_t *end_pidsArr,
             size_t size_end_pidsArr,
 
 
@@ -69,3 +72,4 @@ extern "C" {
 }
 #endif
 
+#endif  // SRC_WITHPOINTS_SRC_MANY_TO_MANY_WITHPOINTS_DRIVER_H_
diff --git a/src/withPoints/src/many_to_one_withPoints.c b/src/withPoints/src/many_to_one_withPoints.c
index 46a86e4..dab7dd0 100644
--- a/src/withPoints/src/many_to_one_withPoints.c
+++ b/src/withPoints/src/many_to_one_withPoints.c
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -36,7 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "access/htup_details.h"
 #endif
 
-//#define DEBUG
 
 #include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
@@ -49,13 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./get_new_queries.h"
 #include "./many_to_one_withPoints_driver.h"
 
-PG_FUNCTION_INFO_V1(many_to_one_withPoints);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-many_to_one_withPoints(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum many_to_one_withPoints(PG_FUNCTION_ARGS);
 
 
 /*******************************************************************************/
@@ -74,8 +67,7 @@ process(
         bool only_cost,
         General_path_element_t **result_tuples,
         size_t *result_count) {
-
-    driving_side[0] = tolower(driving_side[0]);
+    driving_side[0] = (char) tolower(driving_side[0]);
 
     pgr_SPI_connect();
 
@@ -94,17 +86,17 @@ process(
 
     pgr_edge_t *edges_of_points = NULL;
     size_t total_edges_of_points = 0;
-    pgr_get_data_5_columns(edges_of_points_query, &edges_of_points, &total_edges_of_points);
+    pgr_get_edges(edges_of_points_query, &edges_of_points, &total_edges_of_points);
 
 
     pgr_edge_t *edges = NULL;
     size_t total_edges = 0;
-    pgr_get_data_5_columns(edges_no_points_query, &edges, &total_edges);
+    pgr_get_edges(edges_no_points_query, &edges, &total_edges);
 
     free(edges_of_points_query);
     free(edges_no_points_query);
 
-    if ( (total_edges + total_edges_of_points) == 0) {
+    if ((total_edges + total_edges_of_points) == 0) {
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
@@ -113,8 +105,8 @@ process(
 
     char *err_msg = NULL;
     clock_t start_t = clock();
-    int  errcode = do_pgr_many_to_one_withPoints(
-            edges,  total_edges,
+    int errcode = do_pgr_many_to_one_withPoints(
+            edges, total_edges,
             points, total_points,
             edges_of_points, total_edges_of_points,
             start_pidsArr, size_start_pidsArr,
@@ -129,13 +121,14 @@ process(
     time_msg(" processing withPoints many to one", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
     PGR_DBG("Returned message = %s\n", err_msg);
-    if (!err_msg) free(err_msg);
+
+    if (err_msg) free(err_msg);
 
     pfree(edges);
     pgr_SPI_finish();
 
-    
-    if (errcode)  {
+
+    if (errcode) {
         free(start_pidsArr);
         pgr_send_error(errcode);
     }
@@ -144,11 +137,8 @@ process(
 /*                                                                             */
 /*******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(many_to_one_withPoints);
 PGDLLEXPORT Datum
-#endif
 many_to_one_withPoints(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
@@ -158,7 +148,7 @@ many_to_one_withPoints(PG_FUNCTION_ARGS) {
     /*******************************************************************************/
     /*                          MODIFY AS NEEDED                                   */
     /*                                                                             */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                             */
     /*******************************************************************************/
@@ -241,7 +231,7 @@ many_to_one_withPoints(PG_FUNCTION_ARGS) {
         nulls = palloc(7 * sizeof(bool));
 
         size_t i;
-        for(i = 0; i < 7; ++i) {
+        for (i = 0; i < 7; ++i) {
             nulls[i] = false;
         }
 
diff --git a/src/withPoints/src/many_to_one_withPoints_driver.cpp b/src/withPoints/src/many_to_one_withPoints_driver.cpp
index 8d961e5..83ac5b6 100644
--- a/src/withPoints/src/many_to_one_withPoints_driver.cpp
+++ b/src/withPoints/src/many_to_one_withPoints_driver.cpp
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -28,12 +28,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
 
+#include <algorithm>
+#include <set>
 #include <sstream>
 #include <deque>
 #include <vector>
@@ -42,12 +44,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./pgr_dijkstra.hpp"
 #include "./pgr_withPoints.hpp"
 #include "./many_to_one_withPoints_driver.h"
-extern "C" {
 #include "./../../common/src/pgr_types.h"
-}
-#include "./../../common/src/memory_func.hpp"
+#include "./../../common/src/pgr_alloc.hpp"
 
-// #define DEBUG
 
 // CREATE OR REPLACE FUNCTION pgr_withPoint(
 // edges_sql TEXT,
@@ -59,17 +58,17 @@ extern "C" {
 
 int
 do_pgr_many_to_one_withPoints(
-        pgr_edge_t  *edges,                     size_t total_edges,
-        Point_on_edge_t  *points_p,             size_t total_points,
-        pgr_edge_t  *edges_of_points,           size_t total_edges_of_points,
-        int64_t  *start_pidsArr,                size_t size_start_pidsArr,
+        pgr_edge_t *edges, size_t total_edges,
+        Point_on_edge_t *points_p, size_t total_points,
+        pgr_edge_t *edges_of_points, size_t total_edges_of_points,
+        int64_t *start_pidsArr, size_t size_start_pidsArr,
         int64_t end_vid,
         char driving_side,
         bool details,
         bool directed,
         bool only_cost,
         General_path_element_t **return_tuples, size_t *return_count,
-        char ** err_msg){
+        char ** err_msg) {
     std::ostringstream log;
     try {
         std::vector< Point_on_edge_t >
@@ -98,41 +97,40 @@ do_pgr_many_to_one_withPoints(
         std::vector< int64_t > start_vertices(s_start_vertices.begin(), s_start_vertices.end());
 
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_edges;
 
         std::deque< Path > paths;
 
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(gType);
             digraph.graph_insert_data(edges, total_edges);
             digraph.graph_insert_data(new_edges);
             pgr_dijkstra(digraph, paths, start_vertices, end_vid, only_cost);
         } else {
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(edges, total_edges);
             undigraph.graph_insert_data(new_edges);
             pgr_dijkstra(undigraph, paths, start_vertices, end_vid, only_cost);
         }
 
 #if 0
-        for (auto &path :paths) {
+        for (auto &path : paths) {
             adjust_pids(points, path);
         }
 #endif
         if (!details) {
-            for (auto &path :paths) {
+            for (auto &path : paths) {
                 eliminate_details(path, edges_to_modify);
             }
         }
 
         /*
-         *  order paths based on the start_pid
+         * order paths based on the start_pid
          */
-        std::sort(paths.begin(), paths.end(), [](const Path &a,const  Path &b) {
-                return a.start_id() < b.start_id();   
+        std::sort(paths.begin(), paths.end(), [](const Path &a, const Path &b) {
+                return a.start_id() < b.start_id();
                 });
 
         size_t count(0);
@@ -148,11 +146,11 @@ do_pgr_many_to_one_withPoints(
             return 0;
         }
 
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         log << "Converting a set of paths into the tuples\n";
         (*return_count) = (collapse_paths(return_tuples, paths));
 
-#ifndef DEBUG
+#ifndef NDEBUG
         {
             std::ostringstream log;
             log << "OK";
@@ -164,7 +162,7 @@ do_pgr_many_to_one_withPoints(
 #endif
         return 0;
     } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+        log << "Caught unknown exception!\n";
         *err_msg = strdup(log.str().c_str());
         return 1000;
     }
diff --git a/src/withPoints/src/many_to_one_withPoints_driver.h b/src/withPoints/src/many_to_one_withPoints_driver.h
index 841cf61..1f986d4 100644
--- a/src/withPoints/src/many_to_one_withPoints_driver.h
+++ b/src/withPoints/src/many_to_one_withPoints_driver.h
@@ -4,9 +4,9 @@ File: withPoints_driver.h
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_WITHPOINTS_SRC_MANY_TO_ONE_WITHPOINTS_DRIVER_H_
+#define SRC_WITHPOINTS_SRC_MANY_TO_ONE_WITHPOINTS_DRIVER_H_
+
 #pragma once
 
 #include "./../../common/src/pgr_types.h"
@@ -34,17 +37,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-//  CREATE OR REPLACE FUNCTION pgr_withPoint(
-//  edges_sql TEXT,
-//  points_sql TEXT,
-//  start_pid ANYARRAY,
-//  end_pid BIGINT,
-//  directed BOOLEAN DEFAULT true,
+// CREATE OR REPLACE FUNCTION pgr_withPoint(
+// edges_sql TEXT,
+// points_sql TEXT,
+// start_pid ANYARRAY,
+// end_pid BIGINT,
+// directed BOOLEAN DEFAULT true,
     int do_pgr_many_to_one_withPoints(
-            pgr_edge_t  *edges,                     size_t total_edges,
-            Point_on_edge_t  *points,               size_t total_points,
-            pgr_edge_t  *edges_of_points,           size_t total_edges_of_points,
-            int64_t  *start_pidsArr,                size_t size_start_pidsArr,
+            pgr_edge_t *edges, size_t total_edges,
+            Point_on_edge_t *points, size_t total_points,
+            pgr_edge_t *edges_of_points, size_t total_edges_of_points,
+            int64_t *start_pidsArr, size_t size_start_pidsArr,
 
             int64_t end_pid,
 
@@ -60,3 +63,4 @@ extern "C" {
 }
 #endif
 
+#endif  // SRC_WITHPOINTS_SRC_MANY_TO_ONE_WITHPOINTS_DRIVER_H_
diff --git a/src/withPoints/src/msg_logger.hpp b/src/withPoints/src/msg_logger.hpp
index 11124d4..da51caf 100644
--- a/src/withPoints/src/msg_logger.hpp
+++ b/src/withPoints/src/msg_logger.hpp
@@ -4,9 +4,9 @@ File: msg_logger.hpp
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #pragma once
 
+#include <string>
+#include <vector>
 #include "./../../common/src/pgr_types.h"
 
 void
diff --git a/src/withPoints/src/one_to_many_withPoints.c b/src/withPoints/src/one_to_many_withPoints.c
index 0f691e2..3f5d82b 100644
--- a/src/withPoints/src/one_to_many_withPoints.c
+++ b/src/withPoints/src/one_to_many_withPoints.c
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -36,7 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "access/htup_details.h"
 #endif
 
-// #define DEBUG
 
 #include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
@@ -49,13 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./get_new_queries.h"
 #include "./one_to_many_withPoints_driver.h"
 
-PG_FUNCTION_INFO_V1(one_to_many_withPoints);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-one_to_many_withPoints(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum one_to_many_withPoints(PG_FUNCTION_ARGS);
 
 
 /*******************************************************************************/
@@ -74,15 +67,13 @@ process(
         bool only_cost,
         General_path_element_t **result_tuples,
         size_t *result_count) {
-
-    driving_side[0] = tolower(driving_side[0]);
-    PGR_DBG("driving side:%c",driving_side[0]);
-    if (! ((driving_side[0] == 'r')
-                || (driving_side[0] == 'l'))) {
-        driving_side[0] = 'b'; 
+    driving_side[0] = (char) tolower(driving_side[0]);
+    PGR_DBG("driving side:%c", driving_side[0]);
+    if (!((driving_side[0] == 'r')
+                 || (driving_side[0] == 'l'))) {
+        driving_side[0] = 'b';
     }
-    PGR_DBG("estimated driving side:%c",driving_side[0]);
-
+    PGR_DBG("estimated driving side:%c", driving_side[0]);
     pgr_SPI_connect();
 
     PGR_DBG("load the points");
@@ -90,17 +81,18 @@ process(
     size_t total_points = 0;
     pgr_get_points(points_sql, &points, &total_points);
 
-#ifdef DEBUG
+#if 0
+#ifndef NDEBUG
     size_t i = 0;
     for (i = 0; i < total_points; i ++) {
-        PGR_DBG("%ld\t%ld\t%f\t%c",points[i].pid, points[i].edge_id, points[i].fraction, points[i].side);
+        PGR_DBG("%ld\t%ld\t%f\t%c", points[i].pid, points[i].edge_id, points[i].fraction, points[i].side);
     }
 #endif
-
+#endif
     /*
      * TODO move this code to c++
      */
-    PGR_DBG("  -- change the query");
+    PGR_DBG(" -- change the query");
     char *edges_of_points_query = NULL;
     char *edges_no_points_query = NULL;
     get_new_queries(
@@ -114,10 +106,11 @@ process(
     PGR_DBG("load the edges that match the points");
     pgr_edge_t *edges_of_points = NULL;
     size_t total_edges_of_points = 0;
-    pgr_get_data_5_columns(edges_of_points_query, &edges_of_points, &total_edges_of_points);
+    pgr_get_edges(edges_of_points_query, &edges_of_points, &total_edges_of_points);
 
     PGR_DBG("Total %ld edges in query:", total_edges_of_points);
-#ifdef DEBUG
+#if 0
+#ifndef NDEBUG
     for (i = 0; i < total_edges_of_points; i ++) {
         PGR_DBG("%ld\t%ld\t%ld\t%f\t%f",
                 edges_of_points[i].id,
@@ -127,16 +120,17 @@ process(
                 edges_of_points[i].reverse_cost);
     }
 #endif
+#endif
 
 
-
-    PGR_DBG("load the edges that dont match the points");
+    PGR_DBG("load the edges that don't match the points");
     pgr_edge_t *edges = NULL;
     size_t total_edges = 0;
-    pgr_get_data_5_columns(edges_no_points_query, &edges, &total_edges);
+    pgr_get_edges(edges_no_points_query, &edges, &total_edges);
 
     PGR_DBG("Total %ld edges in query:", total_edges);
-#ifdef DEBUG
+#if 0
+#ifndef NDEBUG
     for (i = 0; i < total_edges; i ++) {
         PGR_DBG("%ld\t%ld\t%ld\t%f\t%f",
                 edges[i].id,
@@ -146,12 +140,12 @@ process(
                 edges[i].reverse_cost);
     }
 #endif
-
     PGR_DBG("freeing allocated memory not used anymore");
+#endif
     free(edges_of_points_query);
     free(edges_no_points_query);
 
-    if ( (total_edges + total_edges_of_points) == 0) {
+    if ((total_edges + total_edges_of_points) == 0) {
         PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
@@ -161,9 +155,10 @@ process(
 
     PGR_DBG("Starting processing");
     char *err_msg = NULL;
+    char *log_msg = NULL;
     clock_t start_t = clock();
-    int  errcode = do_pgr_one_to_many_withPoints(
-            edges,  total_edges,
+    do_pgr_one_to_many_withPoints(
+            edges, total_edges,
             points, total_points,
             edges_of_points, total_edges_of_points,
             start_pid,
@@ -174,31 +169,29 @@ process(
             only_cost,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
     time_msg(" processing withPoints one to many", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
-    if (!err_msg) free(err_msg);
+    PGR_DBG("LOG: %s\n", log_msg);
 
-    pfree(edges);
-    pgr_SPI_finish();
+    if (log_msg) free(log_msg);
 
-    
-    if (errcode)  {
-        PGR_DBG("Cleaning arrays because there was an error to avoid leak");
-        free(end_pidsArr);
-        pgr_send_error(errcode);
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        if (end_pidsArr) free(end_pidsArr);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
     }
+    pfree(edges);
+    pgr_SPI_finish();
 }
 
 /*                                                                             */
 /*******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(one_to_many_withPoints);
 PGDLLEXPORT Datum
-#endif
 one_to_many_withPoints(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
@@ -208,7 +201,7 @@ one_to_many_withPoints(PG_FUNCTION_ARGS) {
     /*******************************************************************************/
     /*                          MODIFY AS NEEDED                                   */
     /*                                                                             */
-    General_path_element_t  *result_tuples = 0;
+    General_path_element_t *result_tuples = 0;
     size_t result_count = 0;
     /*                                                                             */
     /*******************************************************************************/
@@ -237,10 +230,7 @@ one_to_many_withPoints(PG_FUNCTION_ARGS) {
         size_t size_end_pidsArr;
         end_pidsArr = (int64_t*)
             pgr_get_bigIntArray(&size_end_pidsArr, PG_GETARG_ARRAYTYPE_P(3));
-        PGR_DBG("targetsArr size %ld ", size_end_pidsArr);
 
-        PGR_DBG("Calling process");
-        PGR_DBG("initial driving side:%s", pgr_text2char(PG_GETARG_TEXT_P(4)));
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
                 pgr_text2char(PG_GETARG_TEXT_P(1)),
@@ -296,7 +286,7 @@ one_to_many_withPoints(PG_FUNCTION_ARGS) {
         nulls = palloc(7 * sizeof(bool));
 
         size_t i;
-        for(i = 0; i < 7; ++i) {
+        for (i = 0; i < 7; ++i) {
             nulls[i] = false;
         }
 
diff --git a/src/withPoints/src/one_to_many_withPoints_driver.cpp b/src/withPoints/src/one_to_many_withPoints_driver.cpp
index 083cb3a..50e0366 100644
--- a/src/withPoints/src/one_to_many_withPoints_driver.cpp
+++ b/src/withPoints/src/one_to_many_withPoints_driver.cpp
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -28,29 +28,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
 
 
+#include <set>
+#include <algorithm>
 #include <sstream>
 #include <deque>
 #include <vector>
 #include <cassert>
 
-// #define DEBUG
 
 #include "./pgr_dijkstra.hpp"
 #include "./pgr_withPoints.hpp"
 #include "./one_to_many_withPoints_driver.h"
 
-extern "C" {
-#include "./../../common/src/pgr_types.h"
-}
-
-#include "./../../common/src/memory_func.hpp"
-
+#include "./../../common/src/basic_vertex.h"
+#include "./../../common/src/pgr_alloc.hpp"
+#include "./../../common/src/pgr_assert.h"
 
 // CREATE OR REPLACE FUNCTION pgr_withPoint(
 // edges_sql TEXT,
@@ -60,21 +58,28 @@ extern "C" {
 // directed BOOLEAN DEFAULT true
 
 
-int
+void
 do_pgr_one_to_many_withPoints(
-        pgr_edge_t  *edges, size_t total_edges,
-        Point_on_edge_t  *points_p, size_t total_points,
-        pgr_edge_t  *edges_of_points, size_t total_edges_of_points,
+        pgr_edge_t *edges, size_t total_edges,
+        Point_on_edge_t *points_p, size_t total_points,
+        pgr_edge_t *edges_of_points, size_t total_edges_of_points,
         int64_t start_vid,
-        int64_t  *end_pidsArr, size_t size_end_pidsArr,
+        int64_t *end_pidsArr, size_t size_end_pidsArr,
         char driving_side,
         bool details,
         bool directed,
         bool only_cost,
         General_path_element_t **return_tuples, size_t *return_count,
-        char ** err_msg){
+        char ** log_msg,
+        char ** err_msg) {
     std::ostringstream log;
+    std::ostringstream err;
     try {
+        pgassert(!(*return_tuples));
+        pgassert((*return_count) == 0);
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+
         /*
          * DOCUMENT:
          *   - Points are treated as the same point when the pid is the same
@@ -86,14 +91,13 @@ do_pgr_one_to_many_withPoints(
 
         int errcode = check_points(points, log);
         if (errcode) {
-            log << "Point(s) with same pid but different edge/fraction/side combination found";
-            *err_msg = strdup(log.str().c_str());
-            return errcode;
+            *log_msg = strdup(log.str().c_str());
+            err << "Unexpected point(s) with same pid but different edge/fraction/side combination found.";
+            *err_msg = strdup(err.str().c_str());
+            return;
         }
 
 
-
-
         std::vector< pgr_edge_t >
             edges_to_modify(edges_of_points, edges_of_points + total_edges_of_points);
 
@@ -123,40 +127,41 @@ do_pgr_one_to_many_withPoints(
         }
 
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_edges;
 
         std::deque< Path > paths;
 
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+            pgrouting::DirectedGraph digraph(
+                    pgrouting::extract_vertices(
+                        pgrouting::extract_vertices(edges, total_edges),
+                        new_edges),
+                    gType);
             digraph.graph_insert_data(edges, total_edges);
             digraph.graph_insert_data(new_edges);
             pgr_dijkstra(digraph, paths, start_vid, end_vertices, only_cost);
         } else {
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+            auto vertices(pgrouting::extract_vertices(edges, total_edges));
+            vertices = pgrouting::extract_vertices(vertices, new_edges);
+            pgrouting::UndirectedGraph undigraph(vertices, gType);
+            vertices.clear();
             undigraph.graph_insert_data(edges, total_edges);
             undigraph.graph_insert_data(new_edges);
             pgr_dijkstra(undigraph, paths, start_vid, end_vertices, only_cost);
         }
 
-#if 0
-        for (auto &path :paths) {
-            adjust_pids(points, path);
-        }
-#endif
         if (!details) {
-            for (auto &path :paths) {
+            for (auto &path : paths) {
                 eliminate_details(path, edges_to_modify);
             }
         }
         /*
-         *  order paths based on the end_pid
+         * order paths based on the end_pid
          */
-        std::sort(paths.begin(), paths.end(), [](const Path &a,const  Path &b) {
-                return a.end_id() < b.end_id();   
+        std::sort(paths.begin(), paths.end(), [](const Path &a, const Path &b) {
+                return a.end_id() < b.end_id();
                 });
 
         size_t count(0);
@@ -168,31 +173,37 @@ do_pgr_one_to_many_withPoints(
             (*return_count) = 0;
             log <<
                 "No paths found between Starting and any of the Ending vertices\n";
-            *err_msg = strdup(log.str().c_str());
-            return 0;
+            *log_msg = strdup(log.str().c_str());
+            return;
         }
 
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         log << "Converting a set of paths into the tuples\n";
         (*return_count) = (collapse_paths(return_tuples, paths));
 
 
-#ifndef DEBUG
-        {
-            std::ostringstream log;
-            log << "OK";
-            *err_msg = strdup(log.str().c_str());
-        }
 
-#else
-        *err_msg = strdup(log.str().c_str());
-#endif
-        return 0;
-    } catch ( ... ) {
-        log << "Caught unknown expection!\n";
-        *err_msg = strdup(log.str().c_str());
-        return 1000;
+        *log_msg = strdup(log.str().c_str());
+        pgassert(!(*err_msg));
+        return;
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        *log_msg = strdup(log.str().c_str());
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        *log_msg = strdup(log.str().c_str());
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        *log_msg = strdup(log.str().c_str());
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(err.str().c_str());
     }
-    return 0;
 }
 
diff --git a/src/withPoints/src/one_to_many_withPoints_driver.h b/src/withPoints/src/one_to_many_withPoints_driver.h
index 07df1f5..a92ffa0 100644
--- a/src/withPoints/src/one_to_many_withPoints_driver.h
+++ b/src/withPoints/src/one_to_many_withPoints_driver.h
@@ -4,9 +4,9 @@ File: withPoints_driver.h
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -26,6 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
+#ifndef SRC_WITHPOINTS_SRC_ONE_TO_MANY_WITHPOINTS_DRIVER_H_
+#define SRC_WITHPOINTS_SRC_ONE_TO_MANY_WITHPOINTS_DRIVER_H_
+
 #pragma once
 
 #include "./../../common/src/pgr_types.h"
@@ -34,25 +37,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 extern "C" {
 #endif
 
-//  CREATE OR REPLACE FUNCTION pgr_withPoint(
-//  edges_sql TEXT,
-//  points_sql TEXT,
-//  start_pid BIGINT,
-//  end_pid BIGINT,
-//  directed BOOLEAN DEFAULT true,
-    int do_pgr_one_to_many_withPoints(
-            pgr_edge_t  *edges,
+    // CREATE OR REPLACE FUNCTION pgr_withPoint(
+    // edges_sql TEXT,
+    // points_sql TEXT,
+    // start_pid BIGINT,
+    // end_pid BIGINT,
+    // directed BOOLEAN DEFAULT true,
+    void do_pgr_one_to_many_withPoints(
+            pgr_edge_t *edges,
             size_t total_edges,
 
-            Point_on_edge_t  *points,
+            Point_on_edge_t *points,
             size_t total_points,
 
-            pgr_edge_t  *edges_of_points,
+            pgr_edge_t *edges_of_points,
             size_t total_edges_of_points,
 
             int64_t start_pid,
 
-            int64_t  *end_pidsArr,
+            int64_t *end_pidsArr,
             size_t size_end_pidsArr,
 
             char driving_side,
@@ -61,9 +64,11 @@ extern "C" {
             bool only_cost,
             General_path_element_t **return_tuples,
             size_t *return_count,
+            char ** log_msg,
             char ** err_msg);
 
 #ifdef __cplusplus
 }
 #endif
 
+#endif  // SRC_WITHPOINTS_SRC_ONE_TO_MANY_WITHPOINTS_DRIVER_H_
diff --git a/src/withPoints/src/one_to_one_withPoints.c b/src/withPoints/src/one_to_one_withPoints.c
index 318e39f..84d05d0 100644
--- a/src/withPoints/src/one_to_one_withPoints.c
+++ b/src/withPoints/src/one_to_one_withPoints.c
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -44,17 +44,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./../../common/src/points_input.h"
 #include "./get_new_queries.h"
 #include "./one_to_one_withPoints_driver.h"
-// #define DEBUG
 #include "./../../common/src/debug_macro.h"
 #include "./../../common/src/time_msg.h"
 
-PG_FUNCTION_INFO_V1(one_to_one_withPoints);
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
-PGDLLEXPORT Datum
-#endif
-one_to_one_withPoints(PG_FUNCTION_ARGS);
+PGDLLEXPORT Datum one_to_one_withPoints(PG_FUNCTION_ARGS);
 
 /*******************************************************************************/
 /*                          MODIFY AS NEEDED                                   */
@@ -71,14 +64,13 @@ process(
         bool only_cost,
         General_path_element_t **result_tuples,
         size_t *result_count) {
-
-    driving_side[0] = tolower(driving_side[0]);
-    PGR_DBG("driving side:%c",driving_side[0]);
-    if (! ((driving_side[0] == 'r')
-                || (driving_side[0] == 'l'))) {
-        driving_side[0] = 'b'; 
+    driving_side[0] = (char) tolower(driving_side[0]);
+    PGR_DBG("driving side:%c", driving_side[0]);
+    if (!((driving_side[0] == 'r')
+                 || (driving_side[0] == 'l'))) {
+        driving_side[0] = 'b';
     }
-    PGR_DBG("estimated driving side:%c",driving_side[0]);
+    PGR_DBG("estimated driving side:%c", driving_side[0]);
 
     pgr_SPI_connect();
 
@@ -87,20 +79,20 @@ process(
     size_t total_points = 0;
     pgr_get_points(points_sql, &points, &total_points);
 
-#ifdef DEBUG
+#ifndef NDEBUG
     size_t i = 0;
     for (i = 0; i < total_points; i ++) {
-       PGR_DBG("%ld\t%ld\t%f\t%c",points[i].pid, points[i].edge_id, points[i].fraction, points[i].side);
+       PGR_DBG("%ld\t%ld\t%f\t%c", points[i].pid, points[i].edge_id, points[i].fraction, points[i].side);
     }
 #endif
 
-    PGR_DBG("  -- change the query");
+    PGR_DBG(" -- change the query");
     char *edges_of_points_query = NULL;
     char *edges_no_points_query = NULL;
-        get_new_queries(
-                edges_sql, points_sql,
-                &edges_of_points_query,
-                &edges_no_points_query);
+    get_new_queries(
+            edges_sql, points_sql,
+            &edges_of_points_query,
+            &edges_no_points_query);
 
     PGR_DBG("edges_of_points_query:\n%s", edges_of_points_query);
     PGR_DBG("edges_no_points_query:\n%s", edges_no_points_query);
@@ -108,10 +100,10 @@ process(
     PGR_DBG("load the edges that match the points");
     pgr_edge_t *edges_of_points = NULL;
     size_t total_edges_of_points = 0;
-    pgr_get_data_5_columns(edges_of_points_query, &edges_of_points, &total_edges_of_points);
+    pgr_get_edges(edges_of_points_query, &edges_of_points, &total_edges_of_points);
 
     PGR_DBG("Total %ld edges in query:", total_edges_of_points);
-#ifdef DEBUG
+#ifndef NDEBUG
     for (i = 0; i < total_edges_of_points; i ++) {
         PGR_DBG("%ld\t%ld\t%ld\t%f\t%f",
                 edges_of_points[i].id,
@@ -124,13 +116,13 @@ process(
 
 
 
-    PGR_DBG("load the edges that dont match the points");
+    PGR_DBG("load the edges that don't match the points");
     pgr_edge_t *edges = NULL;
     size_t total_edges = 0;
-    pgr_get_data_5_columns(edges_no_points_query, &edges, &total_edges);
+    pgr_get_edges(edges_no_points_query, &edges, &total_edges);
 
     PGR_DBG("Total %ld edges in query:", total_edges);
-#ifdef DEBUG
+#ifndef NDEBUG
     for (i = 0; i < total_edges; i ++) {
         PGR_DBG("%ld\t%ld\t%ld\t%f\t%f",
                 edges[i].id,
@@ -145,7 +137,7 @@ process(
     free(edges_of_points_query);
     free(edges_no_points_query);
 
-    if ( (total_edges + total_edges_of_points) == 0) {
+    if ((total_edges + total_edges_of_points) == 0) {
         PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
@@ -155,8 +147,9 @@ process(
 
     PGR_DBG("Starting processing");
     char *err_msg = NULL;
+    char *log_msg = NULL;
     clock_t start_t = clock();
-    int errcode = do_pgr_withPoints(
+    do_pgr_withPoints(
             edges,
             total_edges,
             points,
@@ -171,29 +164,27 @@ process(
             only_cost,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
     time_msg(" processing withPoints one to one", start_t, clock());
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    PGR_DBG("LOG: %s\n", log_msg);
+    if (log_msg) free(log_msg);
 
-    if (!err_msg) free(err_msg);
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
     pfree(edges);
     pgr_SPI_finish();
-
-    if (errcode) {
-        pgr_send_error(errcode);
-    }
-
 }
 
 /*                                                                             */
 /*******************************************************************************/
 
-#ifndef _MSC_VER
-Datum
-#else  // _MSC_VER
+PG_FUNCTION_INFO_V1(one_to_one_withPoints);
 PGDLLEXPORT Datum
-#endif
 one_to_one_withPoints(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
     uint32_t              call_cntr;
@@ -203,7 +194,7 @@ one_to_one_withPoints(PG_FUNCTION_ARGS) {
     /*******************************************************************************/
     /*                          MODIFY AS NEEDED                                   */
     /*                                                                             */
-    General_path_element_t  *result_tuples = NULL;
+    General_path_element_t *result_tuples = NULL;
     size_t result_count = 0;
     /*                                                                             */
     /*******************************************************************************/
@@ -264,7 +255,7 @@ one_to_one_withPoints(PG_FUNCTION_ARGS) {
         HeapTuple    tuple;
         Datum        result;
         Datum        *values;
-        bool*        nulls;
+        bool    *        nulls;
 
         /*******************************************************************************/
         /*                          MODIFY AS NEEDED                                   */
@@ -280,7 +271,7 @@ one_to_one_withPoints(PG_FUNCTION_ARGS) {
         nulls = palloc(6 * sizeof(bool));
 
         size_t i;
-        for(i = 0; i < 6; ++i) {
+        for (i = 0; i < 6; ++i) {
             nulls[i] = false;
         }
 
diff --git a/src/withPoints/src/one_to_one_withPoints_driver.cpp b/src/withPoints/src/one_to_one_withPoints_driver.cpp
index 9ed018f..6c2e8dc 100644
--- a/src/withPoints/src/one_to_one_withPoints_driver.cpp
+++ b/src/withPoints/src/one_to_one_withPoints_driver.cpp
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
@@ -41,10 +41,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include "./pgr_withPoints.hpp"
 #include "./one_to_one_withPoints_driver.h"
 
-// #define DEBUG
 
-
-#include "./../../common/src/memory_func.hpp"
+#include "./../../common/src/basic_vertex.h"
+#include "./../../common/src/pgr_alloc.hpp"
+#include "./../../common/src/pgr_assert.h"
 
 
 // CREATE OR REPLACE FUNCTION pgr_withPoint(
@@ -55,11 +55,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 // directed BOOLEAN DEFAULT true
 
 
-int
+void
 do_pgr_withPoints(
-        pgr_edge_t  *edges,           size_t total_edges,
-        Point_on_edge_t  *points_p,   size_t total_points,
-        pgr_edge_t  *edges_of_points, size_t total_edges_of_points,
+        pgr_edge_t *edges, size_t total_edges,
+        Point_on_edge_t *points_p, size_t total_points,
+        pgr_edge_t *edges_of_points, size_t total_edges_of_points,
         int64_t start_pid,
         int64_t end_pid,
         bool directed,
@@ -68,13 +68,20 @@ do_pgr_withPoints(
         bool only_cost,
         General_path_element_t **return_tuples,
         size_t *return_count,
-        char ** err_msg){
+        char ** log_msg,
+        char ** err_msg) {
     std::ostringstream log;
+    std::ostringstream err;
     try {
-        log << "Entering do_pgr_withPoints\n";
+        pgassert(!(*return_tuples));
+        pgassert((*return_count) == 0);
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+
+        log << "ntering do_pgr_withPoints\n";
         std::vector< Point_on_edge_t >
             points(points_p, points_p + total_points);
-        
+
         log << "total points" << points.size() << "\n";
 
         /*
@@ -82,9 +89,10 @@ do_pgr_withPoints(
          */
         int errcode = check_points(points, log);
         if (errcode) {
-            log << "Point(s) with same pid but different edge/fraction/side combination found";
-            *err_msg = strdup(log.str().c_str());
-            return errcode;
+            *log_msg = strdup(log.str().c_str());
+            err << "Unexpected point(s) with same pid but different edge/fraction/side combination found.";
+            *err_msg = strdup(err.str().c_str());
+            return;
         }
 
         std::vector< pgr_edge_t >
@@ -104,36 +112,37 @@ do_pgr_withPoints(
         int64_t start_vid(start_pid);
         int64_t end_vid(end_pid);
 
-#ifdef DEBUG
-        for (const auto point : points) {
-            if (point.pid == start_pid) {
-                start_vid = point.vertex_id;
-            }
-            if (point.pid == end_pid) {
-                end_vid = point.vertex_id;
-            }
-
-        }
-#endif
         log << "start_vid" << start_vid << "\n";
         log << "end_vid" << end_vid << "\n";
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const auto initial_size = total_edges;
 
         Path path;
 
+        auto vertices(pgrouting::extract_vertices(edges, total_edges));
+        vertices = pgrouting::extract_vertices(vertices, new_edges);
+
+        log << "extracted vertices: ";
+        for (const auto v : vertices) {
+            log << v.id << ", ";
+        }
+        log << "\n";
 
         if (directed) {
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
+
+            pgrouting::DirectedGraph digraph(vertices, gType);
             digraph.graph_insert_data(edges, total_edges);
             digraph.graph_insert_data(new_edges);
+
+
             pgr_dijkstra(digraph, path, start_vid, end_vid, only_cost);
         } else {
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
+
+            pgrouting::UndirectedGraph undigraph(gType);
             undigraph.graph_insert_data(edges, total_edges);
             undigraph.graph_insert_data(new_edges);
+
             pgr_dijkstra(undigraph, path, start_vid, end_vid, only_cost);
         }
 
@@ -142,35 +151,41 @@ do_pgr_withPoints(
         if (count == 0) {
             (*return_tuples) = NULL;
             (*return_count) = 0;
-            log <<
+            *log_msg = strdup(log.str().c_str());
+            err <<
                 "No paths found between Starting and any of the Ending vertices\n";
-            *err_msg = strdup(log.str().c_str());
-            return 0;
+            *log_msg = strdup(err.str().c_str());
+            return;
         }
 
         if (!details) {
             eliminate_details(path, edges_to_modify);
         }
 
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         size_t sequence = 0;
         path.generate_postgres_data(return_tuples, sequence);
         (*return_count) = sequence;
 
-#ifndef DEBUG
-        {
-            std::ostringstream log;
-            log << "OK";
-            *err_msg = strdup(log.str().c_str());
-        }
-
-#else
-        *err_msg = strdup(log.str().c_str());
-#endif
-        return 0;
-    } catch ( ... ) {
-        log << "Caught unknown expection!\n";
-        *err_msg = strdup(log.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+        pgassert(!*err_msg);
+    } catch (AssertFailedException &except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        *log_msg = strdup(log.str().c_str());
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+    } catch (std::exception& except) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        *log_msg = strdup(log.str().c_str());
+        err << except.what() << "\n";
+        *err_msg = strdup(err.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        *log_msg = strdup(log.str().c_str());
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(err.str().c_str());
     }
-    return 1000;
 }
diff --git a/src/withPoints/src/one_to_one_withPoints_driver.h b/src/withPoints/src/one_to_one_withPoints_driver.h
index 40f0cb3..2b63600 100644
--- a/src/withPoints/src/one_to_one_withPoints_driver.h
+++ b/src/withPoints/src/one_to_one_withPoints_driver.h
@@ -4,9 +4,9 @@ File: withPoints_driver.h
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -26,26 +26,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 ********************************************************************PGR-GNU*/
 
-#ifndef SRC_WITHPOINTS_SRC_WITHPOINTS_DRIVER_H_
-#define SRC_WITHPOINTS_SRC_WITHPOINTS_DRIVER_H_
+#ifndef SRC_WITHPOINTS_SRC_ONE_TO_ONE_WITHPOINTS_DRIVER_H_
+#define SRC_WITHPOINTS_SRC_ONE_TO_ONE_WITHPOINTS_DRIVER_H_
+#pragma once
 
+#include "./../../common/src/pgr_types.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "./../../common/src/pgr_types.h"
 
-//  CREATE OR REPLACE FUNCTION pgr_withPoint(
-//  edges_sql TEXT,
-//  points_sql TEXT,
-//  start_pid BIGINT,
-//  end_pid BIGINT,
-//  directed BOOLEAN DEFAULT true,
-    int do_pgr_withPoints(
-            pgr_edge_t  *edges,           size_t total_edges,
-            Point_on_edge_t  *points,     size_t total_points,
-            pgr_edge_t  *edges_of_points, size_t total_edges_of_points,
+    // CREATE OR REPLACE FUNCTION pgr_withPoint(
+    // edges_sql TEXT,
+    // points_sql TEXT,
+    // start_pid BIGINT,
+    // end_pid BIGINT,
+    // directed BOOLEAN DEFAULT true,
+    void do_pgr_withPoints(
+            pgr_edge_t *edges, size_t total_edges,
+            Point_on_edge_t *points, size_t total_points,
+            pgr_edge_t *edges_of_points, size_t total_edges_of_points,
             int64_t start_pid,
             int64_t end_pid,
             bool directed,
@@ -54,10 +55,11 @@ extern "C" {
             bool only_cost,
             General_path_element_t **return_tuples,
             size_t *return_count,
+            char ** log_msg,
             char ** err_msg);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // SRC_WITHPOINTS_SRC_WITHPOINTS_DRIVER_H_
+#endif  //  SRC_WITHPOINTS_SRC_ONE_TO_ONE_WITHPOINTS_DRIVER_H_
diff --git a/src/withPoints/src/pgr_withPoints.cpp b/src/withPoints/src/pgr_withPoints.cpp
index fb9c2cf..b33c416 100644
--- a/src/withPoints/src/pgr_withPoints.cpp
+++ b/src/withPoints/src/pgr_withPoints.cpp
@@ -5,9 +5,9 @@ Generated with Template by:
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) ||  defined(_MSC_VER)
 #include <winsock2.h>
 #include <windows.h>
 #endif
@@ -38,15 +38,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #include <deque>
 #include <set>
 #include <vector>
+#include <algorithm>
 #include <cassert>
 #include "./pgr_withPoints.hpp"
-// #define DEBUG
 #include "./msg_logger.hpp"
 
-
-extern "C" {
 #include "./../../common/src/pgr_types.h"
-}
 
 /*
  * 0 = success
@@ -54,14 +51,13 @@ extern "C" {
  */
 
 int check_points(std::vector< Point_on_edge_t > &points,
-        std::ostringstream  &log) {
-
+        std::ostringstream &log) {
     PGR_LOG_POINTS(log, points, "original points");
-    /* 
+    /*
      * deleting duplicate points
      */
     std::sort(points.begin(), points.end(),
-            [](const Point_on_edge_t &a, const  Point_on_edge_t &b)
+            [](const Point_on_edge_t &a, const Point_on_edge_t &b)
            -> bool {
             if (a.pid != b.pid) return a.pid < b.pid;
             if (a.edge_id != b.edge_id) return a.edge_id < b.edge_id;
@@ -70,7 +66,7 @@ int check_points(std::vector< Point_on_edge_t > &points,
             });
     PGR_LOG_POINTS(log, points, "after sorting");
     auto last = std::unique(points.begin(), points.end(),
-            [](const Point_on_edge_t &a, const  Point_on_edge_t &b) {
+            [](const Point_on_edge_t &a, const Point_on_edge_t &b) {
             return a.pid == b.pid &&
             a.edge_id == b.edge_id &&
             a.fraction == b.fraction &&
@@ -83,7 +79,7 @@ int check_points(std::vector< Point_on_edge_t > &points,
     log << "We have " << total_points << " different points";
 
     last = std::unique(points.begin(), points.end(),
-            [](const Point_on_edge_t &a, const  Point_on_edge_t &b) {
+            [](const Point_on_edge_t &a, const Point_on_edge_t &b) {
             return a.pid == b.pid;
             });
     points.erase(last, points.end());
@@ -99,16 +95,16 @@ int check_points(std::vector< Point_on_edge_t > &points,
 void
 eliminate_details_dd(
         Path &path) {
-    /* 
-     *  There is no path nothing to do
+    /*
+     * There is no path nothing to do
      */
     if (path.empty()) return;
 
     Path newPath(path.start_id(), path.end_id());
-    for (const auto &pathstop :  path) {
-        if ((pathstop.node == path.start_id()) 
-                || (pathstop.node == path.end_id())
-                || (pathstop.node > 0)) {
+    for (const auto &pathstop : path) {
+        if ((pathstop.node == path.start_id())
+                 || (pathstop.node == path.end_id())
+                 || (pathstop.node > 0)) {
             newPath.push_back(pathstop);
         }
     }
@@ -121,17 +117,17 @@ void
 eliminate_details(
         Path &path,
         const std::vector< pgr_edge_t > &point_edges) {
-    /* 
-     *  There is no path nothing to do
+    /*
+     * There is no path nothing to do
      */
     if (path.empty()) return;
 
     Path newPath(path.start_id(), path.end_id());
     double cost = 0.0;
-    for (const auto &pathstop :  path) {
-        if ((pathstop.node == path.start_id()) 
-                || (pathstop.node == path.end_id())
-                || (pathstop.node > 0)) {
+    for (const auto &pathstop : path) {
+        if ((pathstop.node == path.start_id())
+                 || (pathstop.node == path.end_id())
+                 || (pathstop.node > 0)) {
             newPath.push_back(pathstop);
             if (pathstop.node != path.end_id()) cost = 0.0;
             continue;
@@ -141,17 +137,17 @@ eliminate_details(
 
     newPath[0].cost = newPath[1].agg_cost;
     for (unsigned int i = 1; i < newPath.size() - 2; ++i) {
-        /* newPath[i] has: node, edge, cost, agg_cost 
+        /* newPath[i] has: node, edge, cost, agg_cost
          * pgr_type_t has: id, source, target, cost, reverse_cost
          *
          * find the edge where the pathstop.edge == edge.id */
 
-        int64_t edge_to_find =  newPath[i].edge;
+        int64_t edge_to_find = newPath[i].edge;
         auto edge_ptr = std::find_if(point_edges.begin(), point_edges.end(),
                 [&edge_to_find](const pgr_edge_t &edge)
                 {return edge_to_find == edge.id;});
         if (edge_ptr != point_edges.end()) {
-            newPath[i].cost = edge_ptr->target ==  newPath[i+1].node ?
+            newPath[i].cost = edge_ptr->target == newPath[i+1].node ?
                 edge_ptr->cost : edge_ptr->reverse_cost;
         }
     }
@@ -173,7 +169,7 @@ adjust_pids(
     path.end_id(end_pid);
 
     for (auto &path_stop : path) {
-        for (const auto point: points) {
+        for (const auto point : points) {
             if (point.vertex_id == path_stop.node) {
                 path_stop.node = -point.pid;
                 break;
@@ -186,12 +182,12 @@ void
 adjust_pids(
         const std::vector< Point_on_edge_t > &points,
         Path &path) {
-    /* 
-     *  There is no path nothing to do
+    /*
+     * There is no path nothing to do
      */
     if (path.empty()) return;
     /* from, to:
-     *      *  are constant along the path
+     *      * are constant along the path
      *           */
     int64_t start_vid = path.start_id();
     int64_t end_vid = path.end_id();
@@ -218,7 +214,7 @@ struct pointCompare {
 
 bool
 create_new_edges(
-        std::vector< Point_on_edge_t >  &points,
+        std::vector< Point_on_edge_t > &points,
         const std::vector< pgr_edge_t > &edges,
         char driving_side,
         std::vector< pgr_edge_t > &new_edges) {
@@ -230,34 +226,33 @@ create_new_edges(
 
 bool
 create_new_edges(
-        std::vector< Point_on_edge_t >  &points,
+        std::vector< Point_on_edge_t > &points,
         const std::vector< pgr_edge_t > &edges,
         char driving_side,
         std::vector< pgr_edge_t > &new_edges,
         std::ostringstream &log) {
-
-    for (const auto &point : points){
-        log << "point: " 
-            << point.pid <<"\t"
-            << point.edge_id <<"\t"
-            << point.fraction <<"\t"
-            << point.side <<"\t"
-            << point.vertex_id <<"\n";
+    for (const auto &point : points) {
+        log << "point: "
+            << point.pid << "\t"
+            << point.edge_id << "\t"
+            << point.fraction << "\t"
+            << point.side << "\t"
+            << point.vertex_id << "\n";
     }
 
     int64_t vertex_id = 1;
-    std::vector< Point_on_edge_t >  new_points;
+    std::vector< Point_on_edge_t > new_points;
     for (const auto edge : edges) {
         std::set< Point_on_edge_t, pointCompare> points_on_edge;
         for (const auto point : points) {
             if (edge.id == point.edge_id) {
                 points_on_edge.insert(point);
-                log << "working points: " 
-                    << point.pid <<"\t"
-                    << point.edge_id <<"\t"
-                    << point.fraction <<"\t"
-                    << point.side <<"\t"
-                    << point.vertex_id <<"\n";
+                log << "working points: "
+                    << point.pid << "\t"
+                    << point.edge_id << "\t"
+                    << point.fraction << "\t"
+                    << point.side << "\t"
+                    << point.vertex_id << "\n";
             }
         }
         if (points_on_edge.empty()) {
@@ -265,10 +260,10 @@ create_new_edges(
             return false;
         }
 #if 0
-        log << "breaking:  \n"
-            << edge.id << "\t" 
-            << edge.source << "\t" 
-            << edge.target << "\t" 
+        log << "breaking: \n"
+            << edge.id << "\t"
+            << edge.source << "\t"
+            << edge.target << "\t"
             << edge.cost << "\t"
             << edge.reverse_cost << "\n";
 #endif
@@ -278,19 +273,22 @@ create_new_edges(
         double prev_rfraction = 0;
         double agg_cost = 0;
         double agg_rcost = 0;
-        double  last_cost = 0;
-        double  last_rcost = 0;
+        double last_cost = 0;
+        double last_rcost = 0;
         std::vector< Point_on_edge_t> the_points(points_on_edge.begin(), points_on_edge.end());
 
         for (auto &point : the_points) {
-
             /* the point either has
              * vertex_id = source
              * vertex_id = target
              * vertex_id = -newnumber
              */
-            log << "\npid" << point.pid << "\teid" << point.edge_id << "/t" << point.fraction << "\t" << point.side << "\n";
-            if (point.fraction <= 0 || point.fraction >= 1) {
+            log << "\npid"
+                << point.pid
+                << "\teid" << point.edge_id
+                << "/t" << point.fraction
+                << "\t" << point.side << "\n";
+            if (point.fraction <= 0 ||  point.fraction >= 1) {
                 log << "For some reason an invalid fraction was accepted, must be an error\n";
                 return false;
             }
@@ -302,7 +300,7 @@ create_new_edges(
                 log << "vertex_id of the point is the target" << edge.target << "\n";
                 point.vertex_id = edge.target;
             }
-            if (point.fraction > 0 && point.fraction < 1) {
+            if (point.fraction > 0 &&  point.fraction < 1) {
                 log << "vertex_id of the point is " << -point.pid << "\n";
                 point.vertex_id = -point.pid;
                 ++vertex_id;
@@ -311,19 +309,19 @@ create_new_edges(
 
             double deltaFraction = point.fraction - prev_fraction;
             double deltarFraction = point.fraction - prev_rfraction;
-            if ((edge.cost < 0 or edge.reverse_cost < 0)
-                    || driving_side == 'b'
-                    || point.side == 'b') {
+            if ((edge.cost < 0 ||  edge.reverse_cost < 0)
+                     || driving_side == 'b'
+                     || point.side == 'b') {
                 log << "Edge is one way or driving side is both or point side is both\n";
-                log << "Edge is one way: " << (edge.cost < 0 or edge.reverse_cost < 0) << "\n";
+                log << "Edge is one way: " << (edge.cost < 0 ||  edge.reverse_cost < 0) << "\n";
                 log << "driving side: " << driving_side << "\n";
                 log << "point side: " << point.side << "\n";
-                if (point.fraction > 0 && point.fraction < 1) {
+                if (point.fraction > 0 &&  point.fraction < 1) {
                     if (edge.cost >= 0) {
                         last_cost = deltaFraction * edge.cost;
                         pgr_edge_t new_edge = {edge.id , prev_target, point.vertex_id, last_cost, -1};
                         new_edges.push_back(new_edge);
-                        log << "new_edge: (id,source,target,cost,reverse_cost) = ("
+                        log << "new_edge: (id, source, target, cost, reverse_cost) = ("
                             << new_edge.id << "\t"
                             << new_edge.source << "\t"
                             << new_edge.target << "\t"
@@ -334,7 +332,7 @@ create_new_edges(
                         last_rcost = deltarFraction * edge.reverse_cost;
                         pgr_edge_t new_edge = {edge.id , prev_target, point.vertex_id, -1, last_rcost};
                         new_edges.push_back(new_edge);
-                        log << "new_edge: (id,source,target,cost,reverse_cost) = ("
+                        log << "new_edge: (id, source, target, cost, reverse_cost) = ("
                             << new_edge.id << "\t"
                             << new_edge.source << "\t"
                             << new_edge.target << "\t"
@@ -352,17 +350,17 @@ create_new_edges(
                 continue;
             }
 
-            assert(edge.cost > 0 && edge.reverse_cost > 0);
+            assert(edge.cost > 0 &&  edge.reverse_cost > 0);
             assert(point.side != 'b');
 
             if (driving_side == point.side) {
-                log << "Edge is two way and driving side is the same as the side of the point\n";
+                log << "two way and driving side is == than the side of the point\n";
                 log << "Breaking (source, target) edge only when its not the extreme of the segment\n";
-                if (point.fraction > 0 && point.fraction < 1) {
+                if (point.fraction > 0 &&  point.fraction < 1) {
                     last_cost = deltaFraction * edge.cost;
                     pgr_edge_t new_edge = {edge.id , prev_target, point.vertex_id, last_cost, -1};
                     new_edges.push_back(new_edge);
-                    log << "new_edge: (id,source,target,cost,reverse_cost) = ("
+                    log << "new_edge: (id, source, target, cost, reverse_cost) = ("
                         << new_edge.id << "\t"
                         << new_edge.source << "\t"
                         << new_edge.target << "\t"
@@ -375,12 +373,17 @@ create_new_edges(
                 continue;
             }
 
-            log << "Edge is two way and driving side is different than the side of the point\n";
-            if (point.fraction > 0 && point.fraction < 1) {
+            log << "two way and driving side is != than the side of the point\n";
+            if (point.fraction > 0 &&  point.fraction < 1) {
                 last_rcost = deltarFraction * edge.reverse_cost;
-                pgr_edge_t new_edge = {edge.id , prev_rtarget, point.vertex_id, -1, last_rcost};
+                pgr_edge_t new_edge = {
+                    edge.id,
+                    prev_rtarget,
+                    point.vertex_id,
+                    -1,
+                    last_rcost};
                 new_edges.push_back(new_edge);
-                log << "new_edge: (id,source,target,cost,reverse_cost) = ("
+                log << "new_edge: (id, source, target, cost, reverse_cost) = ("
                     << new_edge.id << "\t"
                     << new_edge.source << "\t"
                     << new_edge.target << "\t"
@@ -392,11 +395,15 @@ create_new_edges(
             agg_rcost += last_rcost;
         }
 
-        { // the last segments
-            pgr_edge_t new_edge = {edge.id , prev_target, edge.target,
-                (edge.cost - agg_cost), -1};
+        {  //  the last segments
+            pgr_edge_t new_edge = {
+                edge.id,
+                prev_target,
+                edge.target,
+                (edge.cost - agg_cost),
+                -1};
             new_edges.push_back(new_edge);
-            log << "last edge: (id,source,target,cost,reverse_cost) = ("
+            log << "last edge: (id, source, target, cost, reverse_cost) = ("
                 << new_edge.id << "\t"
                 << new_edge.source << "\t"
                 << new_edge.target << "\t"
@@ -406,7 +413,7 @@ create_new_edges(
             new_edge = {edge.id , prev_rtarget, edge.target,
                 -1, (edge.reverse_cost - agg_rcost)};
             new_edges.push_back(new_edge);
-            log << "last edge: (id,source,target,cost,reverse_cost) = ("
+            log << "last edge: (id, source, target, cost, reverse_cost) = ("
                 << new_edge.id << "\t"
                 << new_edge.source << "\t"
                 << new_edge.target << "\t"
@@ -416,13 +423,13 @@ create_new_edges(
     }
 
     points = new_points;
-    for (const auto &point : points){
-        log << "point: " 
-            << point.pid <<"\t"
-            << point.edge_id <<"\t"
-            << point.fraction <<"\t"
-            << point.side <<"\t"
-            << point.vertex_id <<"\n";
+    for (const auto &point : points) {
+        log << "point: "
+            << point.pid << "\t"
+            << point.edge_id << "\t"
+            << point.fraction << "\t"
+            << point.side << "\t"
+            << point.vertex_id << "\n";
     }
     return true;
 }
diff --git a/src/withPoints/src/pgr_withPoints.hpp b/src/withPoints/src/pgr_withPoints.hpp
index a698fca..260a5a7 100644
--- a/src/withPoints/src/pgr_withPoints.hpp
+++ b/src/withPoints/src/pgr_withPoints.hpp
@@ -4,9 +4,9 @@ File: withPoints_driver.h
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
-Function's developer: 
+Function's developer:
 Copyright (c) 2015 Celia Virginia Vergara Castillo
-Mail: 
+Mail:
 
 ------
 
@@ -27,13 +27,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ********************************************************************PGR-GNU*/
 
 #pragma once
+#include <vector>
 
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/basePath_SSEC.hpp"
 
 int
 check_points(std::vector< Point_on_edge_t > &points,
-                std::ostringstream  &log);
+                std::ostringstream &log);
 
 void
 eliminate_details_dd(
@@ -52,14 +53,14 @@ adjust_pids(
 
 bool
 create_new_edges(
-        std::vector< Point_on_edge_t >  &points,
+        std::vector< Point_on_edge_t > &points,
         const std::vector< pgr_edge_t > &edges,
         char driving_side,
         std::vector< pgr_edge_t > &new_edges);
 
 bool
 create_new_edges(
-        std::vector< Point_on_edge_t >  &points,
+        std::vector< Point_on_edge_t > &points,
         const std::vector< pgr_edge_t > &edges,
         char driving_side,
         std::vector< pgr_edge_t > &new_edges,
diff --git a/src/withPoints/test/doc-pgr_withPoints.test.sql b/src/withPoints/test/doc-pgr_withPoints.test.sql
index 631779e..e263fed 100644
--- a/src/withPoints/test/doc-pgr_withPoints.test.sql
+++ b/src/withPoints/test/doc-pgr_withPoints.test.sql
@@ -70,7 +70,6 @@ BEGIN;
     \echo --q5
 
 
-
     ROLLBACK;
 
 
diff --git a/src/withPoints/test/test.conf b/src/withPoints/test/test.conf
index 93cd2d3..8c22bbd 100644
--- a/src/withPoints/test/test.conf
+++ b/src/withPoints/test/test.conf
@@ -20,7 +20,7 @@
             doc-pgr_withPointsVia
             )],
     },
-# I dont know what this are for or how to use them.
+# I don't know what this are for or how to use them.
 #  TODO ask Steve 
 #    'vpg-vpgis' => {}, # for version specific tests
 #    '8-1' => {},       # for pg 8.x and postgis 1.x
diff --git a/tools/clean/clean.sh b/tools/clean/clean.sh
new file mode 100644
index 0000000..adbf83d
--- /dev/null
+++ b/tools/clean/clean.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+# ------------------------------------------------------------------------------
+#
+# Basic common coding style errors cleaning
+# Copyright(c) pgRouting Contributors
+#
+# -------- USE
+#
+# ./path/to/here/clean <extension>
+#
+# Example
+# ./path/to/here/clean cpp
+# ------------------------------------------------------------------------------
+
+
+EXTENSION=$1
+
+echo $EXTENSION
+# remove trailing spaces
+perl -pi -e 's/\s\+$//' *.$EXTENSION
+
+# " )" -> ")"
+perl -pi -e 's/\s\+\)/)/g' *.$EXTENSION
+# " (" -> "("
+perl -pi -e 's/(\S)\s\+\(/$1(/g' *.$EXTENSION
+
+# add a space before & after =
+perl -pi -e 's/(\S)=/$1 = /g' *.$EXTENSION
+
+#fix >= == <= != += -= *=
+perl -pi -e 's/(\*|!|\+|-|<|=|>) =/$1=/g' *.$EXTENSION
+
+# add a space after: , << 
+perl -pi -e 's/(,|<<)(\S)/$1 $2/g' *.$EXTENSION
+perl -pi -e 's/(,|<<|=)[ ]+$/$1/' *.$EXTENSION
+perl -pi -e 's/(,|<<|=) +/$1 /g' *.$EXTENSION
+
+# add a space around: && ||
+perl -pi -e 's/(&&|\|\|)/ $1 /g' *.$EXTENSION
+
+# "( " -> "("
+perl -pi -e 's/\(\s\+/(/g' *.$EXTENSION
+
+# Missing space before {
+perl -pi -e 's/(\S){/$1 {/g' *.$EXTENSION
+
+
+# add a space before: <<, ==, <=, >=
+perl -pi -e 's/(\S)(<<|<=|==|>=)/$1 $2/g' *.$EXTENSION
+
+# 2 spaces -> 1 space
+perl -pi -e 's/(\S+)  (\S+)/$1 $2/g' *.$EXTENSION
+
+# At least two spaces is best between code and comments
+perl -pi -e 's/(\S+) \/\//$1  \/\/ /g' *.$EXTENSION
+
+# if( for(
+perl -pi -e 's/\s(if|for|while)\(/ $1 \(/g' *.$EXTENSION
+
+# "( " -> "("
+perl -pi -e 's/\(\s\+/(/g' *.$EXTENSION
+
+# remove trailing spaces
+perl -pi -e 's/\s\+$//' *.$EXTENSION
+perl -pi -e 's/ +$//' *.$EXTENSION
+
diff --git a/tools/doxygen/Makefile b/tools/doxygen/Makefile
deleted file mode 100644
index 4dc7835..0000000
--- a/tools/doxygen/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all:  doxygen
-
-doxygen:
-	mkdir -p ../../build/doxy/
-	doxygen  
diff --git a/tools/pre-commit b/tools/git-tools/pre-commit
similarity index 76%
rename from tools/pre-commit
rename to tools/git-tools/pre-commit
index c059776..fc942b8 100755
--- a/tools/pre-commit
+++ b/tools/git-tools/pre-commit
@@ -15,6 +15,8 @@
 # The VERSION file is always one commit behind HEAD
 # ------------------------------------------------------------------------------
 
-VERSION=`git describe --tags --long`
+VERSION="pgrouting-2.3.0.dev"
+COMMITS=`git rev-list HEAD --count`
+HASH=`git rev-parse --short HEAD`
 BRANCH=`git branch | grep '*' | awk '{print $2}'`
-echo $VERSION $BRANCH > $GIT_DIR/../VERSION
+echo $VERSION-$COMMITS-$HASH $BRANCH > $GIT_DIR/../VERSION
diff --git a/tools/licences/GNU_license.txt b/tools/licences/GNU_license.txt
index 63ca261..ca2542a 100644
--- a/tools/licences/GNU_license.txt
+++ b/tools/licences/GNU_license.txt
@@ -1,5 +1,7 @@
 /*PGR-GNU*****************************************************************
 
+FILE: __FILENAME__
+
 Copyright (c) 2015 pgRouting developers
 Mail: project at pgrouting.org
 
@@ -19,4 +21,4 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-********************************************************************PGR-GNU*/
+ ********************************************************************PGR-GNU*/
diff --git a/tools/licences/README.md b/tools/licences/README.md
new file mode 100644
index 0000000..1b1d3db
--- /dev/null
+++ b/tools/licences/README.md
@@ -0,0 +1,9 @@
+
+Add licences to a directory files
+------------------------------------
+
+From this directory execute the command
+
+```
+add-licenses dir [exclude.txt]
+```
diff --git a/tools/licences/add-licenses b/tools/licences/add-licenses
index a5e7768..9a7f2e1 100755
--- a/tools/licences/add-licenses
+++ b/tools/licences/add-licenses
@@ -30,7 +30,7 @@ my %exclude = (
 my $gnu_license = "GNU_license.txt";
 my @GNU_LICENSE = loadLicense($gnu_license);
 my @GNU_BODY = @GNU_LICENSE;
-splice @GNU_BODY, 0, 6;
+splice @GNU_BODY, 0, 8;
 
 my $mit_license = "MIT_license.txt";
 my @MIT_LICENSE = loadLicense($mit_license);
@@ -65,8 +65,8 @@ for my $file (sort @files) {
     my $f = basename($file);
     next if $exclude{$f};
     my $task = get_task($file);
+    print "\n\n PROCESSING '$file' --- task '$task' \n";
     next if $task == 0;
-    print "\n\n PROCESSING '$file'\n";
     update_license($task, $file) if $DOUPDATES;
 }
 
@@ -111,18 +111,20 @@ sub get_task{
     #The license is not found
     if ($license_type == 0) {
         close(IN);
+        # task is "add a licence"
         return 1;
     }
 
     # look for the dividing line
     if ($license_type != 3) {
-        while ($line and ($line ne "------\n")) {
+        while ($line and ($line !~ "------")) {
             $line = <IN>;
         }
 
         #The dividing line is not found
         if (!$line) {
             close(IN);
+            # task is "add a licence"
             return 1;
         }
     }
@@ -138,12 +140,13 @@ sub get_task{
         $line = <IN>;
         if ($LICENSE_BODY[$i] ne $line) {
             close(IN);
+            # task is "update the licence"
             return 2;
         }
     }
 
     close(IN);
-    #print "License up to date\n";
+    # task is do nothing
     return 0;
 }
 
@@ -180,18 +183,19 @@ sub update_license {
     if ($task == 1) {
         print "  Adding full license\n";
         print "     --> Please remove old license and update names if needed\n";
+        $LICENSE[1] =~ s/__FILENAME__/$file_name/;
         @file = (@LICENSE, @file);
 
     } else {
-        print "  Changing Body of license\n";
         #task = 2
+        print "  Changing Body of license\n";
 
 
         # Find the dividing line
         my $first = 0;
         my $last = 0;
         if ($license_type !=3) {
-            while ($file[$first] ne "------\n") {
+            while ($file[$first] !~ "------") {
                 $first++;
             }
         } else {
@@ -202,7 +206,8 @@ sub update_license {
         $last = $first;
 
         # Find the last line
-        while ($file[$last] ne $LICENSE[$#LICENSE]) {
+        #while ($file[$last] =~ne $LICENSE[$#LICENSE]) {
+        while ( $file[$last] !~ /\*+PGR-/) {
             $last++;
         }
 
diff --git a/tools/scripts/fix_typos.sh b/tools/scripts/fix_typos.sh
new file mode 100644
index 0000000..db5d744
--- /dev/null
+++ b/tools/scripts/fix_typos.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+# -*- coding: utf-8 -*-
+###############################################################################
+# $Id$
+#
+#  Project:  GDAL
+#  Purpose:  (Interactive) script to identify and fix typos
+#  Author:   Even Rouault <even.rouault at spatialys.com>
+#
+###############################################################################
+#  Copyright (c) 2016, Even Rouault <even.rouault at spatialys.com>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+#  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+#  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+#  DEALINGS IN THE SOFTWARE.
+###############################################################################
+
+if ! test -d fix_typos; then
+    # Get our fork of codespell that adds --words-white-list and full filename support for -S option
+    mkdir fix_typos
+    cd fix_typos
+    git clone https://github.com/rouault/codespell
+    cd codespell
+    git checkout gdal_improvements
+    cd ..
+    # Aggregate base dictionary + QGIS one + Debian Lintian one
+    curl https://raw.githubusercontent.com/qgis/QGIS/master/scripts/spelling.dat | sed "s/:/->/" | grep -v "colour->" | grep -v "colours->" > qgis.txt
+    curl https://anonscm.debian.org/cgit/lintian/lintian.git/plain/data/spelling/corrections| grep "||" | grep -v "#" | sed "s/||/->/" > debian.txt
+    cat codespell/data/dictionary.txt qgis.txt debian.txt | awk 'NF' > gdal_dict.txt
+    echo "difered->deferred" >> gdal_dict.txt
+    echo "differed->deferred" >> gdal_dict.txt
+    cd ..
+fi
+
+EXCLUDED_FILES="*/doc/i18n/*"
+#EXCLUDED_FILES="$EXCLUDED_FILES,*/src/*/test/*"
+EXCLUDED_FILES="$EXCLUDED_FILES,*/src/*/test/pgtap/*"
+#EXCLUDED_FILES="$EXCLUDED_FILES,*/src/*/src/*"
+#EXCLUDED_FILES="$EXCLUDED_FILES,*/src/*/sql/*"
+#EXCLUDED_FILES="$EXCLUDED_FILES,*/src/*/doc/*"
+EXCLUDED_FILES="$EXCLUDED_FILES,*/fix_typos/*,*/build/*"
+EXCLUDED_FILES="$EXCLUDED_FILES,*/.git/*"
+EXCLUDED_FILES="$EXCLUDED_FILES,*/tools/*"
+
+#WORDS_WHITE_LIST="poSession,FIDN,TRAFIC,HTINK,repID,oCurr,INTREST,oPosition"
+#WORDS_WHITE_LIST="$WORDS_WHITE_LIST,CPL_SUPRESS_CPLUSPLUS,SRP_NAM,ADRG_NAM,'SRP_NAM,AuxilaryTarget"
+# IRIS driver metadata item names: FIXME ?
+#WORDS_WHITE_LIST="$WORDS_WHITE_LIST,TOP_OF_HEIGTH_INTERVAL,BOTTOM_OF_HEIGTH_INTERVAL"
+# libjpeg
+#WORDS_WHITE_LIST="$WORDS_WHITE_LIST,JBUF_PASS_THRU"
+# libgif
+#WORDS_WHITE_LIST="$WORDS_WHITE_LIST,IS_WRITEABLE,E_GIF_ERR_NOT_WRITEABLE"
+# libtiff
+#WORDS_WHITE_LIST="$WORDS_WHITE_LIST,THRESHHOLD_BILEVEL,THRESHHOLD_HALFTONE,THRESHHOLD_ERRORDIFFUSE"
+
+python3 fix_typos/codespell/codespell.py -w -i 3 -q 2 -S $EXCLUDED_FILES \
+    -x tools/scripts/typos_whitelist.txt --words-white-list=$WORDS_WHITE_LIST \
+    -D fix_typos/gdal_dict.txt  .
+
diff --git a/tools/scripts/typos_whitelist.txt b/tools/scripts/typos_whitelist.txt
new file mode 100644
index 0000000..2812cb9
--- /dev/null
+++ b/tools/scripts/typos_whitelist.txt
@@ -0,0 +1,39 @@
+    // FIXME: is it a typo here or in IRIS itself: Perspective or Prespective ?
+    "Prespective from geosync","Equidistant cylindrical","Gnomonic",
+   /* 160 */ {"Bas_St_Wol", "Untergrenze strat. Bew|lkung", "hft", UC_NONE},
+   /* 161 */ {"Bas_St_Wol", "Untergrenze strat. Bew|lkung", "hPa", UC_NONE},
+   /* 164 */ {"Top_St_Wol", "Obergrenze strat. Bew|lkung", "hft", UC_NONE},
+   /* 165 */ {"Top_St_Wol", "Obergrenze strat. Bew|lkung", "hPa", UC_NONE},
+              "Icing Regime 1.Guess(1=gen,2=conv,3=strat,4=freez)", "1",
+              "Icing Regime(1=general,2=convect,3=strat,4=freez)", "1",
+ * The generated swig_type_info structures are assigned staticly to an initial 
+ * The generated swig_type_info structures are assigned staticly to an initial
+            YUR = 0.0;
+            YUR = oES.YUR;
+        double YUR;
+    l_segment->YUR = seg_data.GetDouble(nPos+215, 22);
+    seg_data.Put(psOrbit->YUR,nPos+215,22,"%22.14f");
+/* Putting statics in headers is trouble. */
+See COMMITERS file. 
+  /* When multiple interpeters are used, a module could have already been initialized in
+    const char* pszNAM = record->GetStringSubfield("DSI", 0, "NAM", 0);
+                    const char* pszNAM = record->GetStringSubfield("FDR", iFDRFieldInstance++, "NAM", 0);
+                                                "PRT!NAM",
+    sizeOfFields[nFields] += WriteSubFieldStr(fd, osBaseFileName, 8); /* NAM */
+    sizeOfFields[nFields] += WriteSubFieldStr(fd, osNAM.c_str(), 8); /* NAM */
+                                                  "NAM!STR!PRT!SWO!SWA!NEO!NEA",
+        sizeOfFields[nFields] += WriteSubFieldStr(fd, osBaseFileName, 8); /* NAM */
+      {136, "Socialist Republic of Viet Nam"},
+        double  eps[NANGLES], ua, va, ang, epsa;
+                ang = uv2ang(ua, va);
+                i = (int) ang;
+                epsa = fabs(ang - (i+.5));
+                "     UN=Metres,SD=HHWLT,DX=2.500000,DY=2.500000\n");
+        pszUnitsPer = CPLGetXMLValue( psSrcXML, "metresPerUnit", NULL );
+    {"kilometre",    /* 15 */ 12,  13,  1000.0},
+                    oSRS.SetLinearUnits( "kilometre", 1000.0 );
+{ "kilometre", SRS_UL_KILOMETER_CONV, "km" }, // Leave as 'kilometre' instead of SRS_UL_KILOMETER due to historical usage
+            passport.stMapDescription.eUnitInPlan = SXF_COORD_MU_CENTIMETRE;
+            passport.stMapDescription.eUnitInPlan = SXF_COORD_MU_MILLIMETRE;
+    SXF_COORD_MU_CENTIMETRE,
+    SXF_COORD_MU_MILLIMETRE,
diff --git a/tools/sigs/pgrouting--2.0.0.sig b/tools/sigs/pgrouting--2.0.0.sig
index cea030e..df4e0dc 100644
--- a/tools/sigs/pgrouting--2.0.0.sig
+++ b/tools/sigs/pgrouting--2.0.0.sig
@@ -33,4 +33,5 @@ pgr_trsp(text,integer,float8,integer,float8,boolean,boolean,text)
 pgr_trsp(text,integer,integer,boolean,boolean,text)
 pgr_tsp(float8[][],integer,integer,out integer,out integer)
 pgr_tsp(text,integer,integer)
+pgr_version()
 pgr_versionless(text,text)
diff --git a/tools/sigs/pgrouting--2.0.1.sig b/tools/sigs/pgrouting--2.0.1.sig
index ec900ca..2f22ebb 100644
--- a/tools/sigs/pgrouting--2.0.1.sig
+++ b/tools/sigs/pgrouting--2.0.1.sig
@@ -33,4 +33,5 @@ pgr_trsp(text,integer,float8,integer,float8,boolean,boolean,text)
 pgr_trsp(text,integer,integer,boolean,boolean,text)
 pgr_tsp(float8[][],integer,integer,out integer,out integer)
 pgr_tsp(text,integer,integer)
+pgr_version()
 pgr_versionless(text,text)
diff --git a/tools/sigs/pgrouting--2.2.4.sig b/tools/sigs/pgrouting--2.2.4.sig
new file mode 100644
index 0000000..6afe484
--- /dev/null
+++ b/tools/sigs/pgrouting--2.2.4.sig
@@ -0,0 +1,109 @@
+#VERSION pgrouting 2.2.4
+#TYPES
+pgr_costResult(integer,integer,integer,float8)
+pgr_costResult3(integer,integer,integer,integer,float8)
+pgr_geomResult(integer,integer,integer,geometry)
+#FUNCTIONS
+_pgr_checkverttab(text,text[],in int ,in text ,out text,out text)
+_pgr_createindex(text,text,text,text,in int ,in text )
+_pgr_createindex(text,text,text,in int ,in text )
+_pgr_dijkstra(text,bigint,bigint,boolean,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,bigint,anyarray,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,anyarray,bigint,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_dijkstra(text,anyarray,anyarray,boolean ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+_pgr_drivingdistance(text,bigint,float8,boolean,out integer,out bigint,out bigint,out float,out float)
+_pgr_drivingdistance(text,anyarray,float8,boolean,boolean,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_endpoint(geometry)
+_pgr_getcolumnname(text,text,text,in int ,in text )
+_pgr_getcolumnname(text,text,in int ,in text )
+_pgr_getcolumntype(text,text,text,in int ,in text )
+_pgr_getcolumntype(text,text,in int ,in text )
+_pgr_gettablename(in text,in int ,in text ,out text,out text)
+_pgr_get_statement(text)
+_pgr_iscolumnintable(text,text)
+_pgr_iscolumnindexed(text,text,text,in int ,in text )
+_pgr_iscolumnindexed(text,text,in int ,in text )
+_pgr_ksp(text,bigint,bigint,integer,boolean,boolean,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_makedistancematrix(text,out double precision[],out integer[])
+_pgr_msg(in int,in text,in text )
+_pgr_onerror(in boolean,in int,in text,in text,in text ,in text )
+_pgr_parameter_check(text,text,boolean )
+_pgr_pointtoid(geometry,double precision,text,integer)
+_pgr_quote_ident(text)
+_pgr_startpoint(geometry)
+_pgr_trsp(text,integer,integer,boolean,boolean,text )
+_pgr_trspviavertices(text,integer[],boolean,boolean,text )
+_pgr_versionless(text,text)
+_pgr_withpoints(text,text,bigint,bigint,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,bigint,anyarray,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,anyarray,bigint,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpoints(text,text,anyarray,anyarray,boolean,char,boolean,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+_pgr_withpointsvia(text,bigint[],float[],boolean ,out integer,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float,out float)
+pgr_alphashape(text,float8 ,out float8,out float8)
+pgr_analyzeoneway(text,text[],text[],text[],text[],boolean ,text ,text ,text )
+pgr_analyzegraph(text,double precision,text ,text ,text ,text ,text )
+pgr_apspjohnson(text)
+pgr_apspwarshall(text,boolean,boolean)
+pgr_astar(text,integer,integer,boolean,boolean)
+pgr_bdastar(text,integer,integer,boolean,boolean)
+pgr_bddijkstra(text,integer,integer,boolean,boolean)
+pgr_createtopology(text,double precision,text ,text ,text ,text ,text ,boolean )
+pgr_createverticestable(text,text ,text ,text ,text )
+pgr_dijkstra(text,bigint,bigint,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,bigint,bigint,boolean,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,bigint,anyarray,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,integer,integer,boolean,boolean)
+pgr_dijkstra(text,anyarray,bigint,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstra(text,anyarray,anyarray,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+pgr_dijkstracost(text,bigint,bigint,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,bigint,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,anyarray,bigint,boolean ,out bigint,out bigint,out float)
+pgr_dijkstracost(text,anyarray,anyarray,boolean ,out bigint,out bigint,out float)
+pgr_dijkstravia(text,anyarray,boolean ,boolean ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float,out float)
+pgr_drivingdistance(text,bigint,float8,boolean,boolean)
+pgr_drivingdistance(text,bigint,float8,boolean ,out integer,out bigint,out bigint,out float,out float)
+pgr_drivingdistance(text,anyarray,float8,boolean ,boolean ,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_endpoint(geometry)
+pgr_flipedges(geometry[])
+pgr_floydwarshall(text,boolean ,out bigint,out bigint,out float)
+pgr_getcolumnname(text,text)
+pgr_gettablename(in text,out text,out text)
+pgr_gsoc_vrppdtw(text,integer,integer,out integer,out integer,out integer,out integer )
+pgr_iscolumnintable(text,text)
+pgr_iscolumnindexed(text,text)
+pgr_johnson(text,boolean ,out bigint,out bigint,out float)
+pgr_kdijkstrapath(text,integer,integer array,boolean,boolean)
+pgr_kdijkstracost(text,integer,integer array,boolean,boolean)
+pgr_ksp(text,bigint,bigint,integer,boolean ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_ksp(text,integer,integer,integer,boolean)
+pgr_labelgraph(text,text ,text ,text ,text ,text )
+pgr_nodenetwork(text,double precision,text ,text ,text ,text ,boolean )
+pgr_pointsaspolygon(varchar,float8 )
+pgr_pointstodmatrix(geometry[],integer )
+pgr_pointstovids(geometry[],text,float8 )
+pgr_pointtoedgenode(text,geometry,float8)
+pgr_quote_ident(text)
+pgr_startpoint(geometry)
+pgr_texttopoints(text,integer )
+pgr_trsp(text,integer,integer,boolean,boolean,text )
+pgr_trsp(text,integer,float8,integer,float8,boolean,boolean,text )
+pgr_trspviaedges(text,integer[],float8[],boolean,boolean,text )
+pgr_trspviavertices(text,anyarray,boolean,boolean,text )
+pgr_tsp(float8[][],integer,integer ,out integer,out integer)
+pgr_tsp(text,integer,integer )
+pgr_version()
+pgr_versionless(text,text)
+pgr_vidstodmatrix(text,integer[],bool,bool,bool)
+pgr_vidstodmatrix(in integer[],in geometry[],in text,float8 )
+pgr_vrponedepot(text,text,text,integer,out integer,out integer,out integer,out integer,out integer)
+pgr_withpoints(text,text,bigint,bigint,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,bigint,anyarray,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,anyarray,bigint,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpoints(text,text,anyarray,anyarray,boolean ,char ,boolean ,out integer,out integer,out bigint,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpointscost(text,text,bigint,bigint,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,bigint,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,anyarray,bigint,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointscost(text,text,anyarray,anyarray,boolean ,char ,out bigint,out bigint,out float)
+pgr_withpointsdd(text,text,anyarray,float,boolean ,char ,boolean ,boolean ,out integer,out bigint,out bigint,out bigint,out float,out float)
+pgr_withpointsdd(text,text,bigint,float,boolean ,char ,boolean ,out integer,out bigint,out bigint,out float,out float)
+pgr_withpointsksp(text,text,bigint,bigint,integer,boolean ,boolean ,char ,boolean ,out integer,out integer,out integer,out bigint,out bigint,out float,out float)
diff --git a/tools/template/create.sh b/tools/template/create.sh
index 92c4687..c8207c1 100644
--- a/tools/template/create.sh
+++ b/tools/template/create.sh
@@ -17,20 +17,36 @@ MY_QUERY_LINE2="OUT seq INTEGER,\n    OUT path_seq INTEGER,\n    OUT start_vid B
 MY_RETURN_VALUE_TYPE="General_path_element_t" 
 MY_FUNCTION_NAME_UPPER=$(echo $MY_FUNCTION_NAME | tr 'a-z' 'A-Z')
 
+# Available types to store the edge information:
+#  pgr_edge_t      http://docs.pgrouting.org/doxy/2.3-dev-develop/structpgr__edge__t.html
+#  Pgr_edge_xy_t   http://docs.pgrouting.org/doxy/2.3-dev-develop/structPgr__edge__xy__t.html
+MY_EDGE_TYPE="pgr_edge_t"
+
+# Available functions that read the edge information:
+# pgr_get_edges                 http://docs.pgrouting.org/doxy/2.3-dev-develop/edges__input_8h.html#a5598918a215c72c9bda7a7f016401b73
+# pgr_get_edges_xy              http://docs.pgrouting.org/doxy/2.3-dev-develop/edges__input_8h.html#a5483d52e67b7996d80cd0cf3583d1720
+# pgr_get_edges_xy_reversed     http://docs.pgrouting.org/doxy/2.3-dev-develop/edges__input_8h.html#adce525c316ba6244510553a5cee8451f
+# pgr_get_edges_no_id           http://docs.pgrouting.org/doxy/2.3-dev-develop/edges__input_8h.html#a747dea3b61ecc407746f9d83d923fa64
+MY_EDGE_FUNCTION="pgr_get_edges"
+
+
+
+
+
 #the above variables must be defined
 
 if test -z "$MY_FUNCTION_NAME"; then 
-	exit
+    exit
 fi
 
 #if a directory named MY_FUNCTION_NAME exist we stop
 if [ -d "$MY_FUNCTION_NAME" ]; then
-        echo "directory exists please delete first"
-	exit
+    echo "directory exists please delete first"
+    exit 1
 fi
 if [ -d ../../src/"$MY_FUNCTION_NAME" ]; then
-        echo "directory exists please delete first"
-	exit
+    echo "directory exists please delete first"
+    exit 1
 fi
 
 mkdir "$MY_FUNCTION_NAME"
@@ -40,7 +56,6 @@ cp -r sql  "$MY_FUNCTION_NAME"
 cp -r doc  "$MY_FUNCTION_NAME"
 cp -r test  "$MY_FUNCTION_NAME"
 cp -r  src  "$MY_FUNCTION_NAME"
-cp CMakeLists.txt  "$MY_FUNCTION_NAME"
 
 
 
@@ -68,6 +83,8 @@ sed -i "s/MY_FUNCTION_NAME/$MY_FUNCTION_NAME/" "$MY_FUNCTION_NAME"/src/function1
 sed -i "s/DEVELOPER_NAME/$DEVELOPER_NAME/" "$MY_FUNCTION_NAME"/src/function1.c
 sed -i "s/DEVELOPER_EMAIL/$MY_DEVELOPER_EMAIL/" "$MY_FUNCTION_NAME"/src/function1.c
 sed -i "s/YEAR/$YEAR/" "$MY_FUNCTION_NAME"/src/function1.c
+sed -i "s/MY_EDGE_TYPE/$MY_EDGE_TYPE/" "$MY_FUNCTION_NAME"/src/function1.c
+sed -i "s/MY_EDGE_FUNCTION/$MY_EDGE_FUNCTION/" "$MY_FUNCTION_NAME"/src/function1.c
 sed -i "s/MY_QUERY_LINE1/$MY_QUERY_LINE1/" "$MY_FUNCTION_NAME"/src/function1.c
 sed -i "s/MY_QUERY_LINE2/$MY_QUERY_LINE2/" "$MY_FUNCTION_NAME"/src/function1.c
 sed -i "s/MY_RETURN_VALUE_TYPE/$MY_RETURN_VALUE_TYPE/" "$MY_FUNCTION_NAME"/src/function1.c
@@ -79,6 +96,7 @@ sed -i "s/MY_FUNCTION_NAME/$MY_FUNCTION_NAME/" "$MY_FUNCTION_NAME"/src/function1
 sed -i "s/DEVELOPER_NAME/$DEVELOPER_NAME/" "$MY_FUNCTION_NAME"/src/function1_driver.h
 sed -i "s/DEVELOPER_EMAIL/$MY_DEVELOPER_EMAIL/" "$MY_FUNCTION_NAME"/src/function1_driver.h
 sed -i "s/YEAR/$YEAR/" "$MY_FUNCTION_NAME"/src/function1_driver.h
+sed -i "s/MY_EDGE_TYPE/$MY_EDGE_TYPE/" "$MY_FUNCTION_NAME"/src/function1_driver.h
 sed -i "s/MY_QUERY_LINE1/$MY_QUERY_LINE1/" "$MY_FUNCTION_NAME"/src/function1_driver.h
 sed -i "s/MY_QUERY_LINE2/$MY_QUERY_LINE2/" "$MY_FUNCTION_NAME"/src/function1_driver.h
 sed -i "s/MY_RETURN_VALUE_TYPE/$MY_RETURN_VALUE_TYPE/" "$MY_FUNCTION_NAME"/src/function1_driver.h
@@ -89,6 +107,7 @@ sed -i "s/MY_FUNCTION_NAME/$MY_FUNCTION_NAME/" "$MY_FUNCTION_NAME"/src/function1
 sed -i "s/DEVELOPER_NAME/$DEVELOPER_NAME/" "$MY_FUNCTION_NAME"/src/function1_driver.cpp
 sed -i "s/DEVELOPER_EMAIL/$MY_DEVELOPER_EMAIL/" "$MY_FUNCTION_NAME"/src/function1_driver.cpp
 sed -i "s/YEAR/$YEAR/" "$MY_FUNCTION_NAME"/src/function1_driver.cpp
+sed -i "s/MY_EDGE_TYPE/$MY_EDGE_TYPE/" "$MY_FUNCTION_NAME"/src/function1_driver.cpp
 sed -i "s/MY_QUERY_LINE1/$MY_QUERY_LINE1/" "$MY_FUNCTION_NAME"/src/function1_driver.cpp
 sed -i "s/MY_QUERY_LINE2/$MY_QUERY_LINE2/" "$MY_FUNCTION_NAME"/src/function1_driver.cpp
 sed -i "s/MY_RETURN_VALUE_TYPE/$MY_RETURN_VALUE_TYPE/" "$MY_FUNCTION_NAME"/src/function1_driver.cpp
diff --git a/tools/template/src/function1.c b/tools/template/src/function1.c
index bd1dd71..f74a560 100644
--- a/tools/template/src/function1.c
+++ b/tools/template/src/function1.c
@@ -39,10 +39,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 /*
   Uncomment when needed
 */
-//#define DEBUG
+// #define DEBUG
 
 #include "fmgr.h"
 #include "./../../common/src/debug_macro.h"
+#include "./../../common/src/time_msg.h"
 #include "./../../common/src/pgr_types.h"
 #include "./../../common/src/postgres_connection.h"
 #include "./../../common/src/edges_input.h"
@@ -73,35 +74,49 @@ process( char* edges_sql,
     pgr_SPI_connect();
 
     PGR_DBG("Load data");
-    pgr_edge_t *edges = NULL;
-    int64_t total_tuples = 0;
-    pgr_get_data_5_columns(edges_sql, &edges, &total_tuples);
+    MY_EDGE_TYPE *edges = NULL;
+    size_t total_edges = 0;
 
-    if (total_tuples == 0) {
+    MY_EDGE_FUNCTION(edges_sql, &edges, &total_edges);
+    PGR_DBG("Total %ld edges in query:", total_edges);
+
+    if (total_edges == 0) {
         PGR_DBG("No edges found");
         (*result_count) = 0;
         (*result_tuples) = NULL;
         pgr_SPI_finish();
         return;
     }
-    PGR_DBG("Total %ld tuples in query:", total_tuples);
 
     PGR_DBG("Starting processing");
-    char *err_msg = (char *)"";
+    char *err_msg = NULL;
+    char *log_msg = NULL;
+
+    // Code standard:
+    // Pass the arrays and the sizes on the same line
+    clock_t start_t = clock();
     do_pgr_MY_FUNCTION_NAME(
-            edges,
-            total_tuples,
+            edges, total_edges,
             start_vid,
-            end_vidsArr,
-            size_end_vidsArr,
+            end_vidsArr, size_end_vidsArr,
             directed,
             result_tuples,
             result_count,
+            &log_msg,
             &err_msg);
+    time_msg(" processing pgr_funnyDijkstra", start_t, clock());
+
     PGR_DBG("Returning %ld tuples\n", *result_count);
-    PGR_DBG("Returned message = %s\n", err_msg);
+    PGR_DBG("LOG: %s\n", log_msg);
+    if (log_msg) free(log_msg);
+
+    if (err_msg) {
+        if (*result_tuples) free(*result_tuples);
+        if (end_vidsArr) free(end_vidsArr);
+        elog(ERROR, "%s", err_msg);
+        free(err_msg);
+    }
 
-    free(err_msg);
     pfree(edges);
     pgr_SPI_finish();
 }
@@ -115,9 +130,9 @@ PGDLLEXPORT Datum
 #endif
 MY_FUNCTION_NAME(PG_FUNCTION_ARGS) {
     FuncCallContext     *funcctx;
-    size_t              call_cntr;
-    size_t               max_calls;
-    TupleDesc            tuple_desc;
+    uint32_t            call_cntr;
+    uint32_t            max_calls;
+    TupleDesc           tuple_desc;
 
     /**************************************************************************/
     /*                          MODIFY AS NEEDED                              */
@@ -146,6 +161,9 @@ MY_FUNCTION_NAME(PG_FUNCTION_ARGS) {
         PGR_DBG("targetsArr size %ld ", size_end_vidsArr);
 
         PGR_DBG("Calling process");
+        // Code standard:
+        // Use same order as in the query
+        // Pass the array and it's size on the same line
         process(
                 pgr_text2char(PG_GETARG_TEXT_P(0)),
                 PG_GETARG_INT64(1),
@@ -154,12 +172,13 @@ MY_FUNCTION_NAME(PG_FUNCTION_ARGS) {
                 &result_tuples,
                 &result_count);
 
-        PGR_DBG("Cleaning arrays");
+        // while developing leave the message as a reminder
+        PGR_DBG("Cleaning arrays using free(<array-name>)");
         free(end_vidsArr);
         /*                                                                             */
         /*******************************************************************************/
 
-        funcctx->max_calls = result_count;
+        funcctx->max_calls = (uint32_t) result_count;
         funcctx->user_fctx = result_tuples;
         if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE)
             ereport(ERROR,
@@ -181,22 +200,22 @@ MY_FUNCTION_NAME(PG_FUNCTION_ARGS) {
         HeapTuple    tuple;
         Datum        result;
         Datum        *values;
-        char*        nulls;
+        bool*        nulls;
 
         /*******************************************************************************/
         /*                          MODIFY!!!!!                                        */
         /*  This has to match you ouput otherwise the server crashes                   */
         /*
            MY_QUERY_LINE2
-        ********************************************************************************/
+         ********************************************************************************/
 
 
         values = palloc(8 * sizeof(Datum));
-        nulls = palloc(8 * sizeof(char));
+        nulls = palloc(8 * sizeof(bool));
 
         size_t i;
         for(i = 0; i < 8; ++i) {
-            nulls[i] = ' ';
+            nulls[i] = false;
         }
 
 
@@ -211,7 +230,7 @@ MY_FUNCTION_NAME(PG_FUNCTION_ARGS) {
         values[7] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
         /*******************************************************************************/
 
-        tuple = heap_formtuple(tuple_desc, values, nulls);
+        tuple = heap_form_tuple(tuple_desc, values, nulls);
         result = HeapTupleGetDatum(tuple);
         SRF_RETURN_NEXT(funcctx, result);
     } else {
diff --git a/tools/template/src/function1_driver.cpp b/tools/template/src/function1_driver.cpp
index 660cbed..9656245 100644
--- a/tools/template/src/function1_driver.cpp
+++ b/tools/template/src/function1_driver.cpp
@@ -31,104 +31,130 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #ifdef __MINGW32__
 #include <winsock2.h>
 #include <windows.h>
+#ifdef open
+#undef open
+#endif
 #endif
 
 
 #include <sstream>
 #include <deque>
+#include <algorithm>
 #include <vector>
 #include "./pgr_dijkstra.hpp"
 #include "./MY_FUNCTION_NAME_driver.h"
 
-// #define DEBUG
-
-extern "C" {
 #include "./../../common/src/pgr_types.h"
-}
-
-#include "./../../common/src/memory_func.hpp"
+#include "./../../common/src/pgr_assert.h"
+#include "./../../common/src/pgr_alloc.hpp"
 
 /************************************************************
   MY_QUERY_LINE1
  ***********************************************************/
 void
 do_pgr_MY_FUNCTION_NAME(
-        pgr_edge_t  *data_edges,
-        size_t total_tuples,
+        MY_EDGE_TYPE  *data_edges, size_t total_edges,
         int64_t start_vid,
-        int64_t  *end_vidsArr,
-        int size_end_vidsArr,
+        int64_t  *end_vidsArr, size_t size_end_vidsArr,
         bool directed,
         MY_RETURN_VALUE_TYPE **return_tuples,
         size_t *return_count,
+        char ** log_msg,
         char ** err_msg){
+    std::ostringstream err;
     std::ostringstream log;
     try {
-
-        if (total_tuples == 1) {
-            log << "Required: more than one tuple\n";
+        
+        pgassert(!(*log_msg));
+        pgassert(!(*err_msg));
+        pgassert(!(*return_tuples));
+        pgassert(*return_count == 0);
+        pgassert(total_edges != 0);
+
+        /* depending on the functionality some tests can be done here
+         * For example */
+        if (total_edges <= 1) {
+            err << "Required: more than one edges\n";
             (*return_tuples) = NULL;
             (*return_count) = 0;
-            *err_msg = strdup(log.str().c_str());
+            *err_msg = strdup(err.str().c_str());
             return;
         }
 
         graphType gType = directed? DIRECTED: UNDIRECTED;
-        const int initial_size = total_tuples;
 
         std::deque< Path >paths;
+        // samll logs
         log << "Inserting vertices into a c++ vector structure\n";
-        std::set< int64_t > end_vertices(end_vidsArr, end_vidsArr + size_end_vidsArr);
-#ifdef DEBUG
-        for (const auto &vid : end_vertices) log << vid <<"\n";
-        log << "Destination" << start_vid;
+        std::vector< int64_t > end_vertices(end_vidsArr, end_vidsArr + size_end_vidsArr);
+        std::sort(end_vertices.begin(),end_vertices.end());
+#ifndef NDEBUG
+        // big logs with cycles wrap them so on release they wont consume time
+        log << "end vids: ";
+        for (const auto &vid : end_vertices) log << vid << ",";
+        log << "\nstart vid:" << start_vid << "\n";
 #endif
+
         if (directed) {
+            // very detailed logging
             log << "Working with directed Graph\n";
-            Pgr_base_graph< DirectedGraph > digraph(gType, initial_size);
-            digraph.graph_insert_data(data_edges, total_tuples);
-#ifdef DEBUG
-            digraph.print_graph(log);
+            pgRouting::DirectedGraph digraph(gType);
+            log << "Working with directed Graph 1 \n";
+            digraph.graph_insert_data(data_edges, total_edges);
+
+#ifndef NDEBUG
+            // a graph log is a big log
+            log << digraph;
 #endif
+            
+            log << "Working with directed Graph 2\n";
             pgr_dijkstra(digraph, paths, start_vid, end_vertices, false);
+            log << "Working with directed Graph 3\n";
         } else {
+            // maybe the code is working so cleaner logging
             log << "Working with Undirected Graph\n";
-            Pgr_base_graph< UndirectedGraph > undigraph(gType, initial_size);
-            undigraph.graph_insert_data(data_edges, total_tuples);
-#ifdef DEBUG
-            undigraph.print_graph(log);
-#endif
+            pgRouting::UndirectedGraph undigraph(gType);
+            undigraph.graph_insert_data(data_edges, total_edges);
             pgr_dijkstra(undigraph, paths, start_vid, end_vertices, false);
         }
 
-        size_t count(count_tuples(paths));
+        // use auto when possible
+        auto count(count_tuples(paths));
 
         if (count == 0) {
             (*return_tuples) = NULL;
             (*return_count) = 0;
             log << 
                 "No paths found between Starting and any of the Ending vertices\n";
-            *err_msg = strdup(log.str().c_str());
+            *log_msg = strdup(log.str().c_str());
             return;
         }
 
         // get the space required to store all the paths
-        (*return_tuples) = get_memory(count, (*return_tuples));
+        (*return_tuples) = pgr_alloc(count, (*return_tuples));
         log << "Converting a set of paths into the tuples\n";
         (*return_count) = (collapse_paths(return_tuples, paths));
 
-#ifndef DEBUG
-        *err_msg = strdup("OK");
-#else
+        *err_msg = NULL;
+        *log_msg = strdup(log.str().c_str());
+
+    } catch (AssertFailedException &exept) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << exept.what() << "\n";
         *err_msg = strdup(log.str().c_str());
-#endif
-    } catch ( ... ) {
-        log << "Caught unknown expection!\n";
+        *log_msg = strdup(log.str().c_str());
+    } catch (std::exception& exept) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << exept.what() << "\n";
         *err_msg = strdup(log.str().c_str());
+        *log_msg = strdup(log.str().c_str());
+    } catch(...) {
+        if (*return_tuples) free(*return_tuples);
+        (*return_count) = 0;
+        err << "Caught unknown exception!\n";
+        *err_msg = strdup(log.str().c_str());
+        *log_msg = strdup(log.str().c_str());
     }
 }
-
-
-
-
-
diff --git a/tools/template/src/function1_driver.h b/tools/template/src/function1_driver.h
index 08661ce..4c4c5a0 100644
--- a/tools/template/src/function1_driver.h
+++ b/tools/template/src/function1_driver.h
@@ -38,17 +38,17 @@ extern "C" {
     /*********************************************************
       MY_QUERY_LINE1
      ********************************************************/
-    void
-        do_pgr_MY_FUNCTION_NAME(
-                pgr_edge_t  *data_edges,
-                size_t total_tuples,
-                int64_t start_vid,
-                int64_t  *end_vidsArr,
-                int size_end_vidsArr,
-                bool directed,
-                MY_RETURN_VALUE_TYPE **return_tuples,
-                size_t *return_count,
-                char ** err_msg);
+
+    // Code standard:
+    // Pass the arrays and the sizes on the same line
+    void do_pgr_MY_FUNCTION_NAME(
+            MY_EDGE_TYPE *data_edges, size_t total_edges,
+            int64_t start_vid,
+            int64_t  *end_vidsArr, size_t size_end_vidsArr,
+            bool directed,
+            MY_RETURN_VALUE_TYPE **return_tuples, size_t *return_count,
+            char ** log_msg,
+            char ** err_msg);
 
 
 #ifdef __cplusplus
diff --git a/tools/template/test/pgtap/types-check.sql b/tools/template/test/pgtap/types-check.sql
index 0c371ee..c94d656 100644
--- a/tools/template/test/pgtap/types-check.sql
+++ b/tools/template/test/pgtap/types-check.sql
@@ -1,8 +1,28 @@
 
 \i setup.sql
 
+SELECT plan(19);
 
-SELECT plan(17);
+SELECT has_function('pgr_MY_FUNCTION_NAME', ARRAY['text','bigint','anyarray','boolean']);
+SELECT function_returns('pgr_MY_FUNCTION_NAME', ARRAY['text','bigint','anyarray','boolean'],'setof record');
+
+PREPARE v21q01 AS
+SELECT  'integer'::text AS t1,'integer'::text AS t2,
+'bigint'::text AS t5, 'bigint'::text AS t6,
+'double precision'::text AS t7, 'double precision'::text AS t8;
+
+PREPARE v21q10 AS
+SELECT pg_typeof(seq)::text AS t1, pg_typeof(path_seq)::text AS t2,
+pg_typeof(end_vid)::text AS t4,
+pg_typeof(node)::text AS t5, pg_typeof(edge)::text AS t6,
+pg_typeof(cost)::text AS t7, pg_typeof(agg_cost)::TEXT AS t8 
+FROM ( 
+    SELECT * FROM pgr_MY_FUNCTION_NAME(
+        'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost::FLOAT, reverse_cost::FLOAT FROM edge_table',
+        2, ARRAY[3], true) ) AS a
+limit 1;
+
+SELECT set_eq('v21q01', 'v21q10','pgr_MY_FUNCTION_NAME 1 to many: SHOULD RETURN expected columns names & types');
 
 PREPARE q1 AS
 SELECT * FROM pgr_MY_FUNCTION_NAME(
@@ -34,13 +54,12 @@ SELECT * FROM pgr_MY_FUNCTION_NAME(
     'SELECT id, source, target, cost, reverse_cost FROM edge_table',
     2, ARRAY[5,3]::BIGINT[]);
 
-SELECT lives_ok('q1', 'edges query accepts ANY-INTEGER & ANY NUMERICAL');
-SELECT lives_ok('q2', 'start_vid accepts BIGINT');
-SELECT lives_ok('q3', 'start_vid accepts SMALLINT');
-SELECT lives_ok('q4', 'end_vids accepts array of INTEGER');
-SELECT lives_ok('q4', 'end_vids accepts array of SMALLINT');
-SELECT lives_ok('q5', 'end_vids accepts array of BIGINT');
-SELECT lives_ok('q6', 'end_vids accepts array of BIGINT');
+SELECT lives_ok('q1', 'SHOULD LIVE because edges query accepts ANY-INTEGER & ANY NUMERICAL');
+SELECT lives_ok('q2', 'SHOULD LIVE because start_vid accepts BIGINT');
+SELECT lives_ok('q3', 'SHOULD LIVE because start_vid accepts SMALLINT');
+SELECT lives_ok('q4', 'SHOULD LIVE because end_vids accepts array of INTEGER');
+SELECT lives_ok('q5', 'SHOULD LIVE because end_vids accepts array of SMALLINT');
+SELECT lives_ok('q6', 'SHOULD LIVE because end_vids accepts array of BIGINT');
 
 
 PREPARE q10 AS
@@ -54,9 +73,9 @@ SELECT * FROM pgr_MY_FUNCTION_NAME(
     2, ARRAY[5,3]);
 
 SELECT throws_ok('q10', 'XX000', 'Unexpected Column ''id'' type. Expected ANY-INTEGER',
-    'Throws because id is FLOAT');
+    'SHOULD THROW because id is FLOAT');
 SELECT throws_ok('q11', 'XX000', 'Unexpected Column ''id'' type. Expected ANY-INTEGER',
-    'Throws because id is REAL');
+    'SHOULD THROW because id is REAL');
 
 PREPARE q12 AS
 SELECT * FROM pgr_MY_FUNCTION_NAME(
@@ -69,9 +88,9 @@ SELECT * FROM pgr_MY_FUNCTION_NAME(
     2, ARRAY[5,3]);
 
 SELECT throws_ok('q12', 'XX000', 'Unexpected Column ''source'' type. Expected ANY-INTEGER',
-    'Throws because source is FLOAT');
+    'SHOULD THROW because source is FLOAT');
 SELECT throws_ok('q13', 'XX000', 'Unexpected Column ''source'' type. Expected ANY-INTEGER',
-    'Throws because source is REAL');
+    'SHOULD THROW because source is REAL');
 
 PREPARE q14 AS
 SELECT * FROM pgr_MY_FUNCTION_NAME(
@@ -84,39 +103,39 @@ SELECT * FROM pgr_MY_FUNCTION_NAME(
     2, ARRAY[5,3]);
 
 SELECT throws_ok('q14', 'XX000', 'Unexpected Column ''target'' type. Expected ANY-INTEGER',
-    'Throws because source is FLOAT');
+    'SHOULD THROW because source is FLOAT');
 SELECT throws_ok('q15', 'XX000', 'Unexpected Column ''target'' type. Expected ANY-INTEGER',
-    'Throws because source is REAL');
+    'SHOULD THROW because source is REAL');
 
 
 SELECT throws_ok('
-SELECT * FROM pgr_MY_FUNCTION_NAME(
-    ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
-    2::FLOAT, ARRAY[5,3]);',
+    SELECT * FROM pgr_MY_FUNCTION_NAME(
+        ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
+        2::FLOAT, ARRAY[5,3]);',
     '42883', 'function pgr_MY_FUNCTION_NAME(unknown, double precision, integer[]) does not exist',
-    'Throws because start_vid is FLOAT');
+    'SHOULD THROW because start_vid is FLOAT');
 
 SELECT throws_ok('
-SELECT * FROM pgr_MY_FUNCTION_NAME(
-    ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
-    2::REAL, ARRAY[5,3]);',
+    SELECT * FROM pgr_MY_FUNCTION_NAME(
+        ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
+        2::REAL, ARRAY[5,3]);',
     '42883', 'function pgr_MY_FUNCTION_NAME(unknown, real, integer[]) does not exist',
-    'Throws because start_vid is REAL');
+    'SHOULD THROW because start_vid is REAL');
 
 
 SELECT throws_ok('
-SELECT * FROM pgr_MY_FUNCTION_NAME(
-    ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
-    2, ARRAY[5,3]::FLOAT[]);',
+    SELECT * FROM pgr_MY_FUNCTION_NAME(
+        ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
+        2, ARRAY[5,3]::FLOAT[]);',
     'XX000','Expected array of ANY-INTEGER',
-    'Throws because end_vids array is of FLOAT');
+    'SHOULD THROW because end_vids array is of FLOAT');
 
 SELECT throws_ok('
-SELECT * FROM pgr_MY_FUNCTION_NAME(
-    ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
-    2, ARRAY[5,3]::REAL[]);',
+    SELECT * FROM pgr_MY_FUNCTION_NAME(
+        ''SELECT id, source, target, cost, reverse_cost FROM edge_table'',
+        2, ARRAY[5,3]::REAL[]);',
     'XX000','Expected array of ANY-INTEGER',
-    'Throws because end_vids array is of REAL');
+    'SHOULD THROW because end_vids array is of REAL');
 
 
 
diff --git a/tools/testers/algorithm-tester.pl b/tools/testers/algorithm-tester.pl
index 1ac0cd3..0fec965 100755
--- a/tools/testers/algorithm-tester.pl
+++ b/tools/testers/algorithm-tester.pl
@@ -1,6 +1,6 @@
 #! /usr/bin/perl -w
-    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
-        if 0; #$running_under_some_shell
+eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+if 0; #$running_under_some_shell
 
 use strict;
 use File::Find ();
@@ -16,6 +16,7 @@ use vars qw/*name *dir *prune/;
 *prune  = *File::Find::prune;
 
 my $DOCUMENTATION = 0;
+my $INTERNAL_TESTS = 0;
 my $VERBOSE = 0;
 my $DRYRUN = 0;
 my $DEBUG = 0;
@@ -28,21 +29,22 @@ my $DBPORT;
 
 sub Usage {
     die "Usage: algorithm-tester.pl -pgver vpg -pgisver vpgis -psql /path/to/psql\n" .
-        "       -pgver vpg          - postgresql version\n" .
-        "       -pghost host        - postgresql host or socket directory to use\n" .
-        "       -pgport port        - postgresql port to use\n" .
-        "       -pguser username    - postgresql user role to use\n" .
-        "       -pgisver vpgis      - postgis version\n" .
-        "       -pgrver vpgr        - pgrouting version\n" .
-        "       -psql /path/to/psql - optional path to psql\n" .
-        "       -v                  - verbose messages for small debuging\n" .
-        "       -debug              - verbose messages for debuging(enter twice for more)\n" .
-        "       -debug1             - DEBUG1 messages (for timing reports)\n" .
-        "       -clean              - dropdb pgr_test__db__test\n" .
-        "       -ignorenotice       - ignore NOTICE statements when reporting failures\n" .
-        "       -alg 'dir'          - directory to select which algorithm subdirs to test\n" .
-        "       -documentation      - ONLY generate documentation examples\n" .
-        "       -h                  - help\n";
+    "       -pgver vpg          - postgresql version\n" .
+    "       -pghost host        - postgresql host or socket directory to use\n" .
+    "       -pgport port        - postgresql port to use\n" .
+    "       -pguser username    - postgresql user role to use\n" .
+    "       -pgisver vpgis      - postgis version\n" .
+    "       -pgrver vpgr        - pgrouting version\n" .
+    "       -psql /path/to/psql - optional path to psql\n" .
+    "       -v                  - verbose messages for small debuging\n" .
+    "       -dbg                - use when CMAKE_BUILD_TYPE = DEBUG\n" .
+    "       -debug              - verbose messages for debuging(enter twice for more)\n" .
+    "       -debug1             - DEBUG1 messages (for timing reports)\n" .
+    "       -clean              - dropdb pgr_test__db__test\n" .
+    "       -ignorenotice       - ignore NOTICE statements when reporting failures\n" .
+    "       -alg 'dir'          - directory to select which algorithm subdirs to test\n" .
+    "       -documentation      - ONLY generate documentation examples\n" .
+    "       -h                  - help\n";
 }
 
 print "RUNNING: algorithm-tester.pl " . join(" ", @ARGV) . "\n";
@@ -88,7 +90,7 @@ while (my $a = shift @ARGV) {
     elsif ($a eq '-psql') {
         $psql = shift @ARGV || Usage();
         die "'$psql' is not executable!\n"
-            unless -x $psql;
+        unless -x $psql;
     }
     elsif ($a =~ /^-h/) {
         Usage();
@@ -113,6 +115,9 @@ while (my $a = shift @ARGV) {
         $DOCUMENTATION = 1;
         $DEBUG1 = 0; # disbale timing reports during documentation generation
     }
+    elsif ($a =~ /^-dbg/i) {
+        $INTERNAL_TESTS = 1; #directory internalQueryTests is also tested
+    }
     else {
         warn "Error: unknown option '$a'\n";
         Usage();
@@ -144,18 +149,8 @@ if (length($psql)) {
         $psql = "\"$psql\"";
     }
 }
+print "Operative system found: $OS";
 
-# some unit tests
-#my $server_ver = getServerVersion();
-#my $server_ver = '9.2';
-#print "PSQL=$psql\n";
-#print "SERVER_VERSION=$server_ver\n";
-#print "version_greater_eq('9.1')=" . version_greater_eq($server_ver, '9.1') . "\n";
-#print "version_greater_eq('9.2')=" . version_greater_eq($server_ver, '9.2') . "\n";
-#print "version_greater_eq('9.3')=" . version_greater_eq($server_ver, '9.3') . "\n";
-#print "version_greater_eq('8.3')=" . version_greater_eq($server_ver, '8.3') . "\n";
-#print "template_pgrouting=" . dbExists('template_pgrouting') . "\n";
-#exit;
 
 # Traverse desired filesystems
 File::Find::find({wanted => \&want_tests}, @testpath);
@@ -224,7 +219,7 @@ sub run_test {
         createTestDB($singleDB);
         mysystem("$psql $connopts -A -t -q -f tools/testers/sampledata.sql' $singleDB >> $TMP2 2>\&1 ");
         for my $x (@{$t->{data}}) {
-           mysystem("$psql $connopts -A -t -q -f '$dir/$x' $singleDB >> $TMP2 2>\&1 ");
+            mysystem("$psql $connopts -A -t -q -f '$dir/$x' $singleDB >> $TMP2 2>\&1 ");
         }
         process_single_test($testName, $dir, $singleDB,\%res);
         mysystem("dropdb $connopts $singleDB");
@@ -232,9 +227,14 @@ sub run_test {
 
     mysystem("$psql $connopts -A -t -q -f tools/testers/sampledata.sql $DBNAME >> $TMP2 2>\&1 ");
     for my $x (@{$t->{data}}) {
-       mysystem("$psql $connopts -A -t -q -f '$dir/$x' $DBNAME >> $TMP2 2>\&1 ");
+        mysystem("$psql $connopts -A -t -q -f '$dir/$x' $DBNAME >> $TMP2 2>\&1 ");
     }
 
+    if ($INTERNAL_TESTS) {
+        for my $x (@{$t->{debugtests}}) {
+            process_single_test($x, $dir,, $DBNAME, \%res)
+        }
+    }
     if ($DOCUMENTATION) {
         for my $x (@{$t->{documentation}}) {
             process_single_test($x, $dir,, $DBNAME, \%res)
@@ -244,6 +244,19 @@ sub run_test {
         for my $x (@{$t->{tests}}) {
             process_single_test($x, $dir,, $DBNAME, \%res)
         }
+        if ($OS =~ /msys/ || $OS=~/MSW/ || $OS =~ /cygwin/) {
+            for my $x (@{$t->{windows}}) {
+                process_single_test($x, $dir,, $DBNAME, \%res)
+            }
+        } elsif ($OS=~/Mac/ ||  $OS=~/dar/) {
+            for my $x (@{$t->{macos}}) {
+                process_single_test($x, $dir,, $DBNAME, \%res)
+            }
+        } else {
+            for my $x (@{$t->{linux}}) {
+                process_single_test($x, $dir,, $DBNAME, \%res)
+            }
+        }
     }
 
     return \%res;
@@ -254,93 +267,95 @@ sub process_single_test{
     my $dir = shift;
     my $database = shift;
     my $res = shift;
-        #each tests will use clean data
-
-        print "Processing test: $dir/$x\n";
-        my $t0 = [gettimeofday];
-        #TIN = test_input_file
-        open(TIN, "$dir/$x.test.sql") || do {
-            $res->{"$dir/$x.test.sql"} = "FAILED: could not open '$dir/$x.test.sql' : $!";
+    #each tests will use clean data
+
+    print "Processing test: $dir/$x\n";
+    my $t0 = [gettimeofday];
+    #TIN = test_input_file
+    open(TIN, "$dir/$x.test.sql") || do {
+        $res->{"$dir/$x.test.sql"} = "FAILED: could not open '$dir/$x.test.sql' : $!";
+        $stats{z_fail}++;
+        next;
+    };
+
+    #reason of opening conection is because the set client_min_messages to warning;
+    if ($DOCUMENTATION) {
+        mysystem("mkdir -p '$dir/../doc' "); # make sure the directory exists
+        open(PSQL, "|$psql $connopts --set='VERBOSITY terse' -e $database > $dir/../doc/$x.queries 2>\&1 ") || do {
+            $res->{"$dir/$x.test.sql"} = "FAILED: could not open connection to db : $!";
             $stats{z_fail}++;
             next;
         };
-
-        #reason of opening conection is because the set client_min_messages to warning;
-        if ($DOCUMENTATION) {
-            mysystem("mkdir -p '$dir/../doc' "); # make sure the directory exists
-            open(PSQL, "|$psql $connopts --set='VERBOSITY terse' -e $database > $dir/../doc/$x.queries 2>\&1 ") || do {
-                $res->{"$dir/$x.test.sql"} = "FAILED: could not open connection to db : $!";
-                $stats{z_fail}++;
-                next;
-            };
-            print PSQL "set client_min_messages to WARNING;\n" if $ignore;
-            print PSQL "set client_min_messages to DEBUG1;\n" if $DEBUG1;
-        }
-        else {
-            open(PSQL, "|$psql $connopts --set='VERBOSITY terse' -A -t -q $database > $TMP 2>\&1 ") || do {
-                $res->{"$dir/$x.test.sql"} = "FAILED: could not open connection to db : $!";
-                $stats{z_fail}++;
-                next;
-            };
-        }
         print PSQL "set client_min_messages to WARNING;\n" if $ignore;
         print PSQL "set client_min_messages to DEBUG1;\n" if $DEBUG1;
-        my @d = ();
-        @d = <TIN>; #reads the whole file into the array @d 
-        print PSQL @d; #prints the whole fle stored in @d
-        close(PSQL); #executes everything
-        close(TIN); #closes the input file  /TIN = test input
-
-        return if $DOCUMENTATION;
-
-        my $dfile;
-        my $dfile2;
-        if ($ignore) { #decide how to compare results, if ignoring or not ignoring
-            $dfile2 = $TMP2;
-            mysystem("grep -v NOTICE '$TMP' | grep -v '^CONTEXT:' | grep -v '^PL/pgSQL function' > $dfile2");
-            $dfile = $TMP3;
-            mysystem("grep -v NOTICE '$dir/$x.result' | grep -v '^CONTEXT:' | grep -v '^PL/pgSQL function' > $dfile");
-        }
-        elsif ($DEBUG1) { #to delete CONTEXT lines
-            $dfile2 = $TMP2;
-            mysystem("grep -v '^CONTEXT:' '$TMP' | grep -v '^PL/pgSQL function' > $dfile2");
-            $dfile = $TMP3;
-            mysystem("grep -v '^CONTEXT:' '$dir/$x.result' | grep -v '^PL/pgSQL function' > $dfile");
-        }
-        else {
-            $dfile = "$dir/$x.result";
-            $dfile2 = $TMP;
-        }
-        if (! -f "$dir/$x.result") {
-            $res->{"$dir/$x.test.sql"} = "\nFAILED: result file missing : $!";
-            $stats{z_fail}++;            
+    }
+    else {
+        open(PSQL, "|$psql $connopts --set='VERBOSITY terse' -A -t -q $database > $TMP 2>\&1 ") || do {
+            $res->{"$dir/$x.test.sql"} = "FAILED: could not open connection to db : $!";
+            if (!$INTERNAL_TESTS) {
+               $stats{z_fail}++;
+            }
             next;
-        }
-
-        # use diff -w to ignore white space differences like \r vs \r\n
-        #ignore white spaces when comparing
-        #dfile is expected results
-        #dfile2 is the actual results
-        my $r = `diff -w '$dfile' '$dfile2' `;
-        #looks for removing leading blanks and trailing blanks
-        $r =~ s/^\s*|\s*$//g;
-        if ($r =~ /connection to server was lost/) {
-            $res->{"$dir/$x.test.sql"} = "CRASHED SERVER: $r";
-            $stats{z_crash}++;
-            # allow the server some time to recover from the crash
-            warn "CRASHED SERVER: '$dir/$x.test.sql', sleeping 5 ...\n";
-            sleep 20;
-        }
-        #if the diff has 0 length then everything was the same, so here we detect changes
-        elsif (length($r)) {
-            $res->{"$dir/$x.test.sql"} = "FAILED: $r";
-            $stats{z_fail}++ unless $DEBUG1;
-        }
-        else {
-            $res->{"$dir/$x.test.sql"} = "Passed";
-            $stats{z_pass}++;
-        }
-        print "    test run time: " . tv_interval($t0, [gettimeofday]) . "\n";
+        };
+    }
+    print PSQL "set client_min_messages to WARNING;\n" if $ignore;
+    print PSQL "set client_min_messages to DEBUG1;\n" if $DEBUG1;
+    my @d = ();
+    @d = <TIN>; #reads the whole file into the array @d 
+    print PSQL @d; #prints the whole fle stored in @d
+    close(PSQL); #executes everything
+    close(TIN); #closes the input file  /TIN = test input
+
+    return if $DOCUMENTATION;
+
+    my $dfile;
+    my $dfile2;
+    if ($ignore) { #decide how to compare results, if ignoring or not ignoring
+        $dfile2 = $TMP2;
+        mysystem("grep -v NOTICE '$TMP' | grep -v '^CONTEXT:' | grep -v '^PL/pgSQL function' > $dfile2");
+        $dfile = $TMP3;
+        mysystem("grep -v NOTICE '$dir/$x.result' | grep -v '^CONTEXT:' | grep -v '^PL/pgSQL function' > $dfile");
+    }
+    elsif ($DEBUG1) { #to delete CONTEXT lines
+        $dfile2 = $TMP2;
+        mysystem("grep -v '^CONTEXT:' '$TMP' | grep -v '^PL/pgSQL function' > $dfile2");
+        $dfile = $TMP3;
+        mysystem("grep -v '^CONTEXT:' '$dir/$x.result' | grep -v '^PL/pgSQL function' > $dfile");
+    }
+    else {
+        $dfile = "$dir/$x.result";
+        $dfile2 = $TMP;
+    }
+    if (! -f "$dir/$x.result") {
+        $res->{"$dir/$x.test.sql"} = "\nFAILED: result file missing : $!";
+        $stats{z_fail}++;            
+        next;
+    }
+
+    # use diff -w to ignore white space differences like \r vs \r\n
+    #ignore white spaces when comparing
+    #dfile is expected results
+    #dfile2 is the actual results
+    my $r = `diff -w '$dfile' '$dfile2' `;
+    #looks for removing leading blanks and trailing blanks
+    $r =~ s/^\s*|\s*$//g;
+    if ($r =~ /connection to server was lost/) {
+        $res->{"$dir/$x.test.sql"} = "CRASHED SERVER: $r";
+        $stats{z_crash}++;
+        # allow the server some time to recover from the crash
+        warn "CRASHED SERVER: '$dir/$x.test.sql', sleeping 5 ...\n";
+        sleep 20;
+    }
+    #if the diff has 0 length then everything was the same, so here we detect changes
+    elsif (length($r)) {
+        $res->{"$dir/$x.test.sql"} = "FAILED: $r";
+        $stats{z_fail}++ unless $DEBUG1;
+    }
+    else {
+        $res->{"$dir/$x.test.sql"} = "Passed";
+        $stats{z_pass}++;
+    }
+    print "    test run time: " . tv_interval($t0, [gettimeofday]) . "\n";
 }
 
 sub createTestDB {
@@ -359,10 +374,10 @@ sub createTestDB {
 
     # first create a database with postgis installed in it
     if (version_greater_eq($dbver, '9.1') &&
-            -f "$dbshare/extension/postgis.control") {
+        -f "$dbshare/extension/postgis.control") {
         mysystem("createdb $connopts $databaseName");
         die "ERROR: Failed to create database '$databaseName'!\n"
-            unless dbExists($databaseName);
+        unless dbExists($databaseName);
         my $encoding = '';
         if ($OS =~ /msys/
             || $OS =~ /MSWin/) {
@@ -400,7 +415,7 @@ sub createTestDB {
         -f "$dbshare/extension/postgis.control") {
         my $myver = '';
         if ($vpgr) {
-            $myver = " PGROUTING VERSION '$vpgr'";
+            $myver = " VERSION '$vpgr'";
         }
         print "-- Trying to install pgrouting extension $myver\n" if $DEBUG;
         mysystem("$psql $connopts -c \"create extension pgrouting $myver\" $databaseName");
diff --git a/tools/testers/contraction_data.sql b/tools/testers/contraction_data.sql
new file mode 100644
index 0000000..3b25e63
--- /dev/null
+++ b/tools/testers/contraction_data.sql
@@ -0,0 +1,61 @@
+\set QUIET 1
+
+SET client_min_messages = WARNING;
+
+
+DROP TABLE IF EXISTS edge_table;
+
+--EDGE TABLE CREATE
+CREATE TABLE edge_table (
+    id BIGSERIAL,
+    source BIGINT,
+    target BIGINT,
+    cost FLOAT,
+    reverse_cost FLOAT
+);
+
+--EDGE TABLE ADD DATA
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 1, 1, 2, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 2, 2, 3, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 3, 3, 4, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 4, 6, 5, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 5, 7, 5, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 6, 8, 5, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 7, 8, 7, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 8, 7, 6, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 9, 2, 10, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 10, 10, 9, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 11, 9, 1, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 12, 3, 11, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 13, 11, 10, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 14, 4, 12, 1 , -1);
+
+INSERT INTO edge_table (id, source, target, cost,reverse_cost) 
+VALUES ( 15, 11, 12, 1 , -1);
\ No newline at end of file
diff --git a/tools/testers/pg_prove_tests.sh b/tools/testers/pg_prove_tests.sh
index d6d6bf4..69b0ad1 100755
--- a/tools/testers/pg_prove_tests.sh
+++ b/tools/testers/pg_prove_tests.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # ------------------------------------------------------------------------------
 # Travis CI scripts 
 # Copyright(c) pgRouting Contributors
@@ -9,6 +9,9 @@
 set -e 
 
 PGUSER=$1
+RELEASE_TYPE="b$2"
+echo "RELEASE_TYPE" $RELEASE_TYPE
+
 PGDATABASE="___pgr___test___"
 
 # Define alias function for psql command
@@ -29,6 +32,20 @@ echo "psql -f setup_db.sql"
 run_psql -f setup_db.sql
 #pg_prove ../../src/funnyDijkstra/test/pgtap/* -d $PGDATABASE
 
+#TODO comment out peformance test before merging to MASTER
+
+
+if [ $RELEASE_TYPE = "bDEBUG" ]
+then
+    pg_prove ../../src/internalQueryTests/test/pgtap/* -d $PGDATABASE  -U $PGUSER
+    echo "MADE TEST **********************"
+fi
+
+pg_prove ../../src/max_flow/test/pgtap/* -d $PGDATABASE  -U $PGUSER
+pg_prove ../../src/pickDeliver/test/pgtap/* -d $PGDATABASE  -U $PGUSER
+pg_prove ../../src/astar/test/pgtap/* -d $PGDATABASE  -U $PGUSER
+
+
 pg_prove ../../src/allpairs/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 pg_prove ../../src/alpha_shape/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 pg_prove ../../src/apsp_johnson/test/pgtap/* -d $PGDATABASE  -U $PGUSER
@@ -41,11 +58,14 @@ pg_prove ../../src/driving_distance/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 pg_prove ../../src/kdijkstra/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 pg_prove ../../src/withPoints/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 pg_prove ../../src/trsp/test/pgtap/* -d $PGDATABASE  -U $PGUSER
+pg_prove ../../src/tsp/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 
-pg_prove ../../src/astar/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 pg_prove ../../src/bd_astar/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 pg_prove ../../src/bd_dijkstra/test/pgtap/* -d $PGDATABASE  -U $PGUSER
-pg_prove ../../src/convinience/test/pgtap/* -d $PGDATABASE  -U $PGUSER
+pg_prove ../../src/convenience/test/pgtap/* -d $PGDATABASE  -U $PGUSER
+
+pg_prove ../../src/tsp/test/performance/* -d $PGDATABASE  -U $PGUSER
+pg_prove ../../src/contraction/test/pgtap/* -d $PGDATABASE  -U $PGUSER
 
 if [ "$?" -ne 0 ]
 then
diff --git a/src/vrppdtw/test/pdp-any-00.data b/tools/testers/pickDeliver_pgtap_data.sql
similarity index 83%
rename from src/vrppdtw/test/pdp-any-00.data
rename to tools/testers/pickDeliver_pgtap_data.sql
index 9347f06..51ddcc1 100644
--- a/src/vrppdtw/test/pdp-any-00.data
+++ b/tools/testers/pickDeliver_pgtap_data.sql
@@ -1,16 +1,19 @@
-drop table if exists customer cascade;
-create table customer (
-                id integer not null primary key,
-                x integer,
-                y integer,
-                demand integer,
-                etime integer,
-                ltime integer, 
-                stime integer, 
-                pindex integer,
-                dindex integer 
+
+DROP TABLE IF EXISTS customer CASCADE;
+CREATE table customer (
+                id BIGINT not null primary key,
+                x DOUBLE PRECISION,
+                y DOUBLE PRECISION,
+                demand INTEGER,
+                opentime INTEGER,
+                closetime INTEGER, 
+                servicetime INTEGER, 
+                pindex BIGINT,
+                dindex BIGINT 
                 );
-copy customer (id,x,y,demand,etime,ltime, stime,pindex, dindex) from stdin;
+
+
+COPY customer (id, x, y, demand, opentime, closetime, servicetime, pindex, dindex) FROM stdin;
 0	40	50	0	0	1236	0	0	0
 1	45	68	-10	912	967	90	11	0
 2	45	70	-20	825	870	90	6	0
diff --git a/tools/testers/sampledata.sql b/tools/testers/sampledata.sql
index ec2b5f1..280dae8 100644
--- a/tools/testers/sampledata.sql
+++ b/tools/testers/sampledata.sql
@@ -10,8 +10,11 @@ SET client_min_messages = WARNING;
 ------------------------------------------------------------------------------------------------------
 
     DROP TABLE IF EXISTS edge_table;
+    DROP TABLE IF EXISTS edge_table_vertices_pgr;
     DROP table if exists pointsOfInterest;
     DROP TABLE IF EXISTS restrictions;
+    DROP TABLE IF EXISTS vertex_table;
+    DROP TABLE IF EXISTS categories;
 
 --EDGE TABLE CREATE
 CREATE TABLE edge_table (
@@ -21,6 +24,8 @@ CREATE TABLE edge_table (
     target BIGINT,
     cost FLOAT,
     reverse_cost FLOAT,
+    category_id INTEGER,
+    reverse_category_id INTEGER,
     x1 FLOAT,
     y1 FLOAT,
     x2 FLOAT,
@@ -28,32 +33,39 @@ CREATE TABLE edge_table (
     the_geom geometry
 );
 --EDGE TABLE ADD DATA
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  2,0,   2,1);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES (-1, 1,  2,1,   3,1);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES (-1, 1,  3,1,   4,1);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  2,1,   2,2);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1,-1,  3,1,   3,2);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  0,2,   1,2);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  1,2,   2,2);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  2,2,   3,2);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  3,2,   4,2);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  2,2,   2,3);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1,-1,  3,2,   3,3);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1,-1,  2,3,   3,3);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1,-1,  3,3,   4,3);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  2,3,   2,4);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  4,2,   4,3);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  4,1,   4,2);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  0.5,3.5,  1.999999999999,3.5);
-INSERT INTO edge_table (cost,reverse_cost,x1,y1,x2,y2) VALUES ( 1, 1,  3.5,2.3,  3.5,4);
+INSERT INTO edge_table (
+    category_id, reverse_category_id,
+    cost, reverse_cost,
+    x1, y1,
+    x2, y2) VALUES 
+(3, 1,    1,  1,  2,   0,    2, 1),
+(3, 2,   -1,  1,  2,   1,    3, 1),
+(2, 1,   -1,  1,  3,   1,    4, 1),
+(2, 4,    1,  1,  2,   1,    2, 2),
+(1, 4,    1, -1,  3,   1,    3, 2),
+(4, 2,    1,  1,  0,   2,    1, 2),
+(4, 1,    1,  1,  1,   2,    2, 2),
+(2, 1,    1,  1,  2,   2,    3, 2),
+(1, 3,    1,  1,  3,   2,    4, 2),
+(1, 4,    1,  1,  2,   2,    2, 3),
+(1, 2,    1, -1,  3,   2,    3, 3),
+(2, 3,    1, -1,  2,   3,    3, 3),
+(2, 4,    1, -1,  3,   3,    4, 3),
+(3, 1,    1,  1,  2,   3,    2, 4),
+(3, 4,    1,  1,  4,   2,    4, 3),
+(3, 3,    1,  1,  4,   1,    4, 2),
+(1, 2,    1,  1,  0.5, 3.5,  1.999999999999,3.5),
+(4, 1,    1,  1,  3.5, 2.3,  3.5,4);
 
 UPDATE edge_table SET the_geom = st_makeline(st_point(x1,y1),st_point(x2,y2)),
-dir = CASE WHEN (cost>0 and reverse_cost>0) THEN 'B'   -- both ways
-   WHEN (cost>0 and reverse_cost<0) THEN 'FT'  -- direction of the LINESSTRING
-   WHEN (cost<0 and reverse_cost>0) THEN 'TF'  -- reverse direction of the LINESTRING
-   ELSE '' END;                                -- unknown
+dir = CASE WHEN (cost>0 AND reverse_cost>0) THEN 'B'   -- both ways
+           WHEN (cost>0 AND reverse_cost<0) THEN 'FT'  -- direction of the LINESSTRING
+           WHEN (cost<0 AND reverse_cost>0) THEN 'TF'  -- reverse direction of the LINESTRING
+           ELSE '' END;                                -- unknown
+
 --EDGE TABLE TOPOLOGY
 SELECT pgr_createTopology('edge_table',0.001);
+
 --POINTS CREATE
 CREATE TABLE pointsOfInterest(
     pid BIGSERIAL,
@@ -66,17 +78,19 @@ CREATE TABLE pointsOfInterest(
     newPoint geometry
 );
 
-INSERT INTO pointsOfInterest (x,y,edge_id,side,fraction) VALUES (1.8, 0.4,1,'l',0.4);
-INSERT INTO pointsOfInterest (x,y,edge_id,side,fraction) VALUES (4.2, 2.4,15,'r',0.4);
-INSERT INTO pointsOfInterest (x,y,edge_id,side,fraction) VALUES (2.6, 3.2,12,'l',0.6);
-INSERT INTO pointsOfInterest (x,y,edge_id,side,fraction) VALUES (0.3, 1.8,6,'r',0.3);
-INSERT INTO pointsOfInterest (x,y,edge_id,side,fraction) VALUES (2.9, 1.8,5,'l',0.8);
-INSERT INTO pointsOfInterest (x,y,edge_id,side,fraction) VALUES (2.2, 1.7,4,'b',0.7);
+INSERT INTO pointsOfInterest (x, y, edge_id, side, fraction) VALUES
+(1.8, 0.4,   1, 'l', 0.4),
+(4.2, 2.4,  15, 'r', 0.4),
+(2.6, 3.2,  12, 'l', 0.6),
+(0.3, 1.8,   6, 'r', 0.3),
+(2.9, 1.8,   5, 'l', 0.8),
+(2.2, 1.7,   4, 'b', 0.7);
 UPDATE pointsOfInterest SET the_geom = st_makePoint(x,y);
 
 UPDATE pointsOfInterest
     SET newPoint = ST_LineInterpolatePoint(e.the_geom, fraction)
     FROM edge_table AS e WHERE edge_id = id;
+
 --RESTRICTIONS CREATE
 CREATE TABLE restrictions (
     rid BIGINT NOT NULL,
@@ -86,12 +100,37 @@ CREATE TABLE restrictions (
     via_path TEXT
 );
 
-COPY restrictions (rid, to_cost, target_id, from_edge, via_path) FROM stdin WITH NULL '__NULL__' DELIMITER ',';
-1,100,7,4,__NULL__
-1,100,11,8,__NULL__
-1,100,10,7,__NULL__
-2,4,8,3,5
-3,100,9,16,__NULL__
-\.
+INSERT INTO restrictions (rid, to_cost, target_id, from_edge, via_path) VALUES
+(1, 100,  7,  4, NULL),
+(1, 100, 11,  8, NULL),
+(1, 100, 10,  7, NULL),
+(2,   4,  8,  3, 5),
+(3, 100,  9, 16, NULL);
+
 --RESTRICTIONS END
 
+CREATE TABLE categories (
+    category_id INTEGER,
+    category text,
+    capacity BIGINT
+);
+
+INSERT INTO categories VALUES
+(1, 'Category 1', 130),
+(2, 'Category 2', 100),
+(3, 'Category 3',  80),
+(4, 'Category 4',  50);
+
+--CATEGORIES END
+
+CREATE TABLE vertex_table (
+    id SERIAL,
+    x FLOAT,
+    y FLOAT
+);
+INSERT INTO vertex_table VALUES
+(1,2,0), (2,2,1), (3,3,1), (4,4,1), (5,0,2), (6,1,2), (7,2,2),
+(8,3,2), (9,4,2), (10,2,3), (11,3,3), (12,4,3), (13,2,4);
+
+--VERTEX TABLE END
+
diff --git a/tools/testers/setup_db.sql b/tools/testers/setup_contraction_db.sql
similarity index 92%
copy from tools/testers/setup_db.sql
copy to tools/testers/setup_contraction_db.sql
index 3942eea..f560add 100644
--- a/tools/testers/setup_db.sql
+++ b/tools/testers/setup_contraction_db.sql
@@ -19,6 +19,6 @@ CREATE EXTENSION pgrouting;
 
 BEGIN;
 
-    \i sampledata.sql
+    \i contraction_data.sql
 
 END;
diff --git a/tools/testers/setup_db.sql b/tools/testers/setup_db.sql
index 3942eea..63796f3 100644
--- a/tools/testers/setup_db.sql
+++ b/tools/testers/setup_db.sql
@@ -20,5 +20,6 @@ CREATE EXTENSION pgrouting;
 BEGIN;
 
     \i sampledata.sql
+    \i pickDeliver_pgtap_data.sql
 
 END;
diff --git a/tools/testers/update-tester.sh b/tools/testers/update-tester.sh
new file mode 100755
index 0000000..a2583a8
--- /dev/null
+++ b/tools/testers/update-tester.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+#/*PGR-GNU*****************************************************************
+
+# FILE: update_tester.sh
+
+# Copyright (c) 2015 pgRouting developers
+# Mail: project at pgrouting.org
+#
+# ------
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# ********************************************************************PGR-GNU*/
+
+set -e
+
+# ----------------------
+#
+echo ------------------------------------
+echo All pgRouting versions to be updated must be installed before calling
+echo ------------------------------------
+echo -
+echo -
+#
+# USAGE
+#
+#  bash tools/testers/update-tester.sh
+#
+
+
+function update_test {
+set -e
+
+echo ------------------------------------
+echo ------------------------------------
+echo Updating from $1 to $2
+echo ------------------------------------
+
+INSTALLED=$(locate /usr/share/postgresql/9.3/extension/pgrouting--$1.sql)
+
+if [ "$INSTALLED" == "/usr/share/postgresql/9.3/extension/pgrouting--$1.sql" ]
+then
+    echo "/usr/share/postgresql/9.3/extension/pgrouting--$1.sql found"
+else
+    echo "/usr/share/postgresql/9.3/extension/pgrouting--$1.sql Not found"
+    exit 1
+fi
+
+createdb  ___test_update
+psql  ___test_update  <<EOF
+create extension postgis;
+create extension pgrouting with version '$1';
+select pgr_version();
+alter extension pgrouting update to '$2';
+select pgr_version();
+EOF
+
+dropdb   ___test_update
+} 
+
+#------------------------------------
+### updates from 2.2.x
+#------------------------------------
+
+update_test 2.2.4 2.3.0
+update_test 2.2.3 2.3.0
+update_test 2.2.2 2.3.0
+update_test 2.2.1 2.3.0
+update_test 2.2.0 2.3.0
+
+
+#------------------------------------
+### updates from 2.1.x
+#------------------------------------
+
+update_test 2.1.0 2.3.0
+
+#------------------------------------
+### updates from 2.0.x
+#------------------------------------
+
+echo ------------------------------------
+echo ------------------------------------
+echo Updating from 2.0.0  to 2.3.0
+echo ------------------------------------
+
+createdb  ___test_update
+psql  ___test_update  <<EOF
+create extension postgis;
+create extension pgrouting with version '2.0.0';
+select pgr_version();
+alter extension pgrouting update to '2.1.0';
+select pgr_version();
+alter extension pgrouting update to '2.3.0';
+select pgr_version();
+EOF
+dropdb   ___test_update
+
+# CAN NOT BE Update test from 2.0.1  to 2.3.0
+
+
diff --git a/tools/travis/install-postgres9.5.sh b/tools/travis/install-postgres9.5.sh
index a09240f..dede90e 100755
--- a/tools/travis/install-postgres9.5.sh
+++ b/tools/travis/install-postgres9.5.sh
@@ -36,23 +36,4 @@ if test "$POSTGRESQL_VERSION" = "9.5" ; then
     ps -fea | grep postgres
     #sudo -u $DBUSER psql -c "ALTER ROLE postgres WITH PASSWORD '';"
 
-#else
-
-#echo "starting server"
-#sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION
-
-
-#sudo cp /usr/lib/postgresql/$POSTGRESQL_VERSION/bin/pg_config /usr/bin/pg_config
-
-#echo "Installing pgtap ... this may take some time."
-#wget https://github.com/theory/pgtap/archive/master.zip
-#unzip master.zip
-#cd pgtap-master
-#make
-#make installcheck
-#sudo make install
-#cd ..
-
-#sudo apt-get install -y libtap-parser-sourcehandler-pgtap-perl
-
 fi
diff --git a/tools/travis/install-postgres9.5.sh b/tools/travis/install-postgres9.6.sh
similarity index 68%
copy from tools/travis/install-postgres9.5.sh
copy to tools/travis/install-postgres9.6.sh
index a09240f..df6c7da 100755
--- a/tools/travis/install-postgres9.5.sh
+++ b/tools/travis/install-postgres9.6.sh
@@ -14,10 +14,10 @@ PGUSER="$2"
 echo "Postgres $POSTGRESQL_VERSION"
 echo "User $PGUSER"
 
-if test "$POSTGRESQL_VERSION" = "9.5" ; then
+if test "$POSTGRESQL_VERSION" = "9.6" ; then
 
-    echo "Installing postgresql 9.5 & postgis for 9.5 pgtap & pg_prove"
-    sudo apt-get install -y postgresql-9.5 postgresql-9.5-postgis
+    echo "Installing postgresql 9.6 & postgis for 9.6 pgtap & pg_prove"
+    sudo apt-get install -y postgresql-9.6 postgresql-9.6-postgis-2.2
     #sudo apt-get install -y pgtap libtap-parser-sourcehandler-pgtap-perl
     sudo cp /usr/lib/postgresql/$POSTGRESQL_VERSION/bin/pg_config /usr/bin/pg_config
     sudo /etc/init.d/postgresql stop
@@ -36,23 +36,4 @@ if test "$POSTGRESQL_VERSION" = "9.5" ; then
     ps -fea | grep postgres
     #sudo -u $DBUSER psql -c "ALTER ROLE postgres WITH PASSWORD '';"
 
-#else
-
-#echo "starting server"
-#sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION
-
-
-#sudo cp /usr/lib/postgresql/$POSTGRESQL_VERSION/bin/pg_config /usr/bin/pg_config
-
-#echo "Installing pgtap ... this may take some time."
-#wget https://github.com/theory/pgtap/archive/master.zip
-#unzip master.zip
-#cd pgtap-master
-#make
-#make installcheck
-#sudo make install
-#cd ..
-
-#sudo apt-get install -y libtap-parser-sourcehandler-pgtap-perl
-
 fi
diff --git a/tools/travis/pgrouting_build.sh b/tools/travis/pgrouting_build.sh
index 0168e47..ef834a5 100755
--- a/tools/travis/pgrouting_build.sh
+++ b/tools/travis/pgrouting_build.sh
@@ -10,10 +10,7 @@
 set -e 
 
 # build pgRouting
-cmake  -DPOSTGRESQL_VERSION=$POSTGRESQL_VERSION
-#cmake
+cmake  -DPOSTGRESQL_VERSION=$POSTGRESQL_VERSION -DWITH_DOC=1 -DBUILD_DOXY=1
 make
 sudo make install
-#cd ..
 
-#./tools/testers/algorithm-tester.pl -pgver $POSTGRESQL_VERSION -ignorenotice
diff --git a/tools/travis/pgrouting_test.sh b/tools/travis/pgrouting_test.sh
index 0fddb8b..7758bb9 100755
--- a/tools/travis/pgrouting_test.sh
+++ b/tools/travis/pgrouting_test.sh
@@ -67,7 +67,7 @@ run_psql -c "SELECT pgr_version();"
 #dropdb ___pgr___test___
 #cd ../../
 
-./tools/testers/algorithm-tester.pl -pgver $POSTGRESQL_VERSION -pguser $PGUSER -ignorenotice
+./tools/testers/algorithm-tester.pl -pgver $POSTGRESQL_VERSION -pguser $PGUSER 
 
 if [ "$?" -ne 0 ]
 then
diff --git a/tools/windows/makepgroutingw32.sh b/tools/windows/makepgroutingw32.sh
index 9bb4480..cfc308f 100644
--- a/tools/windows/makepgroutingw32.sh
+++ b/tools/windows/makepgroutingw32.sh
@@ -30,6 +30,6 @@ cd pgrouting
 rm -rf build
 mkdir build
 cd build
-cmake -G "MSYS Makefiles" -DWITH_DD=ON ..
+cmake -G "MSYS Makefiles" ..
 make && make install
 
diff --git a/tools/windows/makepgroutingw64.sh b/tools/windows/makepgroutingw64.sh
index ac98aeb..0d64954 100644
--- a/tools/windows/makepgroutingw64.sh
+++ b/tools/windows/makepgroutingw64.sh
@@ -29,6 +29,6 @@ cd pgrouting
 rm -rf build
 mkdir build
 cd build
-cmake -G "MSYS Makefiles" -DWITH_DD=ON ..
+cmake -G "MSYS Makefiles" ..
 make && make install
 
diff --git a/tools/windows/msbuild_pgrouting.bat b/tools/windows/msbuild_pgrouting.bat
new file mode 100644
index 0000000..b52a774
--- /dev/null
+++ b/tools/windows/msbuild_pgrouting.bat
@@ -0,0 +1,210 @@
+ at echo off
+
+rem doskey cmake="%PROGRAMFILES% (x86)\CMake\bin\cmake.exe"
+echo APPVEYOR=%APPVEYOR%
+
+set BUILD_ROOT_DIR=c:\build
+set BOOST_VER=1_58_0
+set CGAL_VER=4.8.1
+set GMP_LIB_NAME=libgmp-10.lib
+set MPFR_LIB_NAME=libmpfr-4.lib
+if "%APPVEYOR%"=="True" (
+	set MSBUILD_CONFIGURATION=%CONFIGURATION%
+) else (
+	set MSBUILD_CONFIGURATION=RelWithDebInfo
+)
+
+set COMMON_INSTALL_ROOT_DIR=%BUILD_ROOT_DIR%\local
+set BOOST_SRC_DIR=%BUILD_ROOT_DIR%\boost_%BOOST_VER%
+set GMP_ROOT_DIR=%BUILD_ROOT_DIR%\gmp
+set CGAL_SRC_DIR=%BUILD_ROOT_DIR%\CGAL-%CGAL_VER%
+
+set PGROUTING_SRC_DIR=%~dp0..\..\
+set USAGE="Usage: %~nx0 [pg_ver(9.0|9.1|9.2|9.3|9.4|9.5|9.6)] [platform(x86|x64)] (rebuild)"
+
+if "%1"=="9.0" (
+	set PG_VER=9.0
+	set MSVC_VER=9.0
+	set MSVC_YEAR=2008
+	set PROJ_EXT=vcproj
+) else if "%1"=="9.1" (
+	set PG_VER=9.1
+	set MSVC_VER=10.0
+	set MSVC_YEAR=2010
+	set PROJ_EXT=vcxproj
+) else if "%1"=="9.2" (
+	set PG_VER=9.2
+	set MSVC_VER=10.0
+	set MSVC_YEAR=2010
+	set PROJ_EXT=vcxproj
+) else if "%1"=="9.3" (
+	set PG_VER=9.3
+	set MSVC_VER=12.0
+	set MSVC_YEAR=2013
+	set PROJ_EXT=vcxproj
+) else if "%1"=="9.4" (
+	set PG_VER=9.4
+	set MSVC_VER=12.0
+	set MSVC_YEAR=2013
+	set PROJ_EXT=vcxproj
+) else if "%1"=="9.5" (
+	set PG_VER=9.5
+	set MSVC_VER=12.0
+	set MSVC_YEAR=2013
+	set PROJ_EXT=vcxproj
+) else if "%1"=="9.6" (
+	set PG_VER=9.6
+	set MSVC_VER=12.0
+	set MSVC_YEAR=2013
+	set PROJ_EXT=vcxproj
+) else (
+	echo %USAGE%
+	exit /B 1
+)
+
+set RUNTIME=msvc%MSVC_VER:.=%
+set BOOST_TOOLSET=msvc-%MSVC_VER%
+set CMAKE_GENERATOR=Visual Studio %MSVC_VER:.0=% %MSVC_YEAR%
+
+if "%2"=="x86" (
+	set PLATFORM=x86
+	set BOOST_ADDRESS_MODEL=32
+) else if "%2"=="x64" (
+	set PLATFORM=x64
+	set BOOST_ADDRESS_MODEL=64
+	set CMAKE_GENERATOR=%CMAKE_GENERATOR% Win64
+) else (
+	echo %USAGE%
+	exit /B 1
+)
+
+if "%3"=="rebuild" (
+	set REBUILD=1
+) else (
+	set REBUILD=0
+)
+
+echo PG_VER="%PG_VER%"
+echo MSVC_VER="%MSVC_VER%"
+echo RUNTIME="%RUNTIME%"
+echo BOOST_TOOLSET="%BOOST_TOOLSET%"
+echo CMAKE_GENERATOR="%CMAKE_GENERATOR%"
+echo PLATFORM="%PLATFORM%"
+echo REBUILD="%REBUILD%"
+
+set VS100COMNTOOLS=%PROGRAMFILES% (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
+rem TODO:
+set VCVARSALL_BAT_PATH="%PROGRAMFILES% (x86)\Microsoft Visual Studio %MSVC_VER%\VC\vcvarsall.bat"
+if "%RUNTIME%"=="msvc100" if "%PLATFORM%"=="x64" (
+	set OPTION=x86
+) else if "%PLATFORM%"=="x86" (
+	set OPTION=x86
+) else if "%PLATFORM%"=="x64" (
+	set OPTION=amd64
+)
+
+call %VCVARSALL_BAT_PATH% %OPTION%
+
+if "%RUNTIME%"=="msvc100" if "%PLATFORM%"=="x64" (
+	rem quotes to avoid escape error
+	set INCLUDE="%INCLUDE%;%PROGRAMFILES%\Microsoft SDKs\Windows\v7.1\Include"
+	if "%PLATFORM%"=="x86" (
+		set LIB="%LIB%;%PROGRAMFILES%\Microsoft SDKs\Windows\v7.1\Lib"
+	) else if "%PLATFORM%"=="x64" (
+		set LIB="%LIB%;%PROGRAMFILES%\Microsoft SDKs\Windows\v7.1\Lib\x64"
+	)
+)
+
+rem remove quotes
+set INCLUDE=%INCLUDE:"=%
+set LIB=%LIB:"=%
+
+rem echo INCLUDE="%INCLUDE%"
+rem echo LIB="%LIB%"
+
+path %PATH%;%PROGRAMFILES% (x86)\CMake\bin
+
+set COMMON_INSTALL_DIR=%COMMON_INSTALL_ROOT_DIR%\%RUNTIME%\%PLATFORM%
+set CGAL_BUILD_DIR=%CGAL_SRC_DIR%\build\%RUNTIME%\%PLATFORM%
+set GMP_DIR=%GMP_ROOT_DIR%\%PLATFORM%
+set PGROUTING_BUILD_DIR=%PGROUTING_SRC_DIR%build\pg%PG_VER:.=%\%PLATFORM%
+set PGROUTING_INSTALL_DIR=%PGROUTING_SRC_DIR%lib\pg%PG_VER:.=%\%PLATFORM%
+if "%PLATFORM%"=="x86" (
+	set POSTGRESQL_DIR=%PROGRAMFILES% ^(x86^)\PostgreSQL\%PG_VER%
+) else (
+	set POSTGRESQL_DIR=%PROGRAMFILES%\PostgreSQL\%PG_VER%
+)
+
+echo COMMON_INSTALL_DIR="%COMMON_INSTALL_DIR%"
+echo CGAL_BUILD_DIR="%CGAL_BUILD_DIR%"
+echo GMP_DIR="%GMP_DIR%"
+echo PGROUTING_BUILD_DIR="%PGROUTING_BUILD_DIR%"
+echo PGROUTING_INSTALL_DIR="%PGROUTING_INSTALL_DIR%"
+echo POSTGRESQL_DIR="%POSTGRESQL_DIR%"
+
+rem ### Boost ###
+set BOOST_SHORT_VER=%BOOST_VER:_0=%
+set BOOST_INCLUDE_DIR=%COMMON_INSTALL_DIR%\include\boost-%BOOST_SHORT_VER%
+set BOOST_LIBRARY_DIR=%COMMON_INSTALL_DIR%\lib
+set BOOST_THREAD_LIB=%COMMON_INSTALL_DIR%\lib\libboost_thread-vc%MSVC_VER:.=%-mt-%BOOST_SHORT_VER%.lib
+set BOOST_SYSTEM_LIB=%COMMON_INSTALL_DIR%\lib\libboost_system-vc%MSVC_VER:.=%-mt-%BOOST_SHORT_VER%.lib
+set BOOST_WILDCARD_LIB=%COMMON_INSTALL_DIR%\lib\libboost_*-vc%MSVC_VER:.=%-mt-%BOOST_SHORT_VER%.libs
+
+if not exist "%BOOST_SRC_DIR%\b2.exe" (
+	pushd %BOOST_SRC_DIR%
+	call "bootstrap.bat"
+	popd
+)
+rem TODO:better rebuild
+if exist %BOOST_INCLUDE_DIR%\ if %REBUILD%==1 (
+	rmdir /S /Q %BOOST_INCLUDE_DIR%
+	del /S /Q %BOOST_WILDCARD_LIB%
+)
+if not exist %BOOST_INCLUDE_DIR%\ (
+	pushd %BOOST_SRC_DIR%
+	@echo on
+	b2 toolset=%BOOST_TOOLSET% variant=release link=static threading=multi address-model=%BOOST_ADDRESS_MODEL% ^
+		--with-thread --with-system --prefix=%COMMON_INSTALL_DIR% -d0 install
+	@echo off
+	popd
+)
+
+rem ### CGAL ###
+rem TODO:better rebuild
+if exist %CGAL_BUILD_DIR%\ if %REBUILD%==1 (
+	rmdir /S /Q %CGAL_BUILD_DIR%
+)
+if not exist %CGAL_BUILD_DIR%\ (
+	mkdir %CGAL_BUILD_DIR%
+	pushd %CGAL_BUILD_DIR%
+	@echo on
+	cmake -G "%CMAKE_GENERATOR%" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=%COMMON_INSTALL_DIR% ^
+		-DBoost_USE_MULTITHREADED=ON -DCGAL_Boost_USE_STATIC_LIBS=ON -DBoost_USE_STATIC_RUNTIME=OFF ^
+		-DBoost_INCLUDE_DIR:PATH=%BOOST_INCLUDE_DIR% ^
+		-DBOOST_LIBRARYDIR=%BOOST_LIBRARY_DIR% -DGMP_INCLUDE_DIR=%GMP_DIR%\include ^
+		-DGMP_LIBRARIES=%GMP_DIR%\lib\%GMP_LIB_NAME% -DMPFR_INCLUDE_DIR=%GMP_DIR%\include ^
+		-DMPFR_LIBRARIES=%GMP_DIR%\lib\%MPFR_LIB_NAME% -DWITH_CGAL_QT3=OFF -DWITH_CGAL_QT4=OFF ..\..\..\
+	msbuild CGAL.sln /target:Build /property:Configuration=%MSBUILD_CONFIGURATION%
+	msbuild INSTALL.%PROJ_EXT% /target:Build /property:Configuration=%MSBUILD_CONFIGURATION%
+	@echo off
+	popd
+)
+
+rem ### pgRouting ###
+rem TODO:better rebuild
+if exist %PGROUTING_BUILD_DIR%\ if %REBUILD%==1 (
+	rmdir /S /Q %PGROUTING_BUILD_DIR%
+)
+if not exist %PGROUTING_BUILD_DIR%\ (
+	mkdir %PGROUTING_BUILD_DIR%
+	pushd %PGROUTING_BUILD_DIR%
+	@echo on
+	cmake -G "%CMAKE_GENERATOR%" -DPOSTGRESQL_INCLUDE_DIR:PATH="%POSTGRESQL_DIR%\include;%POSTGRESQL_DIR%\include\server;%POSTGRESQL_DIR%\include\server\port;%POSTGRESQL_DIR%\include\server\port\win32;%POSTGRESQL_DIR%\include\server\port\win32_msvc" ^
+		-DPOSTGRESQL_LIBRARIES:FILEPATH="%POSTGRESQL_DIR%\lib\postgres.lib" -DPOSTGRESQL_EXECUTABLE:FILEPATH="%POSTGRESQL_DIR%\bin\postgres.exe" ^
+		-DPOSTGRESQL_PG_CONFIG:FILEPATH="%POSTGRESQL_DIR%\bin\pg_config.exe" -DBoost_INCLUDE_DIR:PATH=%BOOST_INCLUDE_DIR% ^
+		-DBOOST_THREAD_LIBRARIES:FILEPATH="%BOOST_THREAD_LIB%;%BOOST_SYSTEM_LIB%" ^
+		-DCGAL_INCLUDE_DIR:PATH="%COMMON_INSTALL_DIR%\include;%GMP_DIR%\include" -DCGAL_LIBRARIES:FILEPATH=%COMMON_INSTALL_DIR%\lib\libCGAL-vc%MSVC_VER:.=%-mt-%CGAL_VER%.lib ^
+		-DGMP_LIBRARIES:FILEPATH="%GMP_DIR%\lib\%GMP_LIB_NAME%;%GMP_DIR%\lib\%MPFR_LIB_NAME%" -DWITH_DD=ON ..\..\..\
+	@echo off
+	popd
+)
diff --git a/tools/winnie/build_pgrouting.sh b/tools/winnie/build_pgrouting.sh
index a6108b3..b74a9a1 100644
--- a/tools/winnie/build_pgrouting.sh
+++ b/tools/winnie/build_pgrouting.sh
@@ -1,100 +1,151 @@
 #!/bin/sh.exe
 
-# CHANGE THESE TO SUIT YOUR PROJECT
-#all these get passed in by jenkins
-#export OS_BUILD=64 
-#export PG_VER=9.2
-#export PGHOST=localhost
-#export PGPORT=8442
-export PGUSER=postgres
-#export PGROUTING_VER=2.1
-#POSTGIS_VER=2.1.0SVN
+#-------------------------
+# File used in Jenkis setup
+#-------------------------
+
+JENKINS_DEBUG=1
+
+#-----------------
+# variables setup
+#  Variables recived by jenkins setup
+#-----------------
+#export OS_BUILD=
+#export PG_VER=
+#export PGHOST=
+#export PGPORT=
+#export PGROUTING_VER=
+#export POSTIGS_VER=
 #GCC_TYPE=
-#export POSTIGS_VER=2.1.0beta3
-#export GIT_COMMIT=whatever
+#export GIT_COMMIT=
+
+
+if [ $JENKINS_DEBUG -eq 1 ]
+then
+    echo "OS_BUILD ${OS_BUILD}"
+    echo "PG_VER ${PG_VER}"
+    echo "PGHOST ${PGHOST}"
+    echo "PGPORT ${PGPORT}"
+    echo "PGROUTING_VER ${PGROUTING_VER}"
+    echo "POSTGIS_VER ${POSTGIS_VER}"
+    echo "GCC_TYPE ${GCC_TYPE}"
+    echo "GIT_COMMIT ${GIT_COMMIT}"
+fi
+
+#---------------
+# Deduced variables
+#---------------
+
+export PGUSER=postgres
 export PROJECTS=/projects
 export PGPATHEDB=${PROJECTS}/postgresql/rel/pg${PG_VER}w${OS_BUILD}${GCC_TYPE}edb  #this is so winnie know's where to copy the dlls for vc++ edb compiled postgresql testing
-export PATHOLD=$PATH
 export PGPATH=${PROJECTS}/postgresql/rel/pg${PG_VER}w${OS_BUILD}${GCC_TYPE}
+export PATHOLD=$PATH
+export PATHOLD="/mingw/bin:/mingw/include:/c/Windows/system32:/c/Windows"
+export PGWINVER=${PG_VER}w${OS_BUILD}${GCC_TYPE}edb
+export PATH="${PATHOLD}:${PGPATH}/bin:${PGPATH}/lib:${PGPATH}/include"
+export PATH="${PROJECTS}/rel-libiconv-1.13.1w${OS_BUILD}${GCC_TYPE}/include:${PATH}"
+
 
-#export PROJECTS=/c/ming${OS_BUILD}/projects
-if [[ "${GCC_TYPE}" == *gcc48* ]] ; then
-	export PostgreSQL_ROOT=${PGPATH}
-	
-	export PATHOLD="/mingw/bin:/mingw/include:/c/Windows/system32:/c/Windows"
-	export PGWINVER=${PG_VER}w${OS_BUILD}${GCC_TYPE}edb
-	export PATH="${PATHOLD}:${PGPATH}/bin:${PGPATH}/lib:${PGPATH}/include"
-	export PATH="${PROJECTS}/rel-libiconv-1.13.1w${OS_BUILD}${GCC_TYPE}/include:${PATH}"
-	GMP_VER=5.1.2
-	MPFR_VER=3.1.2
-	CGAL_VER=4.2
-	BOOST_VER=1.59.0
-	BOOST_VER_WU=1_59_0
-	BOOST_VER_WUM=1_59
-	ZLIB_VER=1.2.8
-	#export PATH="/mingw/bin:/mingw/include:/c/Windows/system32"
-	#zlib
-	PATH="${PATH}:${PROJECTS}/zlib/rel-${ZLIB_VER}w${OS_BUILD}${GCC_TYPE}/include:${PROJECTS}/zlib/rel-${ZLIB_VER}w${OS_BUILD}${GCC_TYPE}/lib:${PROJECTS}/zlib/rel-${ZLIB_VER}w${OS_BUILD}${GCC_TYPE}/bin"
-	#gmp
-	PATH="${PATH}:${PROJECTS}/CGAL/rel-gmp-${GMP_VER}w${OS_BUILD}${GCC_TYPE}/include:${PROJECTS}/CGAL/rel-gmp-${GMP_VER}w${OS_BUILD}${GCC_TYPE}/lib"
-	#mpfr
-	PATH="${PATH}:${PROJECTS}/CGAL/rel-mpfr-${MPFR_VER}w${OS_BUILD}${GCC_TYPE}/include:${PROJECTS}/CGAL/rel-mpfr-${MPFR_VER}w${OS_BUILD}${GCC_TYPE}/lib:${PROJECTS}/CGAL/rel-mpfr-${MPFR_VER}w${OS_BUILD}${GCC_TYPE}/bin"
-	
-	#boost
-	PATH="${PATH}:${PROJECTS}/boost/rel-${BOOST_VER_WU}w${OS_BUILD}${GCC_TYPE}/lib"
-	#cgal
-	PATH="${PATH}:${PROJECTS}/CGAL/rel-cgal-${CGAL_VER}w${OS_BUILD}${GCC_TYPE}/include:${PROJECTS}/CGAL/rel-cgal-${CGAL_VER}w${OS_BUILD}${GCC_TYPE}/lib"
-	#cmake
-	export PATH="${PATH}:/cmake/bin"
-	export PATH="${PATH}:.:/bin:/include"
-	cd ${PROJECTS}/pgrouting
-	rm -rf build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
-	mkdir build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
-	cd build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
-	cmake -G "MSYS Makefiles"  -DCMAKE_VERBOSE_MAKEFILE=ON -DBOOST_ROOT:PATH=${PROJECTS}/boost/rel-${BOOST_VER_WU}w${OS_BUILD}${GCC_TYPE} -DCGAL_ROOT:PATH=${PROJECTS}/CGAL/rel-cgal-${CGAL_VER}w${OS_BUILD}${GCC_TYPE} -DGMP_ROOT:PATH=${PROJECTS}/CGAL/rel-gmp-${GMP_VER}w${OS_BUILD}${GCC_TYPE} -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DCMAKE_CXX_FLAGS="-I${PROJECTS}/CGAL/rel-gmp-${GMP_VER}w${OS_BUILD}${GCC_TYPE}/include -I${PROJECTS}/CGAL/rel-mpfr-${MPFR_VER}w${OS_BUILD}${GCC_TYP [...]
-else 
-	#alias cmake="/c/ming${OS_BUILD}/cmake-2.8.10.2-win32-x86/bin/cmake"
-	export PostgreSQL_ROOT=${PGPATH}
-	export PATHOLD=$PATH
-	
-	#export PATHOLD=".:/bin:/include:/mingw/bin:/mingw/include:/c/Windows/system32:/c/Windows:/usr/local/bin:/c/ming64/Silksvn/bin:/c/Program Files (x86)/Git/bin"
-	
-	export PATHOLD=".:/bin:/include:/mingw/bin:/mingw/include:/c/Windows/system32:/c/Windows:/usr/local/bin"
-	export PGWINVER=${PG_VER}edb
-
-	export PATH="${PATHOLD}:${PostgreSQL_ROOT}/bin:${PostgreSQL_ROOT}/lib"
-	#export PATH="${PROJECTS}/gettext/rel-gettext-0.18.1/bin:${PROJECTS}/xsltproc:${PROJECTS}/gtk/bin:${PROJECTS}/rel-libiconv-1.13.1w64/include:${PATH}"
-	export PATH="${PATH}:/cmake/bin"
-	echo $PATH
-	cd ${PROJECTS}/pgrouting
-	rm -rf build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
-	mkdir build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
-	cd build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
-	cmake -G "MSYS Makefiles"  ../branches/${PGROUTING_VER}
+if [ $JENKINS_DEBUG -eq 1 ]
+then
+    echo "PGUSER ${PGUSER}"
+    echo "PROJECTS ${PROJECTS}"
+    echo "PGPATHEDB ${PGPATHEDB}"
+    echo "PGPATH ${PGPATH}"
+    echo "PATHOLD ${PATHOLD}"
+    echo "PGWINVER ${PGWINVER}"
+    echo "PATH ${PATH}"
 fi
-#cmake -G "MSYS Makefiles" -DWITH_DD=ON ..
+
+GMP_VER=5.1.2
+MPFR_VER=3.1.2
+CGAL_VER=4.2
+BOOST_VER=1.59.0
+BOOST_VER_WU=1_59_0
+BOOST_VER_WUM=1_59
+ZLIB_VER=1.2.8
+
+if [ $JENKINS_DEBUG -eq 1]
+then
+    echo "GMP_VER ${GMP_VER}"
+    echo "MPFR_VER ${MPFR_VER}"
+    echo "GAL_VER ${CGAL_VER}"
+    echo "BOOST_VER_WU ${BOOST_VER_WU}"
+    echo "BOOST_VER_WUM ${BOOST_VER_WUM}"
+    echo "ZLIB_VER ${ZLIB_VER}"
+fi
+
+#zlib
+ZLIB_PATH="${PROJECTS}/zlib/rel-${ZLIB_VER}w${OS_BUILD}${GCC_TYPE}"
+PATH="${PATH}:${ZLIB_PATH}/include:${ZLIB_PATH}/lib:${ZLIB_PATH}/bin"
+
+#gmp
+GMP_PATH="${PROJECTS}/CGAL/rel-gmp-${GMP_VER}w${OS_BUILD}${GCC_TYPE}"
+PATH="${PATH}:${GMP_PATH}/include:${GMP_PATH}/lib"
+
+#mpfr
+MPFR_PATH="${PROJECTS}/CGAL/rel-mpfr-${MPFR_VER}w${OS_BUILD}${GCC_TYPE}"
+PATH="${PATH}:${MPFR_PATH}/include:${MPFR_PATH}/lib:${MPFR_PATH}/bin"
+
+#boost
+BOOSTROOT_PATH="${PROJECTS}/boost/rel-${BOOST_VER_WU}w${OS_BUILD}${GCC_TYPE}"
+PATH="${PATH}:${BOOSTROOT_PATH}/lib"
+
+#cgal
+CGAL_PATH="${PROJECTS}/CGAL/rel-cgal-${CGAL_VER}w${OS_BUILD}${GCC_TYPE}"
+PATH="${PATH}:${CGAL_PATH}/include:${CGAL_PATH}/lib"
+
+#cmake
+export PATH="${PATH}:/cmake/bin"
+export PATH="${PATH}:.:/bin:/include"
+
+echo "PATH ${PATH}"
+
+cd ${PROJECTS}/pgrouting
+rm -rf build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
+mkdir build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
+cd build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}
+
+cmake -G "MSYS Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON -DBOOST_ROOT:PATH=${BOOSTROOT_PATH} -DCGAL_ROOT:PATH=${CGAL_PATH} -DGMP_ROOT:PATH=${PROJECTS}/CGAL/rel-gmp-${GMP_VER}w${OS_BUILD}${GCC_TYPE} -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DCMAKE_CXX_FLAGS="-I${PROJECTS}/CGAL/rel-gmp-${GMP_VER}w${OS_BUILD}${GCC_TYPE}/include -I${PROJECTS}/CGAL/rel-mpfr-${MPFR_VER}w${OS_BUILD}${GCC_TYPE}/include"  ../branches/${PGROUTING_VER}
+
 #first delete old pgrouting files from installed folder before we reinstall
-echo "The git commit is ${GIT_COMMIT}"
-rm ${PGPATH}/lib/librouting*
+
+ls ${PGPATH}/lib/libpgrouting*
+ls ${PGPATH}/share/extension/pgrouting*
+ls ${PGPATHEDB}/lib/libpgrouting*
+ls ${PGPATHEDB}/share/extension/pgrouting*
+
+rm ${PGPATH}/lib/libpgrouting*
 rm ${PGPATH}/share/extension/pgrouting*
-make && make install
+rm ${PGPATHEDB}/lib/libpgrouting*
+rm ${PGPATHEDB}/share/extension/pgrouting*
+
+ls ${PGPATH}/lib/libpgrouting*
+ls ${PGPATH}/share/extension/pgrouting*
+ls ${PGPATHEDB}/lib/libpgrouting*
+ls ${PGPATHEDB}/share/extension/pgrouting*
+
+make 
+make install
 
 #we need uninstall and reinstall copy to VC++ EDB instance if we want to test on standard Windows installed versions
-rm ${PGPATHEDB}/lib/librouting*
 cp lib/*.dll ${PGPATHEDB}/lib/
-rm ${PGPATHEDB}/share/extension/pgrouting*
 cp lib/*.sql ${PGPATHEDB}/share/extension/
 cp lib/*.control ${PGPATHEDB}/share/extension/
 
+ls ${PGPATH}/lib/libpgrouting*
+ls ${PGPATH}/share/extension/pgrouting*
+ls ${PGPATHEDB}/lib/libpgrouting*
+ls ${PGPATHEDB}/share/extension/pgrouting*
+
 cd ${PROJECTS}/pgrouting/branches/${PGROUTING_VER}
 
 #perl tools/test-runner.pl   -pgver ${PG_VER} -pgport "${PGPORT}"  -clean
-echo "PGVER ${PG_VER}"
-echo "PGVER ${POSTGIS_VER}"
-echo "PGVER ${PGPORT}"
-perl tools/testers/algorithm-tester.pl  -pgver ${PG_VER} -pgisver "${POSTGIS_VER}" -pgport "${PGPORT}" -ignorenotice -clean
-#perl tools/test-runner.pl  -pgver ${PG_VER} -pgisver "${POSTGIS_VER}" -pgport "${PGPORT}" 
-#perl tools/test-runner.pl  -pgver "${PG_VER}" -pgisver "${POSTGIS_VER}" -pgport "${PGPORT}"  -clean -v -alg ksp
+#perl tools/testers/algorithm-tester.pl  -pgver ${PG_VER} -pgisver "${POSTGIS_VER}" -pgport "${PGPORT}"  -alg common -clean -v
+#perl tools/testers/algorithm-tester.pl  -pgver ${PG_VER} -pgisver "${POSTGIS_VER}" -pgport "${PGPORT}"  -alg dijkstra -clean -v
+#perl tools/testers/algorithm-tester.pl  -pgver ${PG_VER} -pgisver "${POSTGIS_VER}" -pgport "${PGPORT}"  -alg contraction
+perl tools/testers/algorithm-tester.pl  -pgver ${PG_VER} -pgisver "${POSTGIS_VER}" -pgport "${PGPORT}"
 
 
 cd ${PROJECTS}/pgrouting/build${PGROUTING_VER}w${OS_BUILD}${GCC_TYPE}/lib

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pgrouting.git



More information about the Pkg-grass-devel mailing list