30 #ifndef OR_TOOLS_ALGORITHMS_DYNAMIC_PARTITION_H_ 31 #define OR_TOOLS_ALGORITHMS_DYNAMIC_PARTITION_H_ 62 const int NumParts()
const {
return part_.size(); }
73 int PartOf(
int element)
const;
109 void Refine(
const std::vector<int>& distinguished_subset);
145 std::vector<int> element_;
148 std::vector<int> index_of_;
151 std::vector<int> part_of_;
168 Part() : start_index(0), end_index(0), parent_part(0), fprint(0) {}
169 Part(
int start_index,
int end_index,
int parent_part, uint64_t fprint)
170 : start_index(start_index),
171 end_index(end_index),
172 parent_part(parent_part),
175 std::vector<Part> part_;
180 std::vector<int> tmp_counter_of_part_;
181 std::vector<int> tmp_affected_parts_;
186 std::vector<int>::const_iterator
end()
const {
return end_; }
188 std::vector<int>::const_iterator
end_;
194 const std::vector<int>::const_iterator& e)
209 void Reset(
int num_nodes);
266 void SetParentAlongPathToRoot(
int node,
int parent);
268 std::vector<int> parent_;
269 std::vector<int> part_size_;
272 std::vector<bool> tmp_part_bit_;
281 return IterablePart(element_.begin() + part_[i].start_index,
282 element_.begin() + part_[i].end_index);
288 return part_of_[element];
294 const Part& p = part_[part];
295 return p.end_index - p.start_index;
301 return part_[part].parent_part;
312 return part_[part].fprint;
320 const int parent = parent_[child];
321 if (parent == child)
return child;
326 inline void MergingPartition::SetParentAlongPathToRoot(
int node,
int parent) {
333 const int old_parent = parent_[child];
334 parent_[child] = parent;
335 if (old_parent == child)
return;
343 parent_[node] = node;
344 part_size_[node] = 1;
349 #endif // OR_TOOLS_ALGORITHMS_DYNAMIC_PARTITION_H_ int ParentOfPart(int part) const
IterablePart(const std::vector< int >::const_iterator &b, const std::vector< int >::const_iterator &e)
void Refine(const std::vector< int > &distinguished_subset)
const int NumParts() const
const std::vector< int > & ElementsInHierarchicalOrder() const
int GetRootAndCompressPath(int node)
void Reset(int num_nodes)
int PartOf(int element) const
int GetRoot(int node) const
std::vector< int >::const_iterator begin() const
std::vector< int >::const_iterator end() const
IterablePart ElementsInPart(int i) const
std::vector< int >::const_iterator begin_
#define DCHECK_GE(val1, val2)
int SizeOfPart(int part) const
std::string DebugString()
void UndoRefineUntilNumPartsEqual(int original_num_parts)
IterablePart ElementsInSamePartAs(int i) const
DynamicPartition(int num_elements)
std::string DebugString(DebugStringSorting sorting) const
uint64_t FprintOfPart(int part) const
std::vector< int >::const_iterator const_iterator
int FillEquivalenceClasses(std::vector< int > *node_equivalence_classes)
std::vector< int >::const_iterator end_
Collection of objects used to extend the Constraint Solver library.
MergingPartition(int num_nodes)
int NumNodesInSamePartAs(int node)
void KeepOnlyOneNodePerPart(std::vector< int > *nodes)
int MergePartsOf(int node1, int node2)
#define DCHECK_LT(val1, val2)