How to order the reaches in the unknown vector to get an upper triangular matrix H

The sorting algorithm will be described, using the previous example, focusing on the loop reaches (figure 3).

In the NODE column array is placed the list of the upstream nodes of the loop reaches, and in the 2 dimension REACH array is placed the list of the loop reaches connected to these nodes. When a reach joins a node, a negative sign is added to it.

NODEREACH
Line 1DC124Ü List of the reachesLine 2DC236-2 connected to the nodeLine 3FC15-4 DC1

In the REACH array, the positive numbers that appear only once are downstream reaches of a loop.

Downstream reaches of a loop: 3, 5, 6

The algorithm can be divided into two steps.

First step: The lines of the REACH array are analyzed. If one (or several) downstream reach of a loop can be found in one line, it is (or they are) stored in the RANGE list. Then the absolute value of all the negative reaches of the line are added to this list.

All the lines matching the criteria are gathered at the top of the REACH array. This way the second step will be applied on the remaining lines.

Summary after the first step:

NODEREACH
Line 1DC236-2Line 2FC15-4Line 3DC124

The problem can either be solved (case here), or some reaches can remain. In this latest case, the second step is processed.

Second step: The remaining lines of the REACH array are analyzed. If one positive reach, already belonging to the RANGE list, can be found in a line, then all the absolute values of the negative reaches of the line are added to this list. This line is removed and gathered to the lines processed by the first step. The second step is processed again for each remaining line until all the reaches have been taken.

The order of the RANGE list is inverse of the order of the reaches in the unknown vector.
RANGE :
36254 Reaches54321 Corresponding columns in the
the loop contains 5 reachesblocks (lines in the unknowns’ vector)