23 lines
906 B
Python
23 lines
906 B
Python
|
|
"""Resonance Linker — Finds second-degree connections in the holographic graph."""
|
|
|
|
class ResonanceLinker:
|
|
def __init__(self, archive):
|
|
self.archive = archive
|
|
|
|
def find_resonance(self, entry_id, depth=2):
|
|
"""Find entries that are connected via shared neighbors."""
|
|
if entry_id not in self.archive._entries: return []
|
|
|
|
entry = self.archive._entries[entry_id]
|
|
neighbors = set(entry.links)
|
|
resonance = {}
|
|
|
|
for neighbor_id in neighbors:
|
|
if neighbor_id in self.archive._entries:
|
|
for second_neighbor in self.archive._entries[neighbor_id].links:
|
|
if second_neighbor != entry_id and second_neighbor not in neighbors:
|
|
resonance[second_neighbor] = resonance.get(second_neighbor, 0) + 1
|
|
|
|
return sorted(resonance.items(), key=lambda x: x[1], reverse=True)
|