Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@HeZhang1994
Created October 22, 2019 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeZhang1994/fb1dd7a0fabb9556daa07c12e269c41c to your computer and use it in GitHub Desktop.
Save HeZhang1994/fb1dd7a0fabb9556daa07c12e269c41c to your computer and use it in GitHub Desktop.
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