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

Negative cycles, Bellman-Ford and the minimum mean cycle on every small weighted digraph, against the oracles. More...

#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <random>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include <gtest/gtest.h>
#include <tpl_graph.H>
#include <Bellman_Ford.H>
#include <Negative_Cycles.H>
#include <Min_Mean_Cycle.H>
#include <Howard_Min_Mean_Cycle.H>
#include <Floyd_Warshall.H>
#include <Johnson.H>
#include "graph_filter_catalog.H"
#include "graph_harness.H"
#include "graph_oracles.H"
Include dependency graph for graph_exhaustive_negative_cycles_test.cc:

Go to the source code of this file.

Classes

class  ExhaustiveBellmanFord< GT >
 
class  ExhaustiveNegativeCycleSearches< GT >
 
class  ExhaustiveNegativeCyclesNotDirected< GT >
 

Functions

 TYPED_TEST_SUITE (ExhaustiveBellmanFord, Directed_Kinds)
 
 TYPED_TEST (ExhaustiveBellmanFord, DetectionMatchesTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, WitnessesFromAStartAreNegativeCycles)
 
 TYPED_TEST (ExhaustiveBellmanFord, WitnessesInTheWholeGraphAreNegativeCycles)
 
 TYPED_TEST (ExhaustiveBellmanFord, FunctorsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, TheTreeOfTheShortestPathsMatchesTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, SequencesOfCallsOnOneObjectMatchTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, DetectionRespectsTheFilter)
 
 TYPED_TEST (ExhaustiveBellmanFord, WitnessesRespectTheFilter)
 
 TYPED_TEST (ExhaustiveBellmanFord, WhitelistsOfNumbersMatchTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, WhitelistsOfPointersMatchTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, DoubleDistancesMatchTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, IntegersNearTheLimitsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, TheTreeNearTheLimitsMatchesTheOracle)
 
 TYPED_TEST (ExhaustiveBellmanFord, TheQueriesOnPathsNearTheLimitsOfInt)
 
 TYPED_TEST (ExhaustiveBellmanFord, WeightsThatAreNotFiniteAreRejectedOrCounted)
 
 TYPED_TEST (ExhaustiveBellmanFord, WeightsThatAreNotFiniteDoNotCountWhenHidden)
 
 TYPED_TEST (ExhaustiveBellmanFord, RandomDigraphsMatchTheOracle)
 
 TYPED_TEST_SUITE (ExhaustiveNegativeCycleSearches, Directed_Kinds)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, SearchesMatchTheOracle)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, SearchesRespectTheFilter)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, SearchesWithDoubleCostsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, MeansMatchTheOracle)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, MeansRespectTheFilter)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, MeansWithDoubleCostsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, FloydDetectsTheNegativeCycles)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, JohnsonDetectsTheNegativeCycles)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, FloydAndJohnsonWithAWhitelistMatchTheOracle)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, SearchesAndMeansNearTheLimitsOfInt)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, FloydAndJohnsonNearTheLimitsOfInt)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, JohnsonQueriesNearTheLimitsOfInt)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, JohnsonAnswersOnTheArcsThatTheFilterShows)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, JohnsonAnswersWithCostsThatHaveFractions)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, RandomDigraphsMatchTheOracle)
 
 TYPED_TEST (ExhaustiveNegativeCycleSearches, DefaultArgumentsReadTheInfoOfTheArcs)
 
 TYPED_TEST_SUITE (ExhaustiveNegativeCyclesNotDirected, Undirected_Kinds)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, DetectionReadsEachArcFromItsSource)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, WitnessesFromAStartReadEachArcFromItsSource)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, WitnessesInTheWholeGraphReadEachArcFromItsSource)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, TheTreeReadsEachArcFromItsSource)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, FunctorsWithOutIteratorReadEachArcFromItsSource)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, FunctorsWithTheirDefaultIteratorReadEachArc)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, TheOtherSearchesRejectTheGraph)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, JohnsonTakesEachArcInBothDirections)
 
 TYPED_TEST (ExhaustiveNegativeCyclesNotDirected, FloydTakesEachArcInBothDirections)
 

