Skip to content

tsort: print nodes and cycles as they are visited #7093

Merged
sylvestre merged 4 commits intouutils:mainfrom
jfinkels:tsort-print-cycle
Jan 13, 2025
Merged

tsort: print nodes and cycles as they are visited #7093
sylvestre merged 4 commits intouutils:mainfrom
jfinkels:tsort-print-cycle

Conversation

@jfinkels
Copy link
Collaborator

@jfinkels jfinkels commented Jan 8, 2025

Update tsort so that

  • nodes are printed as they are visited,
  • cycles are printed as they are discovered,
  • finding a cycle doesn't terminate the traversal,
  • multiple cycles can be found and displayed.

This isn't a perfect solution, as it breaks the cycles arbitrarily and just repeats the process until it can make more progress, but is an improvement on the previous situation.

Fixes #7074

Replace custom `Node::new` function with derived `Default`
implementation, which does the same thing but more concisely.
Update `tsort` so that

* nodes are printed as they are visited,
* cycles are printed as they are discovered,
* finding a cycle doesn't terminate the traversal,
* multiple cycles can be found and displayed.

Fixes uutils#7074
jfinkels and others added 2 commits January 11, 2025 11:47
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
@sylvestre sylvestre merged commit 35b896f into uutils:main Jan 13, 2025
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.

tsort: fails to print all nodes to stdout when a cycle is found

2 participants