ihara-zeta
БесплатноБез исполняемых скриптовНе проверенIhara zeta function for graphs: non-backtracking walks, prime cycles, and spectral analysis via det(I - uB).
от plurigrid★ 73 звезды на GitHubОб этом скилле
Ihara Zeta Function Skill
"The Ihara zeta function encodes all non-backtracking closed walks - the 'prime cycles' of a graph."
Overview
The Ihara zeta function generalizes the Riemann zeta function to graphs:
- Prime cycles - Non-backtracking closed walks (graph analog of primes)
- Determinant formula - ζ_G(u)^{-1} = det(I - uB) relation
- Ramanujan connection - Riemann Hypothesis analog for graphs
- Non-backtracking matrix - Central object for spectral clustering
Definition
Ihara Zeta Function
For a graph G, the Ihara zeta function is:
ζ_G(u) = ∏_{[C]} (1 - u^{|C|})^{-1}
where:
- Product is over equivalence classes [C] of primitive closed non-backtracking walks
- |C| is the length of the cycle
- Primitive = not a power of a shorter cycle
Non-Backtracking Walk
A walk v₀ → v₁ → v₂ → ... → vₖ is non-backtracking if:
vᵢ₊₁ ≠ vᵢ₋₁ for all i
(Never immediately return to the previous vertex)
The Determinant Formula
Bass-Hashimoto Formula
ζ_G(u)^{-1} = (1 - u²)^{|E| - |V|} · det(I - uB)
where B is the non-backtracking matrix.
Non-Backtracking Matrix
Indexed by directed edges (e, f) where head(e) = tail(f) and e ≠ f⁻¹:
function non_backtracking_matrix(G)
# Directed edges: 2|E| entries
directed_edges = [(u,v) for (u,v) in edges(G)
for dir in [(u,v), (v,u)]]
m = length(directed_edges)
B = zeros(m, m)
for (i, e) in enumerate(directed_edges)
for (j, f) in enumerate(directed_edges)
# e = (a→b), f = (c→d)
# Connect if b = c AND a ≠ d (non-backtracking)
if e[2] == f[1] && e[1] != f[2]
B[i, j] = 1
end
end
end
return B
end
Prime Cycles and Möbius
Connection to Number Theory
| Number Theory | Graph Theory |
|---|---|
| Prime number p | Prime cycle C |
| log p | Length |
| Riemann zeta ζ(s) | Ihara zeta ζ_G(u) |
| Prime Number Theorem | Cycle counting asymptotics |
| Riemann Hypothesis | Ramanujan property |
Möbius Function on Paths
A path of length n is prime (non-backtracking) iff μ(n) ≠ 0:
function is_prime_path(path)
"""
Check if path is non-backtracking (prime).
Equivalent to μ(length) ≠ 0 in our encoding.
"""
for i in 2:length(path)-1
if path[i-1] == path[i+1]
return false # Backtracking detected
end
end
return true
end
function moebius_filter(paths)
"""
Filter to prime (non-backtracking) paths using Möbius.
μ(n) ≠ 0 ⟺ n is squarefree ⟺ no repeated factors ⟺ no backtracking.
"""
return filter(is_prime_path, paths)
end
Ramanujan and Riemann Hypothesis
Graph Riemann Hypothesis
A d-regular graph G satisfies the Graph Riemann Hypothesis if all poles of ζ_G(u) in |u| < 1/√(d-1) lie on the circle |u| = 1/√(d-1).
Theorem: G is Ramanujan ⟺ G satisfies the Graph Riemann Hypothesis.
Verification
function check_graph_riemann_hypothesis(G)
d = degree(G)
B = non_backtracking_matrix(G)
# Eigenvalues of B
eigenvalues = eigvals(B)
# Poles of zeta at 1/λ for each eigenvalue λ
poles = 1 ./ eigenvalues
# Check: all poles with |u| < 1/√(d-1) lie on |u| = 1/√(d-1)
critical_radius = 1 / √(d - 1)
for pole in poles
r = abs(pole)
if r < critical_radius && abs(r - critical_radius) > 0.001
return false # Pole inside critical circle but not on it
end
end
return true
end
Spectral Clustering via Non-Backtracking
The Spectral Redemption Theorem
Bordenave-Lelarge-Massoulié (2015):
Non-backtracking spectral clustering succeeds down to the information-theoretic threshold, where adjacency-based methods fail.
function non_backtracking_clustering(G, k)
"""
Cluster graph into k communities using non-backtracking eigenvectors.
Succeeds where spectral clustering on adjacency matrix fails
(the 'spectral redemption' phenomenon).
"""
B = non_backtracking_matrix(G)
# Get top k+1 eigenvectors (skip trivial)
λ, V = eigen(B)
idx = sortperm(abs.(λ), rev=true)
# Project directed edge eigenvectors to vertices
vertex_embeddings = project_to_vertices(G, V[:, idx[2:k+1]])
# Cluster in embedding space
return kmeans(vertex_embeddings, k)
end
Zeta Function Computation
Direct Computation
function ihara_zeta_coefficient(G, n)
"""
Coefficient of u^n in log ζ_G(u).
= (1/n) × (number of primitive closed non-backtracking walks of length n)
"""
B = non_backtracking_matrix(G)
# tr(B^n) counts all closed non-backtracking walks of length n
# Möbius inversion extracts primitive ones
total = tr(B^n)
# Subtract non-primitive (powers of shorter cycles)
primitive_cou
Установить ihara-zeta в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ihara-zeta?
Ihara zeta function for graphs: non-backtracking walks, prime cycles, and spectral analysis via det(I - uB).
Как установить скилл ihara-zeta?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ihara-zeta запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic