Added Borůvka's algorithm.#4645
Conversation
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
graphs/boruvka.py
Outdated
|
|
||
| class Graph: | ||
| """Class Graph.""" | ||
| def __init__(self, num_of_nodes): |
There was a problem hiding this comment.
Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: num_of_nodes
graphs/boruvka.py
Outdated
| self.m_edges = [] | ||
| self.m_component = {} | ||
|
|
||
| def add_edge(self, u, v, weight): |
There was a problem hiding this comment.
Please provide return type hint for the function: add_edge. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
Please provide type hint for the parameter: v
Please provide descriptive name for the parameter: v
Please provide type hint for the parameter: weight
graphs/boruvka.py
Outdated
|
|
||
| self.m_edges.append([u, v, weight]) | ||
|
|
||
| def find_component(self, u): |
There was a problem hiding this comment.
Please provide return type hint for the function: find_component. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
graphs/boruvka.py
Outdated
| return u | ||
| return self.find_component(self.m_component[u]) | ||
|
|
||
| def set_component(self, u): |
There was a problem hiding this comment.
Please provide return type hint for the function: set_component. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
graphs/boruvka.py
Outdated
| for k in self.m_component.keys(): | ||
| self.m_component[k] = self.find_component(k) | ||
|
|
||
| def union(self, component_size, u, v): |
There was a problem hiding this comment.
Please provide return type hint for the function: union. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: component_size
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
Please provide type hint for the parameter: v
Please provide descriptive name for the parameter: v
graphs/boruvka.py
Outdated
|
|
||
| print(self.m_component) | ||
|
|
||
| def boruvka(self): |
There was a problem hiding this comment.
Please provide return type hint for the function: boruvka. If the function does not return a value, please provide the type hint as: def function() -> None:
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
graphs/boruvka.py
Outdated
| class Graph: | ||
| """Class Graph.""" | ||
|
|
||
| def __init__(self, num_of_nodes) -> None: |
There was a problem hiding this comment.
Please provide type hint for the parameter: num_of_nodes
graphs/boruvka.py
Outdated
| self.m_edges = [] | ||
| self.m_component = {} | ||
|
|
||
| def add_edge(self, u, v, weight) -> None: |
There was a problem hiding this comment.
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
Please provide type hint for the parameter: v
Please provide descriptive name for the parameter: v
Please provide type hint for the parameter: weight
graphs/boruvka.py
Outdated
|
|
||
| self.m_edges.append([u, v, weight]) | ||
|
|
||
| def find_component(self, u) -> int: |
There was a problem hiding this comment.
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
graphs/boruvka.py
Outdated
| return u | ||
| return self.find_component(self.m_component[u]) | ||
|
|
||
| def set_component(self, u) -> None: |
There was a problem hiding this comment.
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
graphs/boruvka.py
Outdated
| for k in self.m_component.keys(): | ||
| self.m_component[k] = self.find_component(k) | ||
|
|
||
| def union(self, component_size, u, v) -> None: |
There was a problem hiding this comment.
Please provide type hint for the parameter: component_size
Please provide type hint for the parameter: u
Please provide descriptive name for the parameter: u
Please provide type hint for the parameter: v
Please provide descriptive name for the parameter: v
srkchowdary2000
left a comment
There was a problem hiding this comment.
Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
graphs/boruvka.py
Outdated
| self.m_edges = [] | ||
| self.m_component = {} | ||
|
|
||
| def add_edge(self, u: int, v: int, weight: int) -> None: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: u
Please provide descriptive name for the parameter: v
graphs/boruvka.py
Outdated
|
|
||
| self.m_edges.append([u, v, weight]) | ||
|
|
||
| def find_component(self, u: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: u
graphs/boruvka.py
Outdated
| return u | ||
| return self.find_component(self.m_component[u]) | ||
|
|
||
| def set_component(self, u: int) -> None: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: u
graphs/boruvka.py
Outdated
| for k in self.m_component.keys(): | ||
| self.m_component[k] = self.find_component(k) | ||
|
|
||
| def union(self, component_size: list, u: int, v: int) -> None: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: u
Please provide descriptive name for the parameter: v
|
Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. |
|
This a Borůvka's algorithm, a simple greedy algorithm to find the Minimum spanning tree of a grap. It is also the oldest know graph algorithm, works as efficient as Kruskal's and Prim's algorithm. |
…panning tree. Solved Test Cases Errors.
|
Hi, I have Fixed the Tests. Can you please review the code. Thank you. |
srkchowdary2000
left a comment
There was a problem hiding this comment.
Final Changes for Test Case Errors.
…panning tree. Solved Test Cases Errors.
…panning tree. Solved Test Cases Errors.
srkchowdary2000
left a comment
There was a problem hiding this comment.
Test Case Errors Solved.
|
Hi, Can you please Review my Code. |
|
Please reformat with black because of precommit build |
…panning tree. Solved Test Cases Errors.
|
Not really :) |
|
Even Spaces are not acceptable, is it? 😔 |
|
Rules are Strict. 😂 |
…panning tree. Solved Test Cases Errors.
srkchowdary2000
left a comment
There was a problem hiding this comment.
Precommiting seems difficult than writing Algorithm. Now Final Review Please.
@l3str4nge
…panning tree. Solved Test Cases Errors.
srkchowdary2000
left a comment
There was a problem hiding this comment.
Reduced Each Line Length, Code Formatting.
@l3str4nge
…panning tree. Solved Test Cases Errors.Removed WhiteSpaces.
srkchowdary2000
left a comment
There was a problem hiding this comment.
Removed WhiteSpaces.
|
Final Review Please. |
graphs/boruvka.py
Outdated
|
|
||
|
|
||
| class Graph: | ||
| """Class Graph.""" |
graphs/boruvka.py
Outdated
| def set_component(self, u_node: int) -> None: | ||
| """Finds the component index of a given node""" | ||
|
|
||
| if self.m_component[u_node] == u_node: |
There was a problem hiding this comment.
Would be just self.m_component[u_node] != u_node: and then we don't need else
graphs/boruvka.py
Outdated
| component_size[u_node] += component_size[v_node] | ||
| self.set_component(v_node) | ||
|
|
||
| print(self.m_component) |
There was a problem hiding this comment.
Please remove this print statement
graphs/boruvka.py
Outdated
| num_of_components = self.m_v | ||
|
|
||
| while num_of_components > 1: | ||
| for i in range(len(self.m_edges)): |
There was a problem hiding this comment.
Calling len() each iteration is inefficient.
…panning tree. Code Changes.
…panning tree. Code Changes.
srkchowdary2000
left a comment
There was a problem hiding this comment.
Requested code changes done. Please review my code.
@l3str4nge
|
Can I write python code from scratch for Singular Vector Decompositions and Principal Component Analysis? Thank you So Much. |
* Added Borůvka's algorithm. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.Removed WhiteSpaces. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Code Changes. * Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Code Changes.
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.