Created
October 22, 2019 15:47
-
-
Save HeZhang1994/fb1dd7a0fabb9556daa07c12e269c41c to your computer and use it in GitHub Desktop.
This file contains 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
while len(remaining) > 0 and len(et) < len(vertex) - 1: | |
# Pop the top edge (currently with the least weight) from the 'remaining' edge list. | |
e = remaining.pop(0) # The 0-th element will be removed from 'remaining'. | |
print(e.v1) | |
# Check the two vertices of this edge and the associated groups. ### | |
gi = group(e.v1, groups) | |
gj = group(e.v2, groups) | |
#If two vertices are from different groups, we add them to the known trees. | |
if not gi == gj: | |
vt.add(e.v1) | |
vt.add(e.v2) | |
et.append(e) | |
#Merge the two groups. | |
groups = merge_groups(e.v1, e.v2, groups) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment