Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::net_detail Namespace Reference

Classes

struct  Flow_Sum
 A sum of floating flows that keeps the error of its rounding, as hi + lo, by the error-free addition of Knuth: a small flow beside a large one, as 0.53 beside 7e13, which the sum rounds away, comes back when the large one goes. More...
 

Functions

constexpr bool flow_type_ok (const float *) noexcept
 Whether float can be the type of a flow: it can, but it is deprecated, and this overload, which a static assertion of Net_Arc calls, warns it.
 
constexpr bool flow_type_ok (const void *) noexcept
 Whether any type but float can be the type of a flow, as a static assertion of Net_Arc asks: it can (see flow_type_ok(const float *)).
 
template<class Arc , typename Flow_Type >
void add_flow (Arc *arc, const Flow_Type &slack) noexcept
 
template<typename Flow_Type >
Flow_Type node_residue (const Flow_Type &in, const Flow_Type &out, size_t arcs) noexcept
 
template<class Net >
bool not_short (const Net &net, typename Net::Node *p)
 
template<class Arc , typename Flow_Type >
void subtract_flow (Arc *arc, const Flow_Type &slack) noexcept
 
template<class Net >
void node_flows (const Net &net, typename Net::Node *p, Flow_Sum< typename Net::Flow_Type > &in, Flow_Sum< typename Net::Flow_Type > &out) noexcept
 
template<class Arc , typename Flow_Type >
void push_excess (Arc *arc, bool forward, Flow_Sum< Flow_Type > &in, Flow_Sum< Flow_Type > &out) noexcept
 
template<class Net >
void return_dust (Net &net, typename Net::Node *source, typename Net::Node *sink)
 Returns the dust of a floating flow that a preflow algorithm left in net, from source to sink: what each node but them keeps beyond the tolerance of check_node() goes back toward the source, along arcs with flow from it, and what each sends beyond it that it does not receive goes forward toward the sink, along arcs with flow to it; what a node still keeps or lacks beyond that tolerance, as on an island of arcs with flow apart from both, goes along a shortest path of arcs with flow to the first node that takes it; and when nothing reaches the sink, what still leaves the source, which the rounding of the sums of the nodes may hide, is taken from the arcs of the source with the least flow, if it is within the tolerances of the nodes (and the other way).
 
template<class Net >
bool fill_infinite_path (Net &net)
 
template<class Net >
Net::Flow_Type infinite_arc_preflow (const Net &net)
 
template<class Arc >
auto residual_room (const Arc *a) noexcept
 What a residual arc of a floating flow has left: if it is a mirror, the flow of its image, exactly; else its capacity less its flow.
 
template<typename Flow_Type >
bool without_capacity (const Flow_Type &cap) noexcept
 Whether an arc of capacity cap has none: infinite, or max()
 
template<class Net >
void refuse_infinite_maximum_flow (const Net &net, const char *algorithm)
 Refuse an infinite maximum flow before minimizing its cost.
 

Function Documentation

◆ add_flow()

template<class Arc , typename Flow_Type >
void Aleph::net_detail::add_flow ( Arc *  arc,
const Flow_Type &  slack 
)
inlinenoexcept

◆ fill_infinite_path()

◆ flow_type_ok() [1/2]

constexpr bool Aleph::net_detail::flow_type_ok ( const float *  )
constexprnoexcept

Whether float can be the type of a flow: it can, but it is deprecated, and this overload, which a static assertion of Net_Arc calls, warns it.

The tolerances of the floating flows are relative to the data and to the epsilon of the type, which for float, 1.2e-7, is 2^29 times that of double: so the far magnitude that hides the real improvements comes with ordinary data, as an arc of cost 500 hides from the cycle canceling the cycles of cost -1 among the others on a network of 100 nodes, without notice; the tolerance of check_node(), 1e-9, is below its epsilon; and its integers stay exact only up to 2^24. Use double: float is rejected in 8.0.0. The warning comes from this header, so that a pragma around the code that uses the network does not silence it; including the headers between #pragma GCC diagnostic push, #pragma GCC diagnostic ignored "-Wdeprecated-declarations" and #pragma GCC diagnostic pop does, while moving to double.

Returns
true.

Definition at line 127 of file tpl_net.H.

◆ flow_type_ok() [2/2]

constexpr bool Aleph::net_detail::flow_type_ok ( const void *  )
constexprnoexcept

Whether any type but float can be the type of a flow, as a static assertion of Net_Arc asks: it can (see flow_type_ok(const float *)).

Returns
true.

Definition at line 137 of file tpl_net.H.

◆ infinite_arc_preflow()

◆ node_flows()

template<class Net >
void Aleph::net_detail::node_flows ( const Net &  net,
typename Net::Node *  p,
Flow_Sum< typename Net::Flow_Type > &  in,
Flow_Sum< typename Net::Flow_Type > &  out 
)
noexcept

◆ node_residue()

template<typename Flow_Type >
Flow_Type Aleph::net_detail::node_residue ( const Flow_Type &  in,
const Flow_Type &  out,
size_t  arcs 
)
inlinenoexcept

Definition at line 1250 of file tpl_net.H.

References arcs, and out.

Referenced by Aleph::generic_preflow_vertex_push_maximum_flow(), and Aleph::hlpp_maximum_flow().

