Documentation

CslibFrontier.Computability.Complexity.Problems.UGraph

The adjacency-matrix encoding of undirected graphs #

An undirected graph instance (Cslib.Complexity.UGraphInstance) is a simple graph on Fin n, given by a symmetric adjacency matrix with zero diagonal. It is encoded (Cslib.Complexity.encUGraph) as its digraph (Cslib.Complexity.encDigraph): the unary header 1^n 0 followed by the adjacency matrix row by row, so that the bit at n + 1 + (a * n + b) is the entry of the row a and the column b.

Main definitions #

Main results #

The digraph of an instance, with an arc in each direction for every edge.

The encoding of an instance, that of its digraph (Cslib.Complexity.encDigraph): the unary header 1^n 0, then the adjacency matrix row by row.

The length of the encoding: the header and the n ^ 2 entries of the matrix.

The header, read by position: the bit at i ≤ n is set exactly when i < n.

theorem Cslib.Complexity.UGraphInstance.getElem?_encode_matrix (G : UGraphInstance) {a b : ℕ} (ha : a < G.n) (hb : b < G.n) :
G.encode[G.n + 1 + (a * G.n + b)]? = some (G.adj ⟨a, ha⟩ ⟨b, hb⟩)

The entries of the matrix, read by position: the bit at n + 1 + (a * n + b) is the entry of the row a and the column b.

The encoding of undirected graphs: the unary header 1^n 0, then the adjacency matrix row by row.