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

Maximum flows, cuts, decompositions, minimum costs, assignments and the applications of the networks on every small network, against the oracles. More...

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <limits>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <random>
#include <set>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include <gmpxx.h>
#include <gtest/gtest.h>
#include "allocation_failure.H"
#include <tpl_net.H>
#include <tpl_maxflow.H>
#include <tpl_netcost.H>
#include <tpl_mincost.H>
#include <tpl_netcapgraph.H>
#include <tpl_net_sup_dem.H>
#include <net_apps.H>
#include <Hungarian.H>
#include <Johnson.H>
#include "graph_harness.H"
#include "graph_oracles.H"
Include dependency graph for graph_exhaustive_flow_test.cc:

Go to the source code of this file.

Classes

class  ExhaustiveMaxFlow< Net >
 
class  ExhaustiveMaxFlowCapacities< Net >
 
class  ExhaustiveMinCost< Net >
 
class  ExhaustiveAssignment< C >
 
class  ExhaustiveNodeCapacities< Net >
 
class  ExhaustiveFlowMemory
 

Concepts

concept  @923::Cost_Network
 

Typedefs

using Flow_Nets = ::testing::Types< Net_Graph< Net_Node< int >, Net_Arc< int, int > >, Net_Graph< Net_Node< int >, Net_Arc< int, double > >, Net_Cost_Graph< Net_Cost_Node< int >, Net_Cost_Arc< Empty_Class, long > > >
 The networks of integers, of floating flows and of costs.
 
using Capacity_Nets = ::testing::Types< Net_Graph< Net_Node< int >, Net_Arc< int, int > >, Net_Graph< Net_Node< int >, Net_Arc< int, double > > >
 The networks of integers and of floating flows.
 
using Cost_Nets = ::testing::Types< Net_Cost_Graph< Net_Cost_Node< int >, Net_Cost_Arc< Empty_Class, long > >, Net_Cost_Graph< Net_Cost_Node< int >, Net_Cost_Arc< Empty_Class, double > > >
 The networks with costs, of integers and of floating flows.
 
using Cost_Types = ::testing::Types< int, long, double >
 The types of the costs: integers and floating.
 
using Node_Cap_Nets = ::testing::Types< Net_Cap_Graph< Net_Cap_Node< int, long >, Net_Arc< int, long > >, Net_Cap_Graph< Net_Cap_Node< int, double >, Net_Arc< int, double > > >
 

