Electric network is a kind of utility network in GIS. In this network we have a point layer that consist power stations and end users. Power stations called source and end users called sink. And also we have one or more line layer that consist power lines. (in the simplest case).

The direction of this network is from sources to sinks

My question is how to use pgRouting to identify the direct of this network? pgRouting has function called pgr_createTopology that builds a network topology based on the geometry information. When I call this function it fill source column and target column of my line layer. source and target show the direction of my network. But this direction is not based of source and sink.

In general can we define our own direction in specific network with pgRouting and not use its default direction?

1 Answer 1


pgRouting has several functions listed under "Flow - Family of functions": https://docs.pgrouting.org/latest/en/flow-family.html

These flow functions are probably what you are looking for, the same network topology is used as with other pgRouting functions.

  • Your answer showed me the way. The solution was simpler than I thought. That is BFS. I just need to run BFS on my network.
    – Ali dashti
    Commented May 27, 2020 at 6:48
  • Nice to hear you could solve your problem. You may want to close this question then.
    – dkastl
    Commented Jun 9, 2020 at 9:56

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.