Syntax
EIL=ELsort(EIL)
Input Parameter
Output Parameter
Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, ELsort
, is designed to sort an edge list (EIL) that may contain NaN-separated segments. The function processes these segments to ensure they are sorted in increasing order, both from first to last and left to right, and links the chains together.
Input Parameters
- EIL: The input edge list, which may contain NaN-separated segments.
Output
- EIL: The sorted edge list.
Algorithm Steps
- Initialize a counter
k
to zero. This counter will track the position in the output list.
- Determine the number of NaN-separated segments in the input edge list
EIL
using the function separateNaN
.
- Iterate over each segment
i
from 1 to n
(the number of segments):
- Extract the
i
-th segment using separateNaN(EIL, i)
.
- Identify rows where the first column is greater than the second column, storing this condition in
b
.
- Sort the rows of the segment, flipping rows where
b
is true, to ensure all rows are in increasing order.
- Determine the number of rows in the sorted segment,
ne
.
- Use
CELofEL
to further process the sorted segment and store the result in the output list EIL
starting from position k+1
.
- Update
k
to k + ne + 1
to account for the processed segment and a NaN separator.
- Trim the output list
EIL
to remove any unused trailing rows.
- Correct the order of edges in the list to ensure continuity:
- For each row from the second to the last, if the first element of the current row matches the first element of the previous row, swap the elements of the previous row.
- For each row from the second to the last, if the second element of the current row matches the second element of the previous row, swap the elements of the current row.
Algorithm explaination created using ChatGPT on 2025-08-19 01:29. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21