Loading topic
u and v already connected by the edges chosen so far? If they are, adding edge (u, v) would close a cycle. A disjoint-set structure, also called union-find, answers this in nearly constant time.2 min readDisjointSet class from the previous chapter. You should also be comfortable with Python's sorted and with Big-O notation.3 min readheapq module and the adjacency-list representation from earlier chapters.2 min readDisjointSet and kruskal code from the Kruskal chapter, and the heap-based prim code from the Prim chapter. Throughout, V is the number of vertices and E is the number of edges.3 min readDisjointSet and kruskal functions) and Prim's algorithm (with its lazy prim function). You should also be comfortable with the idea of a connected component.2 min read