[pgrouting-users] Reduce the graph

Stephen Woodbridge woodbri at swoodbridge.com
Fri Mar 9 11:48:33 EST 2012

On 3/9/2012 11:39 AM, Aurélien FILEZ wrote:
> Hi all,
> My edge table has some useless nodes. For example :
> edge_id    v1      v2      the_geom
> 1              1        2      LINESTRING(x1 y1, x2 y2)
> 2              2        3      LINESTRING(x2 y2, x3 y3)
> But the vertex 2 is no used in any other edge.
> So I would like reduce my graph to transforme this previous example to :
> edge_id    v1      v2      the_geom
> 1              1        3      LINESTRING(x1 y1, x2 y2, x3 y3)
> Is there is a way to do that ?
> Thank you all :)

There is no automatic way to do this. I have done a lot of graph 
analysis by adding a cnt column to the vertices_tmp column and then 
updating it to the count of edges connected to that vertex.

Then you can do things like look for:

deadends - cnt=1
connected lines - cnt=2

You could write a stored procedure to that the connected lines, join 
them together, and update the relevant tables to reflect the new topology.


More information about the Pgrouting-users mailing list