Command-line interface#
The dyng command comes with the Python package (pip install dyng installs the console
script; python -m dyng is the same program). It runs the algorithms on files in the formats
of the original tools and writes their output formats, so its results can be compared byte for
byte with the originals’ (ADR 0025).
dyng [--version] [--log-level LEVEL] COMMAND ...
sssp compute | update dynamic single-source shortest paths
mosp compute | update dynamic multi-objective shortest paths (0.2)
label_propagation compute | update dynamic label propagation under vertex batches (0.4)
cycle_count compute | update directed simple-cycle histograms
triad_count compute | update hypergraph triad counts (0.3)
hyper_sssp compute | update dynamic single-source shortest hyperpaths (0.4)
prep SUBCOMMAND MOSP's input preparation (the mospPrep subcommands)
convert INPUT OUTPUT convert a graph between formats
generate GENERATOR the seeded generators (the original tools' and dynG's)
config the build and runtime configuration (dyng.show_config())
dyng COMMAND --help lists every flag of a command. Exit status: 0 on success, 1 when the work
fails (the message is printed as dyng: error: ... on standard error), 2 for a usage error.
Conventions#
Option flags are the option fields. Every field of an algorithm’s Options is a flag with
the field’s name in kebab case, generated from the dataclass (dyng.cycle_count.Options.max_length
is --max-length); an enumeration takes its names (--cuda-engine fused), a boolean has a
--no- form (--no-validate-inputs). The flags of dyng generate are the keyword arguments of
the generator functions in the same way (dyng.generators.legacy.cycle_enum_batch(num_deletions=)
is --num-deletions). A flag that is not given keeps the field’s default.
Backends. --backend sequential|openmp|cuda (default: openmp when the build has it),
--threads T (OpenMP threads; 0 is the OpenMP default, which honours OMP_NUM_THREADS) and
--device D. Every backend gives the same bytes. The CPU wheel has no cuda backend; asking for
it fails with a message that names the CUDA plugin wheels dyng-cu12 and dyng-cu13 (from
0.2.0: pip install "dyng[cu13]" or "dyng[cu12]").
Graph input (--graph PATH, also spelled --input) with --format:
|
Reader |
Notes |
|---|---|---|
|
|
MOSP’s text CSR: |
|
|
|
|
|
|
|
|
--vertex-type int32|int64 and --edge-type int32|int64 choose the id types (sssp, mosp,
convert, mosp_changes; cycle_count supports int32 ids). --properties default|mosp_compatible|cycle_enum_compatible
chooses the graph properties; the default is the preset of the original tool (mosp_compatible
for sssp, mosp and MOSP’s generator, cycle_enum_compatible for cycle_count and its generator).
Batches. MOSP’s files: --changes DIR (DIR/insert.txt with u v w1 .. wK per line and
DIR/delete.txt with u v), or --insert FILE --delete FILE; they are read with MOSP’s
accept and reject rules. The text batch of CycleEnumeration-GPU’s generator: --batch FILE, one
change per line, - u v for a deletion and + u v [w1 .. wK] for an insertion, in graph ids
(the output of dyng generate cycle_enum_batch; see File formats). A --batch file
whose name ends in .dgt is read as the library’s batch text format (+e u v [w..] / -e u v,
File formats) and must hold one batch.
dyng sssp#
dyng sssp compute --graph G [--source S] [options] --out DIR
dyng sssp update --graph G (--changes DIR | --insert F --delete F) [--init DIR [--canonicalize]]
[--source S] [options] --out DIR [--write-graph PREFIX]
Options: --delta, --objective, --cuda-engine, and on update --validate-inputs /
--no-validate-inputs (the fields of dyng.sssp.Options; validate_inputs checks the trees
read with --init, so compute has no such flag). Without --objective every weight column of
the graph gets its own tree, as MOSP computes one tree per objective (--help says so). The
graph needs integer weights: a Matrix Market file without them (a pattern or real matrix)
needs --random-weights MIN,MAX,SEED (and --num-weights K for K objectives), and the error
message says so; --source must name a vertex of the graph.
compute writes DIR/obj<k>/distancesOriginal.txt and DIR/obj<k>/SSSPTreeOriginal.txt, the
files of mospPrep init. update reads the initial trees from --init (the same layout; with
--canonicalize the lowest-id tie rule is applied to them, MOSP’s canonicalizeTree) or computes
them, applies the batch once and updates every tree (dyng.update), then writes
DIR/obj<k>/distancesUpdated.txt and DIR/obj<k>/SSSPTreeUpdated.txt, the files of MOSP’s
mosp driver. --write-graph PREFIX also writes the updated graph as MOSP’s text CSR. One
report line per tree goes to standard output (--quiet suppresses them).
$ dyng prep mtx2csr roadNet-CA.mtx roadNet-CA_ 1 1 100 12345
$ dyng prep changes roadNet-CA_ batch --changes 50000 --ins 50 --seed 1
$ dyng sssp compute --graph roadNet-CA_ --out init
$ dyng sssp update --graph roadNet-CA_ --changes batch --init init --out updated
dyng mosp#
dyng mosp compute --graph G [--source S] [options] --out DIR
dyng mosp update --graph G (--changes DIR | --insert F --delete F) [--init DIR [--canonicalize]]
[--source S] [options] --out DIR [--write-graph PREFIX]
Options (the fields of dyng.mosp.Options): --preferences P1,..,PK (the preference vector,
one integer >= 1 per objective, comma-separated as MOSP’s --pref; default all 1, lcm at most
2^20), --num-objectives K (the first K weight columns; default 0, every column; MOSP’s -k),
--delta, --cuda-engine automatic|fused|operators, --compute-path-costs /
--no-compute-path-costs, and on update --validate-inputs / --no-validate-inputs (it checks
the trees read with --init). The graph and batch flags are those of dyng sssp.
compute writes DIR/obj<k>/distancesOriginal.txt and SSSPTreeOriginal.txt (the files of
mospPrep init) and the combined graph’s outputs DIR/combinedGraph/distancesCsr.txt (the
combined distances, in units of 1/L with L = lcm of the preferences), SSSPTreeCsr.txt (the MOSP
tree) and mospCosts.txt (v c1 .. cK per vertex, INF when unreachable: the path costs).
update reads the initial trees from --init or computes them, applies the batch once, updates
the K trees and rebuilds the combined graph, the MOSP tree and the costs (dyng.mosp.update),
then writes DIR/obj<k>/distancesUpdated.txt, SSSPTreeUpdated.txt and the three
combinedGraph/ files: every byte as MOSP’s mosp driver writes them (with
--num-objectives below the graph’s column count, mospCosts.txt covers every column, as the
original’s does; with --no-compute-path-costs it is not written). The tests compare the output
with the committed fixtures of both originals, with dyng-compat-mosp --mosp and, where it is
built, with MOSP-OpenMP’s mosp.
|
|
|---|---|
|
the same flags |
|
|
|
|
|
not in |
$ dyng prep mtx2csr roadNet-CA.mtx roadNet-CA_ 3 1 100 12345
$ dyng prep changes roadNet-CA_ batch --changes 50000 --ins 50 --seed 777
$ dyng prep init roadNet-CA_ init
$ dyng mosp update --graph roadNet-CA_ --changes batch --init init --preferences 4,1,4 --out out
obj0: invalidated ..., affected ..., iterations ..., engine fused
...
combined: L=4, reachable ... of 1971281, ... edges, affected ...
dyng label_propagation#
dyng label_propagation compute --graph EDGES --seeds FILE [--index-base B] [--num-vertices N]
[options] [--backend sequential|cuda] --out DIR
dyng label_propagation update (--generate legacy|library [generator flags]
| --batches FILE.. [--capacity auto|FILE] [--true-labels FILE])
[--layout slotted|slack] [options] [--per-batch-labels]
[--backend sequential|cuda] --out DIR
LabelPropagation-CUDA’s DynLP (dyng.label_propagation, 0.4; ADR 0108). Options (the fields of
dyng.label_propagation.Options, one flag each): --similarity-threshold published|current|TAU
(tau: published is the stream’s threshold, the average edge weight of the full graph, and the
default of update; with --batches the average weight of the files’ edges, as the original’s
computeAvgEdgeWeight sums them; current is the streaming mode’s average of the current graph,
the default of compute; or a number), --tolerance (delta), --max-iterations,
--on-iteration-limit error|report|fallback_recompute, --update-schedule in_place|damped and
--cuda-engine automatic|fused|operators. The backends are sequential and cuda (no OpenMP
backend in 0.4; default: cuda when the active module has it, else sequential).
compute reads an undirected edge list u v w with float weights (dyng.io.read_edge_list(..., weight_dtype="float32", ids="as_is"); datasets/preprocess/knn_graph.py writes one) and seed
labels v class (class 0 or 1), runs IrLP and writes DIR/dynlp_labels.txt.
update runs the published setup (ADR 0071): a graph with the stream’s row capacities
(Graph.with_capacity), compute on the empty graph, then one update per batch. The stream is
generated (--generate legacy: LabelPropagation-CUDA’s generator, byte for byte; --generate library: the library’s; the generator flags --total-vertices, --average-degree,
--num-batches, --seed, --ground-truth-fraction, --deleted-fraction are its keyword
arguments) or read from .dgt / .dgb files (--batches, applied in order, with
--capacity auto, each vertex’s edges over every batch, or a file of one integer per vertex, and
optionally --true-labels for the accuracy). --layout slack with --similarity-threshold current is the streaming mode. It writes DIR/dynlp_labels.txt (i label, the original’s bytes:
dyng.io.write_labels), with --per-batch-labels also DIR/dynlp_labels_b<i>.txt, and
DIR/stats.csv: the original’s results.csv columns batch, time_ms, iterations, frontier_visits, components, accuracy, eval_ms (the time is the host wall time of the
update call; the accuracy over the active vertices without a seed label, as the original’s
computeAccuracy), then affected, initial_frontier, sparsified_edges, converged, fallback_used, inserted_vertices, deleted_vertices, inserted_edges, dropped_insertions. On the original’s 5k5
stream (--generate legacy --total-vertices 5000 --num-batches 5 --update-schedule damped --backend sequential) the labels are dyng-compat-dynlp’s sequential output byte for byte, and
on cuda the original’s own (the tests).
|
|
|---|---|
|
|
|
|
|
|
|
|
|
not in |
$ dyng label_propagation update --generate legacy --total-vertices 50000 --num-batches 10 \
--update-schedule damped --backend sequential --out run
batch 0: ... ms, 0 iterations, 497 components, accuracy 100.00%
...
dyng cycle_count#
dyng cycle_count compute --graph G [options] [--output FILE]
dyng cycle_count update --graph G [options] [--output FILE]
(--batch FILE | --changes DIR | --insert F --delete F |
--num-deletions D --num-insertions I --seed S [--locality-window W])
[--write-batch FILE] [--compare-recompute]
Options: --max-length, --method, --mode, --cuda-engine, --scheduler, --work-items
(the fields of dyng.cycle_count.Options). Set --max-length for large graphs: without a bound
compute can take exponential time. update requires --max-length (a usage error, exit
status 2, without it), as the original’s --task update requires --max-cycle-length: the
update enumerates the simple paths through the changed edges up to that length.
The histogram is printed in CycleEnumeration-GPU’s CSV (# cycle_size, num_of_cycles, one
len, count line per non-zero length, Total, N), byte for byte as its cycle-enum prints it.
update counts the graph, applies the batch (read from a file, or generated with the arguments
of dyng generate cycle_enum_batch), updates the histogram and prints the updated histogram;
update_seconds= goes to standard error, and with --compare-recompute also
recompute_seconds= and match=yes|no (a mismatch exits with status 1).
The original’s flags and dynG’s:
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The value names are the enumerators of dyng.cycle_count.Options (work_queue, automatic,
two_hop); the original’s other spellings are not accepted. On standard error dyng cycle_count update prints update_seconds= (and recompute_seconds=, match=), not the
original’s deletions=N insertions=M line; the batch’s size is in the histogram’s input (or
--write-batch). The drop-in clone with the original’s flags, exit statuses and timing lines is the C++ tool
dyng-compat-cycle-enum (tools/compat, for the parity harness).
dyng triad_count#
dyng triad_count compute --input H.hg [read flags] [options] [--format json|escher] [--output FILE]
dyng triad_count update --input H.hg [read flags] [options] [--format json|escher] [--output FILE]
--batches FILE [FILE ...] [--compare-recompute]
Options: --kind h_motif|stathyper_type1|stathyper_type2|stathyper_type3 and --cuda-engine
(the fields of dyng.triad_count.Options; default --kind h_motif, the 30 h-motif bins).
Hypergraph input (--input PATH, also spelled --hypergraph): a .hg file
(File formats), read by dyng.io.read_hypergraph with ESCHER-GPU’s loader (the option
set --read-options escher_gpu, the default; --read-options hsosp is H-SOSP’s). The read
flags are the keyword arguments of dyng.io.read_hypergraph: --index-base,
--dedupe-hyperedges, --max-cardinality, --relabel, --num-vertices, --weighted (a file
with ; w on every line; the weights are ignored by triad_count) override the option set’s
fields, and --storage, --line-graph, --id-reuse, --capacity and --store-v2h the
hypergraph’s properties. --min-initial-payload N with --capacity escher_gpu is
CapacityPolicy.escher_gpu(N), ESCHER-GPU’s --payload-capacity. The h-motifs and types 2 and
3 need the line graph and the vertex-to-hyperedge rows (--line-graph none or
--no-store-v2h is an error for them; type 1 needs neither).
Batches (update): --batches FILE ..., applied in order; each file is a .dgt batch file
(+h v1 v2 .. / -h id, any number of batches) or a .dgb binary batch file (by its magic). A
.dgb file that carries the expected ids of every insertion (as the parity harness’s recordings
do) is checked: a batch whose inserted ids differ fails with exit status 1 (the hypergraph was not
built as the recording’s run built it, so later deletions would name other hyperedges: give the
same --num-vertices, --id-reuse, --capacity and --min-initial-payload).
Output. --format json (the default) writes the triad-bins JSON of
dyng.io.write_triad_bins (File formats): the kind, the hypergraph version, the counts
(after the last batch for update) and, for update, one row of deltas per batch.
--format escher prints the lines of ESCHER-GPU@abcf9b2’s build/main (--kind h_motif),
type1, type2 and type3, byte for byte: Hypergraph: N hyperedges, max vertex id V, P pins,
the baseline (Motif counts (30 bins): c0 .. c29, [GPU] Type1 baseline motif count (sum_e C(|e|, 3)): N, [GPU] Type2 baseline motif count: N, [GPU] Type3 baseline motif count: N),
and per batch Batch b (D deletions, I insertions) (when there is more than one batch, as the
original prints it) and the delta (Motif delta counts (30 bins): d0 .. d29, [GPU] TypeN motif delta count: N). The [GPU] prefix is the original’s on every backend; max vertex id is the
hypergraph’s vertex count (ESCHER-GPU’s 1-based largest id). Bin k is ESCHER-GPU’s h-motif
k + 1; its open triads 21-26 (bins 20-25) are always 0. update_seconds= goes to standard
error, and with --compare-recompute also recompute_seconds= and match=yes|no (a mismatch
exits with status 1). The original generates its hypergraph and batches itself; the parity
harness records them as .hg and .dgb files, and dyng triad_count update --format escher
on those files prints the original’s standard output without its generator lines (the test
python/tests/test_triad_count_cli.py diffs every make-test case).
The original’s flags and dynG’s:
ESCHER-GPU |
|
|---|---|
|
|
|
|
|
the hypergraph and batch files the generator writes ( |
|
|
|
|
dyng hyper_sssp#
dyng hyper_sssp compute --input H.hg [read flags] [--source S] [options] --out DIR [--vertex-distances]
dyng hyper_sssp update --input H.hg [read flags] [--source S] [options] --out DIR [--vertex-distances]
--batches FILE [FILE ...] [--compare-recompute]
Shortest hyperpaths from the source vertex --source S (default 0) of a weighted hypergraph
(dyng.hyper_sssp; hyper_sssp: shortest hyperpaths). Options, the fields of
dyng.hyper_sssp.Options one to one: --work-budget X (a multiple of the live line-graph
entries; inf never falls back), --max-iterations N, --on-budget recompute|error,
--cuda-engine automatic|fused|operators and --validate-inputs / --no-validate-inputs.
The default backend is sequential (hyper_sssp has no OpenMP backend in 0.4: --backend openmp fails with exit status 1 and the library’s message); --backend cuda needs a CUDA
plugin wheel.
Hypergraph input (--input PATH, also spelled --hypergraph): a weighted .hg file
(File formats; ; w ends every line: these commands read with --weighted unless the
weights are drawn), read by dyng.io.read_hypergraph with the read flags of dyng triad_count
(above), stored as --storage slack_csr with --line-graph slack_csr (the defaults here;
--storage escher fails with exit status 1: hyper_sssp reads the slack_csr line graph).
--random-weights MIN,MAX,SEED draws one weight per hyperedge, uniform in [MIN, MAX], and
--read-options hsosp is MOSP_ESCHER’s loader (vertices numbered by first appearance,
hyperedges of at most 25 vertices, weights U[1, 100] from its seed 20260725). A hypergraph without
weights fails with exit status 1 and names these flags; weights must lie in [1, 2^28] (with
--validate-inputs, the default).
Batches (update): --batches FILE ..., applied in order; each file is a .dgt batch file
(+h v1 .. ; w / -h id, and the incidence edits +i h v / -i h v) or a .dgb binary batch
file (its flag incidence_edits when a batch has an edit). A .dgb file that carries the
expected ids of every insertion is checked as for dyng triad_count (exit status 1 when the ids
diverge: build the hypergraph as the recording’s run did, for MOSP_ESCHER’s batches --id-reuse insert_first).
Output (--out DIR, created if needed): the result after compute, or after the last batch
of update, in sssp’s distance and parent formats (File formats, MOSP’s
writeDistances() / writeParents()), one line per hyperedge id in [0, hyperedge id bound):
DIR/hyperedge_distances.txt (h D(h), h INF for a dead or unreachable id) and
DIR/hyperedge_parents.txt (h p, -1 for a hyperedge holding the source and for a dead or
unreachable id); with --vertex-distances also DIR/vertex_distances.txt (v d, the smallest
D(h) over v’s hyperedges, 0 for the source). Report lines go to standard output (--quiet
drops them): the compute time and the reachable hyperedges, and per batch its counts (deleted
and inserted hyperedges, removed and added incidences, skipped operations, the line-graph pairs
removed and added, the invalidated hyperedges, the relaxations, the fallback reason and the
engine). update_seconds= goes to standard error, and with --compare-recompute also
recompute_seconds= and match=yes|no (distances and parents of a recompute; a mismatch exits
with status 1).
MOSP_ESCHER’s hsospBench prints timings, not results; the parity harness’s driver
dyng-compat-hsosp replays its sessions (to-dgb, replay, bench).
MOSP_ESCHER@4b86159 ( |
|
|---|---|
|
|
the virtual source row |
|
|
|
|
|
dyng prep#
The six subcommands of MOSP’s mospPrep (MOSP-OpenMP c352151, MOSP-CUDA e220ee2), with its
positional arguments and flags, its output files byte for byte and its report lines (the times
differ); each ends with <command> done in <ms> ms (rc=<status>).
dyng prep mtx2csr <in.mtx> <outPrefix> <K> <wmin> <wmax> <seed>
dyng prep widen <inPrefix> <outPrefix> <K> <wmin> <wmax> <seed>
dyng prep cache <csrPrefix> <binaryPath>
dyng prep changes <csrPrefix> <outDir> [--changes N] [--ins PCT]
[--mode uniform|targeted|reweight|increase] [--local HOPS] [--safe]
[--seed S] [--source s] [--wmin a] [--wmax b] [-k K]
dyng prep init <csrPrefix> <outDir> [--source s] [-k K] [--backend B] [--threads T]
dyng prep expected <csrPrefix> <changesDir> <outDir> [--source s] [-k K] [--backend B] [--threads T]
Subcommand |
What it writes |
|---|---|
|
Matrix Market to MOSP’s text CSR: symmetric matrices get both directions, self-loops and duplicates are dropped, every edge gets K seeded weights in [wmin, wmax] (1 <= K <= 32) |
|
a copy of the graph with random objectives appended until it has K (the existing ones unchanged) |
|
MOSP’s binary cache ( |
|
|
|
|
|
|
dyng convert#
dyng convert INPUT OUTPUT [--format auto|csr|mtx|edges] [reader flags] [--to auto|csr|mtx|edges]
[--weight-column K]
Reads a graph with the reader flags above and writes it as MOSP’s text CSR (--to csr, OUTPUT a
prefix; the graph needs weights), a general coordinate Matrix Market file (--to mtx, the
default for *.mtx; --weight-column chooses the value column) or an edge list (src dst [w..]
per line, the default otherwise). dyng convert g.mtx g_ --to csr --num-weights K --random-weights 1,100,12345 writes the same bytes as mospPrep mtx2csr g.mtx g_ K 1 100 12345.
dyng generate#
dyng generate mosp_changes --graph G --out DIR [--num-changes N] [--insertion-percentage P]
[--mode M] [--weight-min A] [--weight-max B] [--seed S]
[--local-hops H] [--safe-deletions] [--source S]
dyng generate cycle_enum_batch --graph G [--num-deletions D] [--num-insertions I] [--seed S]
[--locality-window W] [--out FILE]
dyng generate vertex_arrival_stream [generator flags] --out DIR [--format dgb|dgt]
[--graph-files]
dyng generate dynlp_vertex_arrival_stream [generator flags] --out DIR [--format dgb|dgt]
[--graph-files]
mosp_changes is MOSP’s generateChangeBatch (the same batch as dyng prep changes and
mospPrep changes, with the generator’s argument names); it writes DIR/insert.txt and
DIR/delete.txt and prints the report line. cycle_enum_batch is CycleEnumeration-GPU’s
generate_batch: the batch in graph ids, deletions first, as text on standard output or in FILE.
Both are bit-exact with the originals for a fixed seed.
The vertex-arrival generators of dyng.label_propagation (0.4) are named as their Python
functions (AD12): vertex_arrival_stream is the library’s
(dyng.generators.vertex_arrival_stream, library-owned draws, bit-exact on every platform) and
dynlp_vertex_arrival_stream LabelPropagation-CUDA’s
(dyng.generators.legacy.dynlp_vertex_arrival_stream, the original’s stream byte for byte). The
generator flags are their keyword arguments: --total-vertices, --average-degree,
--num-batches, --seed, --ground-truth-fraction, --deleted-fraction and --edge-type int32|int64 (Python’s edge_dtype; spelled as the 0.3 commands spell it). Each writes DIR/batches.dgb (--format dgt: DIR/batches.dgt; the batches’
vertex operations and float weights, AD13), DIR/row_capacity.txt (one integer per vertex: the
full degrees), DIR/true_labels.txt (i class), DIR/stream.json (the published
similarity_threshold, the sizes and the options) and, with --graph-files, the original’s
DIR/graph/csr{RowPtr,ColInd,Values,TrueLabels}.txt byte for byte. dyng label_propagation update --batches DIR/batches.dgb --capacity DIR/row_capacity.txt --true-labels DIR/true_labels.txt --similarity-threshold <stream.json's> replays the stream.