GithubHelp home page GithubHelp logo

anthonytasca / pgrouting Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pgrouting/pgrouting

0.0 0.0 0.0 244.04 MB

Repository contains pgRouting library. Development branch is "develop", stable branch is "master"

Home Page: http://www.pgrouting.org

License: GNU General Public License v2.0

CMake 2.24% Batchfile 0.99% C++ 27.23% C 16.33% PLpgSQL 39.49% PLSQL 1.05% SQLPL 2.35% Perl 2.60% Standard ML 5.11% Shell 2.62%

pgrouting's People

Contributors

anthonytasca avatar antonpa avatar apslight avatar clashman avatar cvvergara avatar dersvenhesse avatar dkastl avatar drnextgis avatar grayed avatar hugomd avatar illedran avatar justjkk avatar lvv83 avatar nbrinckm avatar opessoa avatar petebp avatar robe2 avatar rohithsankepally avatar sanak avatar sebastic avatar steigr avatar thayeray avatar thisisashukla avatar titanofold avatar vidhan13j07 avatar woodbri avatar xjtumg avatar yobisource avatar zia- avatar zibon avatar

Watchers

 avatar  avatar

pgrouting's Issues

Use auto

change things like:

int64_t out_edge_id = digraph.graph[*e_outIt].id;

to

auto out_edge_id = digraph.graph[*e_outIt].id

example 1 (discussion)

Data

SELECT id*100 AS id, source*1000 as source, target*1000 as target , cost FROM edge_table where id in (5,9,11);
  id  | source | target | cost 
------+--------+--------+------
  500 |   3000 |   6000 |    1
  900 |   6000 |   9000 |    1
 1100 |   6000 |  11000 |    1
(3 rows)

sampledata

Results

SELECT * FROM pgr_turnPenaltyGraph( 'SELECT id*100 AS id, source*1000 as source, target*1000 as target , cost FROM edge_table where id in (5,9,11)' );
 seq | source | target | cost | original_source_vertex | original_source_edge | original_target_vertex | original_target_edge 
-----+--------+--------+------+------------------------+----------------------+------------------------+----------------------
   1 |      1 |      4 |    1 |                   3000 |                  500 |                   6000 |                  500
   2 |      2 |      5 |    1 |                   6000 |                  900 |                   9000 |                  900
   3 |      3 |      6 |    1 |                   6000 |                 1100 |                  11000 |                 1100
   4 |      4 |      2 |    0 |                   6000 |                  500 |                   6000 |                  900
   5 |      4 |      3 |    0 |                   6000 |                  500 |                   6000 |                 1100
(5 rows)

Lint the code

bash tools/scripts/code_checker.sh turnPenaltyGraph

Should return no errors

example 3 (discussion) _neg

Executing with the full sample data (no multiplication)