◆ not_short()

template<class Net >
bool Aleph::net_detail::not_short ( const Net &  net,
typename Net::Node *  p 
)

◆ push_excess()

template<class Arc , typename Flow_Type >
void Aleph::net_detail::push_excess ( Arc *  arc,
bool  forward,
Flow_Sum< Flow_Type > &  in,
Flow_Sum< Flow_Type > &  out 
)
inlinenoexcept

◆ refuse_infinite_maximum_flow()

template<class Net >
void Aleph::net_detail::refuse_infinite_maximum_flow ( const Net &  net,
const char *  algorithm 
)

Refuse an infinite maximum flow before minimizing its cost.

A path from the source to the sink of arcs of infinite capacity makes the maximum flow infinite, which has no cost to minimize: the network simplex took it as a flow that is not feasible, and the cycle canceling returned it with an infinite cost. The network keeps the flow.

Parameters
[in]netNetwork with the maximum flow.
[in]algorithmName of the algorithm, for the message.
Exceptions
std::domain_errorIf the flow of net is infinite.

Definition at line 516 of file tpl_netcost.H.

References ah_domain_error_if, and Aleph::Net_Graph< NodeT, ArcT >::flow_value().

Referenced by Aleph::max_flow_min_cost_by_cycle_canceling(), and Aleph::max_flow_min_cost_by_network_simplex().

◆ residual_room()

template<class Arc >
auto Aleph::net_detail::residual_room ( const Arc *  a)
inlinenoexcept

What a residual arc of a floating flow has left: if it is a mirror, the flow of its image, exactly; else its capacity less its flow.

A mirror keeps cap - flow as its flow, and cap - (cap - flow) is NaN for an infinite capacity, and 0 for max() with a small flow

Definition at line 380 of file tpl_netcost.H.

Referenced by Aleph::cancel_cycle(), and Aleph::Res_Filt_With_Tolerance< Net >::operator()().

◆ return_dust()

template<class Net >
void Aleph::net_detail::return_dust ( Net &  net,
typename Net::Node *  source,
typename Net::Node *  sink 
)

Returns the dust of a floating flow that a preflow algorithm left in net, from source to sink: what each node but them keeps beyond the tolerance of check_node() goes back toward the source, along arcs with flow from it, and what each sends beyond it that it does not receive goes forward toward the sink, along arcs with flow to it; what a node still keeps or lacks beyond that tolerance, as on an island of arcs with flow apart from both, goes along a shortest path of arcs with flow to the first node that takes it; and when nothing reaches the sink, what still leaves the source, which the rounding of the sums of the nodes may hide, is taken from the arcs of the source with the least flow, if it is within the tolerances of the nodes (and the other way).

What a node keeps or lacks within its tolerance stays: it is the rounding of the sums of its flows, as 0.1 + 0.8 in and their rounded sum out, and returning it lowered by an ulp an arc that the flow saturates, as one of a minimum cut, so that a path of residual capacity went from the source to the sink. Flows only go down. Afterwards every node keeps its flow within the tolerance of check_node(), and a network whose maximum flow is 0 gives 0. Nothing for an integer flow, and, but a pass over the nodes, nothing if no node keeps or lacks any flow. O((b + 1)(V + E) + d log d), where b, the number of searches, is about that of the nodes that the first moves leave beyond their tolerance, at most V + E, and d is the degree of the source or the sink. The augmenting paths return theirs too.

Definition at line 1410 of file tpl_net.H.

References Aleph::and, Aleph::Array< T >::append(), Aleph::between(), Aleph::Array< T >::clear(), Aleph::Array< T >::create(), GraphCommon< GT, Node, Arc >::esize(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), Aleph::Array_Graph< __Graph_Node, __Graph_Arc >::Node_Arc_Iterator::has_curr(), Aleph::introsort(), k, m, Aleph::next(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_COOKIE, Aleph::Net_Graph< NodeT, ArcT >::node_tolerance(), out, Aleph::Array< T >::reserve(), Aleph::search(), Aleph::Array< T >::size(), GraphCommon< GT, Node, Arc >::vsize(), and w.

Referenced by Aleph::aumenting_path_maximum_flow(), Aleph::capacity_scaling_maximum_flow(), Aleph::dinic_maximum_flow(), Aleph::generic_preflow_vertex_push_maximum_flow(), Aleph::hlpp_maximum_flow(), Aleph::max_flow_min_cost_by_cycle_canceling(), Aleph::Network_Simplex< Net >::run(), Aleph::successive_shortest_paths(), TEST(), and TEST().

◆ subtract_flow()

template<class Arc , typename Flow_Type >
void Aleph::net_detail::subtract_flow ( Arc *  arc,
const Flow_Type &  slack 
)
inlinenoexcept

◆ without_capacity()

template<typename Flow_Type >
bool Aleph::net_detail::without_capacity ( const Flow_Type &  cap)
inlinenoexcept

Whether an arc of capacity cap has none: infinite, or max()

Definition at line 498 of file tpl_netcost.H.

Referenced by Aleph::cancel_cycle(), Aleph::max_flow_min_cost_by_cycle_canceling(), and Aleph::Network_Simplex< Net >::without_capacity().