Regina 7.3 Calculation Engine
|
Represents a single bag in a tree decomposition. More...
#include <treewidth/treedecomposition.h>
Public Member Functions | |
~TreeBag () | |
Destroys this bag. More... | |
size_t | size () const |
Returns the number of graph nodes stored in this bag. More... | |
size_t | element (size_t which) const |
Used to query the individual graph nodes stored in this bag. More... | |
bool | contains (size_t element) const |
Queries whether a given graph node is contained in this bag. More... | |
size_t | index () const |
Returns the index of this bag within the full tree decomposition. More... | |
int | type () const |
Returns auxiliary information associated with bags in special classes of tree decompositions. More... | |
ssize_t | subtype () const |
Returns a secondary level of auxiliary information associated with bags in special classes of tree decompositions. More... | |
BagComparison | compare (const TreeBag &rhs) const |
Determines if there is a subset/superset relationship between this and the given bag. More... | |
const TreeBag * | next () const |
Used for a postfix iteration through all of the bags in a tree decomposition. More... | |
const TreeBag * | nextPrefix () const |
Used for a prefix iteration through all of the bags in a tree decomposition. More... | |
const TreeBag * | parent () const |
Returns the parent of this bag in the underlying rooted tree. More... | |
const TreeBag * | children () const |
Returns the first child of this bag in the underlying rooted tree. More... | |
const TreeBag * | sibling () const |
Returns the next sibling of this bag in the underlying rooted tree. More... | |
bool | isLeaf () const |
Determines if this is a leaf bag. More... | |
void | writeTextShort (std::ostream &out) const |
Writes a short text representation of this object to the given output stream. More... | |
TreeBag & | operator= (const TreeBag &)=delete |
void | writeTextLong (std::ostream &out) const |
A default implementation for detailed output. More... | |
std::string | str () const |
Returns a short text representation of this object. More... | |
std::string | utf8 () const |
Returns a short text representation of this object using unicode characters. More... | |
std::string | detail () const |
Returns a detailed text representation of this object. More... | |
Friends | |
class | TreeDecomposition |
Represents a single bag in a tree decomposition.
The class TreeDecomposition is used to build, manipulate and iterate over tree decompositions of graphs. A tree decomposition of a graph G consists of (i) an underlying tree T; and (ii) a bag at every node of this tree. Each bag is a set of zero or more nodes of G, and these bags are subject to various constraints as described in the TreeDecomposition class notes.
In Regina, the underlying tree T is a rooted tree, so that every non-root bag has exactly one parent bag, and every bag has some number of children (possibly many, possibly zero).
This class TreeBag represents a single bag in a tree decomposition.
To build a tree decomposition of a graph, see the various TreeDecomposition class constructors.
Note that a bag may be empty (indeed, if you call TreeDecomposition::makeNice() then it is guaranteed that the root bag will be empty).
Tree bags do not support value semantics: they cannot be copied, swapped, or manually constructed. Their location in memory defines them, and they are often passed and compared by pointer. End users are never responsible for their memory management; this is all taken care of by the TreeDecomposition to which they belong.
|
inline |
Destroys this bag.
|
inline |
Returns the first child of this bag in the underlying rooted tree.
If a bag has no children, then children() will be null
. If a bag has many children, then these will be children()
, children()->sibling()
, children()->sibling()->sibling()
, and so on.
null
if this is a leaf bag (i.e., it has no children). BagComparison regina::TreeBag::compare | ( | const TreeBag & | rhs | ) | const |
Determines if there is a subset/superset relationship between this and the given bag.
Recall that, in a tree decomposition of a graph G, each bag is a set of nodes of G. This function will return one of the following constants:
rhs | the bag to compare with this. |
bool regina::TreeBag::contains | ( | size_t | element | ) | const |
Queries whether a given graph node is contained in this bag.
Suppose this is a bag in a tree decomposition of some graph G, whose nodes are numbered 0,1,2,.... Then contains(x)
queries whether the node numbered x is contained in this bag.
element | the number of some node in the graph G. |
true
if and only if the given node is in this bag.
|
inherited |
Returns a detailed text representation of this object.
This text may span many lines, and should provide the user with all the information they could want. It should be human-readable, should not contain extremely long lines (which cause problems for users reading the output in a terminal), and should end with a final newline. There are no restrictions on the underlying character set.
|
inline |
Used to query the individual graph nodes stored in this bag.
Suppose this is a bag in a tree decomposition of some graph G, whose nodes are numbered 0,1,2,.... Then element(i)
returns the number of the ith node stored in this bag.
Nodes are always stored in ascending order. This means that element(0) < element(1) < element(2) < ...
.
which | indicates which node should be returned; this must be between 0 and size()-1 inclusive. |
|
inline |
Returns the index of this bag within the full tree decomposition.
Suppose the entire tree decomposition contains n bags. Then these bags are automatically numbered 0,1,...,n-1. This member function returns the number of this particular bag.
The numbering of bags follows a leaves-to-root, left-to-right scheme:
b.index() < b.parent()->index()
;b.index() < b.sibling()->index()
;d.size()-1
inclusive.
|
inline |
Determines if this is a leaf bag.
A leaf bag is a bag with no children in the underlying tree.
This is equivalent to testing whether children() is null
.
true
if and only if this is a leaf bag. const TreeBag * regina::TreeBag::next | ( | ) | const |
Used for a postfix iteration through all of the bags in a tree decomposition.
Amongst other things, a postfix iteration is one in which all of the children of any bag b will be processed before b itself.
If d is a non-empty tree decomposition, then you can complete a full postfix iteration of bags as follows:
d.first()
;b.next()
;b.next()
is null
.This iteration processes the children of each bag in order; that is, it processes each bag b before b.sibling()
(if the latter exists).
The bags in a tree decomposition are indexed as 0,1,2,..., as described by the index() member function. This postfix iteration is equivalent to iterating through bags 0,1,2,... in order.
null
if this is the final bag in such an iteration (i.e., the root bag). const TreeBag * regina::TreeBag::nextPrefix | ( | ) | const |
Used for a prefix iteration through all of the bags in a tree decomposition.
Amongst other things, a prefix iteration is one in which each bag will be processed before any of its children.
If d is a non-empty tree decomposition, then you can complete a full prefix iteration of bags as follows:
d.firstPrefix()
(or equivalently, d.root()
);b.nextPrefix()
;b.nextPrefix()
is null
.This iteration processes the children of each bag in order; that is, it processes each bag b before b.sibling()
(if the latter exists).
null
if this is the final bag in such an iteration.
|
inline |
Returns the parent of this bag in the underlying rooted tree.
null
if this bag is at the root of the tree.
|
inline |
Returns the next sibling of this bag in the underlying rooted tree.
Specifically, if the parent of this bag has many children, then sibling() will return the next child after this.
More generally, all of the children of a bag b can be accessed as b.children()
, b.children()->sibling()
, b.children()->sibling()->sibling()
, and so on.
null
if either (i) this is the final child of the parent bag, or (ii) this is the root bag.
|
inline |
Returns the number of graph nodes stored in this bag.
Suppose this is a bag in a tree decomposition of some graph G. Then each bag is a subset of the nodes of G, and this function simply returns the size of this subset.
|
inherited |
Returns a short text representation of this object.
This text should be human-readable, should use plain ASCII characters where possible, and should not contain any newlines.
Within these limits, this short text ouptut should be as information-rich as possible, since in most cases this forms the basis for the Python __str__()
and __repr__()
functions.
__str__()
will use precisely this function, and for most classes the Python __repr__()
function will incorporate this into its output.
|
inline |
Returns a secondary level of auxiliary information associated with bags in special classes of tree decompositions.
If the underlying tree decomposition is of a special type, then each bag may be adorned with some additional information indicating the particular role that the bag plays. This additional information can be accessed through the member functions type() and subtype().
At present, types and subtypes are only stored for nice tree decompositions. See TreeDecomposition::makeNice() for details on what type() and subtype() represent.
|
inline |
Returns auxiliary information associated with bags in special classes of tree decompositions.
If the underlying tree decomposition is of a special type, then each bag may be adorned with some additional information indicating the particular role that the bag plays. This additional information can be accessed through the member functions type() and subtype().
At present, types and subtypes are only stored for nice tree decompositions. See TreeDecomposition::makeNice() for details on what type() and subtype() represent.
|
inherited |
Returns a short text representation of this object using unicode characters.
Like str(), this text should be human-readable, should not contain any newlines, and (within these constraints) should be as information-rich as is reasonable.
Unlike str(), this function may use unicode characters to make the output more pleasant to read. The string that is returned will be encoded in UTF-8.
|
inlineinherited |
A default implementation for detailed output.
This routine simply calls T::writeTextShort() and appends a final newline.
out | the output stream to which to write. |
void regina::TreeBag::writeTextShort | ( | std::ostream & | out | ) | const |
Writes a short text representation of this object to the given output stream.
out | the output stream to which to write. |