Greedy min vertex cover hacktoberfest#5241
Merged
cclauss merged 13 commits intoTheAlgorithms:masterfrom Oct 15, 2021
Merged
Conversation
cclauss
reviewed
Oct 14, 2021
cclauss
reviewed
Oct 14, 2021
graphs/greedy_min_vertex_cover.py
Outdated
| while queue and not queue[0][0] == 0: | ||
| # extract vertex with max rank from queue and add it to s | ||
| argmax = heapq.heappop(queue)[1][0] | ||
| S.add(argmax) |
Member
There was a problem hiding this comment.
Uppercase is reserved for constants in Python yet this line changes S so S is not a constant.
cclauss
reviewed
Oct 14, 2021
graphs/greedy_min_vertex_cover.py
Outdated
Comment on lines
+24
to
+26
| S = set() | ||
| # queue used to store nodes and their rank | ||
| queue = [] |
Member
There was a problem hiding this comment.
Move these definitions down to line 35 so that we do not define variables until we are actually ready to use them.
cclauss
requested changes
Oct 14, 2021
graphs/greedy_min_vertex_cover.py
Outdated
| heapq.heappush(queue, [-1 * len(v), (k, v)]) | ||
|
|
||
| # s = set of chosen vertices | ||
| s = set() |
Member
There was a problem hiding this comment.
Suggested change
| s = set() | |
| chosen_vertices = set() |
and make similar changes elsewhere,
cclauss
approved these changes
Oct 15, 2021
shermanhui
pushed a commit
to shermanhui/Python
that referenced
this pull request
Oct 22, 2021
* added complete graph generator function * added doctest, type hints, wikipedia explanation * added return type hint for function complete_graph * added descriptive name for the parameter: n * random graph generator with doctest and type hints * added Greedy min vertex algorithm * pre-commit hook(s) made changes * Delete complete_graph_generator.py * Delete random_graph_generator.py * fixed doctest * updated commit following highligths * fixed following pre-commit highlights * modified variables names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.