Testing oracles#
Reference solvers and checkers used by the tests, the parity harness and downstream users (dyng::testing).
Stability. The testing oracles are outside the stable tier (PLAN 5.9): they are checked by
the API baseline (ci/api_snapshot.py), but a release may change them with a CHANGELOG entry.
Most are tracked (the 0.1-0.3 oracles of dijkstra.hpp, check_sssp.hpp,
cycle_oracle.hpp, mosp_oracle.hpp, line_graph_oracle.hpp, cbst_host_model.hpp and
triad_reference.hpp, and the 0.4 oracle of hyper_sssp_reference.hpp). The three oracles of label_propagation
(harmonic_solution.hpp, union_find.hpp, lp_host_model.hpp) are frozen since the end of
M10b with the algorithm (ADR 0109): a removed or changed declaration fails the API check unless the
pull request is an api-change. They stay frozen but not stable from 0.4.0, by the author’s
decision of 2026-11-18 on AD15 (GOVERNANCE.md; ci/api_snapshot.py’s FROZEN_OUTSIDE_STABLE,
ADR 0110), as do their Python counterparts in dyng.testing.
triad_reference (dyng/testing/triad_reference.hpp) counts the triads of a hypergraph by brute
force, the oracle of triad_count: the 30-bin h-motif counts and StatHyper’s types 1-3 over the
triangles (and adjacent pairs) of the line graph it rebuilds, following ESCHER-GPU’s CPU reference
with 64-bit counts. It derives the h-motif classes itself, as the orbits of the seven Venn regions
under the permutations of the three hyperedges, numbered in ESCHER’s order by a documented list of
representatives; bins 20-25 (the open triads) are always 0. Like rebuild_line_graph and
cbst_host_model it shares no code with what it checks (it includes no other dynG header, and a
test checks its object file), so it throws std::invalid_argument / std::bad_alloc.
The oracles of label_propagation (0.4, ADR 0068) follow the same rule (standard library only;
an include-graph and link test checks their object files):
harmonic_solution(dyng/testing/harmonic_solution.hpp): the converged harmonic labels F* of a graph with seed labels, by Jacobi-preconditioned conjugate gradients in double to a relative residual of 1e-12 (at most 100,000 iterations), on the components that contain a seed (the others are counted as excluded); its reductions sum fixed chunks in a fixed order, so the result does not depend on the thread count.label_error_against()gives the mean and maximum |F - F*| and the class flips,class_agreement_with()the flips beyond a margin.union_find(dyng/testing/union_find.hpp): disjoint sets whose root is the smallest member.lp_host_model(dyng/testing/lp_host_model.hpp): an exact host model of vertex-arrival batches on fixed slot rows (single-use ids, the batch’s net effect, the original’s flags) and oflabel_propagation’s deterministic stages: the affected set V_aff, the sparsified subgraph G’, its components in the original’s numbering, the 64-bit supernode weights and the initial labels. It replays LabelPropagation-CUDA’s recorded traces field for field.
hyper_sssp_reference, check_hyper_sssp_tree and line_graph_delta
(dyng/testing/hyper_sssp_reference.hpp, M11a, ADR 0082) are the oracle of hyper_sssp,
following MOSP_ESCHER’s test oracle: the line graph rebuilt from the hyperedges, a node-weighted
Dijkstra (stepping into a hyperedge costs its weight) from a source hyperedge at distance 0 or a
source vertex (every hyperedge holding it starts at its own weight), the canonical parents (the
lowest-id tight neighbour), a check that counts distance and parent differences apart, and the net
line-graph change between two states of a hypergraph. They share no code with hyper_sssp or the
container either (an include-graph and link test, with a planted violation that must fail it), and
their results are standard-library types.
-
enum class dyng::testing::cbst_op_status#
How an operation of the model ended.
Values:
-
enumerator ok#
it completed
-
enumerator error#
it failed and the original throws (cbst_op_result::error_type)
-
enumerator process_exit#
it failed and the original ends the process
-
enumerator undefined#
the original’s result is not defined (a race, an out-of-bounds access, an endless chain); the model cannot predict it (cbst_op_result::message)
-
enumerator ok#
-
enum class dyng::testing::triad_pattern : std::uint8_t#
The triad patterns the oracle counts (the oracle’s own list, so that it does not depend on the algorithm it checks).
Values:
-
enumerator h_motif#
the 30-bin h-motif counts of the line graph’s triangles
-
enumerator stathyper_type1#
StatHyper type 1: sum over the hyperedges of C(|e|, 3).
-
enumerator stathyper_type2#
StatHyper type 2: adjacent pairs, C(a, 2) * b * c.
-
enumerator stathyper_type3#
StatHyper type 3: triangles, x * y * z of the pairwise-only overlaps.
-
enumerator h_motif#
-
using dyng::testing::cycle_histogram = std::vector<std::uint64_t>#
A cycle histogram:
counts[len]is the number of directed simple cycles of lengthlen(entries 0 and 1 are always 0).
-
constexpr int dyng::testing::triad_num_classes = 30#
Number of h-motif classes (and bins of the h_motif pattern).
-
constexpr int dyng::testing::triad_num_venn_ids = 128#
Number of Venn ids (7 region bits).
-
std::int64_t dyng::testing::cbst_rank_of_position(std::int64_t position, std::int64_t num_nodes) noexcept#
The in-order rank of the node at heap position
positionof a complete binary search tree withnum_nodesnodes (the CBST layout of both originals).With k = floor(log2(position + 1)) and L = floor(log2(num_nodes)), the rank is min(i, i - i/2 + (num_nodes + 1 - 2^L)) - 1 for i = (2(position + 1 - 2^k) + 1) * 2^(L - k), all in 64 bits.
- Parameters:
position – [in] The heap position, 0 <= position < num_nodes.
num_nodes – [in] The number of nodes, at least 1.
- Returns:
The rank, in [0, num_nodes), or -1 when the arguments are out of range.
-
cbst_layout_check dyng::testing::check_cbst_layout(std::int64_t num_nodes, bool search_every_key = true)#
The layout checks of ESCHER-GPU’s tests/cbst_test.cu on the model’s layout function.
Keys 1..n are placed at their heap positions with row k at offset 4(k - 1); the check counts (1) ranks that do not form a permutation, (2) heap positions whose in-order traversal rank is wrong, (3) keys a BST search from the root does not find (searched for every key when
search_every_key, else for a deterministic sample of at most 65,536 keys), (4) found nodes whose offset is not that of the key’s row and (5) positions whose key, recovered by the layout formula, differs from the key stored there.- Parameters:
num_nodes – [in] The tree size, 1 <= num_nodes <= 2^30.
search_every_key – [in] Search every key (cost n log n) or a sample.
- Returns:
The findings.
-
template<typename vertex_t, typename edge_t, typename weight_t>
sssp_tree_check dyng::testing::check_sssp_tree(const csr_view<vertex_t, edge_t, weight_t> &out, vertex_t source, array_view<const std::int64_t> distances, array_view<const vertex_t> parents, const check_sssp_options &opt = {})# Check distances and parents of a shortest-path tree (a port of MOSP’s checkSospTree()).
The reference distances (and, in canonical mode, parents) come from dijkstra(). Parent consistency: the source and unreachable vertices have parent -1; every other vertex v has a parent p with an edge (p,v) of positive weight and dist[p] + w(p,v) == dist[v]. Canonical: p is the lowest id among all such in-neighbours. The in-edges are rebuilt from
outhere, so the check does not rely on the graph’s own transposition.- Synchronization:
Blocks until the work has completed (synchronous).
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type.
- Parameters:
out – [in] The out-edge CSR the tree belongs to (host memory).
source – [in] The source vertex.
distances – [in] One distance per vertex (host memory).
parents – [in] One parent per vertex (host memory).
opt – [in] Objective and mode.
- Throws:
invalid_argument_error – if the array sizes differ from the vertex count or the objective is out of range.
out_of_memory_error – if host memory cannot be allocated.
- Returns:
The findings.
-
template<typename vertex_t, typename edge_t, typename weight_t>
sssp_tree_check dyng::testing::check_sssp_tree(const graph<vertex_t, edge_t, weight_t> &g, vertex_t source, array_view<const std::int64_t> distances, array_view<const vertex_t> parents, const check_sssp_options &opt = {})# Check a tree of a graph (see the csr_view overload).
- Synchronization:
Blocks until the work has completed (synchronous).
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type.
- Parameters:
g – [in] The graph.
source – [in] The source vertex.
distances – [in] One distance per vertex (host memory).
parents – [in] One parent per vertex (host memory).
opt – [in] Objective and mode.
- Throws:
invalid_argument_error – on size or objective mismatches.
out_of_memory_error – if host memory cannot be allocated.
- Returns:
The findings.
-
template<typename vertex_t, typename edge_t, typename weight_t>
sssp_tree_check dyng::testing::check_sssp_tree(const graph<vertex_t, edge_t, weight_t> &g, const sssp::result<vertex_t> &r, bool require_canonical = true)# Check an sssp result against its graph (source and objective taken from the result).
A result of the CUDA backend (device arrays) is copied to the host first.
- Synchronization:
Blocks until the work has completed (synchronous).
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type.
- Parameters:
g – [in] The graph the result matches.
r – [in] The result.
require_canonical – [in] Parents must be the lowest-id tight in-neighbours.
- Throws:
invalid_argument_error – on size mismatches or a moved-from result.
out_of_memory_error – if host memory cannot be allocated.
cuda_error – if a device result cannot be copied.
- Returns:
The findings.
-
template<typename vertex_t, typename edge_t, typename weight_t>
cycle_histogram dyng::testing::oracle_simple_cycles(const csr_view<vertex_t, edge_t, weight_t> &graph, int max_length = -1)# Directed simple cycles by length, each counted once, by a dynamic program over vertex subsets (CycleEnumeration-GPU’s oracle_simple_cycles).
For every start vertex s the program counts simple paths s -> … -> v over vertex subsets whose other members are all greater than s, and closes them with an edge v -> s; each cycle is produced once, from its minimum vertex. Self-loops and repeated neighbours are ignored; 2-cycles (u -> v -> u) count.
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type (ignored).
- Parameters:
graph – [in] The out-edge CSR (host memory), at most 16 vertices.
max_length – [in] Longest counted cycle (>= 2), or -1 for no bound.
- Throws:
invalid_argument_error – if the graph has more than 16 vertices, max_length is neither -1 nor >= 2, or the view is not on the host.
out_of_memory_error – if host memory cannot be allocated.
- Returns:
The histogram, of size max_length + 1 (no bound: max(num_vertices, 2) + 1).
-
template<typename vertex_t, typename edge_t, typename weight_t>
cycle_histogram dyng::testing::brute_force_simple_cycles(const csr_view<vertex_t, edge_t, weight_t> &graph, int max_length = -1)# Directed simple cycles by length by exhaustive DFS (CycleEnumeration-GPU’s count_simple_cycles_bruteforce): a cycle is counted from its minimum vertex as the root.
Every row entry is followed, so a graph with parallel edges counts a cycle once per choice of parallel edges (a simple graph, e.g. under multi_edges::forbid, counts each cycle once).
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type (ignored).
- Parameters:
graph – [in] The out-edge CSR (host memory).
max_length – [in] Longest counted cycle (>= 2), or -1 for no bound.
- Throws:
invalid_argument_error – if max_length is neither -1 nor >= 2 or the view is not on the host.
out_of_memory_error – if host memory cannot be allocated.
- Returns:
The histogram, of size max_length + 1 (no bound: max(num_vertices, 2) + 1).
-
template<typename vertex_t, typename edge_t, typename weight_t>
csr<vertex_t, edge_t, weight_t> dyng::testing::edge_set_after_batch(const csr_view<vertex_t, edge_t, weight_t> &graph, const edge_batch_view<vertex_t, weight_t> &batch)# The edge set after a batch, computed without the library’s apply: (E minus Del) plus Ins, self-loop insertions ignored, the vertex count grown to the largest inserted id + 1 (the reference graph of CycleEnumeration-GPU’s arbitrary-batch tests).
Deletions are applied before insertions, both as sets. The result has sorted rows without repeats and no weight columns.
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type (ignored).
- Parameters:
graph – [in] The out-edge CSR before the batch (host memory).
batch – [in] The batch (host memory; ids >= 0).
- Throws:
invalid_argument_error – if an id is negative or an array is not on the host.
out_of_memory_error – if host memory cannot be allocated.
- Returns:
The out-edge CSR after the batch.
-
template<typename vertex_t, typename edge_t, typename weight_t>
sssp_tree<vertex_t> dyng::testing::dijkstra(const csr_view<vertex_t, edge_t, weight_t> &out, vertex_t source, int objective = 0)# Dijkstra from
sourcewith ties broken towards the lowest parent id (the canonical tree); a port of MOSP’s dijkstraCsrGraph().- Synchronization:
Blocks until the work has completed (synchronous).
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type.
- Parameters:
out – [in] The out-edge CSR (host memory, objective-major weights, weights >= 1).
source – [in] The source vertex.
objective – [in] The weight column.
- Throws:
invalid_argument_error – if
objectiveis out of range or the view is not on the host.out_of_memory_error – if host memory cannot be allocated.
- Returns:
The canonical tree; all vertices unreachable if
sourceis out of range.
-
template<typename vertex_t, typename edge_t, typename weight_t>
sssp_tree<vertex_t> dyng::testing::dijkstra(const graph<vertex_t, edge_t, weight_t> &g, vertex_t source, int objective = 0)# Dijkstra on a graph’s out-edges (see the csr_view overload).
- Synchronization:
Blocks until the work has completed (synchronous).
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type.
- Parameters:
g – [in] The graph (host storage).
source – [in] The source vertex.
objective – [in] The weight column.
- Throws:
invalid_argument_error – if
objectiveis out of range.out_of_memory_error – if host memory cannot be allocated.
- Returns:
The canonical tree.
-
template<typename edge_t>
harmonic_result dyng::testing::harmonic_solution(const std::vector<edge_t> &row_ptr, const std::vector<std::int32_t> &col_ind, const std::vector<float> &weights, const std::vector<std::uint8_t> &present, const std::vector<std::int8_t> &seed_labels, const harmonic_options &opt = {})# Solve for the harmonic labels of the graph induced by the present vertices.
Entries with a negative column (unused slots) and entries to vertices that are not present are ignored, so a slotted graph’s rows (row_ptr[v] .. the row’s end, the rest -1) can be passed as they are. The graph must be symmetric (an undirected graph stored in both directions).
- Template Parameters:
edge_t – Offset type (std::int32_t or std::int64_t).
- Parameters:
row_ptr – [in] num_vertices + 1 offsets into col_ind.
col_ind – [in] The neighbour of each entry (negative: no entry).
weights – [in] The weight of each entry (non-negative).
present – [in] 1 for the vertices of the current graph.
seed_labels – [in] Per vertex -1 (unlabelled) or its seed label 0 or 1.
opt – [in] Options.
- Throws:
std::invalid_argument – if the sizes disagree, a column is out of range, a seed label is not -1, 0 or 1, or an option is invalid.
- Returns:
The solution.
-
label_error dyng::testing::label_error_against(const std::vector<float> &labels, const harmonic_result &f, const std::vector<std::uint8_t> &present, const std::vector<std::int8_t> &seed_labels)#
Mean and max |F - F*| and the class flips over the compared vertices, summed in vertex order (as LabelPropagation-CUDA’s checkLabels).
- Parameters:
labels – [in] F, one float per vertex.
f – [in] The harmonic solution of the same graph.
present – [in] The present vertices (as given to harmonic_solution()).
seed_labels – [in] The seed labels (as given to harmonic_solution()).
- Throws:
std::invalid_argument – if the sizes disagree.
- Returns:
The comparison.
-
class_agreement dyng::testing::class_agreement_with(const std::vector<float> &labels, const harmonic_result &f, const std::vector<std::uint8_t> &present, const std::vector<std::int8_t> &seed_labels, double margin)#
Count the class flips and those where F* is farther than
marginfrom 0.5.- Parameters:
labels – [in] F, one float per vertex.
f – [in] The harmonic solution.
present – [in] The present vertices.
seed_labels – [in] The seed labels.
margin – [in] The margin (>= 0).
- Throws:
std::invalid_argument – if the sizes disagree or the margin is negative.
- Returns:
The agreement.
-
std::pair<std::vector<std::int64_t>, std::vector<std::int32_t>> dyng::testing::hyper_sssp_reference(const std::vector<std::int64_t> &h2v_offsets, const std::vector<std::int32_t> &h2v_members, std::int32_t num_vertices, const std::vector<std::int64_t> &weights, std::int64_t source, bool source_is_vertex = false)#
Distances and canonical parents of the node-weighted shortest paths over the line graph of a hypergraph (MOSP_ESCHER’s referenceDistances and canonical parents).
- Parameters:
h2v_offsets – [in] The hyperedges by id: id i has the members
h2v_members[h2v_offsets[i] .. h2v_offsets[i + 1])(empty = dead).h2v_members – [in] The members, in [0, num_vertices).
num_vertices – [in] Vertices.
weights – [in] One weight per id, each >= 0.
source – [in] The source: a hyperedge id in [0, ids) (
source_is_vertexfalse; a dead source hyperedge reaches nothing), or a vertex in [0, num_vertices) (source_is_vertextrue).source_is_vertex – [in] Whether
sourceis a vertex.
- Throws:
std::invalid_argument – for malformed offsets, a member or a source out of range, a weight count other than the id count or a negative weight.
std::overflow_error – if a distance would reach INT64_MAX / 4.
std::bad_alloc – if host memory cannot be allocated.
- Returns:
{distances, parents}: one distance (INT64_MAX / 4 for dead or unreachable) and one parent (0-based, -1 for none) per id.
-
std::pair<std::int64_t, std::int64_t> dyng::testing::check_hyper_sssp_tree(const std::vector<std::int64_t> &h2v_offsets, const std::vector<std::int32_t> &h2v_members, std::int32_t num_vertices, const std::vector<std::int64_t> &weights, std::int64_t source, bool source_is_vertex, const std::vector<std::int64_t> &distances, const std::vector<std::int32_t> &parents)#
Checks distances and parents of a hyper_sssp result against the oracle (MOSP_ESCHER’s checkSosp, with the parents checked even where the distances differ).
The distance of every id must equal hyper_sssp_reference()’s; the parent of every id must be its canonical parent, computed from the REFERENCE distances, so a parent error is counted on its own even when distances mismatch. Ids past the end of
distancesorparentscount as INT64_MAX / 4 and -1 (the canonical encodings of ADR 0080: a longer result is checked on the extra ids too, which must be dead or unreachable).- Parameters:
h2v_offsets – [in] The hyperedges by id (see hyper_sssp_reference()).
h2v_members – [in] The members.
num_vertices – [in] Vertices.
weights – [in] One weight per id.
source – [in] The source (see hyper_sssp_reference()).
source_is_vertex – [in] Whether
sourceis a vertex.distances – [in] The distances to check, by id.
parents – [in] The parents to check, by id (0-based, -1 for none).
- Throws:
std::invalid_argument – as hyper_sssp_reference().
std::overflow_error – as hyper_sssp_reference().
std::bad_alloc – if host memory cannot be allocated.
- Returns:
{distance mismatches, parent errors} over max(ids, distances.size(), parents.size()) ids.
-
std::pair<std::vector<std::pair<std::int64_t, std::int64_t>>, std::vector<std::pair<std::int64_t, std::int64_t>>> dyng::testing::line_graph_delta(const std::vector<std::int64_t> &pre_offsets, const std::vector<std::int32_t> &pre_members, const std::vector<std::int64_t> &post_offsets, const std::vector<std::int32_t> &post_members, std::int32_t num_vertices)#
The net change of the line graph between two states of a hypergraph (MOSP_ESCHER’s lineGraphDelta on the two rebuilt line graphs): the pairs adjacent only before (deleted) and only after (inserted).
- Parameters:
pre_offsets – [in] The hyperedges before, by id (see hyper_sssp_reference()).
pre_members – [in] Their members.
post_offsets – [in] The hyperedges after, by id (the id counts may differ: a missing id is dead).
post_members – [in] Their members.
num_vertices – [in] Vertices (of both states).
- Throws:
std::invalid_argument – for malformed offsets or a member out of range.
std::bad_alloc – if host memory cannot be allocated.
- Returns:
{deleted, inserted}: (a, b) id pairs with a < b, each list sorted.
-
line_graph_rows dyng::testing::rebuild_line_graph(const std::vector<std::int64_t> &h2v_offsets, const std::vector<std::int32_t> &h2v_members, std::int32_t num_vertices)#
The line graph of a hypergraph, rebuilt from its hyperedges (MOSP_ESCHER’s rebuildLineGraph).
A hyperedge with an empty row is dead: it has an empty line-graph row and is nobody’s neighbour. Repeated members of a row count once.
- Parameters:
h2v_offsets – [in] The hyperedges by id: id i has the members
h2v_members[h2v_offsets[i] .. h2v_offsets[i + 1])(the layout of hypergraph::h2v() copied to the host).h2v_members – [in] The members, in [0, num_vertices).
num_vertices – [in] Vertices.
- Throws:
std::invalid_argument – for malformed offsets or a member out of range.
std::bad_alloc – if host memory cannot be allocated.
- Returns:
One row per id (h2v_offsets.size() - 1 rows).
-
template<typename vertex_t>
csr<vertex_t, std::int64_t, std::int32_t> dyng::testing::combined_graph_reference(const std::vector<std::vector<vertex_t>> &parents, vertex_t source, const std::vector<std::int32_t> &preferences = {})# The combined graph of K shortest-path trees (a port of MOSP’s combinedGraphReference()).
Edge (p, v) is in the combined graph iff p is the parent of v in some tree T_i; its weight is L * (K + 1) - sum_{i : Parent_i[v] == p} L / Pref_i, with L = lcm(preferences) (1 for no preferences). Rows list their edges in the order of the heads v, and for one head in objective order of the first tree that contains the edge. Solving it with dijkstra() from
sourcegives the canonical MOSP tree (its distances in units of 1/L).- Synchronization:
Blocks until the work has completed (synchronous).
- Template Parameters:
vertex_t – Vertex id type.
- Parameters:
parents – [in] K parent arrays of n entries each (-1: none).
source – [in] The source (it has no in-edge).
preferences – [in] K preferences >= 1, or none (all ones).
- Throws:
invalid_argument_error – if the arrays differ in length, a parent is out of range, or the preferences are not K values >= 1 with lcm <= 2^20, or K is not in [1, 64].
out_of_memory_error – if host memory cannot be allocated.
- Returns:
The combined graph (int64 edge offsets, one int32 weight column).
-
template<typename vertex_t, typename edge_t, typename weight_t>
std::vector<std::int64_t> dyng::testing::mosp_path_costs_reference(const csr_view<vertex_t, edge_t, weight_t> &out, const std::vector<vertex_t> &parent, vertex_t source, int num_objectives = 0)# The objective values of the path from
sourceto every vertex along a tree (MOSP’s mospPathCosts(), written independently): the weights of the tree edge (p, v) are those of the first edge from p to v in p’s row; columns 0..num_objectives-1 are summed.- Synchronization:
Blocks until the work has completed (synchronous).
- Template Parameters:
vertex_t – Vertex id type.
edge_t – Edge offset type.
weight_t – Weight type.
- Parameters:
out – [in] The graph’s out-edges (host memory).
parent – [in] The tree (n entries, -1 for the source and unreachable vertices).
source – [in] The source.
num_objectives – [in] Number of weight columns to sum (0: every column of
out).
- Throws:
invalid_argument_error – if a tree edge is not an edge of
out, the tree has a cycle, num_objectives is out of range, or the view is not in host memory.out_of_memory_error – if host memory cannot be allocated.
- Returns:
n * K values, vertex-major; infinite_distance<int64_t>() for vertices the tree does not connect to the source.
-
const char *dyng::testing::triad_pattern_name(triad_pattern pattern) noexcept#
The name of a pattern (“h_motif”, “stathyper_type1”, …).
- Parameters:
pattern – [in] The pattern.
- Returns:
Its name.
-
int dyng::testing::triad_num_bins(triad_pattern pattern) noexcept#
Number of values a pattern counts: 30 for h_motif, 1 for the StatHyper types.
- Parameters:
pattern – [in] The pattern.
- Returns:
The number of bins.
-
const std::array<std::uint8_t, triad_num_classes> &dyng::testing::triad_class_representatives() noexcept#
The canonical id of each h-motif class in ESCHER’s numbering: element k - 1 is the smallest Venn id of class k (the table of the file comment).
- Returns:
The 30 representatives.
-
int dyng::testing::triad_venn_permuted(int venn_id, const std::array<int, 3> &image)#
The Venn id after a permutation of (A, B, C).
- Parameters:
venn_id – [in] An id in [0, 128).
image – [in] image[x] is the position (0 = A, 1 = B, 2 = C) hyperedge x moves to; a permutation of {0, 1, 2}.
- Throws:
std::invalid_argument – if venn_id is out of range or image is not a permutation.
- Returns:
The id of the permuted triple.
-
int dyng::testing::triad_venn_canonical(int venn_id)#
The canonical id of a Venn id: the smallest id over the six permutations of (A, B, C).
- Parameters:
venn_id – [in] An id in [0, 128).
- Throws:
std::invalid_argument – if venn_id is out of range.
- Returns:
The canonical id.
-
int dyng::testing::triad_motif_class(int venn_id)#
The h-motif class of a Venn id: 1-30, or 0 when fewer than two pairs intersect.
- Parameters:
venn_id – [in] An id in [0, 128).
- Throws:
std::invalid_argument – if venn_id is out of range.
- Returns:
The class.
-
std::array<std::int8_t, triad_num_venn_ids> dyng::testing::triad_motif_class_map()#
The class of every Venn id (triad_motif_class() over [0, 128)).
- Returns:
The 128 classes.
-
int dyng::testing::triad_venn_id(const std::vector<std::int32_t> &a, const std::vector<std::int32_t> &b, const std::vector<std::int32_t> &c)#
The Venn id of three member sets.
- Parameters:
a – [in] The members of A (any order; repeated members count once).
b – [in] The members of B.
c – [in] The members of C.
- Throws:
std::bad_alloc – if host memory cannot be allocated.
- Returns:
The id (bit 0 “A only” … bit 6 “A, B and C”).
-
triad_reference_counts dyng::testing::triad_reference_all(const std::vector<std::int64_t> &offsets, const std::vector<std::int32_t> &members, std::int32_t num_vertices, const std::vector<triad_pattern> &patterns, const triad_reference_options &options = {})#
The counts of the requested patterns of a hypergraph (the others stay 0).
The hypergraph is given by id: id i has the members
members[offsets[i] .. offsets[i + 1])(the layout of hypergraph::h2v() or of a hyperedge_list, copied to the host); an empty row is a dead id and takes part in nothing. Repeated members of a row count once. The line graph is built only when a requested pattern needs it (all but type 1).- Parameters:
offsets – [in] Row offsets (ids + 1 values, from 0 to members.size()).
members – [in] The members, in [0, num_vertices).
num_vertices – [in] Vertices.
patterns – [in] The patterns to count.
options – [in] Threads.
- Throws:
std::invalid_argument – for malformed offsets, a member out of range, more than 2^31 - 1 ids or a negative vertex count.
std::overflow_error – if a requested count (a bin, or a type’s sum) exceeds 2^64 - 1.
std::bad_alloc – if host memory cannot be allocated.
- Returns:
The counts.
-
std::vector<std::uint64_t> dyng::testing::triad_reference(const std::vector<std::int64_t> &offsets, const std::vector<std::int32_t> &members, std::int32_t num_vertices, triad_pattern pattern, const triad_reference_options &options = {})#
The counts of one pattern of a hypergraph (triad_reference_all() for one pattern).
- Parameters:
offsets – [in] Row offsets (ids + 1 values).
members – [in] The members, in [0, num_vertices).
num_vertices – [in] Vertices.
pattern – [in] The pattern.
options – [in] Threads.
- Throws:
std::invalid_argument – as triad_reference_all().
std::overflow_error – as triad_reference_all().
std::bad_alloc – if host memory cannot be allocated.
- Returns:
30 values for h_motif, else 1.
-
std::vector<std::uint64_t> dyng::testing::triad_reference_removed(const std::vector<std::int64_t> &offsets, const std::vector<std::int32_t> &members, std::int32_t num_vertices, const std::vector<std::int64_t> &ids, triad_pattern pattern, const triad_reference_options &options = {})#
removed(G, D): per bin, the triads of G that contain a hyperedge of D, as counts(G) - counts(G \ D) (for the statistics of small test sets).
- Parameters:
offsets – [in] G’s row offsets by id.
members – [in] G’s members.
num_vertices – [in] Vertices.
ids – [in] D: ids of G (dead, out-of-range and repeated ids are ignored).
pattern – [in] The pattern.
options – [in] Threads.
- Throws:
std::invalid_argument – as triad_reference_all().
std::overflow_error – as triad_reference_all().
std::bad_alloc – if host memory cannot be allocated.
- Returns:
30 values for h_motif, else 1.
-
std::vector<std::uint64_t> dyng::testing::triad_reference_added(const std::vector<std::int64_t> &offsets, const std::vector<std::int32_t> &members, std::int32_t num_vertices, const std::vector<std::int64_t> &ids, triad_pattern pattern, const triad_reference_options &options = {})#
added(G’, I): per bin, the triads of G’ (the hypergraph after a batch) that contain an inserted hyperedge of I, as counts(G’) - counts(G’ \ I).
- Parameters:
offsets – [in] G’’s row offsets by id.
members – [in] G’’s members.
num_vertices – [in] Vertices.
ids – [in] I: the inserted ids (hyper_apply_summary::inserted_ids).
pattern – [in] The pattern.
options – [in] Threads.
- Throws:
std::invalid_argument – as triad_reference_all().
std::overflow_error – as triad_reference_all().
std::bad_alloc – if host memory cannot be allocated.
- Returns:
30 values for h_motif, else 1.
-
struct cbst_layout_check#
- #include <dyng/testing/cbst_host_model.hpp>
The findings of check_cbst_layout().
Public Functions
-
inline bool ok() const noexcept#
Whether the layout passed.
- Returns:
true if every counter is 0.
Public Members
-
std::int64_t num_nodes = 0#
the tree size checked
-
std::int64_t not_a_permutation = 0#
ranks out of range or repeated
-
std::int64_t not_in_order = 0#
in-order traversal positions with a wrong rank
-
std::int64_t not_found = 0#
keys a search from the root does not reach
-
std::int64_t wrong_offset = 0#
keys found at a node that holds another row
-
std::int64_t inverse_mismatches = 0#
positions whose recovered key differs
-
inline bool ok() const noexcept#
-
struct cbst_host_policy#
- #include <dyng/testing/cbst_host_model.hpp>
How a cbst_host_model behaves where the originals differ (and where the dynG presets will choose): payload growth, compaction, failures, the construct, scratch buffers.
The presets reproduce each original: escher_gpu() is ESCHER-GPU@abcf9b2, mosp_escher() is MOSP_ESCHER@4b86159. dyng_default()
is the target policy of PLAN 6.4.5 (“compact first, then
grow, fail only at the int32 offset limit”), provisional until the dynG store’s presets are merged (M8a step 4). Every field can be set on its own.
Public Types
-
enum class growth_rule#
What happens when an operation needs more payload than the capacity.
Values:
-
enumerator none#
fail (MOSP_ESCHER: a fixed capacity)
-
enumerator escher_gpu#
grow to max(needed + needed/4, 3 * capacity / 2), at most INT_MAX (ESCHER-GPU)
-
enumerator none#
-
enum class compaction_rule#
Whether and where the payload is compacted.
Values:
-
enumerator none#
never (ESCHER-GPU)
-
enumerator mosp_escher#
MOSP_ESCHER’s trigger points: a fill whose overflow segments do not fit (compact, then refill the rest once), an insert whose surplus rows do not fit (compact before appending them), and compact().
-
enumerator none#
-
enum class failure_rule#
How a failure is reported.
Values:
-
enumerator process_exit#
the original ends the process (ESCHER-GPU: exit(2) / checkCuda’s exit)
-
enumerator exception#
the original throws (MOSP_ESCHER: escher::EscherError)
-
enumerator process_exit#
-
enum class occupancy_rule#
The tail occupancy of a constructed row.
Values:
-
enumerator scan_payload#
the values before the row’s terminator, whatever the caller passes (ESCHER-GPU’s initTailMetadata)
-
enumerator caller_counts_or_zero#
the caller’s row counts, or 0 without them (MOSP_ESCHER)
-
enumerator caller_counts_or_scan#
the caller’s row counts, or the scan without them
-
enumerator scan_payload#
Public Members
-
std::string name#
the preset name (reports)
-
growth_rule growth = growth_rule::escher_gpu#
payload growth
-
compaction_rule compaction = compaction_rule::none#
payload compaction
-
failure_rule failure = failure_rule::process_exit#
how failures are reported
-
occupancy_rule occupancy = occupancy_rule::scan_payload#
construct occupancy
-
scratch_rule scratch = scratch_rule::exact#
scratch growth
-
bool validate_construct = false#
reject negative sizes and a payload above the capacity with an error (MOSP_ESCHER); ESCHER-GPU returns without building the tree when the payload does not fit
-
bool clamp_fill_tail = false#
a tail with occupancy above its capacity has no room (MOSP_ESCHER’s max(0, …)); unclamped it is undefined
-
bool has_rebuild = true#
rebuild() exists (ESCHER-GPU’s rebuildFromDevice)
-
bool has_compact = false#
compact() exists (MOSP_ESCHER)
-
bool counts_bin_launches = true#
degree-bin launches are counted (ESCHER-GPU)
-
std::string error_type#
the exception type a failure reports (“escher::EscherError” for MOSP_ESCHER)
-
std::int64_t max_payload = 2147483647#
the largest payload capacity a growth reaches (2^31 - 1: the int32 offsets; tests lower it)
-
std::int64_t compaction_headroom = 0#
after an operation that compacted at a trigger point, grow by the growth rule when fewer than capacity / compaction_headroom slots are free, to the capacity that leaves that many (at most max_payload); 0: never (dyng_default(): 8)
Public Static Functions
-
static cbst_host_policy escher_gpu()#
ESCHER-GPU@abcf9b2: growth, no compaction, process exit on failure, scanned occupancy, exact scratch, rebuild and launch counters.
- Returns:
The preset.
-
static cbst_host_policy mosp_escher()#
MOSP_ESCHER@4b86159: a fixed capacity, compaction at its trigger points, then escher::EscherError; validated construct with the caller’s row counts, the fill clamps, geometric scratch, compact().
- Returns:
The preset.
-
static cbst_host_policy dyng_default()#
dynG’s default, the target policy of PLAN 6.4.5 (M8a step 5): MOSP_ESCHER’s compaction at its trigger points first, then growth by ESCHER-GPU’s rule where MOSP_ESCHER throws or fewer than 1/8 of the slots stay free after a compaction (compaction_headroom), a failure only beyond max_payload (dyng::capacity_error); scanned occupancy when the caller gives no counts; the construct validation and the fill clamps; geometric scratch; rebuild, compact() and the launch counters.
- Returns:
The preset.
-
static bool from_name(const std::string &name, cbst_host_policy &out)#
The preset of a name: “escher_gpu”, “mosp_escher” or “dyng_default”.
- Parameters:
name – [in] The name.
out – [out] The preset.
- Returns:
false if the name is unknown.
-
enum class growth_rule#
-
struct cbst_op_result#
- #include <dyng/testing/cbst_host_model.hpp>
The outcome of one operation of the model.
Public Members
-
cbst_op_status status = cbst_op_status::ok#
how it ended
-
std::string error_type#
the original’s exception type (status error)
-
std::string message#
what failed (status other than ok)
-
std::vector<std::int32_t> mapping#
insert: the key of every input item
-
std::int64_t compact_return = 0#
compact(): the new bump pointer
-
std::int64_t reusable_slots = -1#
insert: D, the deleted slots at entry
-
bool grew = false#
the payload capacity grew
-
std::int64_t compactions = 0#
payload compactions run
-
bool compaction_changed = false#
a compaction moved a row, changed a length or lowered the bump pointer
-
std::array<std::int64_t, 9> bin_launches = {}#
degree-bin launches, (fill, reuse, unfill) x (thread, warp, block): one per non-empty bin
-
cbst_op_status status = cbst_op_status::ok#
-
struct cbst_key_record#
- #include <dyng/testing/cbst_host_model.hpp>
One key of a model tree, as the originals’ state digests describe it.
Public Members
-
std::int32_t key = 0#
the key (1-based in both originals)
-
std::int32_t avail = 0#
1: a deleted key whose slot an insert may reuse
-
std::int32_t length = 0#
slots of the first segment, the terminator included
-
std::int32_t size = 0#
the node’s size field (the payload size it was built at)
-
std::int32_t occupancy = 0#
values in the tail segment
-
std::int32_t tail_capacity = 0#
usable slots of the tail segment
-
std::int32_t value = 0#
offset of the first segment
-
std::int32_t tail_base = 0#
offset of the tail segment
-
std::int32_t segments = 1#
segments the row walk visited
-
std::int32_t row_len = 0#
values of the row
-
bool terminated = true#
the row walk ended at a terminator inside the payload
-
std::vector<std::int32_t> row#
the row in read order
-
std::int32_t key = 0#
-
struct cbst_model_event#
- #include <dyng/testing/cbst_host_model.hpp>
A payload growth or compaction of a model tree.
Public Types
-
class cbst_host_model#
- #include <dyng/testing/cbst_host_model.hpp>
A sequential host model of one CBST of ESCHER-GPU@abcf9b2 / MOSP_ESCHER@4b86159.
The operations take the originals’ inputs: keys, the flat values of every item and their inclusive prefix sums (item i owns values [prefix[i-1], prefix[i])). Keys are those of the originals (1-based; requested insert keys are ignored, as by both originals). The model is not thread-safe; copies are independent.
Public Functions
-
cbst_host_model(cbst_host_policy policy, std::int64_t payload_capacity, std::int32_t alignment = 4, std::string name = {})#
An empty tree (the originals’ CBSTOperations constructor).
- Parameters:
policy – [in] The behaviour.
payload_capacity – [in] The payload capacity in values.
alignment – [in] The row alignment of surplus inserts.
name – [in] The dataset name (reports).
-
~cbst_host_model()#
Releases the model.
-
cbst_host_model(const cbst_host_model &other)#
A deep copy.
- Parameters:
other – [in] The model.
-
cbst_host_model &operator=(const cbst_host_model &other)#
A deep copy.
- Parameters:
other – [in] The model.
- Returns:
This model.
-
cbst_host_model(cbst_host_model &&other) noexcept#
Moves.
- Parameters:
other – [inout] The model.
-
cbst_host_model &operator=(cbst_host_model &&other) noexcept#
Moves.
- Parameters:
other – [inout] The model.
- Returns:
This model.
-
cbst_op_result construct(const std::vector<std::int32_t> &keys, const std::vector<std::int32_t> &starts, const std::vector<std::int32_t> &flat, const std::vector<std::int32_t> *row_counts = nullptr)#
Builds the tree over a flattened payload (constructCBST).
- Parameters:
keys – [in] The keys in sorted order, one per row.
starts – [in] The offset of every row in
flat.flat – [in] The flattened rows (
flat.size()values are used).row_counts – [in] The caller’s row counts (MOSP_ESCHER’s rowOccupancy), or nullptr.
- Returns:
The outcome.
-
cbst_op_result rebuild(const std::vector<std::int32_t> &starts, const std::vector<std::int32_t> &flat, std::int64_t flat_size, std::int64_t payload_capacity)#
Rebuilds the tree over a new payload with keys 1..n (rebuildCBSTFromDevice).
- Parameters:
starts – [in] The offset of every row.
flat – [in] The payload (its used prefix).
flat_size – [in] The used payload size.
payload_capacity – [in] The new capacity.
- Returns:
The outcome.
-
cbst_op_result insert(const std::vector<std::int32_t> &keys, const std::vector<std::int32_t> &payload, const std::vector<std::int32_t> &prefix)#
Inserts rows: best-fit reuse of deleted slots, then surplus keys (insertCBST).
- Parameters:
keys – [in] The requested keys (ignored, as by both originals; only their number).
payload – [in] The values of every item.
prefix – [in] The inclusive prefix sums of the item sizes.
- Returns:
The outcome;
mappingholds the key of every item.
-
cbst_op_result erase(const std::vector<std::int32_t> &keys)#
Marks keys as deleted (deleteCBST); the rows keep their values.
- Parameters:
keys – [in] The keys; missing keys are ignored.
- Returns:
The outcome.
-
cbst_op_result append(const std::vector<std::int32_t> &keys, const std::vector<std::int32_t> &payload, const std::vector<std::int32_t> &prefix)#
Appends values to rows (fillCBST): into the tail, then overflow segments.
- Parameters:
keys – [in] The keys, one per item.
payload – [in] The values of every item.
prefix – [in] The inclusive prefix sums of the item sizes.
- Returns:
The outcome.
-
cbst_op_result remove_values(const std::vector<std::int32_t> &keys, const std::vector<std::int32_t> &values, const std::vector<std::int32_t> &prefix)#
Removes every occurrence of values from rows (unfillCBST).
- Parameters:
keys – [in] The keys, one per item.
values – [in] The values to remove of every item.
prefix – [in] The inclusive prefix sums of the removal counts.
- Returns:
The outcome.
-
cbst_op_result compact()#
Compacts the payload (MOSP_ESCHER’s compactCBST).
- Returns:
The outcome;
compact_returnis the new bump pointer.
-
const cbst_host_policy &policy() const noexcept#
The policy.
- Returns:
The policy.
-
const std::string &name() const noexcept#
The dataset name.
- Returns:
The name.
-
std::int64_t num_records() const noexcept#
The record count of the tree (the originals’ numRecords).
- Returns:
The count.
-
std::int64_t num_nodes() const noexcept#
The nodes that exist (0 when the original allocated none).
- Returns:
The count.
-
std::int64_t payload_capacity() const noexcept#
The payload capacity.
- Returns:
The capacity in values.
-
std::int64_t bump() const noexcept#
The bump pointer (the used payload prefix).
- Returns:
The offset.
-
std::int32_t alignment() const noexcept#
The row alignment of surplus inserts.
- Returns:
The alignment.
-
std::int64_t scratch_items() const noexcept#
The item capacity of the scratch buffers.
- Returns:
The capacity.
-
std::int64_t scratch_payload() const noexcept#
The value capacity of the scratch buffers.
- Returns:
The capacity.
-
std::int64_t device_bytes() const noexcept#
ESCHER-GPU’s DynamicHypergraph::deviceBytes() formula on the model’s sizes.
- Returns:
72 bytes per record, 4 per payload value, 20 per scratch item, 4 per scratch value.
-
std::int64_t reusable_slots() const noexcept#
The deleted slots (the root’s subtree_avail), or -1 without nodes.
- Returns:
D.
-
std::vector<std::int32_t> keys() const#
The keys in BST (in-order) order.
- Returns:
The keys.
-
std::vector<std::int32_t> subtree_avail() const#
The deleted slots of every subtree, by heap position.
- Returns:
The counts.
-
std::vector<cbst_key_record> records() const#
Every key’s record and row, in BST order.
- Returns:
The records.
-
bool record(std::int32_t key, cbst_key_record &out) const#
One key’s record and row.
- Parameters:
key – [in] The key.
out – [out] The record.
- Returns:
false if no node holds the key.
-
const std::vector<cbst_model_event> &events() const noexcept#
The growths and compactions so far.
- Returns:
The events.
-
std::int64_t num_operations() const noexcept#
The operations applied so far.
- Returns:
The count.
-
bool exited() const noexcept#
Whether a failed operation ended the original’s process (the tree takes no more operations: they return cbst_op_status::undefined).
- Returns:
true after a process_exit.
-
std::vector<std::string> check() const#
The model’s own consistency check: subtree_avail sums (MOSP_ESCHER’s checkSubtreeAvail), BST order of the keys, rows that end inside the payload.
- Returns:
The problems found (empty: none).
-
cbst_host_model(cbst_host_policy policy, std::int64_t payload_capacity, std::int32_t alignment = 4, std::string name = {})#
-
struct check_sssp_options#
- #include <dyng/testing/check_sssp.hpp>
Options of check_sssp_tree().
-
struct sssp_tree_check#
- #include <dyng/testing/check_sssp.hpp>
The findings of check_sssp_tree() (MOSP’s TreeCheck).
Public Functions
-
inline bool ok() const noexcept#
Whether the tree passed.
- Returns:
true if nothing was found (non-canonical parents count only in canonical mode).
-
std::string summary() const#
A one-line summary of the counters.
- Returns:
The summary.
Public Members
-
std::int64_t distance_mismatches = 0#
dist[v] differs from Dijkstra
-
std::int64_t inconsistent_parents = 0#
no edge (p,v) with w > 0 and d[p] + w == d[v]
-
std::int64_t non_canonical_parents = 0#
consistent, but not the lowest id
-
std::int64_t parent_mismatches = 0#
parent differs from Dijkstra (canonical mode only)
-
bool require_canonical = true#
the mode the check ran in
-
inline bool ok() const noexcept#
-
template<typename vertex_t>
struct sssp_tree# - #include <dyng/testing/dijkstra.hpp>
A shortest-path tree on the host.
- Template Parameters:
vertex_t – Vertex id type.
Public Members
-
std::vector<std::int64_t> distances#
infinite_distance<int64_t>() if unreachable
-
struct harmonic_options#
- #include <dyng/testing/harmonic_solution.hpp>
Options of harmonic_solution().
-
struct harmonic_result#
- #include <dyng/testing/harmonic_solution.hpp>
The harmonic solution and how it was reached.
Public Members
-
std::vector<double> solution#
F* per vertex: a present seed holds its label (0 or 1), a determined vertex the solution, every other vertex 0.5.
-
std::vector<std::uint8_t> determined#
1 for the determined vertices: present, unlabelled, in a component with a present seed.
-
bool converged = false#
relative_residual <= relative_tolerance
-
double relative_residual = 0.0#
|r| / |b| at the end (0 when b = 0: x = 0 exactly)
-
std::int64_t iterations = 0#
PCG iterations.
-
std::int64_t num_seeds = 0#
present vertices with a seed label
-
std::int64_t num_unlabelled = 0#
present vertices without one
-
std::int64_t num_determined = 0#
unlabelled vertices of seeded components
-
std::int64_t num_excluded = 0#
unlabelled vertices of seed-free components
-
std::vector<double> solution#
-
struct label_error#
- #include <dyng/testing/harmonic_solution.hpp>
The comparison of labels with the harmonic solution (the oracle’s per-batch line).
Public Members
-
std::int64_t compared = 0#
present unlabelled vertices of seeded components
-
std::int64_t excluded = 0#
present unlabelled vertices of seed-free components
-
double mean = 0.0#
mean |F - F*| over the compared vertices (0 if none)
-
double max = 0.0#
max |F - F*|
-
std::int64_t flips = 0#
compared vertices with (F >= 0.5f) != (F* >= 0.5)
-
std::int64_t compared = 0#
-
struct class_agreement#
- #include <dyng/testing/harmonic_solution.hpp>
Class agreement of labels with the harmonic solution, with a margin.
-
struct line_graph_rows#
- #include <dyng/testing/line_graph_oracle.hpp>
A line graph as a CSR: row i (hyperedge id i) lists
neighbours[offsets[i] .. offsets[i + 1]), sorted.Public Functions
-
inline std::int64_t num_ids() const noexcept#
Number of rows (ids).
- Returns:
offsets.size() - 1.
-
inline std::int64_t num_ids() const noexcept#
-
struct lp_model_batch#
- #include <dyng/testing/lp_host_model.hpp>
One batch for lp_host_model::apply(): arrivals with seed labels, new edges, departures.
Public Members
-
std::vector<std::int32_t> insert_vertices#
Ins, in order.
-
std::vector<std::int8_t> insert_labels#
per arrival: -1 or its seed label 0 / 1
-
std::vector<std::int32_t> delete_vertices#
Del, in order.
-
std::vector<std::int32_t> edge_sources#
new edges (u, v), in order
-
std::vector<std::int32_t> edge_destinations#
see edge_sources
-
std::vector<float> edge_weights#
the weight of each new edge
-
std::vector<std::int32_t> insert_vertices#
-
struct lp_model_report#
- #include <dyng/testing/lp_host_model.hpp>
What one lp_host_model::apply() predicts for the batch.
Public Members
-
std::vector<std::int32_t> inserted#
Ins_eff, in Ins order.
-
std::vector<std::int32_t> deleted#
Del_eff, in Del order.
-
std::vector<std::int32_t> affected#
V_aff (present, unlabelled), sorted.
-
std::vector<std::int32_t> sparsified#
G’ as (min, max) pairs, sorted, flattened.
-
std::int32_t num_components = 0#
components of G’ on Ins_eff
-
std::vector<std::int32_t> component_of_inserted#
component id per Ins_eff vertex
-
std::vector<std::uint64_t> w0#
supernode weight to class 0, per component
-
std::vector<std::uint64_t> w1#
supernode weight to class 1, per component
-
std::vector<float> initial_labels#
per Ins_eff vertex
-
std::int64_t appended = 0#
entries appended (both directions)
-
std::int64_t dropped_absent = 0#
edges not appended: an endpoint is not present
-
std::int64_t dropped_overflow = 0#
entries dropped past their row’s capacity
-
std::vector<std::int32_t> inserted#
-
class lp_host_model#
- #include <dyng/testing/lp_host_model.hpp>
The host model; see the file documentation.
Public Types
Public Functions
-
explicit lp_host_model(const std::vector<std::int64_t> &row_capacity)#
An empty graph whose rows have the given slot capacities.
- Parameters:
row_capacity – [in] Slots of each vertex’s row (>= 0): its full-graph degree.
- Throws:
std::invalid_argument – if a capacity is negative.
-
lp_model_report apply(const lp_model_batch &batch, float tau)#
Apply one batch and predict its stages.
- Parameters:
batch – [in] The batch.
tau – [in] The sparsification threshold.
- Throws:
std::invalid_argument – before any change if an id or an edge endpoint is out of range, the label array does not match the arrivals, a label is not -1, 0 or 1, or a seeded arrival is also deleted.
- Returns:
The prediction.
-
inline std::int32_t num_vertices() const noexcept#
Number of vertices.
- Returns:
The size of the capacity array given at construction.
-
inline const std::vector<vertex_state> &states() const noexcept#
The state of every vertex.
- Returns:
One state per vertex.
-
inline const std::vector<std::uint8_t> &present() const noexcept#
The vertices of V_{t+1}: the active ones after the last batch.
- Returns:
1 for a present vertex, 0 otherwise.
-
inline const std::vector<std::uint8_t> &previously_present() const noexcept#
The vertices of V_t: those present before the last batch.
- Returns:
1 for a vertex that was present, 0 otherwise.
-
inline const std::vector<std::int8_t> &seed_labels() const noexcept#
The seed labels (O’s gtClass).
- Returns:
Per vertex -1 or its seed label 0 / 1.
-
inline const std::vector<std::int64_t> &row_ptr() const noexcept#
The first slot of every row.
- Returns:
num_vertices + 1 offsets (the last one: the number of slots).
-
inline const std::vector<std::int64_t> &row_end() const noexcept#
The end of every row’s entries.
- Returns:
One slot index per vertex.
-
inline const std::vector<std::int32_t> &slot_columns() const noexcept#
The column of every slot.
- Returns:
The columns (-1 for an unused slot).
-
inline const std::vector<float> &slot_weights() const noexcept#
The weight of every slot.
- Returns:
The weights (0 for an unused slot).
-
inline std::int32_t row_overflow_flag() const noexcept#
O’s sticky ERROR_ROW_OVERFLOW flag.
- Returns:
1 once an entry was dropped past its row’s capacity, else 0.
-
inline std::int32_t reinserted_flag() const noexcept#
O’s sticky ERROR_REINSERTED flag.
- Returns:
1 + the largest id inserted while it was not inactive, else 0.
Public Static Functions
-
static float average_weight(const std::vector<std::int32_t> &col_ind, const std::vector<float> &weights)#
The published threshold of a full graph: O’s computeAvgEdgeWeight, the mean of the weights of the entries with a column >= 0, summed in double in entry order, rounded to float (0.5 for a graph without entries).
- Parameters:
col_ind – [in] The columns of the full CSR.
weights – [in] Its weights.
- Throws:
std::invalid_argument – if the sizes differ.
- Returns:
tau.
-
explicit lp_host_model(const std::vector<std::int64_t> &row_capacity)#
-
struct triad_reference_options#
- #include <dyng/testing/triad_reference.hpp>
How the oracle runs.
Public Members
-
int threads = 0#
Threads: 1 runs sequentially, 0 uses OpenMP’s default (sequential in a build without OpenMP). Every thread count gives the same counts.
-
int threads = 0#
-
struct triad_reference_counts#
- #include <dyng/testing/triad_reference.hpp>
The counts of all four patterns.
Public Functions
-
std::vector<std::uint64_t> of(triad_pattern pattern) const#
The counts of one pattern.
- Parameters:
pattern – [in] The pattern.
- Returns:
30 values for h_motif, else 1.
Public Members
-
std::array<std::uint64_t, triad_num_classes> h_motif = {}#
bin k - 1 = class k
-
std::uint64_t type1 = 0#
StatHyper type 1.
-
std::uint64_t type2 = 0#
StatHyper type 2.
-
std::uint64_t type3 = 0#
StatHyper type 3.
-
std::vector<std::uint64_t> of(triad_pattern pattern) const#
-
class union_find#
- #include <dyng/testing/union_find.hpp>
Disjoint sets over the integers [0, size), the root of each set its smallest member.
Public Functions
-
inline explicit union_find(std::int64_t size)#
sizesingleton sets {0}, {1}, …, {size - 1}.- Parameters:
size – [in] Number of elements (>= 0).
- Throws:
std::invalid_argument – if
sizeis negative.
-
inline std::int64_t size() const noexcept#
Number of elements.
- Returns:
The size given at construction.
-
inline std::int64_t find(std::int64_t x)#
The root (smallest member) of the set of
x; halves the path to it.- Parameters:
x – [in] An element in [0, size()).
- Throws:
std::out_of_range – if
xis out of range.- Returns:
The root.
-
inline bool unite(std::int64_t a, std::int64_t b)#
Merge the sets of
aandb: the smaller root becomes the root of the union.- Parameters:
a – [in] An element.
b – [in] An element.
- Throws:
std::out_of_range – if an element is out of range.
- Returns:
True if they were in different sets.
-
inline bool same(std::int64_t a, std::int64_t b)#
Whether
aandbare in the same set.- Parameters:
a – [in] An element.
b – [in] An element.
- Returns:
True if find(a) == find(b).
-
inline explicit union_find(std::int64_t size)#