File size: 1,912 Bytes
e717c2f
 
 
 
edae06c
e717c2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
edae06c
e717c2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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)