Detailed Description

Negative cycles, Bellman-Ford and the minimum mean cycle on every small weighted digraph, against the oracles.

Each test runs one family over every digraph of a domain of graph_harness.H, with loops, parallel and antiparallel arcs and the arcs in two orders, on the three kinds of digraph, with every assignment of the weights of a class: from -2 to 2 on the digraphs of up to 2 nodes and 3 arcs, and -2 or 1 on those of up to 3 nodes and 3 arcs (one more node, and one more arc for the second, with ALEPH_GRAPH_HARNESS=heavy). The filters run with every set of hidden arcs, and the whitelists with every set of shown ones, on the smaller domain; there also run the weights near the limits of int, where a sum that leaves int throws overflow_error, and those of minus infinity and NaN, which throw domain_error once the last pass meets them. After an operation that throws, the object has no computation, the graph none of its data, and the object runs again. The random digraphs have 6 to 8 nodes. The distances are int and double.

The oracle enumerates the simple cycles of the spec, in exact arithmetic: whether there is a negative cycle, which nodes reach one, the least cost of a cycle and the least mean, as a fraction. Every witness must be a closed walk of arcs that the filter shows, in their direction, whose cost is negative or the one reported, and a simple cycle where the documentation promises one.

The families are Bellman_Ford.H, with its tree of shortest paths and the sequences of calls on one object; Negative_Cycles.H; Min_Mean_Cycle.H and Howard_Min_Mean_Cycle.H; and the detection of the negative cycles by Floyd_Warshall.H and Johnson.H, with the answers of Johnson where there is none: its distances, paths, potentials and copy of the graph, with whitelists of numbers and of pointers, double costs with fractions and weights near the limits of int, and the graph that it takes, which it must leave as it was. The last suites take the three kinds of graph that are not directed: Bellman_Ford reads each arc from its source to its target, Floyd_Warshall and Johnson in both directions, and the other searches reject them.

Definition in file graph_exhaustive_negative_cycles_test.cc.

Function Documentation

◆ TYPED_TEST() [1/42]

◆ TYPED_TEST() [2/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
DetectionRespectsTheFilter   
)

◆ TYPED_TEST() [3/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
DoubleDistancesMatchTheOracle   
)

◆ TYPED_TEST() [4/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
FunctorsMatchTheOracle   
)

Definition at line 2205 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [5/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
IntegersNearTheLimitsMatchTheOracle   
)

Definition at line 2548 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [6/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
RandomDigraphsMatchTheOracle   
)

◆ TYPED_TEST() [7/42]

◆ TYPED_TEST() [8/42]

◆ TYPED_TEST() [9/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
TheTreeNearTheLimitsMatchesTheOracle   
)

Definition at line 2571 of file graph_exhaustive_negative_cycles_test.cc.

References k, and run_tree().

◆ TYPED_TEST() [10/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
TheTreeOfTheShortestPathsMatchesTheOracle   
)

Definition at line 2219 of file graph_exhaustive_negative_cycles_test.cc.

References k, and run_tree().

◆ TYPED_TEST() [11/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
WeightsThatAreNotFiniteAreRejectedOrCounted   
)

Definition at line 2699 of file graph_exhaustive_negative_cycles_test.cc.

References k, and run_tree().

◆ TYPED_TEST() [12/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
WeightsThatAreNotFiniteDoNotCountWhenHidden   
)

Definition at line 2729 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [13/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
WhitelistsOfNumbersMatchTheOracle   
)

◆ TYPED_TEST() [14/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
WhitelistsOfPointersMatchTheOracle   
)

◆ TYPED_TEST() [15/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
WitnessesFromAStartAreNegativeCycles   
)

Definition at line 2177 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [16/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
WitnessesInTheWholeGraphAreNegativeCycles   
)

Definition at line 2191 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [17/42]