SELECT * FROM pgr_turnPenaltyGraph('
    SELECT id AS id, source AS source, target AS target,
                  cost, reverse_cost
    FROM edge_table');

Test idea for pgtap

after getting the results:

UPDATE result2_vertices_pgr AS r SET original_id = v.id
FROM edge_table_vertices_pgr AS v WHERE v.id = r.id;

and

UPDATE result2_vertices_pgr SET original_id = id
WHERE id > 0;

give the same result

Finishing the proof of concept

Related to: #18
Related to: #3

This proof of concept shows how we can convert the results table into a version that has the same columns as pgr_lineGraph(). The next step is to prove that we convert this new version of the turnpenaltygraph results table back to the original version.

Currently we can deduce the original_source_vertex and the original_target_vertex of the original table from the new version, but we need to figure out how to deduce both the original_source_edge and the original_target_edge.

Example 3 (Discussion) without the _neg

Executing with the full sample data (no multiplication)

SELECT * FROM pgr_turnPenaltyGraph('
    SELECT id AS id, source AS source, target AS target,
                  cost, reverse_cost
    FROM edge_table');

Todo 1

  • Change the code in such a way that at least the original id is used for one vertex of the equivalent
  • The new vertices id's give them a negative id value so that its easy to distinguish which vertex is new and which vertex is an original id

Related to #3

New way of representing table

The format that the results table should be changed to save storage space

From

 seq | source | target | cost | original_source_vertex | original_source_edge | original_target_vertex | original_target_edge 
-----+--------+--------+------+------------------------+----------------------+------------------------+----------------------
   1 |      1 |      3 |    1 |                      6 |                   11 |                     11 |                   11
   2 |      2 |      4 |    1 |                     11 |                   13 |                     12 |                   13
   3 |      3 |      2 |    0 |                     11 |                   11 |                     11 |                   13

To

  id | 'e'   |source| target | cost
  id | 'v'   |o_vid | o_eid |  irrelevant
-----+------+------+--------+--------+
   1 |  'e' |    1 |      3 |    1 
   2 |  'e' |    2 |      4 |    1 
   3 |  'e' |    3 |      2 |    0 
   1 |  'v' |    6 |     11 |   -1
   2 |  'v' |    11|     13 |   -1
   3 |  'v' |    11|     11 |   -1
   4 |  'v' |    12|     13 |   -1

Hypothesis 2

The number of edges with cost 1 is the same number of edges of the original data:
The following queries give the same result

WITH                                                                         
  going_edges AS (SELECT count(*) FROM edge_table WHERE cost > 0),
  coming_edges AS (SELECT count(*) FROM edge_table WHERE reverse_cost > 0)
SELECT a.count + b.count FROM going_edges AS a, coming_edges AS b;
SELECT count(*) FROM pgr_turnPenaltyGraph('
    SELECT id AS id, source AS source, target AS target,
                  cost, reverse_cost
    FROM edge_table') where cost = 1;

example 2 (discussion)

data

SELECT id*100 AS id, source*1000 as source, target*1000 as target , cost, reverse_cost FROM edge_table where id in (5,9,11);
  id  | source | target | cost | reverse_cost 
------+--------+--------+------+--------------
  500 |   3000 |   6000 |    1 |           -1
  900 |   6000 |   9000 |    1 |            1
 1100 |   6000 |  11000 |    1 |           -1
(3 rows)

sampledata1

Two names for the same type convert to one type

Two names for the same type convert to one type

typedef graph::Pgr_lineGraph <
boost::adjacency_list < boost::vecS, boost::vecS,
    boost::bidirectionalS,
    Line_vertex, Basic_edge >,
Line_vertex, Basic_edge > LinearDirectedGraph;


typedef graph::Pgr_turnPenaltyGraph <
boost::adjacency_list < boost::vecS, boost::vecS,
    boost::bidirectionalS,
    Line_vertex, Basic_edge >,
    Line_vertex, Basic_edge > LinearDirectedGraph;

  • create a file with a appropriate name put both types on the file (together with the namespace where they are defined)
  • include the file in both .hpp files the line graph one and the turn penalty graph one
  • coment out (#if 0 #endif) the definiations that are on both .hpp files
  • compile until fixing bugs created by previous steps
  • delete one of the types
  • compile and fix where the compiler complains using the other type until no more errors

Hypothesis 1

For any value of x where x is a vertex id:

The following 2 queries give the same count

SELECT count(*) FROM pgr_turnPenaltyGraph('SELECT id,source,target,cost FROM edge_table') WHERE original_source_vertex=x AND original_target_vertex=x;
SELECT count(*) FROM pgr_lineGraph('SELECT id AS id, source AS source, target AS target , cost FROM edge_table WHERE source=x or target=x');

pgtap test equivalence 2 edge input

The follwing query

select * from pgr_turnPenaltyGraph(
'select id, source, target, cost, reverse_cost from edge_table where id =1');
 seq | source | target | cost | original_source_vertex | original_source_edge | original_target_vertex | original_target_edge 
-----+--------+--------+------+------------------------+----------------------+------------------------+----------------------
   1 |      2 |      2 |    1 |                      1 |                    1 |                      1 |                    1
   2 |      2 |      4 |    1 |                      1 |                    1 |                      2 |                    1
   3 |      4 |      2 |    1 |                      2 |                    1 |                      1 |                    1
   4 |      4 |      4 |    1 |                      2 |                    1 |                      2 |                    1
(4 rows)

Should have the same results as the followin query

SELECT * FROM pgr_turnPenaltyGraph(
    'select id, source, target, cost from edge_table where id = 1                                                                                                                                                        
    UNION ALL                                                                                                                                                                                                                        
    select id, target AS source, source AS target, reverse_cost AS cost from edge_table where id = 1'
)
seq | source | target | cost | original_source_vertex | original_source_edge | original_target_vertex | original_target_edge
-----+--------+--------+------+------------------------+----------------------+------------------------+----------------------
   1 |      2 |      2 |    1 |                      1 |                    1 |                      1 |                    1
   2 |      2 |      4 |    1 |                      1 |                    1 |                      2 |                    1
   3 |      4 |      2 |    1 |                      2 |                    1 |                      1 |                    1
   4 |      4 |      4 |    1 |                      2 |                    1 |                      2 |                    1
(4 rows)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.