![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Tree decomposition of a Boolean circuit's primal graph. More...
#include "TreeDecomposition.h"
Public Types | |
| template<class T > | |
| using | small_vector = boost::container::static_vector< T, MAX_TREEWIDTH+1 > |
Stack-allocated vector type bounded by MAX_TREEWIDTH+1 elements. | |
| using | Bag = flat_set< gate_t, small_vector > |
| The type of a bag: a small flat set of gate IDs. | |
Public Member Functions | |
| TreeDecomposition (const BooleanCircuit &bc) | |
Compute a tree decomposition of the primal graph of bc. | |
| TreeDecomposition (std::istream &in) | |
| Parse a tree decomposition from a stream (PACE challenge format). | |
| TreeDecomposition (const TreeDecomposition &td) | |
| Copy constructor. | |
| TreeDecomposition & | operator= (const TreeDecomposition &td) |
| Copy assignment. | |
| unsigned | getTreewidth () const |
| Return the treewidth of this decomposition. | |
| void | makeFriendly (gate_t root) |
| Restructure the tree into the friendly normal form. | |
| std::string | toDot () const |
| Render the tree decomposition as a GraphViz DOT string. | |
Static Public Attributes | |
| static constexpr int | MAX_TREEWIDTH = 10 |
| Maximum supported treewidth. | |
| static constexpr int | OPTIMAL_ARITY = 2 |
| Preferred maximum arity of bags in the friendly form. | |
Private Member Functions | |
| TreeDecomposition ()=default | |
| bag_t | findGateConnection (gate_t v) const |
Find the bag whose gate set is closest to gate v (for rooting). | |
| void | reroot (bag_t bag) |
Re-root the tree so that bag becomes the root. | |
| bag_t | addEmptyBag (bag_t parent, const std::vector< bag_t > &children=std::vector< bag_t >()) |
Insert a new empty bag as a child of parent. | |
| void | addGateToBag (gate_t g, bag_t b) |
Add gate g to the contents of bag b. | |
| Bag & | getBag (bag_t b) |
Mutable access to bag b. | |
| const Bag & | getBag (bag_t b) const |
Const access to bag b. | |
| std::vector< bag_t > & | getChildren (bag_t b) |
Mutable access to the children of bag b. | |
| const std::vector< bag_t > & | getChildren (bag_t b) const |
Const access to the children of bag b. | |
| bag_t | getParent (bag_t b) const |
Return the parent of bag b. | |
| void | setParent (bag_t b, bag_t p) |
Set the parent of bag b to p. | |
Private Attributes | |
| std::vector< Bag > | bags |
Bag contents, indexed by bag_t. | |
| std::vector< bag_t > | parent |
| Parent of each bag (root points to itself) | |
| std::vector< std::vector< bag_t > > | children |
| Children of each bag. | |
| bag_t | root |
| Identifier of the root bag. | |
| unsigned | treewidth |
| Treewidth of the decomposition. | |
Friends | |
| class | dDNNFTreeDecompositionBuilder |
| std::istream & | operator>> (std::istream &in, TreeDecomposition &td) |
| Read a tree decomposition in PACE challenge format. | |
Tree decomposition of a Boolean circuit's primal graph.
Provides constructors that compute the decomposition from a BooleanCircuit using the min-fill heuristic, or parse it from an input stream. After construction, makeFriendly() restructures the tree into the "friendly" normal form required by dDNNFTreeDecompositionBuilder.
Definition at line 57 of file TreeDecomposition.h.
| using TreeDecomposition::Bag = flat_set<gate_t, small_vector> |
The type of a bag: a small flat set of gate IDs.
Definition at line 73 of file TreeDecomposition.h.
| using TreeDecomposition::small_vector = boost::container::static_vector<T, MAX_TREEWIDTH+1> |
Stack-allocated vector type bounded by MAX_TREEWIDTH+1 elements.
Used for bag contents to avoid heap allocation for small, bounded sets.
Definition at line 70 of file TreeDecomposition.h.
|
privatedefault |
| TreeDecomposition::TreeDecomposition | ( | const BooleanCircuit & | bc | ) |
Compute a tree decomposition of the primal graph of bc.
Uses the min-fill elimination ordering heuristic. Throws TreeDecompositionException if the computed treewidth exceeds MAX_TREEWIDTH.
| bc | The Boolean circuit to decompose. |
Definition at line 285 of file TreeDecomposition.cpp.

| TreeDecomposition::TreeDecomposition | ( | std::istream & | in | ) |
Parse a tree decomposition from a stream (PACE challenge format).
| in | Input stream containing the decomposition. |
Definition at line 34 of file TreeDecomposition.cpp.
| TreeDecomposition::TreeDecomposition | ( | const TreeDecomposition & | td | ) |
Copy constructor.
| td | Source decomposition. |
|
private |
Insert a new empty bag as a child of parent.
| parent | Parent bag of the new empty bag. |
| children | Children to transfer from parent to the new bag. |
Definition at line 159 of file TreeDecomposition.cpp.


Add gate g to the contents of bag b.
| g | Gate to add. |
| b | Destination bag. |
Definition at line 179 of file TreeDecomposition.cpp.


Find the bag whose gate set is closest to gate v (for rooting).
| v | Gate to search for. |
v. Definition at line 41 of file TreeDecomposition.cpp.


Mutable access to bag b.
| b | Bag identifier. |
Definition at line 114 of file TreeDecomposition.h.

Const access to bag b.
| b | Bag identifier. |
Definition at line 123 of file TreeDecomposition.h.
Mutable access to the children of bag b.
| b | Bag identifier. |
Definition at line 132 of file TreeDecomposition.h.

Const access to the children of bag b.
| b | Bag identifier. |
Definition at line 141 of file TreeDecomposition.h.
Return the parent of bag b.
| b | Bag identifier. |
Definition at line 150 of file TreeDecomposition.h.

|
inline |
Return the treewidth of this decomposition.
Definition at line 196 of file TreeDecomposition.h.

| void TreeDecomposition::makeFriendly | ( | gate_t | root | ) |
Restructure the tree into the friendly normal form.
Reroots the tree at the bag that covers the circuit's root gate and splits/merges bags so that dDNNFTreeDecompositionBuilder can process them efficiently.
| root | The gate that should be covered by the root bag. |
Definition at line 59 of file TreeDecomposition.cpp.

| TreeDecomposition & TreeDecomposition::operator= | ( | const TreeDecomposition & | td | ) |
Copy assignment.
| td | Source decomposition. |
|
private |
Re-root the tree so that bag becomes the root.
| bag | The bag to use as the new root. |
Definition at line 184 of file TreeDecomposition.cpp.


Set the parent of bag b to p.
| b | Bag whose parent is to be set. |
| p | New parent bag. |
Definition at line 159 of file TreeDecomposition.h.

| std::string TreeDecomposition::toDot | ( | ) | const |
Render the tree decomposition as a GraphViz DOT string.
digraph string for visualisation. Definition at line 206 of file TreeDecomposition.cpp.

|
friend |
Definition at line 218 of file TreeDecomposition.h.
|
friend |
Read a tree decomposition in PACE challenge format.
| in | Input stream. |
| td | Tree decomposition to populate. |
in. Definition at line 232 of file TreeDecomposition.cpp.
|
private |
Bag contents, indexed by bag_t.
Definition at line 76 of file TreeDecomposition.h.
|
private |
Children of each bag.
Definition at line 78 of file TreeDecomposition.h.
|
staticconstexpr |
Maximum supported treewidth.
Circuits exceeding this cause an error.
Definition at line 60 of file TreeDecomposition.h.
|
staticconstexpr |
Preferred maximum arity of bags in the friendly form.
Definition at line 62 of file TreeDecomposition.h.
|
private |
Parent of each bag (root points to itself)
Definition at line 77 of file TreeDecomposition.h.
|
private |
Identifier of the root bag.
Definition at line 79 of file TreeDecomposition.h.
|
private |
Treewidth of the decomposition.
Definition at line 80 of file TreeDecomposition.h.