ELcorrect

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - EL/Edge Lists
Introduced first in SolidGeometry 5.3, Creation date: 2023-06-10, Last change: 2025-09-15

finds edges with a wrong direction and turns them



See Also: ELreconnect , ELofELmesh

Example Illustration

 missing image of ELcorrect(EL)

Syntax

[EL,CL]=ELcorrect(EL)

Input Parameter

EL: Edge list with edges in wrong direction

Output Parameter

EL: EL
CL: List of turned edges in the original direction

Examples


ELcorrect([1 2;2 3;3 4;5 4; 1 5])
ELcorrect(ELunsort([1 2;2 3;3 4;5 4; 1 5]))




Copyright 2023-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 correct the direction of edges in an edge list (EL) and return a list of edges that were turned to their original direction (CL).

Input Parameters

Output Results

Algorithm Steps

  1. Identify unique nodes in the edge list using unique(EL).
  2. Find nodes that are not the starting node of any edge using ~ismember(uu,EL(:,1)).
  3. Initialize CL as a zero matrix with the same size as EL and a counter k set to 0.
  4. While there are nodes that are not starting nodes:
    1. Select the first such node mm.
    2. Find edges where this node is the ending node using find(EL(:,2)==mm).
    3. If there is more than one such edge:
      1. Select the first edge zz and the second edge ff.
      2. Flip the direction of the second edge by swapping its nodes.
      3. Increment the counter k and store the flipped edge in CL.
      4. Reorder the edges in EL to maintain consistency.
      5. Update mm to the new ending node of the flipped edge.
    4. If there is only one such edge, clear mm to exit the loop.
  5. Return the corrected edge list EL and the list of turned edges CL.
Algorithm explaination created using ChatGPT on 2025-08-19 00:00. (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