0

I am trying to use pgr_lineGraph() to generate some edge-based catchments from a street network model. My expectation is that pgr_lineGraph() should create a node for every edge in the original graph and then create an edge between the new nodes if their corresponding edges meet at a node in the original graph.

small network extract

I have a small extract of my original larger network (shown above) for which I believe I have correctly generated the topology.

id geom source target cost
5974 "xxxx" 1 2 1
5976 "xxxx" 3 2 1
5977 "xxxx" 2 4 1
5975 "xxxx" 5 3 1
5987 "xxxx" 3 6 1

My expectation is that when I run

SELECT * FROM pgr_lineGraph(
    'SELECT id, source, target, cost FROM schema.network', directed := FALSE
);

I should get a new graph similar to:

source target
5974 5977
5974 5976
5976 5977
5976 5987
5976 5975
5975 5987

But I don't get that, I only get four edges.

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

Am I doing something wrong or is this the expected output from pgr_lineGraph()?

I am using pgr_version 3.0.0-rc1 on postgis_version 3.0.

1 Answer 1

0

Indeed, it is missing 2 edges

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);
 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 result (ignoring the seq value)

 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

The function is still experimental. I added the problem to the issue 2564 of pgRouting.

Regards Vicky Vergara PSC of pgRouting

1
  • Hi Vicky, thanks for confirming the problem and thanks for making it an issue as well. Sep 24, 2023 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.