Skip to content

Gen#34

Open
pratzl wants to merge 4 commits into
mainfrom
gen
Open

Gen#34
pratzl wants to merge 4 commits into
mainfrom
gen

Conversation

@pratzl
Copy link
Copy Markdown
Collaborator

@pratzl pratzl commented May 31, 2026

No description provided.

pratzl added 4 commits May 31, 2026 16:37
complete_graph (include/graph/generators/complete.hpp):
- Generates all n*(n-1) ordered pairs (u,v), u != v
- Output naturally sorted by source_id then target_id
- O(n^2) edge count; size warning in header and user-guide

erdos_renyi_gnm (include/graph/generators/gnm.hpp):
- Fixed edge count variant of Erdos-Renyi: selects exactly m distinct
  edges uniformly at random via rejection sampling on the G(n,p)
  position encoding (pos -> (u,v), same scheme as erdos_renyi.hpp)
- Clamps m to n*(n-1) when too large
- Output sorted by source_id after sampling

Both generators:
- Follow the established pattern: edge_list<VId> return type,
  weight_dist enum, uint64_t seed, VId template parameter
- Added to generators.hpp umbrella header

Tests (tests/generators/test_generators.cpp):
- New TEST_CASEs for complete_graph and erdos_renyi_gnm covering:
  count, no self-loops, ids in range, distinctness, sorted,
  determinism, K(n) full coverage, gnm clamping
- uint64_t template test extended to include both new generators

Docs:
- docs/user-guide/generators.md: TOC entries, individual-include lines,
  complete_graph and erdos_renyi_gnm sections with parameter tables,
  weight_dist options, and usage examples
- agents/bgl_migration_strategy.md: mark G(n,m) and K(n) done in
  §9 table and API block; trim Remaining Gaps; update executive
  summary bullet, Appendix B Done note, scorecard row (67%->83%),
  and overall coverage (~46%->~47%)
watts_strogatz (include/graph/generators/watts_strogatz.hpp):
- Ring lattice with k nearest neighbours + probability-beta rewiring
- Avoids self-loops and duplicate undirected pairs; bidirectional edges
- beta=0 yields pure ring lattice (N*K directed edges)

rmat (include/graph/generators/rmat.hpp):
- Recursive-matrix (Graph500-style) with (a,b,c,d) quadrant probabilities
- 2^scale vertices, descends scale levels per edge
- Default params are standard Graph500 (0.57,0.19,0.19,0.05)
- Self-loops and duplicate directed edges removed

plod (include/graph/generators/plod.hpp):
- Palmer-Steffan power-law out-degree model
- Per-vertex credit drawn from power law, edges to random targets
- No self-loops or duplicates

All three follow the established pattern (edge_list<VId> return,
weight_dist enum, uint64_t seed, VId template param) and are added to
the generators.hpp umbrella header.

Tests: new TEST_CASEs for each covering no-self-loops, id range,
distinctness, sorted, determinism, and model-specific invariants
(WS ring-lattice count, RMAT m bound). uint64_t template test extended.

Docs:
- docs/user-guide/generators.md: TOC, includes, and full sections with
  parameter tables and examples for all three
- agents/bgl_migration_strategy.md: mark WS/R-MAT/PLOD done in §9; only
  SSCA#2 remains; update executive summary, roadmap, Done note, and
  scorecard (generators 83%->95%, overall ~47%->~48%)
ssca (include/graph/generators/ssca.hpp):
- Partitions vertices into consecutive cliques of random size [1, max_clique_size]
- Dense intra-clique edges with up to max_parallel_edges parallel edges
  per pair (a defining SSCA#2 trait)
- Sparse inter-clique edges, accept probability decays as 2^-(clique distance)
- No self-loops; output sorted by source_id

Completes full BGL graph-generator parity. Follows the established
pattern (edge_list<VId> return, weight_dist enum, uint64_t seed, VId
template param); added to generators.hpp umbrella header.

Tests: new TEST_CASE covering no-self-loops, id range, sorted,
determinism, and the empty-graph edge case (clique size 1, no
inter-clique edges). uint64_t template test extended.

Docs:
- docs/user-guide/generators.md: TOC, include, full ssca section
- agents/bgl_migration_strategy.md: mark SSCA#2 done; generators now
  100% (full parity); move generators bullet from gaps to strengths in
  executive summary; clear Remaining Gaps; update API block, roadmap,
  and Done note
dimacs (include/graph/io/dimacs.hpp):
- write_dimacs(os, g, problem="sp") — generic arc list, 1-indexed endpoints,
  edge weight auto-serialized when EV is formattable
- write_dimacs_max_flow(os, g, source, sink, capacity_fn) — emits p/n/a lines
- read_dimacs(is) -> dimacs_graph — handles c/p/n/a/e line kinds; normalizes
  1-indexed endpoints to 0-indexed ids; parses max-flow, sp, and edge formats

metis (include/graph/io/metis.hpp):
- write_metis(os, g, with_weights=false) — treats graph as undirected; builds
  symmetric deduplicated adjacency; sets fmt=001 when with_weights=true and EV
  is formattable
- read_metis(is) -> metis_graph — handles optional fmt 3-digit flag (vertex
  sizes / vertex weights / edge weights) and ncon field; normalizes to 0-indexed

adjacency_list_text (include/graph/io/adjacency_list_text.hpp):
- write_adjacency_list_text(os, g) — one line per vertex: "<id>: <t0> <t1> ..."
- read_adjacency_list_text(is) -> adjacency_list_text_graph — accepts colon
  separator or whitespace-only; preserves vertex set (empty-adjacency lines)

include/graph/io.hpp: extended umbrella to include all six I/O headers.

Tests (tests/io/test_io.cpp): 15 new test cases covering write, read, roundtrip,
and edge cases for all three formats (167 assertions in 34 test cases, all pass).

Docs:
- docs/user-guide/io.md: updated overview table, headers section, added full
  sections (API signatures, examples, reader return fields) for DIMACS, METIS,
  and adjacency-list-text
- agents/bgl_migration_strategy.md: mark all three formats done in §8 table;
  remove "No DIMACS or METIS I/O" from gaps; move I/O to strengths (full BGL
  parity + JSON); strike roadmap items; Graph I/O scorecard 60% -> 100%;
  overall coverage ~48% -> ~50%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant