33 # include <tpl_dynDlist.H> 34 # include <tpl_dynListStack.H> 35 # include <tpl_dynBinHeap.H> 36 # include <tpl_dynSetTree.H> 37 # include <tpl_dynSetHash.H> 38 # include <tpl_random_queue.H> 39 # include <tpl_graph_utils.H> 40 # include <tpl_find_path.H> 41 # include <graph-traverse.H> 45 using namespace Aleph;
49 template <
typename Arc_Info,
typename Flow_Type>
50 struct Net_Arc_Info :
public Arc_Info
58 Net_Arc_Info() noexcept(
std::is_nothrow_constructible<Arc_Info>::value) {}
60 Net_Arc_Info(
const Arc_Info & info, Flow_Type __cap, Flow_Type __flow)
61 noexcept(noexcept(Arc_Info(info)))
62 : Arc_Info(info), cap(__cap), flow(__flow)
81 template <
typename Arc_Info,
typename F_Type =
double>
82 struct Net_Arc :
public Graph_Aarc<Arc_Info>
84 using Base = Graph_Aarc<Arc_Info>;
86 using Flow_Type = F_Type;
97 bool check_arc() const noexcept {
return flow >= 0 and flow <= cap; }
100 noexcept(noexcept(
Base(info)))
104 noexcept(noexcept(
Base(arc.arc_info)))
113 noexcept(std::is_nothrow_copy_assignable<Arc_Info>::value)
128 bool is_residual(
typename Net::Node * src,
typename Net::Arc * a) noexcept
130 assert(a->src_node == src or a->tgt_node == src);
131 return a->tgt_node == src;
141 typename Net::Node * p =
nullptr;
143 void * cookie =
nullptr;
145 void set_cookie(
void * __cookie) noexcept { cookie = __cookie; }
147 Net_Filt(
typename Net::Node * s =
nullptr) noexcept
150 bool operator () (
typename Net::Arc * a)
const noexcept
153 assert(a->src_node == p or a->tgt_node == p);
154 auto src = (
typename Net::Node*) a->src_node;
156 return a->cap - a->flow > 0;
158 assert(is_residual<Net>(p, a));
162 bool operator () (
const Net &,
typename Net::Arc * arc) noexcept
167 typename Net::Node* get_node(
typename Net::Arc * a)
const noexcept
170 assert(a->src_node == p or a->tgt_node == p);
171 return (
typename Net::Node*) (a->src_node == p ? a->tgt_node : a->src_node);
179 template <
class Net,
class Show_Arc = Dft_Show_Arc<Net>>
190 typename Net::Flow_Type
193 return is_residual<Net>(src, a) ? a->flow : a->cap - a->flow;
196 template <
typename Node_Info = Empty_Class>
214 template <
class NodeT = Net_Node<Empty_Class>,
215 class ArcT = Net_Arc<Empty_Class,
double>>
220 using Base = Array_Graph<NodeT, ArcT>;
236 using Node_Type =
typename Node::Node_Type;
239 using Arc_Type =
typename Arc::Arc_Type;
246 return Aleph::out_arcs<Net_Graph>(p);
252 return out_pairs<Net_Graph>(p).
template maps<Node*>
259 return Aleph::in_arcs<Net_Graph>(p);
265 return in_pairs<Net_Graph>(p).
template maps<Node*>
274 sum += it.get_curr_ne()->cap;
283 sum += it.get_curr_ne()->cap;
306 sum += it.get_curr_ne()->flow;
315 sum += it.get_curr_ne()->flow;
320 bool is_source(Node * node) noexcept {
return src_nodes.contains(node); }
323 bool is_sink(Node * node) noexcept {
return sink_nodes.contains(node); }
336 return get_in_degree(p) != 0 or get_out_degree(p) != 0;
343 if (not is_connected(node))
346 auto out_flow = get_out_flow(node);
347 auto in_flow = get_in_flow(node);
350 return out_flow == 0 and in_flow >= 0;
353 return in_flow == 0 and out_flow >= 0;
355 return out_flow == in_flow;
381 if (src_nodes.
size() == 1)
384 if (src_nodes.
size() == 0)
385 throw std::domain_error(
"network has not source node (it has cicles)");
387 Node * super_source = insert_node();
388 src_nodes.
for_each([super_source,
this] (Node * p)
390 insert_arc(super_source, p, get_out_cap(p));
393 with_super_source =
true;
400 if (not with_super_source)
403 assert(src_nodes.
size() == 1);
406 with_super_source =
false;
414 if (sink_nodes.
size() == 1)
417 if (sink_nodes.
size() == 0)
418 throw std::domain_error(
"network has not sink node (it has cicles)");
420 Node * super_sink = insert_node();
421 sink_nodes.
for_each([super_sink,
this] (Node * p)
423 insert_arc(p, super_sink, get_in_cap(p));
425 with_super_sink =
true;
432 if (not with_super_sink)
435 assert(sink_nodes.
size() == 1);
438 with_super_sink =
false;
450 catch (std::bad_alloc)
452 unmake_super_source();
461 unmake_super_source();
483 auto p = Graph::insert_node(node_info);
495 Graph::remove_node(p);
501 Graph::remove_node(p);
510 return insert_node(info);
513 template <
typename ...Args>
514 Node * emplace_node(Args && ... args)
516 return insert_node(Node_Type(args...));
534 Graph::insert_node(p);
546 Graph::remove_node(p);
552 Graph::remove_node(p);
577 const typename Arc::Arc_Type & arc_info = Arc_Type())
579 auto arc = Graph::insert_arc(src_node, tgt_node, arc_info);
581 src_nodes.
remove(tgt_node);
582 sink_nodes.
remove(src_node);
587 if (not arc->check_arc())
588 throw std::overflow_error(
"flow is greater than capacity");
593 template <
typename ...Args>
594 Arc * emplace_arc(Node * src_node, Node * tgt_node,
598 return insert_arc(src_node, tgt_node, cap, flow, Arc_Type(args...));
619 Graph::connect_arc(arc);
621 auto src = this->get_src_node(arc);
622 auto tgt = this->get_tgt_node(arc);
649 return insert_arc(src_node, tgt_node, cap, 0, Arc_Type());
670 const typename Arc::Arc_Type & arc_info = Arc_Type())
672 return insert_arc(src_node, tgt_node, 0, 0, arc_info);
678 auto src = this->get_src_node(arc);
679 auto tgt = this->get_tgt_node(arc);
680 if (get_in_degree(tgt) == 1)
683 Graph::remove_arc(arc);
685 if (get_out_degree(src) == 0)
702 auto src = this->get_src_node(arc);
703 auto tgt = this->get_tgt_node(arc);
704 if (get_in_degree(tgt) == 1)
707 Graph::disconnect_arc(arc);
709 if (get_out_degree(src) == 0)
716 Graph::remove_node(p);
724 : Array_Graph<NodeT, ArcT>::Array_Graph(),
725 Infinity(numeric_limits<typename Arc::
Flow_Type>::max()),
726 with_super_source(net.with_super_source),
727 with_super_sink(net.with_super_sink)
731 using Pair = std::pair<typename Net_Graph::Arc*, typename Net_Graph::Arc*>;
732 zip(this->
arcs(), net.
arcs()).for_each([] (
const Pair & p)
735 auto asrc = p.second;
736 atgt->cap = asrc->cap;
737 atgt->flow = asrc->flow;
745 throw std::out_of_range(
"capacity value is smaller than flow");
755 throw std::out_of_range(
"flow value is greater than capacity");
766 void reset() noexcept
769 it.get_curr_ne()->flow = 0;
786 return this->nodes().all([
this] (Node * p) {
return check_node(p); }) and
787 this->
arcs().all([] (Arc * a) {
return a->check_arc(); }) and
788 get_out_flow(get_source()) == get_in_flow(get_sink());
796 assert(get_in_flow(get_source()) == get_out_flow(get_sink()));
797 return get_out_flow(get_source());
807 : Infinity(numeric_limits<typename Arc::
Flow_Type>::max()),
808 with_super_source(false), with_super_sink(false)
811 friend ostream & operator << (ostream & s, const Path<Net_Graph> & path)
814 return s <<
"Path is Empty";
816 const Net_Graph & net = path.get_graph();
822 s <<
"(" << a->cap <<
"," << a->flow <<
")" 834 using Parc = tuple<typename Net::Arc*, bool>;
845 using SemiPath = tuple<bool, typename Net::Flow_Type, DynList<Parc<Net>>>;
852 cout <<
"Semi path is Empty";
861 auto s = (
typename Net::Node *) a->src_node;
862 auto t = (
typename Net::Node *) a->tgt_node;
863 cout << s->get_info() <<
"(" << a->flow <<
"," << a->cap <<
")" 864 << t->get_info() <<
" " << (get<1>(pa) ?
"Normal" :
"Reduced")
897 typename Net::Flow_Type slack = net.Infinity;
898 using Tuple = tuple<typename Net::Node*, typename Net::Arc*>;
904 Tuple t = it.get_tuple_ne();
906 auto arc = get<1>(t);
907 const auto w = remaining_flow<Net>(p, arc);
915 auto t = it.get_tuple_ne();
917 auto arc = get<1>(t);
919 if (is_residual<Net>(p, arc))
924 assert(arc->check_arc());
949 const typename Net::Flow_Type slack)
955 auto p = it.get_curr_ne();
956 auto arc = get<0>(p);
962 assert(arc->check_arc());
964 assert(net.check_network());
984 typename Net::Flow_Type slack)
995 template <
class Net,
template <
typename T>
class Q>
1001 typename Net::Node * search(
typename Net::Node* start,
1002 typename Net::Node* end,
1003 typename Net::Flow_Type min_slack)
1010 Q<typename Net::Arc*> q;
1011 for (Itor it(start); it.has_curr(); it.next_ne())
1013 auto a = it.get_curr_ne();
1014 if (remaining_flow<Net>(start, a) < min_slack)
1016 auto tgt = net.get_connected_node(a, start);
1022 typename Net::Node * curr =
nullptr;
1023 while (not q.is_empty())
1029 auto s = net.get_src_node(arc);
1030 auto t = net.get_tgt_node(arc);
1038 NODE_COOKIE(curr) = net.get_connected_node(arc, curr);
1043 for (Itor it(curr); it.has_curr(); it.next_ne())
1045 auto a = it.get_curr_ne();
1046 if (remaining_flow<Net>(curr, a) < min_slack)
1050 auto tgt = net.get_connected_node(a, curr);
1067 Path<Net> find(
typename Net::Node * start,
typename Net::Node * end,
1068 const typename Net::Flow_Type & min_slack = 0.0)
1070 auto curr = search(start, end, min_slack);
1076 assert(curr == end);
1078 while (curr != start)
1089 typename Net::Node * end,
1090 typename Net::Flow_Type min_slack = 0.0)
1092 auto t = search(start, end, min_slack);
1099 auto m = std::numeric_limits<typename Net::Flow_Type>::max();
1103 auto a_ptr = net.arcs(t).find_ptr([s, t] (
typename Net::Arc * a)
1105 return ((a->src_node == s and a->tgt_node == t) or
1106 (a->src_node == t and a->tgt_node == s));
1110 bool normal = a->tgt_node == t;
1111 auto slack = normal ? a->cap - a->flow : a->flow;
1112 m = std::min(m, slack);
1113 semi_path.
insert(make_tuple(a, normal));
1117 return make_tuple(
true, m, move(semi_path));
1125 return find_path(net.get_source(), net.get_sink(), min_slack);
1131 return find_path(net.get_sink(), net.get_source(), min_slack);
1139 Path<Net> operator () (
typename Net::Node * start,
1140 typename Net::Node * end,
1141 typename Net::Flow_Type min_slack = 0)
1143 return find(start, end, min_slack);
1146 SemiPath<Net> operator () (
typename Net::Flow_Type min_slack = 0)
1148 return find_aum_path(min_slack);
1151 typename Net::Flow_Type
1152 semi_path(
typename Net::Node * start,
1153 typename Net::Node * end,
1155 const typename Net::Flow_Type & min_slack = 0)
1157 return find_semi_path(start, end, semi_path, min_slack);
1162 template <
class Net>
1166 template <
class Net>
1181 template <
class Net,
template <
typename T>
class Q>
1183 const typename Net::Flow_Type & min_slack)
1185 auto s = net.get_source();
1186 auto t = net.get_sink();
1199 template <
class Net>
1201 const typename Net::Flow_Type & min_slack)
1203 return find_aumenting_path<Net, DynListStack> (net, min_slack);
1215 template <
class Net>
1217 const typename Net::Flow_Type & min_slack)
1219 return find_aumenting_path<Net, DynListQueue> (net, min_slack);
1238 template <
class Net,
template <
typename T>
class Q>
1240 const typename Net::Flow_Type & slack)
1258 template <
class Net>
1261 const typename Net::Flow_Type & slack)
1263 return find_aumenting_semi_path<Net, DynListStack> (net, slack);
1279 template <
class Net>
1282 const typename Net::Flow_Type & slack)
1284 return find_aumenting_semi_path<Net, DynListQueue> (net, slack);
1303 template <
class Net,
template <
typename T>
class Q>
1306 const typename Net::Flow_Type & slack)
1320 template <
class Net>
1323 const typename Net::Flow_Type & slack)
1325 return find_decrementing_path<Net, DynListStack> (net, slack);
1337 template <
class Net>
1340 const typename Net::Flow_Type & slack)
1342 return find_decrementing_path<Net, DynListQueue> (net, slack);
1347 template <
class Net>
1348 struct PP_Res_Node :
public Net_Node<Empty_Class>
1353 typename Net::Flow_Type in_flow;
1354 typename Net::Flow_Type out_flow;
1357 template <
class Net>
1358 struct __Res_Arc :
public Net_Arc<Empty_Class, typename Net::Flow_Type>
1363 typename Net::Arc * img =
nullptr;
1364 __Res_Arc * dup =
nullptr;
1366 bool is_residual()
const {
return img ==
nullptr; }
1370 template <
class Net>
1374 template <
class Net>
1378 template <
class Net>
inline 1380 typename Net::Arc * a)
1384 auto t = net.get_tgt_node(a);
1396 arc->flow = a->flow;
1399 dup->cap = arc->cap;
1400 dup->flow = arc->cap - arc->flow;
1404 template <
class Rnet>
1407 Res_F(
typename Rnet::Node *) noexcept {}
1410 bool operator () (
typename Rnet::Arc * a)
const 1412 return a->cap > a->flow;
1416 template <
class Net>
inline 1417 tuple<PP_Res_Net<Net>,
typename PP_Res_Net<Net>::Node*,
1418 typename PP_Res_Net<Net>::Node*>
1419 preflow_create_residual_net(Net & net)
1425 for (
typename Net::Node_Iterator it(net); it.has_curr(); it.next_ne())
1427 auto p = it.get_curr_ne();
1428 auto q = rnet.insert_node();
1429 q->in_flow = net.get_in_flow(p);
1430 q->out_flow = net.get_out_flow(p);
1431 map_nodes<typename Rnet::Node, typename Net::Node>(q, p);
1434 for (
typename Net::Arc_Iterator it(net); it.has_curr(); it.next_ne())
1435 create_residual_arc(net, rnet, it.get_curr_ne());
1437 return make_tuple(std::move(rnet),
1438 (
typename Rnet::Node*)
NODE_COOKIE(net.get_source()),
1439 (
typename Rnet::Node*)
NODE_COOKIE(net.get_sink()));
1442 template <
class Rnet>
inline 1443 void update_flow(
const Rnet & rnet)
1445 for (
typename Rnet::Arc_Iterator it(rnet); it.has_curr(); it.next_ne())
1447 auto arc = it.get_curr_ne();
1448 auto img = arc->img;
1451 img->flow = arc->flow;
1474 template <
class Net,
1475 template <
class>
class Find_Path>
1478 if (not (net.is_single_source() and net.is_single_sink()))
1479 throw std::domain_error(
"Network is not single source and single sink");
1484 if (not get<0>(semi_path))
1487 increase_flow <Net> (net, get<2>(semi_path), get<1>(semi_path));
1490 return net.get_out_flow(net.get_source());
1517 template <
class Net>
1520 return aumenting_path_maximum_flow <Net, Find_Aumenting_Path_DFS> (net);
1529 template <
class Net>
1539 typename Net::Flow_Type operator () (Net & net)
const 1560 template <
class Net>
1563 return aumenting_path_maximum_flow <Net, Find_Aumenting_Path_BFS> (net);
1572 template <
class Net>
1582 typename Net::Flow_Type operator () (Net & net)
const 1584 return edmonds_karp_maximum_flow<Net>(net);
1588 template <
class Net>
static inline 1589 bool is_node_active(
const Net & net,
typename Net::Node * p)
1591 return net.get_in_flow(p) != net.get_out_flow(p);
1594 template <
class Rnet>
static inline 1595 bool is_node_active(
typename Rnet::Node * p)
1597 return p->in_flow != p->out_flow;
1601 template <
class Net>
static inline 1602 long & node_height(
typename Net::Node * p) {
return NODE_COUNTER(p); }
1605 template <
class Net>
static inline 1606 void init_height_in_nodes(Net & net)
1609 exec(net.get_sink(), [&net] (
typename Net::Node * p,
typename Net::Arc * a)
1612 node_height<Net>(p) = node_height<Net>(net.get_tgt_node(a)) + 1;
1618 template <
class Q_Type>
static inline 1619 void put_in_active_queue(Q_Type & q,
typename Q_Type::Item_Type & p)
1621 if (
NODE_BITS(p).get_bit(Aleph::Maximum_Flow))
1623 NODE_BITS(p).set_bit(Aleph::Maximum_Flow,
true);
1628 template <
class Q_Type>
static inline 1629 typename Q_Type::Item_Type get_from_active_queue(Q_Type & q)
1632 assert(
NODE_BITS(p).get_bit(Aleph::Maximum_Flow));
1633 NODE_BITS(p).set_bit(Aleph::Maximum_Flow,
false);
1638 template <
class Q_Type>
static inline 1639 void remove_from_active_queue(Q_Type & q,
typename Q_Type::Item_Type & p)
1641 assert(
NODE_BITS(p).get_bit(Aleph::Maximum_Flow));
1642 NODE_BITS(p).set_bit(Aleph::Maximum_Flow,
false);
1681 template <
class Net,
class Q_Type>
typename Net::Flow_Type
1684 if (not (net.is_single_source() and net.is_single_sink()))
1685 throw std::domain_error(
"Network is not single source and single sink");
1688 init_height_in_nodes(net);
1690 auto source = net.get_source();
1691 auto sink = net.get_sink();
1692 node_height<Net>(source) = net.vsize();
1693 const auto Max = numeric_limits<long>::max();
1697 for (Itor it(source); it.has_curr(); it.next_ne())
1700 arc->flow = arc->cap;
1701 auto tgt = net.get_tgt_node(arc);
1702 put_in_active_queue(q, tgt);
1705 while (not q.is_empty())
1707 auto src = get_from_active_queue(q);
1708 auto excess = net.get_in_flow(src) - net.get_out_flow(src);
1710 bool was_eligible_arc =
false;
1711 for (Itor it(src); it.has_curr() and excess > 0; it.next_ne())
1713 auto arc = it.get_curr_ne();
1714 auto tgt = net.get_connected_node(arc, src);
1715 if (node_height<Net>(src) != node_height<Net>(tgt) + 1)
1717 m = std::min(m, node_height<Net>(tgt));
1721 was_eligible_arc =
true;
1722 typename Net::Flow_Type flow_to_push;
1723 if (is_residual<Net>(src, arc))
1725 flow_to_push = std::min(arc->flow, excess);
1726 arc->flow -= flow_to_push;
1730 flow_to_push = std::min(arc->cap - arc->flow, excess);
1731 arc->flow += flow_to_push;
1733 excess -= flow_to_push;
1734 if (tgt != source and tgt != sink)
1736 assert(is_node_active(net, tgt));
1737 put_in_active_queue(q, tgt);
1743 if (not was_eligible_arc)
1744 node_height<Net>(src) = m + 1;
1745 put_in_active_queue(q, src);
1749 assert(net.check_network());
1751 return net.flow_value();
1755 template <
class Rnet>
inline 1756 void init_height_in_nodes(Rnet & rnet,
typename Rnet::Node * sink)
1759 exec(sink, [&rnet] (
typename Rnet::Node * p,
typename Rnet::Arc * a)
1762 node_height<Rnet>(p) = node_height<Rnet>(rnet.get_src_node(a)) + 1;
1795 template <
class Net>
typename Net::Flow_Type
1798 using Node =
typename Net::Node;
1808 template <
class Net>
1824 typename Net::Flow_Type
1825 operator () (Net & net)
const 1832 template <
class Net>
1833 struct Compare_Height
1835 bool operator () (
typename Net::Node * n1,
typename Net::Node * n2)
const 1837 return node_height<Net>(n1) > node_height<Net>(n2);
1872 template <
class Net>
typename Net::Flow_Type
1875 using Node =
typename Net::Node;
1885 template <
class Net>
1900 typename Net::Flow_Type operator () (Net & net)
const 1932 template <
class Net>
typename Net::Flow_Type
1935 using Node =
typename Net::Node;
1936 return generic_preflow_vertex_push_maximum_flow<Net, Random_Set<Node*>>(net);
1945 template <
class Net>
1960 typename Net::Flow_Type operator () (Net & net)
const 1999 template <
class Net,
template <
class>
class Maxflow>
2006 Maxflow <Net> () (net);
2008 typename Net::Node * source = net.get_source();
2013 (source, [&vs] (
typename Net::Node * p)
2015 vs.
insert(p);
return true;
2019 const size_t size_vt = net.get_num_nodes() - vs.
size();
2021 vt.
size() < size_vt; it.next_ne())
2023 auto p = it.get_curr_ne();
2030 auto arc = it.get_curr_ne();
2032 if (vt.contains(net.get_src_node(arc)) and
2033 vs.contains(net.get_tgt_node(arc)) > 0)
2039 if (arc->flow == arc->cap)
2040 if (vs.contains(net.get_src_node(arc)) and
2041 vt.contains(net.get_tgt_node(arc)) > 0)
2045 return net.flow_value();
2063 template <
class Net,
2080 typename Net::Flow_Type operator () (Net & net,
2086 return min_cut <Net, Maxflow> (net, vs, vt, cuts, cutt);
2093 # endif // TPL_NET_H bool is_connected(Node *p) const noexcept
Definition: tpl_net.H:334
SemiPath< Net > find_decrementing_path(const Net &net, const typename Net::Flow_Type &slack)
Definition: tpl_net.H:1305
void make_super_source()
Definition: tpl_net.H:379
Flow_Type flow
valor de flujo
Definition: tpl_net.H:92
Definition: tpl_net.H:1809
Definition: tpl_agraph.H:691
Definition: tpl_graph.H:1225
Definition: tpl_agraph.H:301
bool is_single_source() const noexcept
Retorna true si la red es de un solo fuente.
Definition: tpl_net.H:326
Net::Flow_Type heap_preflow_maximum_flow(Net &net)
Definition: tpl_net.H:1873
SemiPath< Net > find_dec_path(typename Net::Flow_Type min_slack=0.0)
Encuentra un camino de decremento de al menos un slack.
Definition: tpl_net.H:1129
Flow_Type cap
valor de capacidad
Definition: tpl_net.H:89
const DynSetTree< Node * > & get_src_nodes() const noexcept
Retorna el conjunto de nodos fuente que contiene la red.
Definition: tpl_net.H:366
Node * get_connected_node(Arc *arc, Node *node) const noexcept
Definition: graph-dry.H:488
size_t get_in_degree(Node *p) const noexcept
Definition: tpl_net.H:289
const unsigned char Processing
#define NODE_COOKIE(p)
Definition: aleph-graph.H:333
Net::Flow_Type edmonds_karp_maximum_flow(Net &net)
Definition: tpl_net.H:1561
void set_flow(Arc *arc, const Flow_Type &flow)
Definition: tpl_net.H:752
void decrease_flow(Net &net, const DynList< Parc< Net >> &semi_path, typename Net::Flow_Type slack)
Definition: tpl_net.H:983
Flow_Type get_in_cap(Node *node) const noexcept
Retorna la capacidad total de entrada del nodo node.
Definition: tpl_net.H:270
Definition: tpl_net.H:139
bool is_sink(Node *node) noexcept
Retorna true si node es sumidero.
Definition: tpl_net.H:323
size_t remove(const Key &key)
Definition: tpl_dynSetTree.H:327
Node * get_current_node() const
Definition: tpl_graph.H:3159
Net_Graph(const Net_Graph &net)
Definition: tpl_net.H:723
Definition: tpl_net.H:996
void insert(Arc *arc)
Definition: tpl_graph.H:2951
Arc * insert_arc(Node *src_node, Node *tgt_node, const Flow_Type &cap, const Flow_Type &flow, const typename Arc::Arc_Type &arc_info=Arc_Type())
Definition: tpl_net.H:575
void for_each(Operation &operation) noexcept(noexcept(operation))
Definition: htlist.H:589
void make_super_nodes()
Definition: tpl_net.H:443
tuple< typename Net::Arc *, bool > Parc
Definition: tpl_net.H:834
void make_super_sink()
Definition: tpl_net.H:412
size_t get_out_degree(Node *p) const noexcept
Definition: tpl_net.H:296
Definition: tpl_net.H:216
SemiPath< Net > find_aumenting_semi_path(const Net &net, const typename Net::Flow_Type &slack)
Definition: tpl_net.H:1239
bool is_source(Node *node) noexcept
Retorna true si node es fuente.
Definition: tpl_net.H:320
Flow_Type get_out_cap(Node *node) const noexcept
Retorna la capacidad total de salida del nodo node.
Definition: tpl_net.H:279
Definition: tpl_graph.H:1693
size_t out_degree(typename GT::Node *p, SA sa=SA())
Definition: tpl_graph.H:1976
Definition: graph-traverse.H:42
Node * get_sink() const
Retorna un nodo sumidero de la red.
Definition: tpl_net.H:469
SemiPath< Net > find_aum_path(typename Net::Flow_Type min_slack=0.0)
Encuentra un camino de aumento de al menos un slack.
Definition: tpl_net.H:1123
Definition: tpl_dynListQueue.H:50
void unmake_super_nodes()
Definition: tpl_net.H:459
bool check_arc() const noexcept
Definition: tpl_net.H:97
Net::Flow_Type random_preflow_maximum_flow(Net &net)
Definition: tpl_net.H:1933
DynList< typename GT::Node * > out_nodes(typename GT::Node *p, SA sa=SA())
Definition: tpl_graph.H:1829
Net::Flow_Type aumenting_path_maximum_flow(Net &net)
Definition: tpl_net.H:1476
size_t in_degree(typename GT::Node *p, SA sa=SA())
Definition: tpl_graph.H:1948
void copy_graph(GT >gt, const GT &gsrc, const bool cookie_map=false)
Definition: tpl_graph.H:3482
const unsigned char Unprocessed
virtual void remove_arc(Arc *arc)
Elimina de la red el arco arc.
Definition: tpl_net.H:676
#define NODE_COUNTER(p)
Definition: aleph-graph.H:311
T & insert(const T &item)
Definition: htlist.H:1400
const Flow_Type & get_flow(Arc *arc) const noexcept
retorna el valor de capacidad del arco.
Definition: tpl_net.H:761
Net::Flow_Type remaining_flow(typename Net::Node *src, typename Net::Arc *a) noexcept
Definition: tpl_net.H:191
const unsigned char Processed
SemiPath< Net > find_aumenting_semi_path_dfs(const Net &net, const typename Net::Flow_Type &slack)
Definition: tpl_net.H:1260
SemiPath< Net > find_aumenting_semi_path_bfs(const Net &net, const typename Net::Flow_Type &slack)
Definition: tpl_net.H:1281
bool check_network()
Definition: tpl_net.H:784
Definition: tpl_dynBinHeap.H:55
Flow_Type get_in_flow(Node *node) const noexcept
Retorna el valor de flujo de entrada del nodo.
Definition: tpl_net.H:311
Definition: tpl_graph.H:53
Node * insert_node(Node *p)
Definition: tpl_net.H:532
bool with_super_source
true si a la red se le ha añadido un supra fuente.
Definition: tpl_net.H:801
Definition: tpl_agraph.H:43
const Key & get_item() const
Retorna un elemento cualquiera del conjunto.
Definition: tpl_dynSetTree.H:524
DynList< typename GT::Arc * > arcs(typename GT::Node *p, SA sa=SA())
Definition: tpl_graph.H:1893
typename Arc::Flow_Type Flow_Type
Tipo que representa la capacidad y el flujo.
Definition: tpl_net.H:233
void unmake_super_sink() noexcept
Definition: tpl_net.H:430
tuple< bool, typename Net::Flow_Type, DynList< Parc< Net > >> SemiPath
Definition: tpl_net.H:845
ArcT Arc
Tipo de arco.
Definition: tpl_net.H:227
void increase_flow(Net &net, const DynList< Parc< Net >> &semi_path, const typename Net::Flow_Type slack)
Definition: tpl_net.H:947
Arc * insert_arc(Node *src_node, Node *tgt_node, const Flow_Type &cap)
Definition: tpl_net.H:647
bool with_super_sink
true si a la red se le ha añadido un supra sumidero.
Definition: tpl_net.H:804
virtual void remove_node(Node *p) noexcept
Elimina un nodo de una red de flujo junto con todos sus arcos.
Definition: tpl_net.H:714
Path< Net > find_aumenting_path_dfs(const Net &net, const typename Net::Flow_Type &min_slack)
Definition: tpl_net.H:1200
Net::Flow_Type min_cut(Net &net, DynSetTree< typename Net::Node *> &vs, DynSetTree< typename Net::Node *> &vt, DynList< typename Net::Arc *> &cuts, DynList< typename Net::Arc *> &cutt)
Definition: tpl_net.H:2000
void next_ne() noexcept
Definition: tpl_dynDlist.H:433
Flow_Type flow_value() const
Definition: tpl_net.H:794
Container< Arc * > arcs() const
Definition: graph-dry.H:2109
void set_cap(Arc *arc, const Flow_Type &cap)
Coloca valor de capacidad a un arco.
Definition: tpl_net.H:742
tuple< __Graph_Arc *, __Graph_Node *> ArcPair
Pair of arc and node (topologically related)
Definition: graph-dry.H:2553
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Definition: graph-dry.H:447
#define NODE_BITS(p)
Definition: aleph-graph.H:305
Definition: tpl_net.H:2065
const size_t & size() const
Retorna la cardinalidad del conjunto.
Definition: tpl_dynSetTree.H:502
Arc * insert_arc(Node *src_node, Node *tgt_node, const typename Arc::Arc_Type &arc_info=Arc_Type())
Definition: tpl_net.H:669
Node * insert_node(const Node_Type &node_info)
Definition: tpl_net.H:481
Definition: tpl_net.H:1530
bool check_node(Node *node) noexcept
Definition: tpl_net.H:341
Net::Flow_Type ford_fulkerson_maximum_flow(Net &net)
Definition: tpl_net.H:1518
Definition: tpl_dynSetTree.H:61
bool is_single_sink() const noexcept
Retorna true si la red es de un solo sumidero.
Definition: tpl_net.H:329
const DynSetTree< Node * > & get_sink_nodes() const noexcept
Retorna el conjunto de nodos sumidero que contiene la red.
Definition: tpl_net.H:369
Definition: tpl_graph.H:1270
GT::Arc * get_curr_ne() const noexcept
Definition: tpl_graph.H:1734
Path< Net > find_aumenting_path(const Net &net, const typename Net::Flow_Type &min_slack)
Definition: tpl_net.H:1182
void reset_nodes() const
Definition: graph-dry.H:630
const Flow_Type & get_cap(Arc *arc) const noexcept
Retorna el valor de flujo de un arco.
Definition: tpl_net.H:764
DynList< Arc * > out_arcs(Node *p) const noexcept
Arcos que salen desde p.
Definition: tpl_net.H:244
SemiPath< Net > find_decrementing_path_dfs(const Net &net, const typename Net::Flow_Type &slack)
Definition: tpl_net.H:1322
typename GT::Out_Iterator __Out_Iterator
Definition: tpl_graph.H:1780
void disconnect_arc(Arc *arc) noexcept
Definition: tpl_net.H:700
SemiPath< Net > find_decrementing_path_bfs(const Net &net, const typename Net::Flow_Type &slack)
Definition: tpl_net.H:1339
Definition: filter_iterator.H:68
Arc * connect_arc(Arc *arc)
Definition: tpl_net.H:617
Definition: tpl_net.H:1886
typename GT::In_Iterator __In_Iterator
Definition: tpl_graph.H:1788
Node * get_source() const
Retorna un nodo fuente de la red.
Definition: tpl_net.H:466
__Graph_Arc * insert_arc(__Graph_Node *src, __Graph_Node *tgt, const Arc_Type &arc_info)
Definition: graph-dry.H:899
void unmake_super_source() noexcept
Definition: tpl_net.H:398
Flow_Type get_out_flow(Node *node) const noexcept
Retorna el valor de flujo de salida del nodo.
Definition: tpl_net.H:302
Net::Flow_Type fifo_preflow_maximum_flow(Net &net)
Definition: tpl_net.H:1796
bool has_current_arc() const noexcept
Definition: tpl_graph.H:3237
Definition: tpl_graph.H:3135
Node * insert_node(Node_Type &&info=Node_Type())
Definition: tpl_net.H:508
DynList< typename GT::Arc * > in_arcs(typename GT::Node *p, SA sa=SA())
Definition: tpl_graph.H:1878
Net::Flow_Type generic_preflow_vertex_push_maximum_flow(Net &net)
Definition: tpl_net.H:1682
Key * insert(const Key &key)
Definition: tpl_dynSetTree.H:195
Path< Net > find_aumenting_path_bfs(const Net &net, const typename Net::Flow_Type &min_slack)
Definition: tpl_net.H:1216
Definition: tpl_net.H:1946
DynList< typename GT::Node * > in_nodes(typename GT::Node *p, SA sa=SA())
Definition: tpl_graph.H:1846
Definition: tpl_net.H:1573