-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pauline - Fire #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really well done Pauline, nice work. I appreciate how you got these done ASAP.
# Time Complexity - O(v + e) Using BFS, the function checks each vertex through the queue once, and all edges | ||
# associated with that queue once or twice at most. Checking for non biparition-able graphs via edges beforehand | ||
# and only adding to the queue any edges with vertices that haven't been visited as a vertex prevents | ||
# repeat vertices from being visited. | ||
|
||
# Space Complexity - O(v) - A hash, and set, and a queue are created where the max number of elements added will never exceed | ||
# the number of vertices (v) in the graph. group_hash will always have two keys between which the vertices are divided into based on | ||
# edges, to_visit is a set of all vertices to delete from (in O(1) time), while bfs at worst will have all vertices in the Queue, | ||
# as the function doesn't add any edges that have already been visited. to_visit mostly exists to track any vertices | ||
# in a graph that aren't reached by a group of other vertices in the graph, which group_hash and bfs_q can't account for. | ||
def possible_bipartition(dislikes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation of Breadth-first-search. Well done!
# set current group for leading vertex | ||
v_group = 1 | ||
|
||
# set current group for edges | ||
e_group = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works to label the groups, I just used the symbols :red
, and :green
to label the groups.
Will update with any improvements as I revisit. Thank you!!