Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_net.H File Reference

Network flow graph structures. More...

#include <algorithm>
#include <cmath>
#include <limits>
#include <set>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include <tpl_array.H>
#include <tpl_sort_utils.H>
#include <tpl_dynDlist.H>
#include <tpl_dynListStack.H>
#include <tpl_dynBinHeap.H>
#include <tpl_dynSetTree.H>
#include <tpl_dynSetHash.H>
#include <tpl_random_queue.H>
#include <tpl_graph_utils.H>
#include <tpl_find_path.H>
#include <graph-traverse.H>
#include <ah-errors.H>
#include <cookie_guard.H>
Include dependency graph for tpl_net.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::Net_Arc_Info< Arc_Info, Flow_Type >
 Arc info extension that stores capacity and flow values. More...
 
struct  Aleph::Net_Arc< Arc_Info, F_Type >
 Arc of a flow network implemented with adjacency lists. More...
 
struct  Aleph::Net_Filt< Net >
 Arc filter for residual traversal in flow networks. More...
 
struct  Aleph::Net_Graph< NodeT, ArcT >
 Flow network implemented with adjacency lists. More...
 
struct  Aleph::net_detail::Flow_Sum< Flow_Type >
 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...
 
class  Aleph::Find_Aumenting_Path< Net, Q >
 Augmenting-path search over a directed network. More...
 
struct  Aleph::PP_Res_Node< Net >
 Residual node used by preflow-push algorithms. More...
 
struct  Aleph::__Res_Arc< Net >
 Arc of the residual network of the preflow-push algorithms. More...
 
struct  Aleph::Res_F< Rnet >
 Residual arc filter: keep arcs with residual capacity. More...
 
struct  Aleph::Ford_Fulkerson_Maximum_Flow< Net >
 Functor wrapper for ford_fulkerson_maximum_flow(). More...
 
struct  Aleph::Edmonds_Karp_Maximum_Flow< Net >
 Functor wrapper for edmonds_karp_maximum_flow(). More...
 
struct  Aleph::Fifo_Preflow_Maximum_Flow< Net >
 Functor wrapper for fifo_preflow_maximum_flow(). More...
 
struct  Aleph::Compare_Height< Net >
 Compare nodes by height (higher first). More...
 
struct  Aleph::Heap_Preflow_Maximum_Flow< Net >
 Functor wrapper for heap_preflow_maximum_flow(). More...
 
struct  Aleph::Random_Preflow_Maximum_Flow< Net >
 Functor wrapper for random_preflow_maximum_flow(). More...
 
struct  Aleph::Min_Cut< Net, Maxflow >
 Functor wrapper for min_cut(). More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::net_detail
 

Typedefs

template<class Net >
using Aleph::__Net_Iterator = Digraph_Iterator< Net, Net_Filt< Net > >
 
template<class Net , class Show_Arc = Dft_Show_Arc<Net>>
using Aleph::Net_Iterator = Filter_Iterator< typename Net::Node *, __Net_Iterator< Net >, Show_Arc >
 Residual-graph iterator adapter for flow networks.
 
template<typename Node_Info = Empty_Class>
using Aleph::Net_Node = Graph_Anode< Node_Info >
 Node type for flow networks.
 
template<class Net >
using Aleph::Parc = std::tuple< typename Net::Arc *, bool >
 Arc entry for a semi-path.
 
template<class Net >
using Aleph::SemiPath = std::tuple< bool, typename Net::Flow_Type, DynList< Parc< Net > > >
 Semi-path tuple:
 
template<class Net >
using Aleph::Find_Aumenting_Path_DFS = Find_Aumenting_Path< Net, DynListStack >
 Augmenting-path finder using DFS (stack).
 
template<class Net >
using Aleph::Find_Aumenting_Path_BFS = Find_Aumenting_Path< Net, DynListQueue >
 Augmenting-path finder using BFS (queue).
 
template<class Net >
using Aleph::AP_Res_Net = Array_Digraph< Net_Node< Empty_Class >, __Res_Arc< Net > >
 Residual network for augmenting-path algorithms.
 
