(self, n: int, m: int)
| 46 | return n |
| 47 | |
| 48 | def __connect(self, n: int, m: int) -> None: |
| 49 | pn = self.__find(n) |
| 50 | pm = self.__find(m) |
| 51 | if pn == pm: |
| 52 | return |
| 53 | if self.heights.get(pn, 1) > self.heights.get(pm, 1): |
| 54 | self.parents[pn] = pm |
| 55 | else: |
| 56 | self.parents[pm] = pn |
| 57 | self.heights[pm] = self.heights.get(pn, 1) + 1 |
| 58 | self.components -= 1 |
| 59 | |
| 60 | def valid_tree(self, n: int, edges: List[List[int]]) -> bool: |
| 61 | # init here as not sure that ctor will be re-invoked in different tests |
no test coverage detected