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

Classes

struct  Built
 A graph made from a spec, with its nodes and arcs by number. More...
 
class  Check
 The failures of one property over a domain. More...
 
struct  Domain
 Which multigraphs for_each_spec() gives. More...
 
struct  Spec
 A small multigraph: its nodes are 0 . More...
 

Typedefs

using Undirected_Kinds = ::testing::Types< Aleph::List_Graph< Aleph::Graph_Node< int >, Aleph::Graph_Arc< int > >, Aleph::List_SGraph< Aleph::Graph_Snode< int >, Aleph::Graph_Sarc< int > >, Aleph::Array_Graph< Aleph::Graph_Anode< int >, Aleph::Graph_Aarc< int > > >
 The kinds of graph that are not directed, with int infos.
 
using Directed_Kinds = ::testing::Types< Aleph::List_Digraph< Aleph::Graph_Node< int >, Aleph::Graph_Arc< int > >, Aleph::List_SDigraph< Aleph::Graph_Snode< int >, Aleph::Graph_Sarc< int > >, Aleph::Array_Digraph< Aleph::Graph_Anode< int >, Aleph::Graph_Aarc< int > > >
 The directed kinds, with int infos.
 
using All_Kinds = ::testing::Types< Aleph::List_Graph< Aleph::Graph_Node< int >, Aleph::Graph_Arc< int > >, Aleph::List_SGraph< Aleph::Graph_Snode< int >, Aleph::Graph_Sarc< int > >, Aleph::Array_Graph< Aleph::Graph_Anode< int >, Aleph::Graph_Aarc< int > >, Aleph::List_Digraph< Aleph::Graph_Node< int >, Aleph::Graph_Arc< int > >, Aleph::List_SDigraph< Aleph::Graph_Snode< int >, Aleph::Graph_Sarc< int > >, Aleph::Array_Digraph< Aleph::Graph_Anode< int >, Aleph::Graph_Aarc< int > > >
 The six kinds, with int infos.
 

Enumerations

enum class  Mode { light , normal , heavy }
 The sizes of the domains. More...
 

Functions

Mode mode ()
 ALEPH_GRAPH_HARNESS=light, normal or heavy, or else light in a build with a sanitizer and normal without one.
 
bool heavy ()
 Whether the mode is heavy, which asks for the larger domains.
 
Domain domain (int max_nodes, int max_arcs)
 The domain of max_nodes nodes and max_arcs arcs, of one more of each in heavy mode, and of one arc less in light mode.
 
unsigned seed (unsigned seed)
 The seed of the random tests: ALEPH_GRAPH_HARNESS_SEED, or seed.
 
size_t failures_shown ()
 How many failures a check prints: ALEPH_GRAPH_HARNESS_SHOW, or 8.
 
template<class F >
size_t for_each_spec (const Domain &d, bool directed, F &&f)
 Calls f(spec) with every spec of d, smallest first, and returns how many there were.
 
template<class F >
size_t for_each_simple_graph (int min_nodes, int max_nodes, bool directed, F &&f)
 Calls f(spec) with every simple graph of n nodes, for n from min_nodes to max_nodes: each set of pairs of distinct nodes, or of ordered pairs in a digraph, as arcs from the smaller node unless directed.
 
Spec random_spec (std::mt19937 &rng, int n, int m, bool directed, bool loops=true, bool parallel=true)
 A random spec of n nodes and m arcs, with loops and parallel arcs if asked; parallel is ignored when m exceeds the number of places.
 
void random_weights (std::mt19937 &rng, Spec &s, long long lo, long long hi)
 Gives each arc of s a weight from lo to hi.
 
template<class Node >
int num (Node *p)
 The number of a node of a built graph.
 
template<class GT >
GT::Node * node_of (const GT &g, int i)
 The node of a graph whose number is i.
 
template<class F >
bool run_with_small_stack (F &&f, size_t kb=256)
 Runs f in a thread whose stack has kb KiB, and returns false if the thread could not run; without POSIX threads, it runs f in this thread.
 
template<class F , class Filt >
void with_each_throw (F &f, const Filt &filt, const char *name)
 Calls f(filt, name), as the loop over the filters of a test does, and again for each call k of the filter in that first call, with the filter throwing graph_filters::Thrown_By_Filter at its call k: what it throws has to come out of f, through the algorithm that f calls, if f calls the filter that many times again.
 

Typedef Documentation

◆ All_Kinds

◆ Directed_Kinds

The directed kinds, with int infos.

Definition at line 399 of file graph_harness.H.

◆ Undirected_Kinds

The kinds of graph that are not directed, with int infos.

Definition at line 393 of file graph_harness.H.

Enumeration Type Documentation

◆ Mode

enum class graph_harness::Mode
strong

The sizes of the domains.

Enumerator
light 
normal 
heavy 

