[pgrouting-users] Disconnected nodes

Stephen Woodbridge woodbri at swoodbridge.com
Tue Apr 16 07:59:43 PDT 2013

On 4/16/2013 10:49 AM, Pavel Iacovlev wrote:
> Hello,
> I have a graph and I want to find all the the disconnected nodes, and by
> "disconnected" I mean all the nodes that have no path to node A. There
> is a case where A can be more then 1 node, and I need to find out if
> there is a path to at least one of them.
> My first idea is just to route to A from each node, easy to implement,
> but if I will have many nodes this will prove problematic.
> Any ideas how to do this more efficiently inside PostgreSQL ?

If you check out the sew-devel-2_0 branch in github you will find some 
graph analysis code that does this in src/common/sql/

This can probably just copy the sql and use it. Or at least look at it 
for how it works. Ask if you have questions.

This branch is stable at the moment if you want to clone it and build it 
and give it a test run. It installs on pg 9.1+ as an extension:

create extension pgrouting;


More information about the Pgrouting-users mailing list