template<class Net >
using Aleph::PP_Res_Net = Array_Digraph< PP_Res_Node< Net >, __Res_Arc< Net > >
 Residual network for preflow-push algorithms.
 

Functions

constexpr bool Aleph::net_detail::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 Aleph::net_detail::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 Net >
bool Aleph::is_residual (typename Net::Node *src, typename Net::Arc *a) noexcept
 Return true if arc a is residual with respect to src.
 
template<class Net >
Net::Flow_Type Aleph::remaining_flow (typename Net::Node *src, typename Net::Arc *a) noexcept
 Return the remaining flow of a as seen from src.
 
template<class Net >
void Aleph::print (const DynList< Parc< Net > > &sp)
 Print a semi-path to stdout.
 
template<class Arc , typename Flow_Type >
void Aleph::net_detail::add_flow (Arc *arc, const Flow_Type &slack) noexcept
 
template<typename Flow_Type >
Flow_Type Aleph::net_detail::node_residue (const Flow_Type &in, const Flow_Type &out, size_t arcs) noexcept
 
template<class Net >
bool Aleph::net_detail::not_short (const Net &net, typename Net::Node *p)
 
template<class Arc , typename Flow_Type >
void Aleph::net_detail::subtract_flow (Arc *arc, const Flow_Type &slack) noexcept
 
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
 
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) noexcept
 
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).
 
template<class Net >
Net::Flow_Type Aleph::increase_flow (Net &net, const Path< Net > &path)
 Increase flow along an augmenting path.
 
template<class Net >
void Aleph::increase_flow (Net &net, const DynList< Parc< Net > > &semi_path, const typename Net::Flow_Type slack)
 Increase flow along a semi-path by a given slack.
 
template<class Net >
void Aleph::decrease_flow (Net &net, const DynList< Parc< Net > > &semi_path, const typename Net::Flow_Type slack)
 Decrease flow along a semi-path by a given slack.
 
template<class Net , template< typename T > class Q>
Path< Net > Aleph::find_aumenting_path (const Net &net, const typename Net::Flow_Type &min_slack)
 Find an augmenting path using DFS or BFS based on Q.
 
template<class Net >
Path< Net > Aleph::find_aumenting_path_dfs (const Net &net, const typename Net::Flow_Type &min_slack)
 Find an augmenting path using DFS.
 
template<class Net >
Path< Net > Aleph::find_aumenting_path_bfs (const Net &net, const typename Net::Flow_Type &min_slack)
 Find an augmenting path using BFS.
 
template<class Net , template< typename T > class Q>
SemiPath< Net > Aleph::find_aumenting_semi_path (const Net &net, const typename Net::Flow_Type &slack)
 Find an augmenting semi-path using DFS or BFS based on Q.
 
template<class Net >
SemiPath< Net > Aleph::find_aumenting_semi_path_dfs (const Net &net, const typename Net::Flow_Type &slack)
 Find an augmenting semi-path using DFS.
 
template<class Net >
SemiPath< Net > Aleph::find_aumenting_semi_path_bfs (const Net &net, const typename Net::Flow_Type &slack)
 Find an augmenting semi-path using BFS.
 
template<class Net , template< typename T > class Q>
SemiPath< Net > Aleph::find_decrementing_path (const Net &net, const typename Net::Flow_Type &slack)
 Find a decrementing semi-path using DFS or BFS based on Q.
 
template<class Net >
SemiPath< Net > Aleph::find_decrementing_path_dfs (const Net &net, const typename Net::Flow_Type &slack)
 Find a decrementing semi-path using DFS.
 
template<class Net >
SemiPath< Net > Aleph::find_decrementing_path_bfs (const Net &net, const typename Net::Flow_Type &slack)
 Find a decrementing semi-path using BFS.
 
template<class Net >
void Aleph::create_residual_arc (const Net &net, PP_Res_Net< Net > &rnet, typename Net::Arc *a)
 Create residual arcs for a in the residual network.
 
