[pgrouting-users] Can pgRouting assign source and target id that follows the same direction?

Hello, guys, I am working with PostgreSQL 9.2 and pgRouting 2.0 to route my river network. My question is hard to give it a brief title, so I post some details in the forum,

pgRouting assign number of source and target

Can I achieve my goal? Or is there any other way to solve this problem? Please give me some hint to begin with and feel free to give me any suggestion, thanks!

On 5/27/2014 1:27 PM, Heinz Chen wrote:

Hello, guys, I am working with PostgreSQL 9.2 and pgRouting 2.0 to route
my river network. My question is hard to give it a brief title, so I
post some details in the forum,

pgRouting assign number of source and target
<http://stackoverflow.com/questions/23887283/pgrouting-assign-number-of-source-and-target&gt;

Can I achieve my goal? Or is there any other way to solve this problem?
Please give me some hint to begin with and feel free to give me any
suggestion, thanks!

Tolerance defines the minimum distance between two points that will get merged into a single point. For example if you have two point and the distance between them in datbase units is less than tolerance then they will be considered the same point and will get assigned the same number.

given an edge segment in your geometry table before you run pgr_createtopology() how do you know the direction of flow? based on the direction of digitization? We do not look at this in assigning numbers. Numbers are assigned on a first come first assigned basis as we process the edges.

To solve your problem, you probably need to write a node renumbering algorithm, that works something like this: 1. run pgr_createtopology() 2. from the network sink (ie: the drain of river network) do a depth first search and assign numbers in reverse order (largest from the drain, smaller as you move upstream).

I would create new node source and target columns for this. There might be a better way to solve this problem but it is not obvious at the moment.

also responded on stackoverflow.

-Steve