import numpy as np import sympy from collections import Counter from typing import Dict, List, Tuple class PrimeNetwork: """ Represents the Radial Prime Topology as an instantiated graph object. Used for both visualization and signal routing validation. """ def __init__(self, max_integer: int = 1000): self.max_integer = max_integer self.positions: Dict[int, Tuple[float, float]] = {} self.gpf_map: Dict[int, int] = {} self.prime_counts = Counter() self.primes: List[int] = [] self.composites: List[int] = [] # Build the network immediately self._build() def _get_gpf(self, n: int) -> int: """Returns the Greatest Prime Factor.""" if n <= 1: return 1 i = 2 while i * i <= n: if n % i: i += 1 else: n //= i return n def _build(self): """Constructs the network nodes and edges.""" for n in range(1, self.max_integer + 1): # Radial position based on Mod 10 angle = np.pi/2 - (2 * np.pi * (n % 10)) / 10 # Clockwise from Top radius = n self.positions[n] = (radius * np.cos(angle), radius * np.sin(angle)) if n > 1: if sympy.isprime(n): self.primes.append(n) else: self.composites.append(n) gpf = self._get_gpf(n) self.gpf_map[n] = gpf self.prime_counts[gpf] += 1 elif n == 1: self.primes.append(1) def validate_wave(self, heat_code: int) -> bool: """Check if a subset of the wave aligns with valid network topology.""" residue = heat_code % 10 return residue in [1, 3, 7, 9] # Pre-calc network SHARED_NETWORK = PrimeNetwork(max_integer=2000)