template<class Net >
std::tuple< PP_Res_Net< Net >, typename PP_Res_Net< Net >::Node *, typename PP_Res_Net< Net >::Node * > Aleph::preflow_create_residual_net (Net &net)
 Build the residual network for preflow-push algorithms.
 
template<class Rnet >
void Aleph::update_flow (const Rnet &rnet)
 Propagate residual arc flows back to their original arcs.
 
template<class Net , template< class > class Find_Path>
Net::Flow_Type Aleph::aumenting_path_maximum_flow (Net &net)
 Maximize flow using repeated augmenting-path searches.
 
template<class Net >
Net::Flow_Type Aleph::ford_fulkerson_maximum_flow (Net &net)
 Maximize flow using the Ford-Fulkerson algorithm.
 
template<class Net >
Net::Flow_Type Aleph::edmonds_karp_maximum_flow (Net &net)
 Maximize flow using the Edmonds-Karp algorithm.
 
template<class Net >
static bool Aleph::is_node_active (const Net &net, typename Net::Node *p)
 Return true if p has excess flow in net.
 
template<class Rnet >
static bool Aleph::is_node_active (typename Rnet::Node *p)
 Return true if residual node p has excess flow.
 
template<class Net >
static long & Aleph::node_height (typename Net::Node *p)
 Access the height label stored in NODE_COUNTER.
 
template<class Net >
static void Aleph::init_height_in_nodes (Net &net)
 Initialize node heights with BFS distance to the sink.
 
template<class Q_Type >
static void Aleph::put_in_active_queue (Q_Type &q, typename Q_Type::Item_Type &p)
 Enqueue an active node if it is not already enqueued.
 
template<class Q_Type >
static Q_Type::Item_Type Aleph::get_from_active_queue (Q_Type &q)
 Dequeue an active node and clear its queue mark.
 
template<class Q_Type >
static void Aleph::remove_from_active_queue (Q_Type &q, typename Q_Type::Item_Type &p)
 Remove a node from the active queue and clear its queue mark.
 
template<class Net >
bool Aleph::net_detail::fill_infinite_path (Net &net)
 
template<class Net >
Net::Flow_Type Aleph::net_detail::infinite_arc_preflow (const Net &net)
 
template<class Net , class Q_Type >
Net::Flow_Type Aleph::generic_preflow_vertex_push_maximum_flow (Net &net, Q_Type q=Q_Type())
 Generic preflow-push maximum flow (vertex-oriented).
 
template<class Rnet >
void Aleph::init_height_in_nodes (Rnet &rnet, typename Rnet::Node *sink)
 Initialize node heights in a residual network from sink.
 
template<class Net >
Net::Flow_Type Aleph::fifo_preflow_maximum_flow (Net &net)
 Preflow-push maximum flow using a FIFO queue of active nodes.
 
template<class Net >
Net::Flow_Type Aleph::heap_preflow_maximum_flow (Net &net)
 Preflow-push maximum flow using a height-ordered heap.
 
template<class Net >
Net::Flow_Type Aleph::random_preflow_maximum_flow (Net &net)
 Preflow-push maximum flow using a random active-node queue.
 
template<class Net >
Net::Flow_Type Aleph::random_preflow_maximum_flow (Net &net, const unsigned long seed)
 Preflow-push maximum flow using a random active-node queue whose order takes the seed seed.
 
template<class Net , template< class > class Maxflow>
Net::Flow_Type Aleph::min_cut (Net &net, DynSetTree< typename Net::Node * > &vs, DynSetTree< typename Net::Node * > &vt, DynList< typename Net::Arc * > &cuts, DynList< typename Net::Arc * > &cutt)
 Compute max flow and the corresponding minimum cut.
 

Detailed Description

Network flow graph structures.

Defines graph structures for network flow problems with capacities, flows, and source/sink management.

Features

  • Capacity and flow on arcs
  • Source and sink node management
  • Residual graph computation
See also
tpl_maxflow.H Maximum flow algorithms
tpl_netcost.H Minimum cost flow
Author
Leandro Rabindranath León

Definition in file tpl_net.H.