Syntax
EL=ELunsort(EL)
Input Parameter
Output Parameter
Examples
EL=ELofn(10); [EL ELunsort(EL)]
Copyright 2013-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 algorithm is designed to randomly unsort an edge list by swapping its rows. It is primarily used for testing purposes in various applications.
Input Parameters
- EL: The original edge list that needs to be unsorted.
Output
- EL: The unsorted edge list after random row exchanges.
Algorithm Steps
- Determine the number of rows
n
in the edge list EL
using size(EL,1)
.
- If
n
is greater than 2, proceed with the unsorting process.
- For each row in the edge list, perform the following:
- Call the
swapind
function to get two random indices k
and m
.
- Swap the rows at indices
k
and m
in the edge list EL
.
Function: swapind
This function generates two distinct random indices for swapping rows in the edge list.
Steps
- Check if
n
is less than 2. If true, return empty indices i1
and i2
.
- Generate a random index
i1
using ceil(rand*n)
and ensure it is at least 1.
- Generate a second random index
i2
using ceil(rand*n)
and ensure it is distinct from i1
and at least 1.
Algorithm explaination created using ChatGPT on 2025-08-19 00:18. (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