6 # include <tpl_graph.H>
7 # include <tpl_dynSetTree.H>
50 template <
typename Node_Info = Empty_Class>
85 Graph_Snode(
const Node_Info & info) : node_info(info), num_arcs(0)
147 template <
typename Arc_Info = Empty_Class>
160 : arc_info(info), src_node(NULL), tgt_node(NULL)
165 Graph_Sarc(
void * src,
void * tgt,
const Arc_Info & data)
166 : arc_info(data), src_node(src), tgt_node(tgt)
171 Graph_Sarc(
void * src,
void * tgt) : src_node(src), tgt_node(tgt)
206 template <
typename __Graph_Node = Graph_Snode<
int>,
207 typename __Graph_Arc = Graph_Sarc<
int>>
248 return this->get_curr();
276 :
DynList<void*>::Iterator(src->arc_list), src_node(src)
297 return (Node*) a->get_connected_node(src_node);
328 return this->get_curr();
338 GRAPH_ITERATIVE_METHODS;
340 GRAPH_SEARCH_METHODS;
361 I(p->arc_list.is_empty());
371 Arc * insert_arc(Node * src, Node * tgt,
void * a)
373 Arc * arc = (Arc*) a;
378 src->arc_list.append(a);
380 if (not digraph and src != tgt)
382 tgt->arc_list.append(a);
386 arc_list.append(arc);
420 void disconnect_arc(Arc * arc)
422 Node * src = (Node*) arc->src_node;
423 Node * tgt = (Node*) arc->tgt_node;
425 src->arc_list.remove(arc);
428 if (not digraph and src != tgt)
430 tgt->arc_list.remove(arc);
455 virtual void remove_node(Node * p)
457 for (
typename DynSetArc::Iterator it(arc_list); it.has_curr(); )
459 Arc * arc = (Arc*) it.get_curr();
461 if (get_src_node(arc) == p or get_tgt_node(arc) == p)
477 Node * get_first_node()
const
482 Arc * get_first_arc()
const
487 Arc * get_first_arc(Node * p)
const
489 return (Arc*) p->arc_list.get_first();
501 arc_list.for_each( [] (
const Arc * p) {
delete p; } );
502 node_list.for_each( [] (
const Node * p) {
delete p; } );
516 inter_copy_graph<GT, List_SGraph>(*
this, g,
false);
522 node_list.
swap(g.node_list);
523 arc_list.
swap(g.arc_list);
539 copy_graph(*
this, const_cast<List_SGraph&>(g));
558 Cmp_Arc(Cmp && __cmp = Cmp()) : cmp(__cmp) { }
560 Cmp_Arc(Cmp & __cmp) : cmp(__cmp) { }
564 Arc * arc1 = (Arc*) s1;
565 Arc * arc2 = (Arc*) s2;
566 return cmp(arc1, arc2);
572 template <
class Compare>
573 void sort_arcs(Compare & cmp)
575 Cmp_Arc<Compare> comp(cmp);
576 mergesort<HTList, Cmp_Arc<Compare>>(arc_list, comp);
579 template <
class Compare>
580 void sort_arcs(Compare && cmp = Compare())
582 mergesort<Cmp_Arc<Compare>>(arc_list, Cmp_Arc<Compare>(cmp));
605 template <
typename __Graph_Node = Graph_Snode<
int>,
606 typename __Graph_Arc = Graph_Sarc<
int>>
613 typedef __Graph_Node Node;
615 typedef __Graph_Arc Arc;
619 this->digraph =
true;
624 this->digraph =
true;
633 this->digraph =
true;
641 this->digraph =
true;
647 this->digraph =
true;
Node * Set_Type
El tipo de conjunto sobre el cual se itera.
Definition: tpl_sgraph.H:269
Node_Arc_Iterator(Node *src)
Instancia un iterador sobre el nodo _src_node.
Definition: tpl_sgraph.H:275
virtual void remove_arc(Arc *arc)
Definition: tpl_sgraph.H:447
Definition: tpl_sgraph.H:607
Graph_Snode(const Node_Info &info)
Definition: tpl_sgraph.H:85
size_t remove(const Key &key)
Definition: tpl_dynSetTree.H:274
Node * get_tgt_node() const
Retorna el nodo destino del arco actual.
Definition: tpl_sgraph.H:294
Arc * Item_Type
Tipo de elemento que retorna get_current()
Definition: tpl_sgraph.H:313
GRAPH_INSERTION_METHODS
Definition: tpl_sgraph.H:416
Arc * get_current_arc() const
Retorna un puntero al arco actual.
Definition: tpl_sgraph.H:326
Node * get_current_node() const
retorna el nodo actual.
Definition: tpl_sgraph.H:246
Node * get_tgt_node() const
Retorna el nodo destino del arco actual (sólo cuenta si es digrafo)
Definition: tpl_sgraph.H:335
void swap(DynSetTree &dset)
Definition: tpl_dynSetTree.H:65
Node * get_src_node() const
Retorna el nodo origen del arco actual (sólo cuenta si es digrafo)
Definition: tpl_sgraph.H:332
const Key & get_first()
Definition: tpl_dynSetTree.H:386
Graph_Snode(Graph_Snode *node)
Definition: tpl_sgraph.H:105
virtual Node * insert_node(Node *p)
Definition: tpl_sgraph.H:359
Arc * get_current() const
Definition: tpl_sgraph.H:288
Arc * get_current_arc() const
Retorna el arco actual.
Definition: tpl_sgraph.H:282
Definition: tpl_sgraph.H:228
void copy_graph(GT >gt, GT &gsrc, const bool cookie_map=false)
Definition: tpl_graph.H:2505
Arc * Item_Type
El tipo de dato que retorna get_current().
Definition: tpl_sgraph.H:266
Node * Item_Type
Tipo de elemento que retorna get_current()
Definition: tpl_sgraph.H:233
Arc * get_curr() const
Definition: tpl_sgraph.H:291
List_SGraph Set_Type
El tipo de conjunto sobre el cual se itera.
Definition: tpl_sgraph.H:236
Graph_Snode()
Definition: tpl_sgraph.H:68
Definition: tpl_sgraph.H:51
Definition: tpl_sgraph.H:208
Definition: tpl_sgraph.H:308
Definition: tpl_sgraph.H:259
List_SGraph Set_Type
El tipo de conjunto sobre el cual se itera.
Definition: tpl_sgraph.H:316
Definition: tpl_sgraph.H:148
Node_Arc_Iterator()
Instancia un iterador vacío (inválido).
Definition: tpl_sgraph.H:272