Represents a tree decomposition of a graph.
A valid tree decomposition satisfies three properties:
- Vertex coverage: The union of all bags equals all vertices of the graph.
- Edge coverage: For each edge
(u, v), some bag contains bothuandv. - Running intersection: For each vertex
v, the bags containingvform a connected subtree.
The width of a tree decomposition is max(|bag|) - 1. The treewidth of a graph
is the minimum width over all valid tree decompositions.
Examples
iex> td = %Yog.Property.TreeDecomposition{
...> bags: %{0 => MapSet.new([1, 2]), 1 => MapSet.new([2, 3])},
...> tree: Yog.undirected() |> Yog.add_edge_ensure(0, 1, 1),
...> width: 1
...> }
iex> is_struct(td, Yog.Property.TreeDecomposition)
true
Summary
Types
A bag is a set of vertices from the original graph.
A tree decomposition struct containing bags, a tree graph connecting bag indices, and the decomposition width.
Functions
Validates that a tree decomposition satisfies all three properties.
Types
@type bag() :: MapSet.t(Yog.node_id())
A bag is a set of vertices from the original graph.
@type t() :: %Yog.Property.TreeDecomposition{ bags: %{required(non_neg_integer()) => bag()}, tree: Yog.Graph.t(), width: non_neg_integer() }
A tree decomposition struct containing bags, a tree graph connecting bag indices, and the decomposition width.