1 # ifndef GRAPH_TO_TREE_H
2 # define GRAPH_TO_TREE_H
4 # include <tpl_tree_node.H>
5 # include <tpl_graph.H>
6 # include <tpl_graph_utils.H>
10 template <
class GT,
typename Key,
class Convert>
static
12 template <
class GT,
typename Key,
class Convert>
static void
13 __graph_to_tree_node(GT & g,
typename GT::Node * groot,
16 template <
class GT,
typename Key,
typename Convert,
class SA>
static inline
17 void __graph_to_tree_node(GT & g,
typename GT::Node * groot,
89 template <
class GT,
typename Key,
93 if (not is_graph_acyclique<GT>(g))
94 throw std::domain_error(
"Graph is not a tree (not acyclique)");
98 Convert () (groot, troot);
100 __graph_to_tree_node <GT, Key, Convert, SA> (g, groot, troot);
167 template <
class GT,
typename Key,
175 void graph_to_tree(
typename GT::Node * groot,
178 typedef typename GT::Node Node;
179 typedef typename GT::Arc Arc;
184 Arc * arc = it.get_current_arc();
188 ARC_BITS(arc).set_bit(Convert_Tree,
true);
189 Node * gtgt = it.get_tgt_node();
192 (*convert) (gtgt, ttgt);
196 graph_to_tree(gtgt, ttgt);
201 typename GT::Node * groot,
204 if (not is_graph_acyclique<GT>(g))
205 throw std::domain_error(
"Graph is not a tree (not acyclique)");
211 (*convert) (groot, troot);
213 graph_to_tree(groot, troot);
236 operator () (GT & g,
typename GT::Node * groot, Convert && conv = Convert())
238 return graph_to_tree(g, groot, conv);
242 operator () (GT & g,
typename GT::Node * groot, Convert & conv)
244 return graph_to_tree(g, groot, conv);
249 template <
class GT,
typename Key,
typename Convert,
class SA>
static inline
250 void __graph_to_tree_node(GT & g,
typename GT::Node * groot,
253 typedef typename GT::Node Node;
254 typedef typename GT::Arc Arc;
259 Arc * arc = it.get_current_arc();
263 ARC_BITS(arc).set_bit(Convert_Tree,
true);
264 Node * gtgt = it.get_tgt_node();
267 Convert () (gtgt, ttgt);
271 __graph_to_tree_node <GT, Key, Convert, SA> (g, gtgt, ttgt);
277 # endif // GRAPH_TO_TREE_H
Tree_Node< Key > * graph_to_tree_node(GT &g, typename GT::Node *groot)
Definition: graph_to_tree.H:91
Tree_Node< Key > * operator()(GT &g, typename GT::Node *groot, Convert &&conv=Convert())
Definition: graph_to_tree.H:236
void insert_rightmost_child(Tree_Node *p)
Definition: tpl_tree_node.H:327
Definition: tpl_tree_node.H:35
Definition: graph_to_tree.H:170
#define IS_ARC_VISITED(p, bit)
Definition: aleph-graph.H:275
Definition: tpl_graph.H:634
void next()
Adelanta el iterador una posición.
Definition: filter_iterator.H:143
#define ARC_BITS(p)
Definition: aleph-graph.H:266
Definition: tpl_graph.H:694