Functions

 TYPED_TEST_SUITE (ExhaustiveMaxFlow, Flow_Nets)
 
 TYPED_TEST (ExhaustiveMaxFlow, AugmentingPathsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveMaxFlow, PreflowsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveMaxFlow, RandomPreflowMatchesTheOracle)
 
 TYPED_TEST (ExhaustiveMaxFlow, DinicScalingAndHlppMatchTheOracle)
 
 TYPED_TEST_SUITE (ExhaustiveMaxFlowCapacities, Capacity_Nets)
 
 TYPED_TEST (ExhaustiveMaxFlowCapacities, AugmentingPathsTakeEveryCapacity)
 
 TYPED_TEST (ExhaustiveMaxFlowCapacities, PreflowsTakeEveryCapacity)
 
 TYPED_TEST (ExhaustiveMaxFlowCapacities, RandomPreflowTakesEveryCapacity)
 
 TYPED_TEST (ExhaustiveMaxFlowCapacities, DinicScalingAndHlppTakeEveryCapacity)
 
 TYPED_TEST (ExhaustiveMaxFlow, MaxFlowsFromAFlowAlreadyThere)
 
 TYPED_TEST (ExhaustiveMaxFlow, SecondRunsKeepTheMaximum)
 
 TYPED_TEST (ExhaustiveMaxFlow, MinCutsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveMaxFlow, DecompositionsRebuildFlowsWithCycles)
 
 TYPED_TEST (ExhaustiveMaxFlow, DecompositionsRebuildTheMaximumFlow)
 
 TYPED_TEST (ExhaustiveMaxFlow, AugmentingPathSearchesMatchTheOracle)
 
 TYPED_TEST (ExhaustiveMaxFlow, SuperSourcesAndSinksMatchTheOracle)
 
 TYPED_TEST_SUITE (ExhaustiveMinCost, Cost_Nets)
 
 TYPED_TEST (ExhaustiveMinCost, CycleCancelingMatchesTheOracle)
 
 TYPED_TEST (ExhaustiveMinCost, SimplexAndShortestPathsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveMinCost, CheapestMaxFlowsTakeEveryCost)
 
 TYPED_TEST (ExhaustiveMinCost, CheapestMaxFlowsTakeNegativeCosts)
 
 TYPED_TEST (ExhaustiveMinCost, CheapestMaxFlowsOnRandomNetworks)
 
 TYPED_TEST (ExhaustiveMinCost, CheapestMaxFlowsFromAFlowAlreadyThere)
 
 TEST (ExhaustiveFloatingFlow, TenthsStayNearTheExactMaximum)
 
 TEST (ExhaustiveFloatingFlow, CutsDecompositionsAndStatisticsOfTenths)
 
 TEST (ExhaustiveFloatingFlow, RealsStayNearTheExactMaximum)
 
 TEST (ExhaustiveFloatingFlow, TenthsOnRandomNetworksStayNearTheExactMaximum)
 
 TEST (ExhaustiveFloatingFlow, CheapestMaxFlowsOfTenths)
 
 TEST (ExhaustiveFloatingFlow, PathsCarryTheLeastCapacityExactly)
 
 TEST (ExhaustiveFloatingFlow, SmallFlowsBesideLargeCapacitiesStay)
 
 TYPED_TEST_SUITE (ExhaustiveAssignment, Cost_Types)
 
 TYPED_TEST (ExhaustiveAssignment, HungarianMatchesTheOracle)
 
 TYPED_TEST (ExhaustiveAssignment, AssignmentByFlowMatchesTheOracle)
 
 TEST (ExhaustiveAssignmentLimits, HungarianWithCostsNearTheLimits)
 
 TYPED_TEST (ExhaustiveAssignment, TransportationMatchesTheOracle)
 
 TEST (ExhaustiveAssignmentLimits, TransportationOfTenths)
 
 TYPED_TEST (ExhaustiveMinCost, TransshipmentMatchesTheOracle)
 
 TEST (ExhaustiveNetApps, CirculationsMatchTheOracle)
 
 TEST (ExhaustiveNetApps, ProjectSelectionsMatchTheOracle)
 
 TEST (ExhaustiveNetApps, BaseballEliminationsMatchTheOracle)
 
 TEST (ExhaustiveNetApps, SegmentationsMatchTheOracle)
 
 TEST (ExhaustiveNetApps, SurveysMatchTheOracle)
 
 TYPED_TEST_SUITE (ExhaustiveNodeCapacities, Node_Cap_Nets)
 
 TYPED_TEST (ExhaustiveNodeCapacities, AuxiliaryNetworksMatchTheOracle)
 
 TEST (ExhaustiveSupplyDemand, TheAuxiliaryNetworkMatchesTheOracle)
 
 TEST (ExhaustiveNetworkCopies, CopiesKeepTheNetwork)
 
 TEST_F (ExhaustiveFlowMemory, SuperNodesWhenMemoryRunsOut)
 
 TEST_F (ExhaustiveFlowMemory, SuppliesWhenMemoryRunsOut)
 
 TEST_F (ExhaustiveFlowMemory, CopiesWhenMemoryRunsOut)
 
 TEST_F (ExhaustiveFlowMemory, NodeCapacitiesWhenMemoryRunsOut)
 
 TEST_F (ExhaustiveFlowMemory, CheapestFlowsWhenMemoryRunsOut)
 
 TEST (ExhaustiveJohnson, IntegerDistancesThatFitDoNotOverflow)
 
 TYPED_TEST (ExhaustiveMaxFlow, MembersKeepTheirContracts)
 
 TYPED_TEST (ExhaustiveMinCost, ResidualNetworksMirrorTheFlow)
 

Detailed Description

Maximum flows, cuts, decompositions, minimum costs, assignments and the applications of the networks on every small network, against the oracles.

Each test runs one family of algorithms over every digraph of a domain of graph_harness.H (up to 4 nodes and 3 arcs for the maximum flows; one more of each with ALEPH_GRAPH_HARNESS=heavy), with loops, parallel and antiparallel arcs and the arcs in two orders (in one for the floating flows, which are exact there and run as the integers do), with the source and the sink taken over every pair of nodes, and compares each answer with an oracle of this file, which uses the standard library only, and GMP for the exact rationals. A network has the sources and the sinks that its arcs give, so the tests make the source the only one with arcs of capacity 0 to the others, and the sink likewise; if the source has arcs in or the sink arcs out, the flow goes from a node added before the source to one added after the sink. Every flow that an algorithm leaves is checked: within the capacities, conserved, and of the value that it returns.

The families: the maximum flows (augmenting paths, preflows, Dinic, the scaling and HLPP), from zero, from a flow already there and on a second run, with every class of capacities and on random networks; the minimum cuts, the decompositions and the statistics; the augmenting paths and semi-paths; the super sources and sinks; the floating flows of tenths, of real numbers and of capacities far apart, against exact rationals; the cheapest maximum flows (cycle canceling, network simplex and successive shortest paths), the transshipment, the transportation and the assignments, by flow and by Hungarian; the applications of net_apps.H; the capacities of the nodes; the supplies and demands; the copies of the networks; the networks when memory runs out; and Johnson with integer weights next to the limits.

