Uniform labeled tree#

Uniform labeled trees (Cayley trees).

tinto.theory.cayley.adjacent_pair_degrees(n, a, c)[source]#

Law of the other degrees of two adjacent nodes of the uniform labeled tree.

Given that u and v are adjacent, with \(a = d_u - 1\) and \(c = d_v - 1\),

\[P(a, c) = \binom{n-3}{a+c-1}\binom{a+c}{a} \left(\frac2n\right)^{a+c-1} \left(1 - \frac2n\right)^{n-2-a-c} 2^{-(a+c)}.\]
Parameters:
  • n (int) – Number of nodes, n >= 3.

  • a (int) – Degrees minus one.

  • c (int) – Degrees minus one.

Return type:

Fraction

Examples

>>> sum(adjacent_pair_degrees(5, a, c) for a in range(4) for c in range(4))
Fraction(1, 1)
tinto.theory.cayley.distance_two_pair_degrees(n, a, c)[source]#

Law of the other degrees of two nodes at distance two in the uniform labeled tree.

Given that u and v have a common neighbor, with \(a = d_u - 1\) and \(c = d_v - 1\), summing over the degree D of the middle node without u and v,

\[P(a, c) = \sum_D \binom{n-4}{D-1} \left(\frac3n\right)^{D-1} \left(1 - \frac3n\right)^{n-3-D} \binom{D}{a}\binom{D-a}{c} 3^{-D}.\]
Parameters:
  • n (int) – Number of nodes, n >= 4.

  • a (int) – Degrees minus one.

  • c (int) – Degrees minus one.

Return type:

Fraction

Examples

>>> sum(distance_two_pair_degrees(6, a, c) for a in range(5) for c in range(5))
Fraction(1, 1)
tinto.theory.cayley.mean(n, k=1)[source]#

Mean stabilization time on the uniform labeled tree with n nodes, k colors.

The degree of a fixed node is 1 + Binomial(n - 2, 1/n); averaging rho() over it gives \(\mathbb E S / n\). Monochrome, \(\mathbb E T = n - n(1 - 1/n)^{n-1}\).

Parameters:
  • n (int) – Number of nodes.

  • k (int, default=1) – Number of colors.

Return type:

float

Examples

>>> round(mean(200), 6)
126.239634

A single node never moves:

>>> mean(1)
0.0
tinto.theory.cayley.pair_degrees(n, i, j)[source]#

Joint law of the degrees of two distinct nodes of the uniform labeled tree.

\[P(d_u = i, d_v = j) = \binom{n-2}{i-1}\binom{n-i-1}{j-1} n^{2-i-j} \left(1 - \frac2n\right)^{n-i-j}.\]
Parameters:
  • n (int) – Number of nodes, n >= 3.

  • i (int) – Degrees, at least 1.

  • j (int) – Degrees, at least 1.

Return type:

Fraction

Examples

>>> sum(pair_degrees(5, i, j) for i in range(1, 5) for j in range(1, 5))
Fraction(1, 1)
tinto.theory.cayley.pair_distances(n)[source]#

Probabilities that two distinct nodes of the uniform labeled tree are adjacent, or at distance two.

Parameters:

n (int) – Number of nodes.

Returns:

(2/n, 3(n-2)/n^2).

Return type:

tuple of Fraction

Examples

>>> pair_distances(5)
(Fraction(2, 5), Fraction(9, 25))
tinto.theory.cayley.pgf(n, k, v)[source]#

Probability generating function of the number of peaks on the uniform labeled tree, k >= 2 colors.

Percolating the monochrome edges and Lagrange inversion give

\[\mathbb E\, v^{S_n} = \frac{n!}{(k-1) k^{n-1} n^n} [z^n] \exp\big((k-1) n F(z, v)\big), \quad F = C\big(z e^{(v-1) z}\big) + (v-1) z,\]

with C the Cayley tree function. The coefficient is computed by power series arithmetic in z, at a numeric v.

Parameters:
  • n (int) – Number of nodes.

  • k (int) – Number of colors, at least 2.

  • v (float) – Point of evaluation.

Return type:

float

Examples

>>> round(pgf(10, 3, 1.0), 12)
1.0
tinto.theory.cayley.slope(k=1)[source]#

Asymptotic slope of the variance on the uniform labeled tree.

\[\lim_{n \to \infty} \frac{\mathrm{Var}\, T_n}{n} = e^{-1/k} - \left(1 + \frac{1}{k^2}\right) e^{-2/k}.\]
Parameters:

k (int, default=1) – Number of colors.

Return type:

float

Examples

>>> round(slope(), 6)
0.097209
tinto.theory.cayley.variance(n, k=1)[source]#

Variance of the stabilization time on the uniform labeled tree with n nodes, k colors.

Monochrome, the closed form \(n(n-1)(1-2/n)^{n-1} + m - m^2\) with \(m = n(1-1/n)^{n-1}\). With k >= 2 colors, the double integrals over the labels of a pair of nodes, split by their distance (adjacent, at distance two, further) through the pair-degree laws of the Cayley tree. The kink of min(s, t) is integrated on the two triangles separately.

Parameters:
  • n (int) – Number of nodes, n >= 4 when k >= 2.

  • k (int, default=1) – Number of colors.

Return type:

float

Examples

>>> round(variance(200), 6)
19.422343
>>> round(variance(200, 3), 6)
29.174695