Repository navigation
Description
Student: Raj Manoj Patil
Task: R23-T037 · 7 of 10
Repository: https://github.com/S-AI-Projects/TheAlgorithms-Python
Assigned working branch: student/e26b07f0759
Goal
CONTRIBUTING.md asks for doctests covering both valid and erroneous input. Bring graphs/greedy_min_vertex_cover.py (2 doctests today) up to that standard. Only 2 doctests: add graphs that are empty, a single edge, a star and a cycle, and check that the result really is a vertex cover.
Steps
- Run
uv run pytest graphs/greedy_min_vertex_cover.py --cov=graphs --cov-report=term-missingand note which lines of this file are not covered. - For each public function (
greedy_min_vertex_cover), list valid, boundary and invalid inputs. - Add doctests for every uncovered branch and at least one erroneous input per function (showing the Traceback/exception line).
- Run
uv run python -m doctest -von the file and paste the summary line. - Make the code change in the repository: graphs/greedy_min_vertex_cover.py: doctests for empty graph, single edge, star and cycle, each checking the result covers every edge. Re-run the automated check and the repo's own tests afterwards.
- Prepare the PR: on branch R23-T037, commit the code change plus your work/R23-T037/ evidence, put your findings in the PR description and open the PR against the org fork. For a later upstream PR, create a second branch containing only the code change (no work/ folder).
Done when
☐ graphs/greedy_min_vertex_cover.py doctests rise from 2 to cover an empty graph, a single edge, a star and a cycle.
☐ Each new doctest checks that every edge has at least one endpoint in the returned cover.
☐ Coverage of the file is 100% (graphs/greedy_min_vertex_cover.py).
Additional task guidance
Additional curated task guidance
Item:
graphs/greedy_min_vertex_cover.py (64 lines; 2 doctests)
Task type:
Doctest completeness
Code change (goes into the PR):
graphs/greedy_min_vertex_cover.py: doctests for empty graph, single edge, star and cycle, each checking the result covers every edge.
Automated check:
uv run pytest graphs/greedy_min_vertex_cover.py --cov=graphs --cov-report=term-missing # report shows 100% (or justified) for this file
Prerequisites:
Linux/WSL2/Codespaces with uv (https://docs.astral.sh/uv/getting-started/installation/); run uv sync --group=test once – it installs the Python version CI uses (.python-version = 3.15t) and the test dependencies, about 1–2 GB
Upstream PR rules:
Follow CONTRIBUTING.md: type hints on every parameter/return, doctests for valid and erroneous input, snake_case file names, no duplicate of an existing implementation, no hand edits to DIRECTORY.md. CI (pytest with doctests, ruff) must pass – bots close PRs without tests or type hints. Keep work/ (benchmarks, notes, property tests) out of the upstream branch; put results in the PR description.
Source (pinned):
https://github.com/TheAlgorithms/Python/blob/574d100b7181956e9c8384552fd078165e4cc326/graphs/greedy_min_vertex_cover.py
Change:
No change recorded
PR destination:
Preserved pilot guidance
Submission checklist
- Complete this task and its checks.
- Add the required evidence and link your pull request here.
- Select this S-AI-Projects fork as the PR base repository.
- Request instructor review.
Keep this PR focused on this task. Do not submit assignment PRs to the upstream repository.
Activity