The capacities, and the costs, are in units of the type of the flow: 1 for the integers and 1/4 for the floating types, so that a floating flow is exact; the spec that a failure prints has them in w.

Definition in file graph_exhaustive_flow_test.cc.

Typedef Documentation

◆ Capacity_Nets

using Capacity_Nets = ::testing::Types<Net_Graph<Net_Node<int>, Net_Arc<int, int> >, Net_Graph<Net_Node<int>, Net_Arc<int, double> >>

The networks of integers and of floating flows.

Definition at line 878 of file graph_exhaustive_flow_test.cc.

◆ Cost_Nets

The networks with costs, of integers and of floating flows.

Definition at line 2243 of file graph_exhaustive_flow_test.cc.

◆ Cost_Types

using Cost_Types = ::testing::Types<int, long, double>

The types of the costs: integers and floating.

Definition at line 3125 of file graph_exhaustive_flow_test.cc.

◆ Flow_Nets

using Flow_Nets = ::testing::Types<Net_Graph<Net_Node<int>, Net_Arc<int, int> >, Net_Graph<Net_Node<int>, Net_Arc<int, double> >, Net_Cost_Graph<Net_Cost_Node<int>, Net_Cost_Arc<Empty_Class, long> >>

The networks of integers, of floating flows and of costs.

Definition at line 768 of file graph_exhaustive_flow_test.cc.

◆ Node_Cap_Nets

using Node_Cap_Nets = ::testing::Types<Net_Cap_Graph<Net_Cap_Node<int, long>, Net_Arc<int, long> >, Net_Cap_Graph<Net_Cap_Node<int, double>, Net_Arc<int, double> >>

Definition at line 4105 of file graph_exhaustive_flow_test.cc.

Function Documentation

◆ TEST() [1/17]

TEST ( ExhaustiveAssignmentLimits  ,
HungarianWithCostsNearTheLimits   
)

◆ TEST() [2/17]

TEST ( ExhaustiveAssignmentLimits  ,
TransportationOfTenths   
)

◆ TEST() [3/17]

TEST ( ExhaustiveFloatingFlow  ,
CheapestMaxFlowsOfTenths   
)

◆ TEST() [4/17]

TEST ( ExhaustiveFloatingFlow  ,
CutsDecompositionsAndStatisticsOfTenths   
)

◆ TEST() [5/17]

TEST ( ExhaustiveFloatingFlow  ,
PathsCarryTheLeastCapacityExactly   
)

◆ TEST() [6/17]

TEST ( ExhaustiveFloatingFlow  ,
RealsStayNearTheExactMaximum   
)

◆ TEST() [7/17]

TEST ( ExhaustiveFloatingFlow  ,
SmallFlowsBesideLargeCapacitiesStay   
)

◆ TEST() [8/17]

TEST ( ExhaustiveFloatingFlow  ,
TenthsOnRandomNetworksStayNearTheExactMaximum   
)

◆ TEST() [9/17]

TEST ( ExhaustiveFloatingFlow  ,
TenthsStayNearTheExactMaximum   
)

Definition at line 2486 of file graph_exhaustive_flow_test.cc.

References check().

◆ TEST() [10/17]

◆ TEST() [11/17]

TEST ( ExhaustiveNetApps  ,
BaseballEliminationsMatchTheOracle   
)

◆ TEST() [12/17]

◆ TEST() [13/17]

◆ TEST() [14/17]

TEST ( ExhaustiveNetApps  ,
SegmentationsMatchTheOracle   
)

Definition at line 3885 of file graph_exhaustive_flow_test.cc.

References Aleph::and, check(), cols, LL, m, r, rows, and Aleph::segment_image().

◆ TEST() [15/17]

TEST ( ExhaustiveNetApps  ,
SurveysMatchTheOracle   
)

◆ TEST() [16/17]

TEST ( ExhaustiveNetworkCopies  ,
CopiesKeepTheNetwork   
)

Definition at line 4493 of file graph_exhaustive_flow_test.cc.

References r.

◆ TEST() [17/17]

◆ TEST_F() [1/5]

◆ TEST_F() [2/5]

◆ TEST_F() [3/5]

◆ TEST_F() [4/5]

◆ TEST_F() [5/5]

◆ TYPED_TEST() [1/28]

TYPED_TEST ( ExhaustiveAssignment  ,
AssignmentByFlowMatchesTheOracle   
)

