Fix Kahn's algorithm by Dharshini-RS03 · Pull Request #15074 · TheAlgorithms/Python · GitHub
Skip to content

Fix Kahn's algorithm - #15074

Open
Dharshini-RS03 wants to merge 1 commit into
TheAlgorithms:masterfrom
Dharshini-RS03:topo-sort
Open

Fix Kahn's algorithm#15074
Dharshini-RS03 wants to merge 1 commit into
TheAlgorithms:masterfrom
Dharshini-RS03:topo-sort

Conversation

@Dharshini-RS03

Copy link
Copy Markdown

Describe your change:

  • Fixed Kahn’s algorithm to support sparse/non-contiguous vertex IDs.

  • Improved queue performance using deque and added doctests for sparse graphs.

  • Add an algorithm?

  • Fix a bug or typo in an existing algorithm?

  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.

  • Documentation change?

Checklist:

@algorithms-keeper algorithms-keeper Bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Aug 23, 2026

@cclauss cclauss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a benchmark that proves that the proposed changes could save significant runtime.

@algorithms-keeper algorithms-keeper Bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes A maintainer has requested changes to this PR enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Inefficient pop(0) queue operations and IndexError on sparse vertex IDs in graphs/kahns_algorithm_topo.py

2 participants