32 # include <tpl_graph.H> 33 # include <tpl_dynSetTree.H> 35 using namespace Aleph;
76 template <
typename Node_Info = Empty_Class>
98 noexcept(std::is_nothrow_copy_constructible<Node_Info>::value) :
Base(info)
104 noexcept(std::is_nothrow_move_constructible<Node_Info>::value)
111 noexcept(std::is_nothrow_copy_constructible<Node_Info>::value)
118 noexcept(std::is_nothrow_copy_assignable<Node_Info>::value)
122 this->node_info = node.node_info;
142 noexcept(std::is_nothrow_copy_assignable<Node_Info>::value)
185 template <
typename Arc_Info = Empty_Class>
193 noexcept(std::is_nothrow_copy_constructible<Arc_Info>::value)
200 noexcept(std::is_nothrow_move_constructible<Arc_Info>::value)
207 noexcept(std::is_nothrow_copy_constructible<Arc_Info>::value)
214 noexcept(std::is_nothrow_copy_assignable<Arc_Info>::value)
218 this->arc_info = arc.arc_info;
222 Graph_Sarc(
void * src,
void * tgt,
const Arc_Info & data)
223 noexcept(std::is_nothrow_copy_constructible<Arc_Info>::value)
224 :
Base(src, tgt, data)
229 Graph_Sarc(
void * src,
void * tgt, Arc_Info && data)
230 noexcept(std::is_nothrow_move_constructible<Arc_Info>::value)
231 :
Base(src, tgt, move(data))
266 template <
typename __Graph_Node = Graph_Snode<
unsigned long>,
267 typename __Graph_Arc = Graph_Sarc<
unsigned long>>
269 :
public GraphCommon<List_SGraph<__Graph_Node, __Graph_Arc>,
270 __Graph_Node, __Graph_Arc>
274 using Node = __Graph_Node;
275 using Arc = __Graph_Arc;
277 using Arc_Type =
typename Arc::Arc_Type;
279 friend class GraphCommon<List_SGraph<__Graph_Node, __Graph_Arc>,
280 __Graph_Node, __Graph_Arc>;
283 __Graph_Node, __Graph_Arc>;
286 using CommonBase::insert_node;
287 using CommonBase::insert_arc;
299 List_SGraph() noexcept { }
301 virtual ~List_SGraph()
306 List_SGraph(
const List_SGraph & g)
311 void swap(List_SGraph & g) noexcept
313 this->common_swap(g);
314 node_list.
swap(g.node_list);
315 arc_list.
swap(g.arc_list);
318 List_SGraph(List_SGraph && g) noexcept
323 List_SGraph & operator = (
const List_SGraph & g)
330 copy_graph(*
this, const_cast<List_SGraph&>(g));
335 List_SGraph & operator = (List_SGraph && g) noexcept
361 : DynSetNode::Iterator(g.node_list)
369 return this->get_curr();
372 Node * get_current_node_ne()
const noexcept
374 return this->get_curr_ne();
392 using Item_Type = Arc *;
419 Arc * get_current_arc_ne()
const noexcept
421 return get_curr_ne();
424 Arc * get_current_arc()
const 432 Arc * a = get_curr_ne();
433 return (Node*) a->get_connected_node(src_node);
439 Arc * a = get_curr();
440 return (Node*) a->get_connected_node(src_node);
464 : DynSetArc::Iterator(_g.arc_list)
472 return this->get_curr_ne();
478 return (Node*) get_current_arc_ne()->src_node;
484 return (Node*) get_current_arc_ne()->tgt_node;
490 return this->get_curr();
494 Node *
get_src_node()
const {
return (Node*) get_current_arc()->src_node; }
497 Node *
get_tgt_node()
const {
return (Node*) get_current_arc()->tgt_node; }
519 assert(p->arc_list.is_empty());
528 Arc * insert_arc(Node * src, Node * tgt,
void * a)
530 Arc * arc = (Arc*) a;
535 src->arc_list.append(a);
537 if (not this->digraph and src != tgt)
539 tgt->arc_list.append(a);
543 arc_list.append(arc);
549 void disconnect_arc(Arc * arc)
551 Node * src = (Node*) arc->src_node;
552 Node * tgt = (Node*) arc->tgt_node;
554 src->arc_list.remove_ne([arc] (
auto a) {
return a == arc; });
557 if (not this->digraph and src != tgt)
559 tgt->arc_list.remove_ne([arc] (
auto a) {
return a == arc; });
584 virtual void remove_node(Node * p) noexcept
587 arc_list.
for_each([
this, &arcs_to_remove, p] (
auto arc)
589 if (this->get_src_node(arc) == p or this->get_tgt_node(arc) == p)
591 this->disconnect_arc(arc);
593 arcs_to_remove.
append(arc);
597 arcs_to_remove.
for_each([
this] (
auto a)
608 Node * get_first_node()
const 613 Arc * get_first_arc()
const 618 Arc * get_first_arc(Node * p)
const 620 return (Arc*) p->arc_list.get_first();
625 void clear() noexcept
627 arc_list.
for_each( [] (Arc * p) {
delete p; } );
628 node_list.
for_each( [] (Node * p) {
delete p; } );
636 Cmp_Arc(Cmp && __cmp = Cmp())
637 noexcept(std::is_nothrow_constructible<Cmp>::value and
638 std::is_nothrow_move_assignable<Cmp>::value)
642 noexcept(std::is_nothrow_constructible<Cmp>::value)
647 Arc * arc1 = (Arc*) s1;
648 Arc * arc2 = (Arc*) s2;
649 return cmp(arc1, arc2);
655 template <
class Compare>
656 void sort_arcs(Compare & cmp) noexcept
658 Cmp_Arc<Compare> comp(cmp);
659 mergesort<HTList, Cmp_Arc<Compare>>(arc_list, comp);
662 template <
class Compare>
663 void sort_arcs(Compare && cmp = Compare()) noexcept
665 mergesort<Cmp_Arc<Compare>>(arc_list, Cmp_Arc<Compare>(cmp));
686 template <
typename __Graph_Node = Graph_Snode<
int>,
687 typename __Graph_Arc = Graph_Sarc<
int>>
694 using Node = __Graph_Node;
696 using Arc = __Graph_Arc;
700 this->digraph =
true;
705 this->digraph =
true;
714 this->digraph =
true;
723 this->digraph =
true;
729 this->digraph =
true;
Node_Info & get_info() noexcept
Return a modifiable reference to the data contained in the node.
Definition: graph-dry.H:242
Node * get_src_node() const
Retorna el nodo origen del arco actual (sólo cuenta si es digrafo)
Definition: tpl_sgraph.H:494
Node * get_tgt_node() const
Retorna el nodo destino del arco actual (sólo cuenta si es digrafo)
Definition: tpl_sgraph.H:497
Definition: tpl_sgraph.H:77
Node * get_tgt_node() const
Retorna el nodo destino del arco actual.
Definition: tpl_sgraph.H:437
Graph_Snode(const Node_Info &info) noexcept(std::is_nothrow_copy_constructible< Node_Info >::value)
Definition: tpl_sgraph.H:97
Graph_Snode(Graph_Snode *node) noexcept(std::is_nothrow_copy_assignable< Node_Info >::value)
Definition: tpl_sgraph.H:141
Definition: tpl_sgraph.H:688
size_t remove(const Key &key)
Definition: tpl_dynSetTree.H:327
Node * get_tgt_node_ne() const noexcept
Retorna el nodo destino del arco actual.
Definition: tpl_sgraph.H:430
Node_Arc_Iterator() noexcept
Instancia un iterador vacÃo (inválido).
Definition: tpl_sgraph.H:398
T & get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Definition: htlist.H:1639
virtual void remove_arc(Arc *arc) noexcept
Definition: tpl_sgraph.H:576
void for_each(Operation &operation) noexcept(noexcept(operation))
Definition: htlist.H:589
Node_Arc_Iterator(Node *src) noexcept
Instancia un iterador sobre el nodo _src_node.
Definition: tpl_sgraph.H:401
void copy_graph(GT >gt, const GT &gsrc, const bool cookie_map=false)
Definition: tpl_graph.H:3482
Definition: graph-dry.H:272
void swap(DynSetTree &dset)
Definition: tpl_dynSetTree.H:96
Definition: graph-dry.H:329
size_t num_arcs
data associated to the node. Access it with get_info()
Definition: graph-dry.H:227
Node * get_src_node_ne() const noexcept
Retorna el nodo origen del arco actual (sólo cuenta si es digrafo)
Definition: tpl_sgraph.H:476
Definition: graph-dry.H:206
const Key & get_first() const
Definition: tpl_dynSetTree.H:483
NodeInfo Node_Type
The node.
Definition: graph-dry.H:233
Node * get_current_node() const
retorna el nodo actual.
Definition: tpl_sgraph.H:367
Arc * get_curr_ne() const noexcept
Return get_current_arc() without exception.
Definition: tpl_sgraph.H:408
Node * Item_Type
Tipo de elemento que retorna get_curr()
Definition: tpl_sgraph.H:353
Arc * get_curr() const
Return get_current_arc()
Definition: tpl_sgraph.H:414
virtual Node * insert_node(Node *p)
Definition: tpl_sgraph.H:517
T & get_curr() const
Definition: htlist.H:1649
Node * get_tgt_node_ne() const noexcept
Retorna el nodo destino del arco actual (sólo cuenta si es digrafo)
Definition: tpl_sgraph.H:482
Definition: tpl_sgraph.H:348
Arc * Item_Type
Tipo de elemento que retorna get_curr()
Definition: tpl_sgraph.H:456
Definition: htlist.H:1622
T & append(const T &item)
Definition: htlist.H:1471
Arc * get_current_arc() const
Retorna un puntero al arco actual.
Definition: tpl_sgraph.H:488
Arc * get_current_arc_ne() const noexcept
Retorna un puntero al arco actual.
Definition: tpl_sgraph.H:470
Definition: tpl_sgraph.H:268
Definition: tpl_sgraph.H:451
Definition: tpl_sgraph.H:385
Definition: tpl_sgraph.H:186