No public endorsements yet.
Loading review…
Sign in with ORCIDConcept map
Definition
A tree decomposition of a finite simple graph consists of a finite tree and a bag of graph vertices at every tree node. Every graph vertex occurs in a bag, the endpoints of every graph edge occur together in a bag, and the tree nodes whose bags contain any fixed graph vertex induce a connected subtree.
The width of a decomposition is its largest bag cardinality minus one, using natural-number subtraction. The treewidth of a graph is the least width of any of its tree decompositions. The natural-number convention gives the empty graph treewidth zero.
Lean source view on GitHub
| 1 | import Mathlib.Combinatorics.SimpleGraph.Acyclic |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Treewidth |
| 6 | type: definition |
| 7 | --- |
| 8 | A tree decomposition of a finite simple graph consists of a finite tree and |
| 9 | a bag of graph vertices at every tree node. Every graph vertex occurs in a |
| 10 | bag, the endpoints of every graph edge occur together in a bag, and the tree |
| 11 | nodes whose bags contain any fixed graph vertex induce a connected subtree. |
| 12 | |
| 13 | The width of a decomposition is its largest bag cardinality minus one, using |
| 14 | natural-number subtraction. The treewidth of a graph is the least width of |
| 15 | any of its tree decompositions. The natural-number convention gives the empty |
| 16 | graph treewidth zero. |
| 17 | -/ |
| 18 | |
| 19 | namespace Lax17.Treewidth |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | /-- A finite tree decomposition of a simple graph. -/ |
| 24 | structure TreeDecomposition {V : Type u} [DecidableEq V] |
| 25 | (G : SimpleGraph V) where |
| 26 | /-- The node type of the decomposition tree. -/ |
| 27 | Node : Type |
| 28 | /-- The decomposition tree has finitely many nodes. -/ |
| 29 | [nodeFintype : Fintype Node] |
| 30 | /-- Decomposition-tree nodes have decidable equality. -/ |
| 31 | [nodeDecidableEq : DecidableEq Node] |
| 32 | /-- The tree on decomposition nodes. -/ |
| 33 | tree : SimpleGraph Node |
| 34 | /-- The node graph is a tree. -/ |
| 35 | isTree : tree.IsTree |
| 36 | /-- The bag assigned to each decomposition node. -/ |
| 37 | bag : Node → Finset V |
| 38 | /-- Every graph vertex occurs in a bag. -/ |
| 39 | vertex_mem_bag : ∀ v : V, ∃ i : Node, v ∈ bag i |
| 40 | /-- The endpoints of every graph edge occur together in a bag. -/ |
| 41 | edge_mem_bag : |
| 42 | ∀ ⦃x y : V⦄, G.Adj x y → ∃ i : Node, x ∈ bag i ∧ y ∈ bag i |
| 43 | /-- Bags containing a fixed graph vertex induce a connected subtree. -/ |
| 44 | bag_indices_connected : |
| 45 | ∀ v : V, (tree.induce {i : Node | v ∈ bag i}).Connected |
| 46 | |
| 47 | namespace TreeDecomposition |
| 48 | |
| 49 | /-- The maximum bag cardinality minus one. -/ |
| 50 | noncomputable def width {V : Type u} [DecidableEq V] |
| 51 | {G : SimpleGraph V} (D : TreeDecomposition G) : ℕ := |
| 52 | letI : Fintype D.Node := D.nodeFintype |
| 53 | (Finset.univ.sup fun i : D.Node => (D.bag i).card) - 1 |
| 54 | |
| 55 | end TreeDecomposition |
| 56 | |
| 57 | /-- `G` has a tree decomposition of width at most `k`. -/ |
| 58 | def HasTreewidthAtMost {V : Type u} [Fintype V] [DecidableEq V] |
| 59 | (G : SimpleGraph V) (k : ℕ) : Prop := |
| 60 | ∃ D : TreeDecomposition G, D.width ≤ k |
| 61 | |
| 62 | /-- The least width of a tree decomposition of `G`. |
| 63 | |
| 64 | The fallback makes the definition total. For a finite graph it is unreachable, |
| 65 | because the decomposition with one bag containing every vertex always exists. |
| 66 | -/ |
| 67 | noncomputable def treewidth {V : Type u} [Fintype V] [DecidableEq V] |
| 68 | (G : SimpleGraph V) : ℕ := |
| 69 | letI := Classical.decPred (HasTreewidthAtMost G) |
| 70 | letI := Classical.propDecidable (∃ k, HasTreewidthAtMost G k) |
| 71 | if h : ∃ k, HasTreewidthAtMost G k then Nat.find h else 0 |
| 72 | |
| 73 | end Lax17.Treewidth |
| 74 |
Community review
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.
0 comments