/* Copyright (c) 2003-2015 Tommi Junttila Released under the GNU Lesser General Public License version 3.
This file is part of bliss.
bliss is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 3 of the License.
bliss is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with bliss. If not, see <http://www.gnu.org/licenses/>.
*/
/** \internal * \brief A class for refinable, backtrackable ordered partitions. * * This is rather a data structure with some helper functions than * a proper self-contained class. * That is, for efficiency reasons the fields of this class are directly * manipulated from bliss::AbstractGraph and its subclasses. * Conversely, some methods of this class modify the fields of * bliss::AbstractGraph, too.
*/ class Partition
{ public: /** * \brief Data structure for holding information about a cell in a Partition.
*/ class Cell
{ friendclass Partition; public: unsignedint length; /* Index of the first element of the cell in
the Partition::elements array */ unsignedint first; unsignedint max_ival; unsignedint max_ival_count; private: bool in_splitting_queue; public: bool in_neighbour_heap; /* Pointer to the next cell, null if this is the last one. */
Cell* next;
Cell* prev;
Cell* next_nonsingleton;
Cell* prev_nonsingleton; unsignedint split_level; /** Is this a unit cell? */ bool is_unit() const {return(length == 1); } /** Is this cell in splitting queue? */ bool is_in_splitting_queue() const {return(in_splitting_queue); }
};
private:
/** \internal * Data structure for remembering information about splits in order to * perform efficient backtracking over the splits.
*/ class RefInfo { public: unsignedint split_cell_first; int prev_nonsingleton_first; int next_nonsingleton_first;
}; /** \internal * A stack for remembering the splits, used for backtracking.
*/
KStack<RefInfo> refinement_stack;
class BacktrackInfo { public: unsignedint refinement_stack_size; unsignedint cr_backtrack_point;
};
/** \internal * The main stack for enabling backtracking.
*/
std::vector<BacktrackInfo> bt_stack;
public:
AbstractGraph* graph;
/* Used during equitable partition refinement */
KQueue<Cell*> splitting_queue; void splitting_queue_add(Cell* const cell);
Cell* splitting_queue_pop(); bool splitting_queue_is_empty() const; void splitting_queue_clear();
/** Type for backtracking points. */ typedefunsignedint BacktrackPoint;
/** * Get a new backtrack point for the current partition
*/
BacktrackPoint set_backtrack_point();
/** * Backtrack to the point \a p and remove it.
*/ void goto_backtrack_point(BacktrackPoint p);
/** * Split the non-unit Cell \a cell = {\a element,e1,e2,...,en} containing * the element \a element in two: * \a cell = {e1,...,en} and \a newcell = {\a element}. * @param cell a non-unit Cell * @param element an element in \a cell * @return the new unit Cell \a newcell
*/
Cell* individualize(Cell* const cell, constunsignedint element);
typedef std::vector<unsignedint>::iterator uint_pointer_substitute; typedef std::vector<unsignedint>::const_iterator
uint_pointer_to_const_substitute;
std::vector<unsignedint> elements_vec;
uint_pointer_substitute elements; /* invariant_values[e] gives the invariant value of the element e */
std::vector<unsignedint> invariant_values_vec;
uint_pointer_substitute invariant_values; /* element_to_cell_map[e] gives the cell of the element e */
std::vector<Cell*> element_to_cell_map_vec;
cell_pointer_pointer_substitute element_to_cell_map; /** Get the cell of the element \a e */
Cell* get_cell(constunsignedint e) const { return element_to_cell_map_vec[e];
} /* in_pos[e] points to the elements array s.t. *in_pos[e] = e */
std::vector<uint_pointer_substitute> in_pos_vec;
std::vector<uint_pointer_substitute>::iterator in_pos;
Partition();
~Partition();
/** * Initialize the partition to the unit partition (all elements in one cell) * over the \a N > 0 elements {0,...,\a N-1}.
*/ void init(constunsignedint N);
/** * Returns true iff the partition is discrete, meaning that all * the elements are in their own cells.
*/ bool is_discrete() const {return(free_cells == 0); }
/** * Print the partition into the file stream \a fp.
*/
size_t print(FILE* const fp, constbool add_newline = true) const;
/** * Print the partition cell sizes into the file stream \a fp.
*/
size_t print_signature(FILE* const fp, constbool add_newline = true) const;
/* * Splits the Cell \a cell into [cell_1,...,cell_n] * according to the invariant_values of the elements in \a cell. * After splitting, cell_1 == \a cell. * Returns the pointer to the Cell cell_n; * cell_n != cell iff the Cell \a cell was actually splitted. * The flag \a max_ival_info_ok indicates whether the max_ival and * max_ival_count fields of the Cell \a cell have consistent values * when the method is called. * Clears the invariant values of elements in the Cell \a cell as well as * the max_ival and max_ival_count fields of the Cell \a cell.
*/
Cell *zplit_cell(Cell * const cell, constbool max_ival_info_ok);
/* * Some auxiliary stuff needed for distribution count sorting. * To make the code thread-safe (modulo the requirement that each graph is * only accessed in one thread at a time), the arrays are owned by * the partition instance, not statically defined.
*/ unsignedint dcs_count[256]; unsignedint dcs_start[256]; void dcs_cumulate_count(constunsignedint max);
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.