27 #line 620 "reducciones.nw" 28 # ifndef TPL_NET_SUP_DEM_H 29 # define TPL_NET_SUP_DEM_H 31 # include <tpl_netgraph.H> 35 #line 586 "reducciones.nw" 40 template <
typename Node_Info,
typename F_Type =
long>
47 Flow_Type supply_flow;
56 :
Net_Node<Node_Info, F_Type>(node_info), supply_flow(0) { }
61 :
Net_Node<Node_Info, F_Type>(*node), supply_flow(node->supply_flow) { }
64 #line 629 "reducciones.nw" 81 template <
class NodeT = Net_Sup_Dem_Node<Empty_Class,
double>,
82 class ArcT = Net_Arc<Empty_Class,
double> >
100 #line 675 "reducciones.nw" 111 Node *
insert_node(
const Node_Type & node_info,
const Flow_Type & supply = 0)
113 Node * p = Net_Class::insert_node(node_info);
114 p->supply_flow = supply;
130 #line 719 "reducciones.nw" 141 return super_source !=
nullptr or super_sink !=
nullptr;
144 #line 739 "reducciones.nw" 172 throw std::domain_error(
"Auxiliar net is already computed");
173 if (this->residual_net)
174 throw std::domain_error(
"Residual net has been already computed");
176 super_source = insert_node();
177 super_sink = insert_node();
179 for (Node_Iterator<Net_Sup_Dem_Graph> it(*
this); it.has_curr(); it.next_ne())
181 Node * p = it.get_curr_ne();
182 if (p->supply_flow > 0)
184 if (p->out_cap < p->supply_flow)
185 throw std::range_error(gnu::autosprintf(
"Supply flow in node at %p is " 186 "greater than out capacity", p));
187 insert_arc(super_source, p, p->supply_flow);
189 else if (p->supply_flow < 0)
191 if (p->in_cap < -p->supply_flow)
192 throw std::range_error(gnu::autosprintf(
"Supply flow in node at %p is " 193 "smaller than in capacity", p));
194 insert_arc(p, super_sink, -p->supply_flow);
197 if (this->get_out_degree(super_source) == 0)
199 remove_node(super_source);
200 super_source =
nullptr;
202 if (this->get_in_degree(super_sink) == 0)
204 remove_node(super_sink);
205 super_sink =
nullptr;
209 #line 825 "reducciones.nw" 211 #line 833 "reducciones.nw" 221 if (not exist_aux_net())
222 throw std::domain_error(
"Auxiliar net has not been computed");
223 for (Node_Iterator<Net_Sup_Dem_Graph> it(*
this); it.has_curr(); it.next_ne())
225 Node * p = it.get_curr_ne();
226 Flow_Type & supply_flow = p->supply_flow;
227 if (supply_flow == 0)
229 if (supply_flow > 0 and p->out_flow < supply_flow)
231 else if (supply_flow < 0 and p->in_flow < -supply_flow)
254 for (Node_Iterator<Net_Sup_Dem_Graph> it(*
this); it.has_curr(); it.next_ne())
256 Node * p = it.get_curr_ne();
257 Flow_Type & supply_flow = p->supply_flow;
258 if (supply_flow == 0)
260 if (supply_flow > 0 and p->out_flow < supply_flow)
262 else if (supply_flow < 0 and p->in_flow < -supply_flow)
266 #line 895 "reducciones.nw" 282 if (supply > 0 and p->out_cap < supply)
283 throw std::range_error(gnu::autosprintf(
"Supply flow in node at %p is " 284 "greater than out capacity", p));
285 else if (supply < 0 and p->in_cap < -supply)
286 throw std::range_error(gnu::autosprintf(
"Supply flow in node at %p is " 287 "smaller than in capacity", p));
288 p->supply_flow = supply;
290 #line 922 "reducciones.nw" 294 if (not exist_aux_net())
295 throw std::domain_error(
"Auxiliar net has not been computed");
297 if (this->residual_net)
299 this->unmake_residual_net();
300 this->unmake_super_nodes();
302 if (super_source !=
nullptr)
304 remove_node(super_source);
305 super_source =
nullptr;
307 if (super_sink !=
nullptr)
309 remove_node(super_sink);
310 super_sink =
nullptr;
313 #line 664 "reducciones.nw" 318 # endif // TPL_NET_SUP_DEM_H Definition: tpl_net_sup_dem.H:83
F_Type Flow_Type
Tipo que representa el flujo.
Definition: tpl_net_sup_dem.H:45
NodeT Node
Tipo de node.
Definition: tpl_net_sup_dem.H:91
Net_Sup_Dem_Node(Net_Sup_Dem_Node *node)
Definition: tpl_net_sup_dem.H:60
Definition: tpl_dynDlist.H:51
Definition: tpl_net_sup_dem.H:41
Definition: tpl_net.H:216
void non_feasible_nodes(DynDlist< Node *> &supply_list, DynDlist< Node *> &demand_list)
Definition: tpl_net_sup_dem.H:252
Node * insert_node(const Node_Type &node_info, const Flow_Type &supply=0)
Definition: tpl_net_sup_dem.H:111
Node::Node_Type Node_Type
Tipo de atributo que almacena un nodo.
Definition: tpl_net_sup_dem.H:95
Definition: tpl_agraph.H:43
Node * insert_node(const Flow_Type &supply=0)
Definition: tpl_net_sup_dem.H:126
NodeInfo Node_Type
The node.
Definition: graph-dry.H:233
Net_Sup_Dem_Graph * compute_aux_net()
Definition: tpl_net_sup_dem.H:169
Net_Sup_Dem_Node(const Node_Info &node_info)
Definition: tpl_net_sup_dem.H:55
void set_supply_flow(Node *p, const Flow_Type &supply)
Definition: tpl_net_sup_dem.H:280
Net_Graph< NodeT, ArcT > Net_Class
La clase de red tradicional.
Definition: tpl_net_sup_dem.H:87
bool is_feasible() const
Definition: tpl_net_sup_dem.H:219
Flow_Type & get_supply_flow()
Retorna el valor de provisión del nodo.
Definition: tpl_net_sup_dem.H:49
ArcT Arc
Tipo de arco.
Definition: tpl_net_sup_dem.H:89
Arc::Flow_Type Flow_Type
Tipo que representa la capacidad y el flujo.
Definition: tpl_net_sup_dem.H:93
T & append(const T &item)
Definition: tpl_dynDlist.H:149
bool exist_aux_net() const
Retorna true si la red auxiliar ya ha sido creada.
Definition: tpl_net_sup_dem.H:139
Arc::Arc_Type Arc_Type
Tipo de atributo que almacena un arco.
Definition: tpl_net_sup_dem.H:97