Skip to content

Conversation

@ThalesMMS
Copy link
Contributor

This pull request introduces improved support for self-loop edges (edges where the source and destination are the same node) throughout the graph rendering and layout codebase. It adds robust handling for self-loops in rendering, ensures nodes are not duplicated, and enhances the Sugiyama algorithm to correctly process self-loops. Comprehensive tests have also been added to verify these behaviors.

Self-loop rendering enhancements:

  • Added a generic buildSelfLoopPath method to EdgeRenderer, allowing all renderers to create and draw self-loop paths with optional arrowheads. This is now used in ArrowEdgeRenderer, SugiyamaEdgeRenderer, and TreeEdgeRenderer to properly visualize self-loops. [1] [2] [3] [4]

Graph structure and algorithm improvements:

  • Updated Graph.addEdgeS to prevent node duplication when adding self-loops, ensuring a single node instance is used and not added multiple times.
  • Modified SugiyamaAlgorithm to correctly handle self-loops and reversed edges, including preserving edge data when reversing, initializing coordinates for empty layers, and restoring cycles with proper edge data. [1] [2] [3] [4] [5]

Rendering consistency:

  • Standardized paint and line type handling for self-loops and regular edges in edge renderers, ensuring consistent visual styles. [1] [2] [3]

Testing improvements:

  • Added new tests to verify that self-loops do not duplicate nodes, that self-loop paths are built and rendered correctly, and that the SugiyamaAlgorithm robustly handles graphs with self-loops.

Introduces logic to render self-referential edges (loops) in ArrowEdgeRenderer, SugiyamaEdgeRenderer, and TreeEdgeRenderer. Adds buildSelfLoopPath utility and corresponding test coverage for loop path generation.
Refactored addEdgeS to prevent adding duplicate nodes when an edge is a self-loop. Added a test to verify that self-loop edges do not result in multiple instances of the same node.
Replaces arc-based loop edge rendering with a cubic Bezier curve for improved control over loop shape. Updates start, end, and control point calculations to use node position and dimensions, enhancing visual consistency and flexibility.
Ensures that edge data, such as bend points, is retained when edges are reversed in the SugiyamaAlgorithm. This prevents loss of associated metadata during edge manipulation and improves graph consistency.
Improved the restoreCycle method by adding null checks, using toList() for safe iteration, and clearing the reversed list after restoration. This enhances code safety and prevents potential runtime errors.
Added a check to initialize coordinates when empty and skip empty layers in overlap resolution. Added a test to verify SugiyamaAlgorithm handles a single node with a self-loop without errors.
…ulation-and-tests

Adjust self-loop control points for smooth tangents
@nabil6391
Copy link
Owner

This is perfect, @ThalesMMS , can you please share some screenshots? Would love to see the actual UI for Sugiyama layout

@nabil6391
Copy link
Owner

@ThalesMMS Please fix the test if possible

@ThalesMMS
Copy link
Contributor Author

ThalesMMS commented Oct 10, 2025

Simulator Screenshot - iPhone 17 Pro Max - 2025-10-10 at 12 13 42 Simulator Screenshot - iPhone 17 Pro Max - 2025-10-10 at 12 28 23

Performance Results (5 runs avg):

  1. Circle : 0.0 ms
  2. RadialTree : 10.0 ms
  3. Balloon : 13.0 ms
  4. TidierTree : 27.0 ms
  5. Buchheim : 55.0 ms
  6. Eiglsperger : 5138.0 ms
  7. Sugiyama : 5518.0 ms
    00:14 +37: All tests passed!

@nabil6391 nabil6391 merged commit c620ddc into nabil6391:master Oct 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants