tutte_polynomial

tutte_polynomial#

graph_tool.structure.tutte_polynomial(g)[git][source]#

Return the Tutte polynomial of a graph.

Parameters:
gGraph

Graph to be used. Edge directions are ignored.

Returns:
Tnumpy.ndarray

Two-dimensional array of the coefficients, where T[i, j] is the coefficient of \(x^iy^j\).

See also

chromatic_polynomial

Specialization that counts proper colorings

graph_tool.spectral.num_spanning_trees

Number of spanning trees

Notes

The Tutte polynomial [tutte-contribution-1954] is

\[T_G(x, y) = \sum_{A\subseteq E}(x-1)^{k(A)-k(E)}(y-1)^{k(A)+|A|-|V|},\]

where \(k(A)\) is the number of connected components of the spanning subgraph with edges \(A\). Many invariants are evaluations of it: \(T_G(1,1)\) is the number of spanning trees (of a connected graph), \(T_G(2,1)\) the number of spanning forests, \(T_G(2,0)\) the number of acyclic orientations, and the chromatic polynomial (see chromatic_polynomial()) is \(T_G(1-k, 0)\) up to a factor.

The polynomial is computed by deletion and contraction, \(T_G = T_{G-e} + T_{G/e}\), applied to whole classes of parallel edges at once, with the product over the blocks (biconnected components) of the graph taken at every step, and with a cache of the blocks already computed, keyed by their canonical forms (computed with bliss for blocks with ten or more classes of parallel edges), so that isomorphic minors are computed once, as in [haggard-computing-2010]. The edges are removed along a breadth-first front of the vertices (numbered from a vertex of minimum degree), which keeps the number of distinct minors small. The time is exponential in the number of edges in the worst case, which makes the computation feasible only for graphs with a few tens of edges in the blocks (e.g. the Tutte polynomial of a \(6\times 6\) grid, with 60 edges, takes under one second); trees and other graphs with small blocks are fast.

References

[tutte-contribution-1954]

William T. Tutte, “A contribution to the theory of chromatic polynomials”, Canadian Journal of Mathematics 6, 80-91 (1954), DOI: 10.4153/CJM-1954-010-9 [sci-hub, @tor]

[haggard-computing-2010]

Gary Haggard, David J. Pearce and Gordon Royle, “Computing Tutte polynomials”, ACM Transactions on Mathematical Software 37, 24 (2010), DOI: 10.1145/1824801.1824802 [sci-hub, @tor]

Examples

>>> g = gt.complete_graph(4)
>>> T = gt.tutte_polynomial(g)
>>> print(T)
[[0 2 3 1]
 [2 4 0 0]
 [3 0 0 0]
 [1 0 0 0]]
>>> print(T.sum())    # T(1, 1), the number of spanning trees
16