Definition at line 3196 of file graph_exhaustive_flow_test.cc.

References Aleph::and, check(), r, and Aleph::solve_assignment().

◆ TYPED_TEST() [2/28]

◆ TYPED_TEST() [3/28]

TYPED_TEST ( ExhaustiveAssignment  ,
TransportationMatchesTheOracle   
)

Definition at line 3357 of file graph_exhaustive_flow_test.cc.

References Aleph::and, check(), col, m, r, row, and Aleph::solve_transportation().

◆ TYPED_TEST() [4/28]

◆ TYPED_TEST() [5/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
AugmentingPathsMatchTheOracle   
)

Definition at line 854 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [6/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
DecompositionsRebuildFlowsWithCycles   
)

◆ TYPED_TEST() [7/28]

◆ TYPED_TEST() [8/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
DinicScalingAndHlppMatchTheOracle   
)

Definition at line 869 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [9/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
MaxFlowsFromAFlowAlreadyThere   
)

Definition at line 1046 of file graph_exhaustive_flow_test.cc.

References Aleph::and, and check().

◆ TYPED_TEST() [10/28]

◆ TYPED_TEST() [11/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
MinCutsMatchTheOracle   
)

Definition at line 1235 of file graph_exhaustive_flow_test.cc.

References Aleph::and, and check().

◆ TYPED_TEST() [12/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
PreflowsMatchTheOracle   
)

Definition at line 859 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [13/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
RandomPreflowMatchesTheOracle   
)

Definition at line 864 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [14/28]

TYPED_TEST ( ExhaustiveMaxFlow  ,
SecondRunsKeepTheMaximum   
)

Definition at line 1084 of file graph_exhaustive_flow_test.cc.

References Aleph::and, and check().

◆ TYPED_TEST() [15/28]

◆ TYPED_TEST() [16/28]

TYPED_TEST ( ExhaustiveMaxFlowCapacities  ,
AugmentingPathsTakeEveryCapacity   
)

Definition at line 884 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [17/28]

TYPED_TEST ( ExhaustiveMaxFlowCapacities  ,
DinicScalingAndHlppTakeEveryCapacity   
)

Definition at line 899 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [18/28]

TYPED_TEST ( ExhaustiveMaxFlowCapacities  ,
PreflowsTakeEveryCapacity   
)

Definition at line 889 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [19/28]

TYPED_TEST ( ExhaustiveMaxFlowCapacities  ,
RandomPreflowTakesEveryCapacity   
)

Definition at line 894 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [20/28]

TYPED_TEST ( ExhaustiveMinCost  ,
CheapestMaxFlowsFromAFlowAlreadyThere   
)

Definition at line 2335 of file graph_exhaustive_flow_test.cc.

References Aleph::and, check(), and graph_harness::Spec::w.

◆ TYPED_TEST() [21/28]

TYPED_TEST ( ExhaustiveMinCost  ,
CheapestMaxFlowsOnRandomNetworks   
)

◆ TYPED_TEST() [22/28]

TYPED_TEST ( ExhaustiveMinCost  ,
CheapestMaxFlowsTakeEveryCost   
)

◆ TYPED_TEST() [23/28]

TYPED_TEST ( ExhaustiveMinCost  ,
CheapestMaxFlowsTakeNegativeCosts   
)

◆ TYPED_TEST() [24/28]

TYPED_TEST ( ExhaustiveMinCost  ,
CycleCancelingMatchesTheOracle   
)

Definition at line 2249 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [25/28]

◆ TYPED_TEST() [26/28]

TYPED_TEST ( ExhaustiveMinCost  ,
SimplexAndShortestPathsMatchTheOracle   
)

Definition at line 2261 of file graph_exhaustive_flow_test.cc.

◆ TYPED_TEST() [27/28]

◆ TYPED_TEST() [28/28]

◆ TYPED_TEST_SUITE() [1/5]

TYPED_TEST_SUITE ( ExhaustiveAssignment  ,
Cost_Types   
)

◆ TYPED_TEST_SUITE() [2/5]

TYPED_TEST_SUITE ( ExhaustiveMaxFlow  ,
Flow_Nets   
)

◆ TYPED_TEST_SUITE() [3/5]

TYPED_TEST_SUITE ( ExhaustiveMaxFlowCapacities  ,
Capacity_Nets   
)

◆ TYPED_TEST_SUITE() [4/5]

TYPED_TEST_SUITE ( ExhaustiveMinCost  ,
Cost_Nets   
)

◆ TYPED_TEST_SUITE() [5/5]

TYPED_TEST_SUITE ( ExhaustiveNodeCapacities  ,
Node_Cap_Nets   
)