Skip to content

test: cover topological sort edge cases - #15628

Closed
devam007 wants to merge 1 commit into
TheAlgorithms:masterfrom
devam007:codex/topological-edge-case-doctests
Closed

devam007 wants to merge 1 commit into
TheAlgorithms:masterfrom
devam007:codex/topological-edge-case-doctests

Conversation

@devam007

Copy link
Copy Markdown
Contributor

Describe your change

  • Add or change doctests? -- Algorithm logic is unchanged.

Add examples for an empty graph, an isolated vertex, disconnected components,
and a self-loop to Kahn's topological sort. The disconnected example verifies
vertex membership and edge ordering without requiring one arbitrary ordering
between independent components. A self-loop must return None.

Validation

Local Python 3.12.8: all 14 doctest examples pass as one pytest item. An external
check also enumerated all 512 directed graphs on three vertices (including
self-loops), comparing cycle feasibility against exhaustive vertex permutations;
empty and isolated graphs bring that check to 514 cases. This validates existing
behavior; it is a coverage improvement, not an algorithm bug fix. Targeted Ruff
lint, formatting and whitespace checks pass. Python 3.15t and the full upstream
suite were not run locally.

  • Read CONTRIBUTING.md and AGENTS.md.
  • One algorithm file changed; only its doctest examples changed.

@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Oct 23, 2026
@algorithms-keeper

Copy link
Copy Markdown

Multiple Pull Request Detected

@devam007, we are extremely excited that you want to submit multiple algorithms in this repository but we have a limit on how many pull request a user can keep open at a time. This is to make sure all maintainers and users focus on a limited number of pull requests at a time to maintain the quality of the code.

This pull request is being closed as the user already has an open pull request. Please focus on your previous pull request before opening another one. Thank you for your cooperation.

User opened pull requests (including this one): #15628, #15627, #15626, #15625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant