Update app.py
Browse files
app.py
CHANGED
|
@@ -181,12 +181,11 @@ def int_to_bin(n: int, d: int) -> str:
|
|
| 181 |
|
| 182 |
# ---------- Deterministic 2D layout (no rotation) ----------
|
| 183 |
# Even bits → X offsets, odd bits → Y offsets, decreasing magnitudes.
|
| 184 |
-
def layout_positions(d: int, base: float = 900.0):
|
| 185 |
n = 1 << d # number of nodes = 2^d
|
| 186 |
|
| 187 |
-
|
| 188 |
if mode == "bipartite":
|
| 189 |
-
# Left: odd parity, Right: even parity
|
| 190 |
odds = [v for v in range(n) if (bin(v).count("1") % 2) == 1]
|
| 191 |
evens = [v for v in range(n) if (bin(v).count("1") % 2) == 0]
|
| 192 |
|
|
|
|
| 181 |
|
| 182 |
# ---------- Deterministic 2D layout (no rotation) ----------
|
| 183 |
# Even bits → X offsets, odd bits → Y offsets, decreasing magnitudes.
|
| 184 |
+
def layout_positions(d: int, base: float = 900.0, mode: str = "default"):
|
| 185 |
n = 1 << d # number of nodes = 2^d
|
| 186 |
|
|
|
|
| 187 |
if mode == "bipartite":
|
| 188 |
+
# Left: odd parity, Right: even parity
|
| 189 |
odds = [v for v in range(n) if (bin(v).count("1") % 2) == 1]
|
| 190 |
evens = [v for v in range(n) if (bin(v).count("1") % 2) == 0]
|
| 191 |
|