2 # ifndef TPL_FIND_PATH_H
3 # define TPL_FIND_PATH_H
5 # include <tpl_graph_utils.H>
32 template <
class GT,
class SA = Dft_Show_Arc<GT> >
36 typename GT::Node * end;
39 bool find_path(
typename GT::Node * curr,
typename GT::Arc * arc)
57 typename GT::Arc * next_arc = i.get_current_arc();
61 ARC_BITS(next_arc).set_bit(Find_Path,
true);
62 typename GT::Node * next_node = i.get_tgt_node();
63 if (find_path(next_node, next_arc))
65 I(path->get_last_node() == end);
71 path->remove_last_node();
76 bool find_path(GT & g,
typename GT::Node * start,
77 typename GT::Node * end_node,
Path<GT> & p)
80 throw std::invalid_argument(
"Path does not belong to graph");
88 g.reset_bit_nodes(Find_Path);
89 g.reset_bit_arcs(Find_Path);
91 NODE_BITS(start).set_bit(Find_Path,
true);
96 typename GT::Arc * arc = i.get_current_arc();
97 ARC_BITS(arc).set_bit(Find_Path,
true);
99 typename GT::Node * next_node = i.get_tgt_node();
103 if (find_path(next_node, arc))
127 typename GT::Node * end_node,
Path<GT> & path)
129 return find_path(g, start_node, end_node, path);
157 template <
class GT,
class SA = Dft_Show_Arc<GT> >
162 bool find_path(GT & g,
typename GT::Node * start,
163 typename GT::Node * end,
Path<GT> & path)
166 throw std::invalid_argument(
"Path does not belong to graph");
175 q.
put(i.get_current_arc());
177 NODE_BITS(start).set_bit(Find_Path,
true);
179 bool path_found =
false;
181 while (not q.is_empty())
183 typename GT::Arc * arc = q.
get();
184 typename GT::Node * src = g.get_src_node(arc);
185 typename GT::Node * tgt = g.get_tgt_node(arc);
193 ARC_BITS(arc).set_bit(Find_Path,
true);
205 typename GT::Arc * a = i.get_current_arc();
223 typename GT::Node * p = end;
250 typename GT::Node * end,
Path<GT> & path)
252 return find_path(g, start, end, path);
259 # endif // TPL_FIND_PATH_H
#define NODE_COOKIE(p)
Definition: aleph-graph.H:248
bool operator()(GT &g, typename GT::Node *start_node, typename GT::Node *end_node, Path< GT > &path)
Definition: tpl_find_path.H:126
void insert(Arc *arc)
Definition: tpl_graph.H:1758
#define IS_NODE_VISITED(p, bit)
Definition: aleph-graph.H:242
bool operator()(GT &g, typename GT::Node *start, typename GT::Node *end, Path< GT > &path)
Definition: tpl_find_path.H:249
Definition: tpl_find_path.H:158
Definition: tpl_dynListQueue.H:22
bool inside_graph(GT &gr) const
retorna true si el camino this refiere al grafo gr
Definition: tpl_graph.H:1562
#define IS_ARC_VISITED(p, bit)
Definition: aleph-graph.H:275
Definition: tpl_graph.H:26
Definition: tpl_find_path.H:33
void next()
Adelanta el iterador una posición.
Definition: filter_iterator.H:143
#define NODE_BITS(p)
Definition: aleph-graph.H:221
void clear_path()
Limpia el camino (se eliminan todos sus nodos y arcos).
Definition: tpl_graph.H:1620
#define ARC_BITS(p)
Definition: aleph-graph.H:266
T get()
Definition: tpl_dynListQueue.H:107
Definition: tpl_graph.H:694
T & put(const T &data)
Definition: tpl_dynListQueue.H:86