| Conditions | 5 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from abc import ABCMeta, abstractmethod |
||
| 19 | def __init__(self, G): |
||
| 20 | minpq = MinPQ.create() |
||
| 21 | self.tree = Bag() |
||
| 22 | for e in G.edges(): |
||
| 23 | minpq.enqueue(e) |
||
| 24 | |||
| 25 | uf = UnionFind.create(G.vertex_count()) |
||
| 26 | |||
| 27 | while not minpq.is_empty() and self.tree.size() < G.vertex_count() - 1: |
||
| 28 | e = minpq.del_min() |
||
| 29 | v = e.start() |
||
| 30 | w = e.end() |
||
| 31 | if not uf.connected(v, w): |
||
| 32 | uf.union(v, w) |
||
| 33 | self.tree.add(e) |
||
| 34 | |||
| 37 |