Skip to content

The diameter of the Tonnetz graph

The computations for section 4.3 of the brief. Contains 3 code cells and 1 figures.

math/notebooks/04-cap.ipynb

The code does not run here. The outputs you see were saved when the notebooks were last run.
Code, comments and printed output are in Turkish. The explanations are translated.

Brief 4.3: at most how many steps of a fifth or a third does it take to get from one pitch to another?

This notebook produces computations and figures. The proofs and the report text belong to the students.

Setup

Loads the package and the plotting library. kaydet saves a figure as PNG and SVG into rapor/sekiller. tablo_yaz writes a table as CSV into rapor/tablolar and prints it. t53 is the Tonnetz with 53 divisions, used in the rest of the notebook.

Setup code (imports and helper functions)
from pathlib import Pathimport csvimport matplotlib.pyplot as pltfrom tonnetz import *from tonnetz.plot import draw_latticeRAPOR = Path("..") / ".." / "rapor"SEKIL = RAPOR / "sekiller"; SEKIL.mkdir(parents=True, exist_ok=True)TABLO = RAPOR / "tablolar"; TABLO.mkdir(parents=True, exist_ok=True)def kaydet(fig, ad):    for uzanti in ("png", "svg"):        fig.savefig(SEKIL / f"{ad}.{uzanti}", dpi=300, bbox_inches="tight")def tablo_yaz(ad, basliklar, satirlar):    with open(TABLO / f"{ad}.csv", "w", newline="", encoding="utf-8") as f:        w = csv.writer(f); w.writerow(basliklar); w.writerows(satirlar)    genislik = [max(len(str(x)) for x in sutun) for sutun in zip(basliklar, *satirlar)]    for satir in (basliklar, *satirlar):        print("  ".join(str(x).rjust(g) for x, g in zip(satir, genislik)))t53 = Tonnetz.tet(53)

Diameter

distances_from(t, 0) uses breadth-first search to find the least number of edges from pitch 0 to every pitch. diameter is the largest of these distances. The third column is 3d² + 3d + 1. This is the largest number of points reachable within d steps in a hexagonal lattice, and N cannot exceed it. The last column gives how many pitches lie at each distance.

In 2

satirlar = []for N in TETS:    t = Tonnetz.tet(N); d = diameter(t)    dagilim = [distances_from(t, 0).count(k) for k in range(d + 1)]    satirlar.append([N, d, 3 * d * d + 3 * d + 1, " ".join(map(str, dagilim))])tablo_yaz("cap", ["N", "çap", "3d²+3d+1", "uzaklık dağılımı (0, 1, 2, ...)"], satirlar)

Output

 N  çap  3d²+3d+1  uzaklık dağılımı (0, 1, 2, ...)
12    2        19                            1 6 5
19    3        37                         1 6 10 2
31    4        61                       1 6 10 8 6
41    4        61                     1 6 12 12 10
53    5        91                   1 6 12 16 14 4

Heat map

The distances from pitch 0 for 53 divisions are shown on the lattice. The number in each node is the distance, and the colour darkens with distance.

In 3

uzaklik = distances_from(t53, 0)fig, ax = plt.subplots(figsize=(10, 6.5))draw_lattice(t53, ax, cols=12, rows=8, node_values=dict(enumerate(uzaklik)))kaydet(fig, "cap-isi-53")
On the lattice with 53 divisions each node shows its distance from pitch 0. The node colour darkens as the distance grows.

Every number on this site comes from data produced by the Python core and is checked by tests.

TÜBİTAK 2204-A mathematics project