Definition at line 154 of file graph_harness.H.

Function Documentation

◆ domain()

◆ failures_shown()

size_t graph_harness::failures_shown ( )
inline

How many failures a check prints: ALEPH_GRAPH_HARNESS_SHOW, or 8.

Definition at line 193 of file graph_harness.H.

Referenced by graph_harness::Check::fail().

◆ for_each_simple_graph()

template<class F >
size_t graph_harness::for_each_simple_graph ( int  min_nodes,
int  max_nodes,
bool  directed,
F &&  f 
)

Calls f(spec) with every simple graph of n nodes, for n from min_nodes to max_nodes: each set of pairs of distinct nodes, or of ordered pairs in a digraph, as arcs from the smaller node unless directed.

Returns how many there were.

Definition at line 291 of file graph_harness.H.

References graph_harness::Spec::arcs, Aleph::count(), and graph_harness::Spec::n.

Referenced by TYPED_TEST().

◆ for_each_spec()

template<class F >
size_t graph_harness::for_each_spec ( const Domain &  d,
bool  directed,
F &&  f 
)

Calls f(spec) with every spec of d, smallest first, and returns how many there were.

In a directed domain (u, v) and (v, u) are different arcs; otherwise each arc is also given from its other end.

Definition at line 203 of file graph_harness.H.

References Aleph::and, graph_harness::Spec::arcs, Aleph::count(), graph_harness::Domain::directions, k, graph_harness::Domain::loops, m, graph_harness::Domain::max_arcs, graph_harness::Domain::max_nodes, graph_harness::Spec::n, graph_harness::Domain::parallel, and graph_harness::Domain::reversed.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), and TYPED_TEST().

◆ heavy()

bool graph_harness::heavy ( )
inline

Whether the mode is heavy, which asks for the larger domains.

Definition at line 172 of file graph_harness.H.

References heavy, and mode().

Referenced by domain(), TEST(), TEST(), TEST(), TEST(), TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), and TYPED_TEST().

◆ mode()

Mode graph_harness::mode ( )
inline

ALEPH_GRAPH_HARNESS=light, normal or heavy, or else light in a build with a sanitizer and normal without one.

Definition at line 158 of file graph_harness.H.

References ALEPH_GRAPH_HARNESS_SANITIZED, heavy, light, m, and normal.

Referenced by domain(), heavy(), TEST(), TYPED_TEST(), and TYPED_TEST().

◆ node_of()

template<class GT >
GT::Node * graph_harness::node_of ( const GT &  g,
int  i 
)

The node of a graph whose number is i.

Definition at line 384 of file graph_harness.H.

Referenced by TYPED_TEST(), and TYPED_TEST().

◆ num()

◆ random_spec()

Spec graph_harness::random_spec ( std::mt19937 &  rng,
int  n,
int  m,
bool  directed,
bool  loops = true,
bool  parallel = true 
)
inline

A random spec of n nodes and m arcs, with loops and parallel arcs if asked; parallel is ignored when m exceeds the number of places.

Definition at line 316 of file graph_harness.H.

References Aleph::and, graph_harness::Spec::arcs, k, m, graph_harness::Spec::n, and rng.

Referenced by TEST(), TEST(), TEST(), TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), and TYPED_TEST().

◆ random_weights()

void graph_harness::random_weights ( std::mt19937 &  rng,
Spec &  s,
long long  lo,
long long  hi 
)
inline

Gives each arc of s a weight from lo to hi.

Definition at line 349 of file graph_harness.H.

References graph_harness::Spec::arcs, rng, w, and graph_harness::Spec::w.

Referenced by TEST(), TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), and TYPED_TEST().

◆ run_with_small_stack()

template<class F >
bool graph_harness::run_with_small_stack ( F &&  f,
size_t  kb = 256 
)

Runs f in a thread whose stack has kb KiB, and returns false if the thread could not run; without POSIX threads, it runs f in this thread.

Definition at line 416 of file graph_harness.H.

Referenced by TYPED_TEST().

◆ seed()

unsigned graph_harness::seed ( unsigned  seed)
inline

The seed of the random tests: ALEPH_GRAPH_HARNESS_SEED, or seed.

Definition at line 186 of file graph_harness.H.

References seed.

◆ with_each_throw()

template<class F , class Filt >
void graph_harness::with_each_throw ( F &  f,
const Filt &  filt,
const char *  name 
)

Calls f(filt, name), as the loop over the filters of a test does, and again for each call k of the filter in that first call, with the filter throwing graph_filters::Thrown_By_Filter at its call k: what it throws has to come out of f, through the algorithm that f calls, if f calls the filter that many times again.

For a filter of graph_filter_catalog.H whose call is not noexcept.

Definition at line 507 of file graph_harness.H.

References k, and out.

Referenced by graph_contract_matrix::for_each_filter().