4 # include <tpl_netgraph.H>
34 typename Net::Node * source = NULL;
35 long min_degree = numeric_limits<long>::max();
38 typename GT::Node * p = it.get_current();
40 if (g.get_num_arcs(p) < min_degree)
42 source = mapped_node<GT, Net> (p);
43 min_degree = g.get_num_arcs(p);
52 typename GT::Arc * a = it.get_current();
53 typename Net::Node * src = mapped_node<GT, Net> (g.get_src_node(a));
54 typename Net::Node * tgt = mapped_node<GT, Net> (g.get_tgt_node(a));
56 net.insert_arc(tgt, src, 1);
59 net.insert_arc(src, tgt, 1);
62 I(source->in_degree == 0);
64 long min_k = min_degree;
67 typename Net::Node * sink = it.get_current();
74 from_sink_arcs.
append(it.get_current());
78 net.disconnect_arc(it.get_current());
80 const typename Net::Flow_Type flow = Max_Flow <Net> () (net);
84 while (not from_sink_arcs.
is_empty())
85 net.connect_arc(from_sink_arcs.
get());
125 long operator () (GT & g) {
return edge_connectivity <GT, Max_Flow> (g); }
167 typename Net::Node * source = NULL;
168 long min_degree = numeric_limits<long>::max();
171 typename GT::Node * p = it.get_current();
172 typename Net::Node * q = net.insert_node();
173 GT::map_nodes (p, q);
175 if (g.get_num_arcs(p) < min_degree)
177 source = mapped_node<GT, Net> (p);
178 min_degree = g.get_num_arcs(p);
187 typename GT::Arc * a = it.get_current();
188 typename Net::Node * src = mapped_node<GT, Net>(g.get_src_node(a));
189 typename Net::Node * tgt = mapped_node<GT, Net>(g.get_tgt_node(a));
192 typename Net::Arc * arc = net.insert_arc(tgt, src, 1);
198 typename Net::Arc * arc = net.insert_arc(src, tgt, 1);
205 long min_k = numeric_limits<long>::max();
208 typename Net::Node * sink = it.get_current();
215 from_sink_arcs.
append(it.get_current());
219 net.disconnect_arc(it.get_current());
223 const typename Net::Flow_Type flow =
237 while (not from_sink_arcs.
is_empty())
238 net.connect_arc(from_sink_arcs.
get());
242 it = tmp_vs.
begin(); it != tmp_vs.
end(); it++)
243 l.
insert(mapped_node <Net, GT> (*it));
246 it = tmp_vt.
begin(); it != tmp_vt.
end(); it++)
247 r.
insert(mapped_node <Net, GT> (*it));
252 typename Net::Arc* arc = it.get_current();
253 cut.
append(mapped_arc<Net, GT> (arc));
294 long operator () (GT & g,
299 return compute_min_cut <GT, Max_Flow, SA> (g, l, r, cut);
324 typename GT::Node * p = it.get_current();
330 typename GT::Arc * a = it.get_current();
331 typename Net::Node * src = mapped_node<GT,Net>(g.get_src_node(a));
332 typename Net::Node * tgt = mapped_node<GT,Net>(g.get_tgt_node(a));
333 net.insert_arc(tgt, src, 1);
334 net.insert_arc(src, tgt, 1);
337 long min_k = g.get_num_nodes();
342 typename Net::Node * source = k.get_current();
347 typename Net::Arc * from_arc = it.get_current();
348 typename Net::Arc * to_arc =
349 search_arc <Net> (net, net.get_tgt_node(from_arc), source);
351 I(net.get_tgt_node(to_arc) == source);
352 to_source_list.
append(to_arc);
357 net.disconnect_arc(it.get_current());
361 for (j.
next(); j.has_current(); j.
next())
363 typename Net::Node * sink = j.get_current();
364 if (search_arc <Net> (net, source, sink) != NULL)
370 from_sink_arcs.
append(it.get_current());
374 net.disconnect_arc(it.get_current());
381 typename Net::Node * p = it.get_current();
382 if (p == source or p == sink)
388 typename Net::Node * ps =
389 aux_net.insert_node(p->get_info());
390 typename Net::Node * pt =
391 aux_net.insert_node(p->get_info());
392 map.
insert(p, aux_net.insert_arc(ps, pt, 1));
397 typename Net::Arc * a = it.get_current();
399 typename Net::Node * nsrc = net.get_src_node(a);
400 typename Net::Node * ntgt = net.get_tgt_node(a);
401 typename Net::Node * asrc = NULL;
402 typename Net::Node * atgt = NULL;
408 typename Net::Arc * arc = map.
find(nsrc);
409 asrc = aux_net.get_tgt_node(arc);
416 typename Net::Arc * arc = map.
find(ntgt);
417 atgt = aux_net.get_src_node(arc);
419 aux_net.insert_arc(asrc, atgt, 1);
423 const typename Net::Flow_Type flow = Max_Flow <Net> () (aux_net);
428 while (not from_sink_arcs.
is_empty())
429 net.connect_arc(from_sink_arcs.
get());
434 while (not to_source_list.
is_empty())
435 net.connect_arc(to_source_list.
get());
445 # endif // TPL_KGRAPH_H
void swap(DynDlist &l)
Definition: tpl_dynDlist.H:295
long compute_min_cut(GT &g, Aleph::set< typename GT::Node * > &l, Aleph::set< typename GT::Node * > &r, DynDlist< typename GT::Arc * > &cut)
Definition: tpl_kgraph.H:160
Definition: tpl_netgraph.H:66
#define NODE_COOKIE(p)
Definition: aleph-graph.H:248
Definition: tpl_dynDlist.H:26
Definition: tpl_graph.H:751
Definition: tpl_netgraph.H:1708
iterator begin()
Retorna un iterador posicionado al primer elemento del conjunto.
Definition: Set.H:459
void swap(set &c)
Definition: Set.H:453
#define ARC_COOKIE(p)
Definition: aleph-graph.H:281
Definition: tpl_dynDlist.H:332
long vertex_connectivity(GT &g)
Definition: tpl_kgraph.H:318
std::pair< iterator, bool > insert(const T &value)
Definition: Set.H:488
bool has_current() const
Retorna true si iterador aún tiene elemento actual.
Definition: dlink.H:554
Definition: tpl_kgraph.H:291
Definition: tpl_graph.H:634
void next()
Adelanta el iterador una posición.
Definition: filter_iterator.H:143
Definition: tpl_netgraph.H:2326
Definition: tpl_dynMapTree.H:289
Definition: tpl_kgraph.H:111
Definition: tpl_netgraph.H:205
Definition: tpl_graph.H:814
long operator()(GT &g)
Definition: tpl_kgraph.H:125
T get()
Si this es una cola, entonces extrae el elemento más antiguo.
Definition: tpl_dynDlist.H:250
Definition: tpl_netgraph.H:1646
long edge_connectivity(GT &g)
Definition: tpl_kgraph.H:30
iterator end()
Retorna un iterador posicionado al último elemento del conjunto.
Definition: Set.H:465
Definition: tpl_graph.H:694
bool is_empty() const
retorna true si this está vacía
Definition: dlink.H:127
Key * insert(const Key &key, const Type &data)
Definition: tpl_dynMapTree.H:74
T & append(const T &item)
Definition: tpl_dynDlist.H:106
Type & find(const Key &key)
Definition: tpl_dynMapTree.H:223