27 # ifndef TPL_INDEXARC_H 28 # define TPL_INDEXARC_H 30 # include <tpl_dynSetTree.H> 31 # include <tpl_graph.H> 33 using namespace Aleph;
64 template <
class ,
class >
class Tree =
Rand_Tree,
71 typedef typename GT::Arc GT_Arc;
72 typedef typename GT::Node GT_Node;
73 typedef typename GT::Arc_Type GT_Arc_Type;
74 typedef typename GT::Node_Type GT_Node_Type;
76 typedef std::pair<void*, void*> Node_Pair;
80 bool operator () (GT_Arc * a1, GT_Arc * a2)
const 82 if (a1->src_node < a2->src_node)
85 return not (a2->src_node < a1->src_node) and a1->tgt_node < a2->tgt_node;
113 GT_Arc ** ret_val = index.
search(&arc);
115 if (ret_val !=
nullptr)
121 std::swap(arc.src_node, arc.tgt_node);
122 ret_val = index.
search(&arc);
124 if (ret_val ==
nullptr)
127 assert(((src == (*ret_val)->src_node) and (tgt == (*ret_val)->tgt_node)) or
128 ((tgt == (*ret_val)->src_node) and (src == (*ret_val)->tgt_node)));
145 GT_Arc ** ret_val = index.
search(&arc);
147 return ret_val !=
nullptr ? *ret_val :
nullptr;
157 return search(a->src_node, a->tgt_node);
172 const GT_Arc_Type & info)
174 GT_Arc * a =
search(src, tgt);
177 throw std::domain_error(
"There is already in arc between these nodes");
179 a = g.insert_arc(src, tgt, info);
187 GT_Arc_Type && info = GT_Arc_Type())
189 GT_Arc * a =
search(src, tgt);
192 throw std::domain_error(
"There is already in arc between these nodes");
194 a = g.insert_arc(src, tgt, std::forward<GT_Arc_Type>(info));
201 void remove(GT_Arc * e)
224 GT_Arc * a = it.get_curr_ne();
248 IndexArc(GT & __g,
bool with_init =
true, SA && __sa = SA())
263 IndexArc(GT & __g,
bool with_init, SA & __sa) : g(__g), sa(__sa)
GT_Arc * search_directed(void *src, void *tgt)
Definition: tpl_indexArc.H:139
Definition: tpl_graph.H:1225
IndexArc(GT &__g, bool with_init, SA &__sa)
Definition: tpl_indexArc.H:263
size_t remove(const Key &key)
Definition: tpl_dynSetTree.H:327
GT_Arc * search(GT_Arc *a)
Definition: tpl_indexArc.H:155
void clear_index()
Elimina todos los arcos del Ãndice.
Definition: tpl_indexArc.H:214
GT_Arc * insert(GT_Arc *e)
Inserta en el Ãndice el arco a.
Definition: tpl_indexArc.H:96
GT_Arc * insert_in_graph(GT_Node *src, GT_Node *tgt, const GT_Arc_Type &info)
Definition: tpl_indexArc.H:171
Definition: tpl_rand_tree.H:676
IndexArc(GT &__g, bool with_init=true, SA &&__sa=SA())
Definition: tpl_indexArc.H:248
GT_Arc * insert_in_graph(GT_Node *src, GT_Node *tgt, GT_Arc_Type &&info=GT_Arc_Type())
Definition: tpl_indexArc.H:186
Definition: tpl_graph.H:1063
void remove_from_graph(GT_Arc *a)
Elimina del Ãndice y del grafo el arco a.
Definition: tpl_indexArc.H:207
const size_t & size() const
Retorna la cardinalidad del conjunto.
Definition: tpl_dynSetTree.H:502
Definition: tpl_indexArc.H:67
size_t size() const
Retorna la cantidad de arcos que contiene el Ãndice.
Definition: tpl_indexArc.H:270
GT_Arc * search(void *src, void *tgt)
Definition: tpl_indexArc.H:107
void empty()
Elimina todos los elementos del conjunto.
Definition: tpl_dynSetTree.H:133
void build_index()
Inserta todos los arcos del grafo en el Ãndice.
Definition: tpl_indexArc.H:220
Key * search(const Key &key) const
Definition: tpl_dynSetTree.H:462