35 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
38 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
41 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
44 friend class Graph<NodeInfo, ArcInfo, GraphInfo>;
50 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
53 friend class Digraph<NodeInfo, ArcInfo, GraphInfo>;
59 template <
class Node,
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
62 friend class Graph<NodeInfo, ArcInfo, GraphInfo>;
72 template <
class Node,
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
75 friend class Digraph<NodeInfo, ArcInfo, GraphInfo>;
84 template <
class GT,
class Node,
class Arc,
85 typename NodeInfoType,
typename ArcInfoType>
90 return *
static_cast<GT *
>(
this);
93 const GT & const_me()
const 95 return *
static_cast<const GT *
>(
this);
99 static void copy_graph(
const GT &, GT &);
103 return nth_it(me().nodes_begin(), me().nodes_end(), i);
108 return nth_it(const_me().nodes_begin(), const_me().nodes_end(), i);
114 for_each_it(const_me().nodes_begin(), const_me().nodes_end(), op);
120 for_each_it(const_me().nodes_begin(), const_me().nodes_end(),
121 std::forward<Op>(op));
124 template <
class ContainerRet = SLList<Node *>,
class Pred>
127 return filter_it(const_me().nodes_begin(), const_me().nodes_end(), pred);
130 template <
class ContainerRet = SLList<Node *>,
class Pred>
133 return filter_it(const_me().nodes_begin(), const_me().nodes_end(),
134 std::forward<Pred>(pred));
137 template <
typename RetT = NodeInfoType,
141 return map_it<ContainerRet>(const_me().nodes_begin(),
142 const_me().nodes_end(), op);
145 template <
typename RetT = NodeInfoType,
149 return map_it<ContainerRet>(const_me().nodes_begin(),
150 const_me().nodes_end(), std::forward<Op>(op));
153 template <
typename RetT = NodeInfoType,
155 class Op,
class Pred>
158 return map_if_it<ContainerRet>(const_me().nodes_begin(),
159 const_me().nodes_end(),
163 template <
typename RetT = NodeInfoType,
165 class Op,
class Pred>
168 return map_if_it<ContainerRet>(const_me().nodes_begin(),
169 const_me().nodes_end(),
170 op, std::forward<Pred>(pred));
173 template <
typename RetT = NodeInfoType,
175 class Op,
class Pred>
178 return map_if_it<ContainerRet>(const_me().nodes_begin(),
179 const_me().nodes_end(),
180 std::forward<Op>(op), pred);
183 template <
typename RetT = NodeInfoType,
185 class Op,
class Pred>
186 ContainerRet
map_nodes_if(Op && op = Op(), Pred && pred = Pred())
const 188 return map_if_it<ContainerRet>(const_me().nodes_begin(),
189 const_me().nodes_end(),
190 std::forward<Op>(op),
191 std::forward<Pred>(pred));
194 template <
typename RetT,
class Op>
197 return fold_it<RetT>(const_me().nodes_begin(), const_me().nodes_end(),
201 template <
typename RetT,
class Op>
202 RetT
fold_nodes(
const RetT & init_val, Op && op = Op())
const 204 return fold_it<RetT>(const_me().nodes_begin(), const_me().nodes_end(),
205 init_val, std::forward<Op>(op));
208 template <
typename RetT,
class Op>
211 return fold_it<RetT>(const_me().nodes_begin(), const_me().nodes_end(),
212 std::forward<RetT>(init_val), op);
215 template <
typename RetT,
class Op>
218 return fold_it<RetT>(const_me().nodes_begin(), const_me().nodes_end(),
219 std::forward<RetT>(init_val),
220 std::forward<Op>(op));
223 template <
class Pred>
226 return all_it(const_me().nodes_begin(), const_me().nodes_end(), pred);
229 template <
class Pred>
232 return all_it(const_me().nodes_begin(), const_me().nodes_end(),
233 std::forward<Pred>(pred));
236 template <
class Pred>
239 return exists_it(const_me().nodes_begin(), const_me().nodes_end(), pred);
242 template <
class Pred>
245 return exists_it(const_me().nodes_begin(), const_me().nodes_end(),
246 std::forward<Pred>(pred));
249 template <
class Pred>
252 return none_it(const_me().nodes_begin(), const_me().nodes_end(), pred);
255 template <
class Pred>
258 return none_it(const_me().nodes_begin(), const_me().nodes_end(),
259 std::forward<Pred>(pred));
262 template <
class Pred>
265 for (
auto it = const_me().nodes_begin();
266 it != const_me().nodes_end(); ++it)
272 template <
class Pred>
275 return search_node<Pred>(pred);
278 template <
class Pred>
284 template <
class Pred>
288 std::forward<Pred>(pred));
291 template <
class Pred>
294 remove_if_it(me().nodes_begin(), me().nodes_end(), pred);
297 template <
class Pred>
301 std::forward<Pred>(pred));
306 return to_list_it<Node *>(const_me().nodes_begin(),
307 const_me().nodes_end());
312 return nth_it(me().arcs_begin(), me().arcs_end(), i);
317 return nth_it(const_me().arcs_begin(), const_me().arcs_end(), i);
323 for_each_it(const_me().arcs_begin(), const_me().arcs_end(), op);
329 for_each_it(const_me().arcs_begin(), const_me().arcs_end(),
330 std::forward<Op>(op));
333 template <
class ContainerRet = SLList<Arc *>,
class Pred>
336 return filter_it(const_me().arcs_begin(), const_me().arcs_end(), pred);
339 template <
class ContainerRet = SLList<Arc *>,
class Pred>
342 return filter_it(const_me().arcs_begin(), const_me().arcs_end(),
343 std::forward<Pred>(pred));
346 template <
typename RetT = ArcInfoType,
350 return map_it<ContainerRet>(const_me().arcs_begin(),
351 const_me().arcs_end(), op);
354 template <
typename RetT = ArcInfoType,
358 return map_it<ContainerRet>(const_me().arcs_begin(),
359 const_me().arcs_end(), std::forward<Op>(op));
362 template <
typename RetT = ArcInfoType,
364 class Op,
class Pred>
367 return map_if_it<ContainerRet>(const_me().arcs_begin(),
368 const_me().arcs_end(),
372 template <
typename RetT = ArcInfoType,
374 class Op,
class Pred>
377 return map_if_it<ContainerRet>(const_me().arcs_begin(),
378 const_me().arcs_end(),
379 op, std::forward<Pred>(pred));
382 template <
typename RetT = ArcInfoType,
384 class Op,
class Pred>
387 return map_if_it<ContainerRet>(const_me().arcs_begin(),
388 const_me().arcs_end(),
389 std::forward<Op>(op), pred);
392 template <
typename RetT = ArcInfoType,
394 class Op,
class Pred>
395 ContainerRet
map_arcs_if(Op && op = Op(), Pred && pred = Pred())
const 397 return map_if_it<ContainerRet>(const_me().arcs_begin(),
398 const_me().arcs_end(),
399 std::forward<Op>(op),
400 std::forward<Pred>(pred));
403 template <
typename RetT,
class Op>
406 return fold_it<RetT>(const_me().arcs_begin(), const_me().arcs_end(),
410 template <
typename RetT,
class Op>
411 RetT
fold_arcs(
const RetT & init_val, Op && op = Op())
const 413 return fold_it<RetT>(const_me().arcs_begin(), const_me().arcs_end(),
414 init_val, std::forward<Op>(op));
417 template <
typename RetT,
class Op>
420 return fold_it<RetT>(const_me().arcs_begin(), const_me().arcs_end(),
421 std::forward<RetT>(init_val), op);
424 template <
typename RetT,
class Op>
427 return fold_it<RetT>(const_me().arcs_begin(), const_me().arcs_end(),
428 std::forward<RetT>(init_val),
429 std::forward<Op>(op));
432 template <
class Pred>
435 return all_it(const_me().arcs_begin(), const_me().arcs_end(), pred);
438 template <
class Pred>
441 return all_it(const_me().arcs_begin(), const_me().arcs_end(),
442 std::forward<Pred>(pred));
445 template <
class Pred>
448 return exists_it(const_me().arcs_begin(), const_me().arcs_end(), pred);
451 template <
class Pred>
454 return exists_it(const_me().arcs_begin(), const_me().arcs_end(),
455 std::forward<Pred>(pred));
458 template <
class Pred>
461 return none_it(const_me().arcs_begin(), const_me().arcs_end(), pred);
464 template <
class Pred>
467 return none_it(const_me().arcs_begin(), const_me().arcs_end(),
468 std::forward<Pred>(pred));
471 template <
class Pred>
474 for (
auto it = const_me().arcs_begin();
475 it != const_me().arcs_end(); ++it)
481 template <
class Pred>
484 return search_arc<Pred>(pred);
487 template <
class Pred>
493 template <
class Pred>
497 std::forward<Pred>(pred));
500 template <
class Pred>
506 template <
class Pred>
509 remove_if_it(me().arcs_begin(), me().arcs_end(), std::forward<Pred>(pred));
514 return to_list_it<Arc *>(const_me().arcs_begin(), const_me().arcs_end());
519 return nth_it(me().arcs_begin(p), me().arcs_end(p), i);
524 return nth_it(const_me().arcs_begin(p), const_me().arcs_end(p), i);
530 for_each_it(const_me().arcs_begin(p), const_me().arcs_end(p), op);
536 for_each_it(const_me().arcs_begin(p), const_me().arcs_end(p),
537 std::forward<Op>(op));
540 template <
class ContainerRet = SLList<Arc *>,
class Pred>
543 return filter_it(const_me().arcs_begin(p), const_me().arcs_end(p), pred);
546 template <
class ContainerRet = SLList<ArcInfoType>,
class Pred>
549 return filter_it(const_me().arcs_begin(p), const_me().arcs_end(p),
550 std::forward<Pred>(pred));
553 template <
typename RetT = ArcInfoType,
557 return map_it<ContainerRet>(const_me().arcs_begin(p),
558 const_me().arcs_end(p), op);
561 template <
typename RetT = ArcInfoType,
565 return map_it<ContainerRet>(const_me().arcs_begin(p),
566 const_me().arcs_end(p),
567 std::forward<Op>(op));
570 template <
typename RetT = ArcInfoType,
572 class Op,
class Pred>
575 return map_if_it<ContainerRet>(const_me().arcs_begin(p),
576 const_me().arcs_end(p),
580 template <
typename RetT = ArcInfoType,
582 class Op,
class Pred>
586 return map_if_it<ContainerRet>(const_me().arcs_begin(p),
587 const_me().arcs_end(p),
588 op, std::forward<Pred>(pred));
591 template <
typename RetT = ArcInfoType,
593 class Op,
class Pred>
596 return map_if_it<ContainerRet>(const_me().arcs_begin(p),
597 const_me().arcs_end(p),
598 std::forward<Op>(op), pred);
601 template <
typename RetT = ArcInfoType,
603 class Op,
class Pred>
607 return map_if_it<ContainerRet>(const_me().arcs_begin(p),
608 const_me().arcs_end(p),
609 std::forward<Op>(op),
610 std::forward<Pred>(pred));
613 template <
typename RetT,
class Op>
616 return fold_it<RetT>(const_me().arcs_begin(p), const_me().arcs_end(p),
620 template <
typename RetT,
class Op>
623 return fold_it<RetT>(const_me().arcs_begin(p), const_me().arcs_end(p),
624 init_val, std::forward<Op>(op));
627 template <
typename RetT,
class Op>
630 return fold_it<RetT>(const_me().arcs_begin(p), const_me().arcs_end(p),
631 std::forward<RetT>(init_val), op);
634 template <
typename RetT,
class Op>
637 return fold_it<RetT>(const_me().arcs_begin(p), const_me().arcs_end(p),
638 std::forward<RetT>(init_val),
639 std::forward<Op>(op));
642 template <
class Pred>
645 return all_it(const_me().arcs_begin(p), const_me().arcs_end(p), pred);
648 template <
class Pred>
651 return all_it(const_me().arcs_begin(p), const_me().arcs_end(p),
652 std::forward<Pred>(pred));
655 template <
class Pred>
658 return exists_it(const_me().arcs_begin(p), const_me().arcs_end(p), pred);
661 template <
class Pred>
664 return exists_it(const_me().arcs_begin(p), const_me().arcs_end(p),
665 std::forward<Pred>(pred));
668 template <
class Pred>
671 return none_it(const_me().arcs_begin(p), const_me().arcs_end(p), pred);
674 template <
class Pred>
677 return none_it(const_me().arcs_begin(p), const_me().arcs_end(p),
678 std::forward<Pred>(pred));
681 template <
class Pred>
684 for (
auto it = const_me().arcs_begin(p);
685 it != const_me().arcs_end(p); ++it)
691 template <
class Pred>
694 return search_adjacent_arc<Pred>(p, pred);
697 template <
class Pred>
703 template <
class Pred>
707 std::forward<Pred>(pred));
710 template <
class Pred>
713 remove_if_it(me().arcs_begin(p), me().arcs_end(p), pred);
716 template <
class Pred>
720 std::forward<Pred>(pred));
725 return to_list_it<Arc *>(const_me().arcs_begin(p), const_me().arcs_end(p));
730 for_each_node([&tag](Node * node)
738 for_each_node([](Node * node)
746 for_each_arc([&tag](Arc * arc)
754 for_each_arc([](Arc * arc)
762 reset_all_node_tag(tag);
763 reset_all_arc_tag(tag);
768 reset_all_node_tag();
774 for_each_node([](Node * node)
776 node->cookie() =
nullptr;
782 for_each_arc([](Arc * arc)
784 arc->cookie() =
nullptr;
790 for_each_node([](Node * node)
798 for_each_arc([](Arc * arc)
806 reset_node_counter();
812 reset_node_cookies();
818 for_each_node([](Node * node)
826 for_each_arc([](Arc * arc)
833 template <
typename GT,
class Node,
class Arc,
834 typename NodeInfoType,
typename ArcInfoType>
840 for (
auto it = src.nodes_begin(); it != src.nodes_end(); ++it)
842 Node * p = it.get_current();
843 Node * q = tgt.insert_node(p->get_info());
847 for (
auto it = src.arcs_begin(); it != src.arcs_end(); ++it)
849 Arc * a = it.get_current();
850 Node * ssrc = a->get_src_node();
851 Node * stgt = a->get_tgt_node();
852 Node * tsrc = map_nodes[ssrc];
853 Node * ttgt = map_nodes[stgt];
854 tgt.insert_arc(tsrc, ttgt, a->get_info());
858 template <
typename NodeInfo,
861 class Graph :
public BaseGraph<Graph<NodeInfo, ArcInfo, GraphInfo>,
862 GraphNode<NodeInfo, ArcInfo, GraphInfo>,
864 GraphNode<NodeInfo, ArcInfo, GraphInfo>,
865 NodeInfo, ArcInfo, GraphInfo>,
871 GraphNode<NodeInfo, ArcInfo, GraphInfo>,
872 NodeInfo, ArcInfo, GraphInfo>,
876 using NodeInfoType = NodeInfo;
881 using Node = GraphNode<NodeInfo, ArcInfo, GraphInfo>;
891 return static_cast<GNode *
>(ptr);
896 return static_cast<GArc *
>(ptr);
901 return static_cast<GAdArc *
>(ptr);
906 GNode * node_zero = 0;
909 return (
GNode *) (node_address - off_set);
917 return (
GArc *) (arc_address - off_set);
939 arc->
get_item().arc_in_src_node = arc_in_src_node;
944 arc->
get_item().arc_in_tgt_node = arc_in_src_node;
948 arc->
get_item().arc_in_tgt_node = arc_in_tgt_node;
960 Node * src_node = arc->
get_item().src_node;
963 arc_in_src_node->
del();
965 delete arc_in_src_node;
967 Node * tgt_node = arc->
get_item().tgt_node;
969 if (src_node != tgt_node)
972 arc_in_tgt_node->
del();
974 delete arc_in_tgt_node;
982 void remove_node(
GNode *);
986 : info(), num_nodes(0), node_list(), num_arcs(0), arc_list()
992 : info(_info), num_nodes(0), num_arcs(0)
998 : info(std::move(_info)), num_nodes(0), num_arcs(0)
1004 : info(g.info), num_nodes(0), num_arcs(0)
1006 Base::copy_graph(g, *
this);
1026 Base::copy_graph(g, *
this);
1040 std::swap(info, g.
info);
1062 throw std::underflow_error(
"Graph has not nodes");
1064 return &dl_to_node(node_list.
get_next())->get_item();
1070 throw std::underflow_error(
"Graph has not nodes");
1072 return &dl_to_node(const_cast<DL &>(node_list).get_next())->get_item();
1078 throw std::underflow_error(
"Graph has not arcs");
1080 return &dl_to_arc(arc_list.
get_next())->get_item();
1086 throw std::underflow_error(
"Graph has not arcs");
1088 return &dl_to_arc(const_cast<DL &>(arc_list).get_next())->get_item();
1115 GNode * node = insert_gnode(
new GNode(
Node(std::forward<NodeInfo>(info))));
1121 GArc * arc = insert_garc(s, t);
1127 Arc * arc = insert_arc(src, tgt);
1134 Arc * arc = insert_arc(src, tgt);
1141 GArc * arc = to_garc(a);
1147 GNode * node = to_gnode(n);
1162 : Base(), graph_ptr(nullptr)
1168 : Base(const_cast<
DL *>(&g.node_list)),
1169 graph_ptr(const_cast<
Graph *>(&g))
1175 : Base(const_cast<
DL *>(&g.node_list), curr),
1176 graph_ptr(const_cast<
Graph *>(&g))
1182 : Base(it), graph_ptr(it.graph_ptr)
1198 (Base &) *
this = it;
1199 graph_ptr = it.graph_ptr;
1212 std::swap(graph_ptr, it.graph_ptr);
1217 return &dl_to_node(Base::get_current())->get_item();
1222 return &dl_to_node(Base::get_current())->get_item();
1227 if (not Base::has_current())
1228 throw std::overflow_error(
"There is not current element");
1230 GNode * p = dl_to_node(Base::get_current());
1247 : Base(), graph_ptr(nullptr)
1253 : Base(const_cast<
DL *>(&g.arc_list)),
1254 graph_ptr(const_cast<
Graph *>(&g))
1260 : Base(const_cast<
DL *>(&g.arc_list), curr),
1261 graph_ptr(const_cast<
Graph *>(&g))
1267 : Base(it), graph_ptr(it.graph_ptr)
1283 (Base &) *
this = it;
1284 graph_ptr = it.graph_ptr;
1297 std::swap(graph_ptr, it.graph_ptr);
1302 return &dl_to_arc(Base::get_current())->get_item();
1307 return &dl_to_arc(Base::get_current())->get_item();
1312 if (not Base::has_current())
1313 throw std::overflow_error(
"There is not current element");
1315 GArc * a = dl_to_arc(Base::get_current());
1334 : Base(), graph_ptr(nullptr), node_ptr(nullptr)
1341 graph_ptr(const_cast<
Graph *>(&g)), node_ptr(n)
1348 graph_ptr(const_cast<
Graph *>(&g)), node_ptr(n)
1354 : Base(it), graph_ptr(it.graph_ptr), node_ptr(it.node_ptr)
1370 (Base &) *
this = it;
1371 graph_ptr = it.graph_ptr;
1372 node_ptr = it.node_ptr;
1385 std::swap(graph_ptr, it.graph_ptr);
1386 std::swap(node_ptr, it.node_ptr);
1391 return &dl_to_adjacent_arc(Base::get_current())->get_item()->get_item();
1396 return &dl_to_adjacent_arc(Base::get_current())->get_item()->get_item();
1411 return get_current()->get_connected_node(node_ptr);
1416 return get_current()->get_connected_node(node_ptr);
1437 return NodeIterator(*
this, const_cast<DL *>(&node_list));
1457 return ArcIterator(*
this, const_cast<DL *>(&arc_list));
1481 Arc * search_arc(Node *, Node *);
1483 template <
class Cmp>
1488 quicksort<Node, C>(*dl_to_node(&node_list), c);
1491 template <
class Cmp>
1494 sort_nodes<Cmp>(cmp);
1497 template <
class Cmp>
1502 quicksort<Arc, C>(*dl_to_arc(&arc_list), c);
1505 template <
class Cmp>
1508 sort_arcs<Cmp>(cmp);
1514 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
1531 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
1541 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
1546 if (it.get_tgt_node() == t)
1550 if (it.get_tgt_node() == s)
1556 template <
typename NodeInfo,
1560 DigraphNode<NodeInfo, ArcInfo, GraphInfo>,
1562 DigraphNode<NodeInfo, ArcInfo, GraphInfo>,
1563 NodeInfo, ArcInfo, GraphInfo>,
1569 DigraphNode<NodeInfo, ArcInfo, GraphInfo>,
1570 NodeInfo, ArcInfo, GraphInfo>,
1574 using NodeInfoType = NodeInfo;
1579 using Node = DigraphNode<NodeInfo, ArcInfo, GraphInfo>;
1589 return static_cast<GNode *
>(ptr);
1594 return static_cast<GArc *
>(ptr);
1599 return static_cast<GAdArc *
>(ptr);
1604 GNode * node_zero = 0;
1607 return (
GNode *) (node_address - off_set);
1615 return (
GAdArc *) (arc_address - off_set);
1635 GArc * arc_in_arc_list =
new GArc(arc);
1637 arc->
get_item().arc_in_arc_list = arc_in_arc_list;
1648 GArc * arc_in_arc_list = arc->
get_item().arc_in_arc_list;
1650 arc_in_arc_list->
del();
1652 delete arc_in_arc_list;
1654 Node * src_node = arc->
get_item().src_node;
1661 void remove_node(
GNode *);
1665 : info(), num_nodes(0), node_list(), num_arcs(0), arc_list()
1671 : info(_info), num_nodes(0), num_arcs(0)
1677 : info(std::move(_info)), num_nodes(0), num_arcs(0)
1683 : info(g.info), num_nodes(0), num_arcs(0)
1685 copy_graph(g, *
this);
1705 Base::copy_graph(g, *
this);
1719 std::swap(info, g.
info);
1741 throw std::underflow_error(
"Graph has not nodes");
1743 return &dl_to_node(node_list.
get_next())->get_item();
1749 throw std::underflow_error(
"Graph has not nodes");
1751 return &dl_to_node(const_cast<DL &>(node_list).get_next())->get_item();
1757 throw std::underflow_error(
"Graph has not arcs");
1759 return &dl_to_arc(arc_list.
get_next())->get_item()->get_item();
1765 throw std::underflow_error(
"Graph has not arcs");
1767 return &dl_to_arc(const_cast<DL &>(arc_list).get_next())->get_item()
1795 GNode * node = insert_gnode(
new GNode(
Node(std::forward<NodeInfo>(info))));
1801 GAdArc * arc = insert_garc(s, t);
1807 Arc * arc = insert_arc(src, tgt);
1814 Arc * arc = insert_arc(src, tgt);
1821 GAdArc * arc = to_garc(a);
1827 GNode * node = to_gnode(n);
1842 : Base(), graph_ptr(nullptr)
1848 : Base(const_cast<
DL *>(&g.node_list)),
1849 graph_ptr(const_cast<
Digraph *>(&g))
1855 : Base(const_cast<
DL *>(&g.node_list), curr),
1856 graph_ptr(const_cast<
Digraph *>(&g))
1862 : Base(it), graph_ptr(it.graph_ptr)
1878 (Base &) *
this = it;
1879 graph_ptr = it.graph_ptr;
1892 std::swap(graph_ptr, it.graph_ptr);
1897 return &dl_to_node(Base::get_current())->get_item();
1902 return &dl_to_node(Base::get_current())->get_item();
1907 if (not Base::has_current())
1908 throw std::overflow_error(
"There is not current element");
1910 GNode * p = dl_to_node(Base::get_current());
1927 : Base(), graph_ptr(nullptr)
1933 : Base(const_cast<
DL *>(&g.arc_list)),
1934 graph_ptr(const_cast<
Digraph *>(&g))
1940 : Base(const_cast<
DL *>(&g.arc_list), curr),
1941 graph_ptr(const_cast<
Digraph *>(&g))
1947 : Base(it), graph_ptr(it.graph_ptr)
1963 (Base &) *
this = it;
1964 graph_ptr = it.graph_ptr;
1977 std::swap(graph_ptr, it.graph_ptr);
1982 return &dl_to_arc(Base::get_current())->get_item()->get_item();
1987 return &dl_to_arc(Base::get_current())->get_item()->get_item();
1992 if (not Base::has_current())
1993 throw std::overflow_error(
"There is not current element");
1995 GArc * a = dl_to_arc(Base::get_current());
2014 : Base(), graph_ptr(nullptr), node_ptr(nullptr)
2021 graph_ptr(const_cast<
Digraph *>(&g)), node_ptr(n)
2028 graph_ptr(const_cast<
Digraph *>(&g)), node_ptr(n)
2034 : Base(it), graph_ptr(it.graph_ptr), node_ptr(it.node_ptr)
2050 (Base &) *
this = it;
2051 graph_ptr = it.graph_ptr;
2052 node_ptr = it.node_ptr;
2065 std::swap(graph_ptr, it.graph_ptr);
2066 std::swap(node_ptr, it.node_ptr);
2071 return &dl_to_adjacent_arc(Base::get_current())->get_item();
2076 return &dl_to_adjacent_arc(Base::get_current())->get_item();
2091 return get_current()->get_tgt_node();
2096 return get_current()->get_tgt_node();
2117 return NodeIterator(*
this, const_cast<DL *>(&node_list));
2137 return ArcIterator(*
this, const_cast<DL *>(&arc_list));
2161 Arc * search_arc(Node *, Node *);
2163 template <
class Cmp>
2166 quicksort<Node, Cmp>(*dl_to_node(&node_list), cmp);
2169 template <
class Cmp>
2172 sort_nodes<Cmp>(cmp);
2175 template <
class Cmp>
2178 quicksort<Arc, Cmp>(*dl_to_arc(&arc_list), cmp);
2181 template <
class Cmp>
2184 sort_arcs<Cmp>(cmp);
2190 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
2195 while (curr_link != &arc_list)
2197 GArc * arc = dl_to_arc(curr_link);
2209 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
2225 template <
typename NodeInfo,
typename ArcInfo,
typename GraphInfo>
2230 if (it.get_tgt_node() == t)
2238 # endif // DSGGRAPH_H RetT fold_arcs(const RetT &init_val, Op &&op=Op()) const
Definition: graph.H:411
Node * insert_node(NodeInfo &&info)
Definition: graph.H:1793
AdjacentArcIterator(const AdjacentArcIterator &it)
Definition: graph.H:2033
ArcIterator arcs_end()
Definition: graph.H:1450
ArcIterator(ArcIterator &&it)
Definition: graph.H:1952
AdjacentArcIterator(const Graph &g, Node *n)
Definition: graph.H:1339
ArcInfo ArcInfoType
Definition: graph.H:1575
void del()
Definition: graph.H:1905
Node * get_src_node()
Definition: graph.H:1399
Definition: nodesdef.H:999
ArcIterator(const ArcIterator &it)
Definition: graph.H:1946
const Arc * get_current() const
Definition: graph.H:2074
ContainerRet map_arcs_if(Op &&op, Pred &pred) const
Definition: graph.H:385
~Graph()
Definition: graph.H:1015
void swap(AdjacentArcIterator &it)
Definition: graph.H:1382
Node * get_first_node()
Definition: graph.H:1738
NodeIterator(NodeIterator &&it)
Definition: graph.H:1867
Digraph(const GraphInfo &_info)
Definition: graph.H:1670
bool remove_first_node_if(Pred &&pred=Pred())
Definition: graph.H:285
NodeIterator nodes_begin()
Definition: graph.H:1420
static GNode * to_gnode(Node *node)
Definition: graph.H:1602
ContainerRet map_nodes(Op &op) const
Definition: graph.H:139
void del()
Definition: graph.H:1310
ContainerRet map_nodes_if(Op &op, Pred &pred) const
Definition: graph.H:156
void for_each_adjacent_arc(Node *p, Op &op) const
Definition: graph.H:528
nat_t SetSizeType
Definition: graph.H:879
Arc * get_first_arc()
Definition: graph.H:1754
bool exists_arc(Pred &&pred) const
Definition: graph.H:452
bool none_it(const It &, const It &, Pred &)
Definition: italgorithms.H:325
void sort_nodes(Cmp &cmp)
Definition: graph.H:1484
void remove_node(GNode *)
Definition: graph.H:1515
void clear()
Definition: graph.H:2210
Arc * nth_adjacent_arc(Node *p, nat_t i)
Definition: graph.H:517
bool is_empty() const
Definition: nodesdef.H:153
void remove_arc(GArc *arc)
Definition: graph.H:958
Node * get_tgt_node()
Definition: graph.H:1409
ContainerRet filter_arcs(Pred &pred) const
Definition: graph.H:334
AdjacentArcIterator(const Graph &g, Node *n, DL *curr)
Definition: graph.H:1346
ArcIterator()
Definition: graph.H:1246
Definition: nodesdef.H:113
static GAdArc * to_garc(Arc *arc)
Definition: graph.H:1610
Arc * get_current()
Definition: graph.H:1980
ContainerRet map_adjacent_arcs_if(Node *p, Op &&op, Pred &pred) const
Definition: graph.H:594
bool all_adjacent_arcs(Node *p, Pred &&pred) const
Definition: graph.H:649
Node * get_first_node() const
Definition: graph.H:1067
T & get_item()
Definition: nodesdef.H:454
void for_each_node(Op &&op=Op()) const
Definition: graph.H:118
Arc * insert_arc(Node *src, Node *tgt, ArcInfo &&info)
Definition: graph.H:1132
void remove_arc(Arc *a)
Definition: graph.H:1819
void remove_node_if(Pred &&pred=Pred())
Definition: graph.H:298
Node * search_node(Pred &pred) const
Definition: graph.H:263
bool remove_first_adjacent_arc_if(Node *p, Pred &&pred)
Definition: graph.H:704
AdjacentArcIterator(AdjacentArcIterator &&it)
Definition: graph.H:2039
Graph(const GraphInfo &_info)
Definition: graph.H:991
void del()
Definition: graph.H:1225
ContainerRet map_adjacent_arcs_if(Node *p, Op &op, Pred &&pred=Pred()) const
Definition: graph.H:584
ContainerRet filter_adjacent_arcs(Node *p, Pred &pred) const
Definition: graph.H:541
static GNode * to_gnode(Node *node)
Definition: graph.H:904
Arc * search_arc(Pred &pred) const
Definition: graph.H:472
void for_each_arc(Op &op) const
Definition: graph.H:321
NodeIterator(const Graph &g)
Definition: graph.H:1167
const AdjacentArcIterator arcs_end(Node *p) const
Definition: graph.H:2155
void reset_all_tags() const
Definition: graph.H:766
void sort_nodes(Cmp &cmp)
Definition: graph.H:2164
bool exists_adjacent_arc(Node *p, Pred &&pred) const
Definition: graph.H:662
Digraph(GraphInfo &&_info)
Definition: graph.H:1676
bool remove_first_adjacent_arc_if(Node *p, Pred &pred)
Definition: graph.H:698
void reset_arc_cookies() const
Definition: graph.H:780
const NodeIterator nodes_begin() const
Definition: graph.H:1425
bool exists_arc(Pred &pred) const
Definition: graph.H:446
nat_t num_arcs
Definition: graph.H:923
NodeIterator nodes_end()
Definition: graph.H:1430
bool all_nodes(Pred &&pred=Pred()) const
Definition: graph.H:230
Graph()
Definition: graph.H:985
bool none_arc(Pred &pred) const
Definition: graph.H:459
void sort_nodes(Cmp &&cmp=Cmp())
Definition: graph.H:1492
Definition: iterator.H:36
const NodeIterator nodes_begin() const
Definition: graph.H:2105
SLList< Arc * > arcs() const
Definition: graph.H:512
Arc * search_adjacent_arc(Node *p, Pred &&pred) const
Definition: graph.H:692
RetT fold_nodes(const RetT &init_val, Op &op) const
Definition: graph.H:195
const AdjacentArcIterator arcs_begin(Node *p) const
Definition: graph.H:2145
bool is_digraph() const
Definition: graph.H:2187
void sort_arcs(Cmp &&cmp=Cmp())
Definition: graph.H:2182
ContainerRet map_adjacent_arcs(Node *p, Op &op) const
Definition: graph.H:555
GraphInfo info
Definition: graph.H:1618
Arc * get_first_arc() const
Definition: graph.H:1762
ArcIterator arcs_end()
Definition: graph.H:2130
ContainerRet map_arcs(Op &op) const
Definition: graph.H:348
AdjacentArcIterator(const Digraph &g, Node *n)
Definition: graph.H:2019
AdjacentArcIterator()
Definition: graph.H:2013
static GNode * dl_to_node(DL *ptr)
Definition: graph.H:889
ArcIterator arcs_begin()
Definition: graph.H:2120
DL arc_list
Definition: graph.H:1622
Arc * nth_arc(nat_t i) const
Definition: graph.H:315
GNode * insert_gnode(GNode *p)
Definition: graph.H:926
RetT fold_nodes(RetT &&init_val, Op &&op=Op()) const
Definition: graph.H:216
Arc * get_current() const
Definition: graph.H:1394
ArcIterator(const ArcIterator &it)
Definition: graph.H:1266
RetT fold_adjacent_arcs(Node *p, RetT &&init_val, Op &&op=Op()) const
Definition: graph.H:635
ContainerRet filter_it(const It &, const It &, Pred &)
Definition: italgorithms.H:196
Arc * get_current()
Definition: graph.H:2069
const GraphInfo & get_info() const
Definition: graph.H:1733
Arc * get_current()
Definition: graph.H:1389
nat_t num_arcs
Definition: graph.H:1621
ArcIterator arcs_begin()
Definition: graph.H:1440
ContainerRet filter_adjacent_arcs(Node *p, Pred &&pred=Pred()) const
Definition: graph.H:547
Graph(GraphInfo &&_info)
Definition: graph.H:997
RetT & nth_it(const It &, const It &, nat_t)
Definition: italgorithms.H:172
nat_t get_num_arcs() const
Definition: graph.H:1096
~Digraph()
Definition: graph.H:1694
AdjacentArcIterator arcs_begin(Node *p)
Definition: graph.H:1460
NodeIterator()
Definition: graph.H:1841
bool all_adjacent_arcs(Node *p, Pred &pred) const
Definition: graph.H:643
ArcIterator(const Digraph &g, DL *curr)
Definition: graph.H:1939
ContainerRet map_arcs_if(Op &&op=Op(), Pred &&pred=Pred()) const
Definition: graph.H:395
ContainerRet map_nodes_if(Op &op, Pred &&pred=Pred()) const
Definition: graph.H:166
AdjacentArcIterator()
Definition: graph.H:1333
const NodeIterator nodes_end() const
Definition: graph.H:1435
Arc * get_first_arc()
Definition: graph.H:1075
SLList< Node * > nodes() const
Definition: graph.H:304
static GNode * dl_to_node(DL *ptr)
Definition: graph.H:1587
void swap(ArcIterator &it)
Definition: graph.H:1974
AdjacentArcIterator(AdjacentArcIterator &&it)
Definition: graph.H:1359
nat_t num_arcs
Definition: nodesdef.H:1003
ArcIterator(ArcIterator &&it)
Definition: graph.H:1272
Node * get_current()
Definition: graph.H:1215
Node * search_node(Pred &&pred=Pred()) const
Definition: graph.H:273
DL arc_list
Definition: graph.H:924
void map_nodes(Node< SG > *p, Node< TG > *q)
Definition: graphutilities.H:99
Arc * get_current()
Definition: graph.H:1300
void remove_node(Node *n)
Definition: graph.H:1145
ContainerRet filter_nodes(Pred &pred) const
Definition: graph.H:125
ContainerRet map_arcs(Op &&op=Op()) const
Definition: graph.H:356
ContainerRet map_adjacent_arcs_if(Node *p, Op &&op=Op(), Pred &&pred=Pred()) const
Definition: graph.H:605
NodeIterator(NodeIterator &&it)
Definition: graph.H:1187
bool exists_node(Pred &&pred=Pred()) const
Definition: graph.H:243
void del()
Definition: nodesdef.H:208
ArcInfo & get_info()
Definition: nodesdef.H:1123
const AdjacentArcIterator arcs_begin(Node *p) const
Definition: graph.H:1465
NodeIterator nodes_begin()
Definition: graph.H:2100
DL node_list
Definition: graph.H:1620
RetT fold_arcs(RetT &&init_val, Op &&op=Op()) const
Definition: graph.H:425
void sort_arcs(Cmp &cmp)
Definition: graph.H:1498
RetT fold_adjacent_arcs(Node *p, RetT &&init_val, Op &op) const
Definition: graph.H:628
ContainerRet map_nodes(Op &&op=Op()) const
Definition: graph.H:147
const NodeIterator nodes_end() const
Definition: graph.H:2115
bool none_node(Pred &pred) const
Definition: graph.H:250
Node * get_src_node() const
Definition: graph.H:1404
NodeIterator(const Digraph &g, DL *curr)
Definition: graph.H:1854
void reset_arcs() const
Definition: graph.H:824
Arc * get_current() const
Definition: graph.H:1985
void reset_all_arc_tag() const
Definition: graph.H:752
GraphInfo GraphInfoType
Definition: graph.H:878
ContainerRet filter_arcs(Pred &&pred=Pred()) const
Definition: graph.H:340
Node * get_first_node()
Definition: graph.H:1059
const GraphInfo & get_info() const
Definition: graph.H:1054
GraphInfo info
Definition: graph.H:920
void swap(AdjacentArcIterator &it)
Definition: graph.H:2062
bool exists_it(const It &, const It &, Pred &)
Definition: italgorithms.H:310
ContainerRet map_arcs_if(Op &op, Pred &pred) const
Definition: graph.H:365
void reset_arc_counter() const
Definition: graph.H:796
Node * get_current()
Definition: graph.H:1895
nat_t SetSizeType
Definition: graph.H:1577
Node * get_src_node()
Definition: graph.H:2079
const ArcIterator arcs_end() const
Definition: graph.H:1455
void remove_arc(Arc *a)
Definition: graph.H:1139
bool none_node(Pred &&pred=Pred()) const
Definition: graph.H:256
static GArc * dl_to_arc(DL *ptr)
Definition: graph.H:1592
Arc * get_current() const
Definition: graph.H:1305
typename GT::Node Node
Definition: graphutilities.H:78
static GArc * dl_to_arc(DL *ptr)
Definition: graph.H:894
const ArcIterator arcs_begin() const
Definition: graph.H:2125
ContainerRet map_adjacent_arcs(Node *p, Op &&op=Op()) const
Definition: graph.H:563
NodeIterator(const Graph &g, DL *curr)
Definition: graph.H:1174
nat_t get_num_arcs() const
Definition: graph.H:1776
void swap(NodeIterator &it)
Definition: graph.H:1209
bool has_current() const
Definition: nodesdef.H:362
void for_each_it(const It &, const It &, Op &)
Definition: italgorithms.H:183
GAdArc * insert_garc(Node *src, Node *tgt)
Definition: graph.H:1631
bool exists_node(Pred &pred) const
Definition: graph.H:237
void for_each_arc(Op &&op) const
Definition: graph.H:327
RetT fold_nodes(const RetT &init_val, Op &&op=Op()) const
Definition: graph.H:202
bool none_adjacent_arc(Node *p, Pred &&pred) const
Definition: graph.H:675
static GAdArc * dl_to_adjacent_arc(DL *ptr)
Definition: graph.H:1597
bool exists_adjacent_arc(Node *p, Pred &pred) const
Definition: graph.H:656
void reset_tag(GraphTag tag) const
Definition: graph.H:760
Node * get_current() const
Definition: graph.H:1220
ArcInfo ArcInfoType
Definition: graph.H:877
Definition: italgorithms.H:33
Node * nth_node(nat_t i) const
Definition: graph.H:106
Definition: nodesdef.H:415
nat_t num_nodes
Definition: graph.H:1619
void swap(ArcIterator &it)
Definition: graph.H:1294
ArcIterator()
Definition: graph.H:1926
ContainerRet filter_nodes(Pred &&pred=Pred()) const
Definition: graph.H:131
NodeIterator(const NodeIterator &it)
Definition: graph.H:1861
ContainerRet map_nodes_if(Op &&op=Op(), Pred &&pred=Pred()) const
Definition: graph.H:186
static GArc * to_garc(Arc *arc)
Definition: graph.H:912
nat_t num_nodes
Definition: graph.H:921
Digraph()
Definition: graph.H:1664
GraphInfo & get_info()
Definition: graph.H:1049
Arc * insert_arc(Node *s, Node *t)
Definition: graph.H:1799
RetT fold_adjacent_arcs(Node *p, const RetT &init_val, Op &&op=Op()) const
Definition: graph.H:621
void reset_node_cookies() const
Definition: graph.H:772
ArcIterator(const Graph &g, DL *curr)
Definition: graph.H:1259
Arc * insert_arc(Node *s, Node *t)
Definition: graph.H:1119
Digraph(const Digraph &g)
Definition: graph.H:1682
Arc * search_arc(Node *, Node *)
Definition: graph.H:1543
void remove_if_it(const It &, const It &, Pred &)
Definition: italgorithms.H:375
Arc * get_first_arc() const
Definition: graph.H:1083
bool is_digraph() const
Definition: graph.H:1511
Node * insert_node()
Definition: graph.H:1101
bool remove_first_arc_if(Pred &pred)
Definition: graph.H:488
ContainerRet map_nodes_if(Op &&op, Pred &pred) const
Definition: graph.H:176
void for_each_adjacent_arc(Node *p, Op &&op) const
Definition: graph.H:534
void reset_all_node_tag() const
Definition: graph.H:736
AdjacentArcIterator arcs_end(Node *p)
Definition: graph.H:1470
AdjacentArcIterator arcs_begin(Node *p)
Definition: graph.H:2140
void remove_node(GNode *)
Definition: graph.H:2191
Arc * insert_arc(Node *src, Node *tgt, const ArcInfo &info)
Definition: graph.H:1125
Node * get_tgt_node()
Definition: graph.H:2089
RetT fold_nodes(RetT &&init_val, Op &op) const
Definition: graph.H:209
Arc * search_adjacent_arc(Node *p, Pred &pred) const
Definition: graph.H:682
NodeInfo info
Definition: nodesdef.H:1002
bool all_arcs(Pred &pred) const
Definition: graph.H:433
const ArcIterator arcs_begin() const
Definition: graph.H:1445
const Node * get_tgt_node() const
Definition: graph.H:1414
void reset_cookies() const
Definition: graph.H:810
void remove_adjacent_arc_if(Node *p, Pred &&pred)
Definition: graph.H:717
void sort_arcs(Cmp &cmp)
Definition: graph.H:2176
bool remove_first_if_it(const It &, const It &, Pred &)
Definition: italgorithms.H:356
RetT fold_adjacent_arcs(Node *p, const RetT &init_val, Op &op) const
Definition: graph.H:614
RetT fold_arcs(RetT &&init_val, Op &op) const
Definition: graph.H:418
void reset_nodes() const
Definition: graph.H:816
Node * insert_node(const NodeInfo &info)
Definition: graph.H:1107
GArc * insert_garc(Node *src, Node *tgt)
Definition: graph.H:933
void reset_counters() const
Definition: graph.H:804
Definition: iterator.H:112
void remove_node(Node *n)
Definition: graph.H:1825
void remove_arc_if(Pred &&pred)
Definition: graph.H:507
Node * get_current() const
Definition: graph.H:1900
void reset_all_node_tag(GraphTag tag) const
Definition: graph.H:728
void sort_nodes(Cmp &&cmp=Cmp())
Definition: graph.H:2170
bool all_arcs(Pred &&pred) const
Definition: graph.H:439
Graph(Graph &&g)
Definition: graph.H:1009
static void copy_graph(const GT &, GT &)
Definition: graph.H:836
void remove_adjacent_arc_if(Node *p, Pred &pred)
Definition: graph.H:711
nat_t get_num_nodes() const
Definition: graph.H:1771
unsigned long int nat_t
Definition: types.H:50
GraphInfo & get_info()
Definition: graph.H:1728
static GAdArc * dl_to_adjacent_arc(DL *ptr)
Definition: graph.H:899
Digraph(Digraph &&g)
Definition: graph.H:1688
void reset_node_counter() const
Definition: graph.H:788
GNode * insert_gnode(GNode *p)
Definition: graph.H:1624
Arc * insert_arc(Node *src, Node *tgt, const ArcInfo &info)
Definition: graph.H:1805
void swap(Digraph &g)
Definition: graph.H:1717
SLList< Arc * > adjacent_arcs(Node *p) const
Definition: graph.H:723
NodeIterator()
Definition: graph.H:1161
AdjacentArcIterator(const AdjacentArcIterator &it)
Definition: graph.H:1353
AdjacentArcIterator(const Digraph &g, Node *n, DL *curr)
Definition: graph.H:2026
void remove_arc_if(Pred &pred)
Definition: graph.H:501
DL adjacent_arc_list
Definition: nodesdef.H:1004
const AdjacentArcIterator arcs_end(Node *p) const
Definition: graph.H:1475
Node * get_src_node() const
Definition: graph.H:2084
DL node_list
Definition: graph.H:922
ArcIterator(const Graph &g)
Definition: graph.H:1252
Arc * nth_arc(nat_t i)
Definition: graph.H:310
void clear()
Definition: graph.H:1532
void swap(Graph &g)
Definition: graph.H:1038
void swap(NodeIterator &it)
Definition: graph.H:1889
bool all_nodes(Pred &pred) const
Definition: graph.H:224
void remove_arc(GAdArc *arc)
Definition: graph.H:1646
RetT fold_arcs(const RetT &init_val, Op &op) const
Definition: graph.H:404
GraphTag
Definition: graphutilities.H:37
void reset_all_arc_tag(GraphTag tag) const
Definition: graph.H:744
void for_each_node(Op &op) const
Definition: graph.H:112
Node * nth_node(nat_t i)
Definition: graph.H:101
void sort_arcs(Cmp &&cmp=Cmp())
Definition: graph.H:1506
bool none_adjacent_arc(Node *p, Pred &pred) const
Definition: graph.H:669
void remove_node_if(Pred &pred)
Definition: graph.H:292
Arc * search_arc(Node *, Node *)
Definition: graph.H:2227
NodeIterator(const Digraph &g)
Definition: graph.H:1847
bool remove_first_node_if(Pred &pred)
Definition: graph.H:279
typename GT::Arc Arc
Definition: graphutilities.H:79
const ArcIterator arcs_end() const
Definition: graph.H:2135
ArcIterator(const Digraph &g)
Definition: graph.H:1932
Arc * nth_adjacent_arc(Node *p, nat_t i) const
Definition: graph.H:522
Node * get_first_node() const
Definition: graph.H:1746
Arc * search_arc(Pred &&pred) const
Definition: graph.H:482
bool none_arc(Pred &&pred) const
Definition: graph.H:465
void del()
Definition: graph.H:1990
nat_t get_num_nodes() const
Definition: graph.H:1091
ContainerRet map_adjacent_arcs_if(Node *p, Op &op, Pred &pred) const
Definition: graph.H:573
Definition: nodesdef.H:1049
const Node * get_tgt_node() const
Definition: graph.H:2094
bool remove_first_arc_if(Pred &&pred)
Definition: graph.H:494
Graph(const Graph &g)
Definition: graph.H:1003
GraphInfo GraphInfoType
Definition: graph.H:1576
DL *& get_next()
Definition: nodesdef.H:168
NodeIterator nodes_end()
Definition: graph.H:2110
NodeIterator(const NodeIterator &it)
Definition: graph.H:1181
Node * insert_node()
Definition: graph.H:1781
Node * insert_node(NodeInfo &&info)
Definition: graph.H:1113
void insert_prev(DL *node)
Definition: nodesdef.H:198
Node * insert_node(const NodeInfo &info)
Definition: graph.H:1787
Definition: nodesdef.H:293
void swap(DL *node)
Definition: nodesdef.H:229
AdjacentArcIterator arcs_end(Node *p)
Definition: graph.H:2150
bool all_it(const It &, const It &, Pred &)
Definition: italgorithms.H:295
ContainerRet map_arcs_if(Op &op, Pred &&pred=Pred()) const
Definition: graph.H:375
Arc * insert_arc(Node *src, Node *tgt, ArcInfo &&info)
Definition: graph.H:1812