![]() |
Q2NSViz 0.1.0
Q2NS trace visualizer
|
Disjoint-set data structure with path compression and union by rank. More...
Public Member Functions | |
| str | find (self, str x) |
| Find the root representative of the set containing x. | |
| union (self, str a, str b) | |
| Merge the sets containing a and b using union by rank. | |
| dict[str, list[str]] | groups (self) |
Return all components as {root: [members]}. | |
Disjoint-set data structure with path compression and union by rank.
Used by SimulationStateManager to compute the connected components of the entanglement graph.
| str q2nsviz.logic.UnionFind.find | ( | self, | |
| str | x | ||
| ) |
Find the root representative of the set containing x.
Inserts x into the structure on first access. Uses iterative two-pass path compression so the call stack never grows with set size.
| x | Element label to look up. |
Definition at line 136 of file logic.py.
Referenced by q2nsviz.logic.UnionFind.groups(), and q2nsviz.logic.UnionFind.union().
| dict[str, list[str]] q2nsviz.logic.UnionFind.groups | ( | self | ) |
Return all components as {root: [members]}.
Definition at line 178 of file logic.py.
References q2nsviz.logic.UnionFind.find().
| q2nsviz.logic.UnionFind.union | ( | self, | |
| str | a, | ||
| str | b | ||
| ) |
Merge the sets containing a and b using union by rank.
| a | First element label. |
| b | Second element label. |
Definition at line 161 of file logic.py.
References q2nsviz.logic.UnionFind.find().