TYPED_TEST ( ExhaustiveBellmanFord  ,
WitnessesRespectTheFilter   
)

◆ TYPED_TEST() [18/42]

◆ TYPED_TEST() [19/42]

◆ TYPED_TEST() [20/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
FloydAndJohnsonWithAWhitelistMatchTheOracle   
)

◆ TYPED_TEST() [21/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
FloydDetectsTheNegativeCycles   
)

Definition at line 2920 of file graph_exhaustive_negative_cycles_test.cc.

References graph_harness::Check::expect(), and k.

◆ TYPED_TEST() [22/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
JohnsonAnswersOnTheArcsThatTheFilterShows   
)

◆ TYPED_TEST() [23/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
JohnsonAnswersWithCostsThatHaveFractions   
)

Definition at line 3599 of file graph_exhaustive_negative_cycles_test.cc.

◆ TYPED_TEST() [24/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
JohnsonDetectsTheNegativeCycles   
)

Definition at line 2938 of file graph_exhaustive_negative_cycles_test.cc.

References graph_harness::Check::expect(), and k.

◆ TYPED_TEST() [25/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
JohnsonQueriesNearTheLimitsOfInt   
)

◆ TYPED_TEST() [26/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
MeansMatchTheOracle   
)

Definition at line 2837 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [27/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
MeansRespectTheFilter   
)

◆ TYPED_TEST() [28/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
MeansWithDoubleCostsMatchTheOracle   
)

Definition at line 2872 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [29/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
RandomDigraphsMatchTheOracle   
)

◆ TYPED_TEST() [30/42]

◆ TYPED_TEST() [31/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
SearchesMatchTheOracle   
)

Definition at line 2788 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [32/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
SearchesRespectTheFilter   
)

◆ TYPED_TEST() [33/42]

TYPED_TEST ( ExhaustiveNegativeCycleSearches  ,
SearchesWithDoubleCostsMatchTheOracle   
)

Definition at line 2823 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [34/42]

TYPED_TEST ( ExhaustiveNegativeCyclesNotDirected  ,
DetectionReadsEachArcFromItsSource   
)

Definition at line 3741 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [35/42]

◆ TYPED_TEST() [36/42]

TYPED_TEST ( ExhaustiveNegativeCyclesNotDirected  ,
FunctorsWithOutIteratorReadEachArcFromItsSource   
)

Definition at line 3797 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [37/42]

TYPED_TEST ( ExhaustiveNegativeCyclesNotDirected  ,
FunctorsWithTheirDefaultIteratorReadEachArc   
)

Definition at line 3811 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [38/42]

TYPED_TEST ( ExhaustiveNegativeCyclesNotDirected  ,
JohnsonTakesEachArcInBothDirections   
)

◆ TYPED_TEST() [39/42]

◆ TYPED_TEST() [40/42]

TYPED_TEST ( ExhaustiveNegativeCyclesNotDirected  ,
TheTreeReadsEachArcFromItsSource   
)

Definition at line 3783 of file graph_exhaustive_negative_cycles_test.cc.

References k, and run_tree().

◆ TYPED_TEST() [41/42]

TYPED_TEST ( ExhaustiveNegativeCyclesNotDirected  ,
WitnessesFromAStartReadEachArcFromItsSource   
)

Definition at line 3755 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST() [42/42]

TYPED_TEST ( ExhaustiveNegativeCyclesNotDirected  ,
WitnessesInTheWholeGraphReadEachArcFromItsSource   
)

Definition at line 3769 of file graph_exhaustive_negative_cycles_test.cc.

References k.

◆ TYPED_TEST_SUITE() [1/3]

TYPED_TEST_SUITE ( ExhaustiveBellmanFord  ,
Directed_Kinds   
)

◆ TYPED_TEST_SUITE() [2/3]

TYPED_TEST_SUITE ( ExhaustiveNegativeCycleSearches  ,
Directed_Kinds   
)

◆ TYPED_TEST_SUITE() [3/3]