pgRouting / pgrouting

Repository contains pgRouting library. Development branch is "develop", stable branch is "master"
https://pgrouting.org
GNU General Public License v2.0
1.13k stars 362 forks source link

pgr_lingraph not giving expected results #2564

Closed cvvergara closed 1 month ago

cvvergara commented 10 months ago

Problem

from stackexchange

To Reproduce

create table lnedges(
id INTEGER,
source INTEGER,
target INTEGER,
cost INTEGER);
INSERT INTO lnedges (id, source, target, cost)
VALUES 
(5974, 1, 2, 1),
(5976, 3, 2, 1),
(5977, 2, 4, 1),
(5975, 5, 3, 1),
(5987, 3, 6, 1);
SELECT * FROM pgr_lineGraph(
    'SELECT id, source, target, cost FROM lnedges', directed := FALSE
);

Results

 seq | source | target | cost | reverse_cost 
-----+--------+--------+------+--------------
   1 |   5974 |   5977 |    1 |           -1
   2 |   5975 |   5976 |    1 |           -1
   3 |   5975 |   5987 |    1 |           -1
   4 |   5976 |   5977 |    1 |           -1
(4 rows)

Expected results Missing edges marked with xx

     seq | source | target | cost | reverse_cost 
    -----+--------+--------+------+--------------
       1 |   5974 |   5977 |    1 |           -1
       2 |   5975 |   5976 |    1 |           -1
       3 |   5975 |   5987 |    1 |           -1
       4 |   5976 |   5977 |    1 |           -1
       x |   5976 |   5987 |    1 |           -1
       x |   5974 |   5976 |    1 |           -1
cvvergara commented 1 month ago

This are the new results

seq | source | target | cost | reverse_cost 
-----+--------+--------+------+--------------
   1 |   5974 |   5976 |    1 |           -1
   2 |   5974 |   5977 |    1 |           -1
   3 |   5975 |   5987 |    1 |           -1
   4 |   5976 |   5975 |    1 |           -1
   5 |   5976 |   5977 |    1 |           -1
   6 |   5976 |   5987 |    1 |           -1
(6 rows)