Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a table and a random set of edges with source and target columns, how can I find out which edges connect with each other and then group them together using PostgreSQL?

share|improve this question
In most graphs, such as a classic road network, all edges are connected somehow. Therefore there would be only one group. What kind of graph are you thinking about? Is it not fully connected? – underdark Jan 20 '13 at 17:10
i have a graph of interconnected edges, w/ each edge tagged to a set of available mode of transport, so when i query the shortest path using pgRouting, what i do next is find out which mode of transport are available in each of them, then which of the available mode of transport are the most used, i do this to avoid too much transition on the mode of transport, e.g. |--walk-->mode1-->mode2-->walk-->mode3-->walk--| so base on the example i have 4 groups, walk,mode1,mode2,mode3, to get the length of each group, i just have to run SUM() on sql, but how to do it on individual walk edges? – Charles Jordan Cabero Jan 21 '13 at 11:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.