Hi all,
I'm trying to find a way to rank order a network. I have two columns with "start" and "end" destinations of each segment of the network. In the case of this problem, there will always be a last destination, though their may be multiple paths into the network. I've included a simple example.
To do this in C++ or Matlab I would use a For Loop and something like an insertion sort algorithm to build the list where the prior row's "end" is equal to current rows "start" then apply the rank order to the sorted list by group. I know in principle that I would perform this in M by wrapping it in a Group function, but beyond that I'm uncertain how to compare different columns in different row in this way.
In the event of ties (where two nodes feed into one) which is given each rank is not important.
Simple Data Example
Group | Start | End |
1 | A | C |
1 | C | D |
1 | B | C |
1 | E | F |
1 | D | E |
2 | K | L |
2 | M | O |
2 | L | M |
2 | N | O |
2 | O | P |
Network diagram
Desired Results
Order Number | Group | Start | End |
1 | 1 | A | C |
3 | 1 | C | D |
2 | 1 | B | C |
5 | 1 | E | F |
4 | 1 | D | E |
1 | 2 | K | L |
3 | 2 | M | O |
2 | 2 | L | M |
4 | 2 | N | O |
5 | 2 | O | P |
Any ideas?