Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCreate bipartite.py #2060
Create bipartite.py #2060
Conversation
|
Code is working fine in my local machine...i don't understand why it is failing here |
|
What input are you giving the program?? ./graphs/bipartite.py:25: Explaination ==> Explanation |
|
What is |
|
Now it can be merged. |
Co-authored-by: Christian Clauss <[email protected]>
| @@ -35,6 +35,12 @@ | |||
|
|
|||
|
|
|||
| def bipartite(partition: list, adjacent_edges: list) -> int: | |||
This comment has been minimized.
This comment has been minimized.
cclauss
Jun 7, 2020
Member
| def bipartite(partition: list, adjacent_edges: list) -> int: | |
| def bipartite(partition: list, adjacent_edges: list) -> bool: |
It would be more Pythonic to return True or False instead of 0 or 1
| step = 2 | ||
| while queue: | ||
| node = queue.pop(0) | ||
| flag = 0 |
This comment has been minimized.
This comment has been minimized.
cclauss
Jun 7, 2020
Member
What is flag measuring? Could we please have a more self documenting variable name? It should be a bool (True/False), not 0/1.
| return 1 | ||
|
|
||
|
|
||
| def colour(adjacent_edges): # Assigning alternative colours to the nodes of the graph |
This comment has been minimized.
This comment has been minimized.
| queue = [] | ||
| queue.append(0) |
This comment has been minimized.
This comment has been minimized.
| if step % 2 == 0: | ||
| partition[i] = 'B' | ||
| else: | ||
| partition[i] = 'W' |
This comment has been minimized.
This comment has been minimized.
cclauss
Jun 7, 2020
Member
| if step % 2 == 0: | |
| partition[i] = 'B' | |
| else: | |
| partition[i] = 'W' | |
| partition[i] = 'W' if step % 2 else 'B' |
| partition[i] = 'B' | ||
| else: | ||
| partition[i] = 'W' | ||
| if flag == 1: |
This comment has been minimized.
This comment has been minimized.
| partition[i] = 'W' | ||
| if flag == 1: | ||
| step += 1 | ||
| return bipartite(partition, adjacent_edges) # return 1 if the graph is bipartite and 0 otherwise. |
This comment has been minimized.
This comment has been minimized.
cclauss
Jun 7, 2020
Member
| return bipartite(partition, adjacent_edges) # return 1 if the graph is bipartite and 0 otherwise. | |
| # return True if the graph is bipartite or False if it is not. | |
| return bipartite(partition, adjacent_edges) |
Lines must not be longer than 88 characters max as discussed in CONTRIBUTING.md.
| user_input = sys.stdin.read() | ||
| data = list(map(int, user_input.split())) |
This comment has been minimized.
This comment has been minimized.
cclauss
Jun 7, 2020
Member
| user_input = sys.stdin.read() | |
| data = list(map(int, user_input.split())) | |
| data = [int(x) for x in input("Enter integers separated by spaces").split()] |
|
On your machine do |
stale
bot
commented
Jul 8, 2020
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |


jntushar commentedJun 2, 2020
•
edited
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.