12 template <
typename Type>
15 template <
typename Type>
18 template <
typename Type>
20 nodes_.resize(nbElmt_);
23 template <
typename Type>
27 template <
typename Type>
43 template <
typename Type>
46 std::stringstream res;
48 for(
const auto &node : nodes_) {
49 if(1 or node.parent_) {
50 res <<
"id: " << &node - &nodes_[0];
52 res <<
", parent: " << node.parent_ - &nodes_[0];
56 res <<
" root: " << findRoot(&node) - &nodes_[0];
57 res <<
" weight: " << (float)node.weight_;
58 res <<
" cArc: " << node.corArc_;
65 template <
typename Type>
67 const std::function<std::string(std::size_t)> &printFunction) {
69 std::stringstream res;
71 for(
const auto &node : nodes_) {
73 res <<
"id: " << printFunction(&node - &nodes_[0])
74 <<
" weight: " << (float)node.weight_;
76 res <<
", parent: " << printFunction(node.parent_ - &nodes_[0]);
80 res <<
" root: " << printFunction(findRoot(&node) - &nodes_[0]);
86 template <
typename Type>
89 std::stringstream res;
90 std::vector<DynGraphNode<Type> *> roots;
91 roots.reserve(nodes_.size());
92 for(
const auto &n : nodes_) {
93 roots.emplace_back(n.findRoot());
95 std::sort(roots.begin(), roots.end());
96 const auto it = std::unique(roots.begin(), roots.end());
97 roots.erase(it, roots.end());
98 res <<
"nb nodes " << nodes_.size() << std::endl;
99 res <<
"nb cc " << roots.size() << std::endl;
105 template <
typename Type>
113 Type parentWeight = curNode->
weight_;
116 Type gParentWeight = parentNode->
weight_;
123 parentNode->
weight_ = parentWeight;
125 curNode = parentNode;
126 parentNode = gParentNode;
127 parentWeight = gParentWeight;
130 gParentWeight = gParentNode->
weight_;
131 gParentNode = gParentNode->
parent_;
141 template <
typename Type>
149#ifdef TTK_ENABLE_OPENMP
150#pragma omp atomic read
157 template <
typename Type>
159 const auto root = findRoot();
160 return root !=
nullptr ? root->corArc_ : -1;
163 template <
typename Type>
168 template <
typename Type>
173 auto minW = minNode->weight_;
177 return std::make_tuple(curNode, minNode);
182 minW = minNode->weight_;
186 return std::make_tuple(curNode, minNode);
189 template <
typename Type>
196 if(std::get<0>(nNodes) !=
this) {
206 if(weight > std::get<1>(nNodes)->weight_) {
216 std::get<1>(nNodes)->
parent_ =
nullptr;
217 std::get<1>(nNodes)->
corArc_ = corArc;
225 template <
typename Type>
227#ifndef TTK_ENABLE_KAMIKAZE
231 dbg.printErr(
"DynGraph remove edge in root node");
Minimalist debugging class.
void setDebugMsgPrefix(const std::string &prefix)
void removeEdge(DynGraphNode< Type > *const n)
remove the link btwn n and its parent
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
class representing a node of a tree and the link to its parent if not the root
void evert()
Make this node the root of its tree.
DynGraphNode * findRoot() const
Get representative node.
std::tuple< DynGraphNode< Type > *, DynGraphNode< Type > * > findMinWeightRoot() const
bool insertEdge(DynGraphNode *const n, const Type weight, const idSuperArc corArc)
void setRootArc(const idSuperArc arcId)
idSuperArc findRootArc() const