29 #ifndef CMAPPEDDIRGRAPH_HPP_
30 #define CMAPPEDDIRGRAPH_HPP_
32 #include <sutil/CMappedTree.hpp>
67 template <
typename TIdx,
typename TNode>
89 template <
typename TIdx,
typename TNode>
103 gr_parent_names_.clear();
104 gr_parent_addrs_.clear();
105 gr_child_addrs_.clear();
118 template <
typename TIdx,
typename TNode>
127 TNode& tmp_node = *it;
130 tmp_node.gr_parent_addrs_.
clear();
131 tmp_node.gr_child_addrs_.clear();
138 TNode& tmp_node = *it;
147 typename std::vector<TIdx>::iterator itp,itpe;
148 for(itp = tmp_node.gr_parent_names_.begin(), itpe = tmp_node.gr_parent_names_.end();
152 if(tmp_node2add == NULL)
155 std::cerr<<
"\nCBranchingStructure::linkNodes(): Warning.";
156 std::cerr<<
"Orphan node found: "<<*itp<<
". Ignoring.";
161 tmp_node.gr_parent_addrs_.push_back(tmp_node2add);
162 tmp_node2add->child_addrs_.push_back(&tmp_node);
165 std::cerr<<
"\n\tAdding child "<<tmp_node.name_
166 <<
" to (parent) "<<tmp_node2add->name_;
167 std::cerr<<std::flush;
174 bool flag = genSpanningTree();
178 st_broken_edges_.
clear();
182 TNode &tmp_node = *it;
183 typename std::vector<TIdx>::iterator itp,itpe;
184 for(itp = tmp_node.gr_parent_names_.begin(), itpe = tmp_node.gr_parent_names_.end();
189 if(test_parent != tmp_node.parent_addr_)
191 std::pair<TNode*, TNode*> tmp_broken_edge;
192 tmp_broken_edge.first = test_parent;
193 tmp_broken_edge.second = &tmp_node;
194 st_broken_edges_.push_back(tmp_broken_edge);
209 template <
typename TIdx,
typename TNode>
220 struct SSTreeStruct{
bool in_stree_; TNode* node_; };
221 SSTreeStruct *in_stree =
new SSTreeStruct[graph_sz];
231 in_stree[i].node_ = &(*it);
233 { in_stree[i].in_stree_ =
true; }
235 { in_stree[i].in_stree_ =
false; }
239 bool complete =
false;
240 int nodes_in_stree_pre = 1, nodes_in_stree_curr = 1;
241 while(
false == complete)
244 for(
int i=0; i<graph_sz; ++i)
246 if(in_stree[i].in_stree_){
continue; }
249 typename std::vector<TIdx>::iterator itp, itpe;
250 for(itp = in_stree[i].node_->gr_parent_names_.begin(),itpe = in_stree[i].node_->gr_parent_names_.end();
258 if(in_stree[pnidx].in_stree_)
260 in_stree[i].node_->parent_name_ = in_stree[pnidx].node_->name_;
261 in_stree[i].in_stree_ =
true;
262 nodes_in_stree_curr++;
270 for(
int i=0; complete && i<graph_sz; ++i)
271 { complete = (complete && in_stree[i].in_stree_); }
273 if(
false == complete && nodes_in_stree_curr == nodes_in_stree_pre)
276 { nodes_in_stree_pre = nodes_in_stree_curr; }
Definition: CMappedTree.hpp:155
virtual bool clear()
Definition: CMappedList.hpp:1127
Definition: CMappedList.hpp:85
virtual bool genSpanningTree()
Definition: CMappedDirGraph.hpp:210
std::vector< TIdx > gr_parent_names_
Definition: CMappedDirGraph.hpp:94
virtual bool linkNodes()
Definition: CMappedTree.hpp:316
virtual T * at(const std::size_t arg_idx)
Definition: CMappedList.hpp:832
std::vector< TNode * > gr_child_addrs_
Definition: CMappedDirGraph.hpp:98
Definition: CMappedDirGraph.hpp:90
std::vector< std::pair< TNode *, TNode * > > st_broken_edges_
Definition: CMappedDirGraph.hpp:73
Definition: CMappedDirGraph.hpp:68
Definition: CMappedTree.hpp:66
std::vector< TNode * > gr_parent_addrs_
Definition: CMappedDirGraph.hpp:96
virtual TNode * getRootNode()
Definition: CMappedTree.hpp:132
virtual bool linkNodes()
Definition: CMappedDirGraph.hpp:119
virtual std::size_t size() const
Definition: CMappedList.hpp:240
virtual int getIndexNumericAt(const Idx &arg_idx) const
Definition: CMappedList.hpp:910
SMGNodeBase()
Definition: CMappedDirGraph.hpp:101