Skip to content

Add COO representation; restructure core into LinearAlgebra - #28

Open
WoWaster wants to merge 2 commits into
mainfrom
coo-representation
Open

WoWaster wants to merge 2 commits into
mainfrom
coo-representation

Conversation

@WoWaster

Copy link
Copy Markdown
Member

Summary

Two commits, reviewable separately:

  1. refactor: restructure the core library (no behaviour change)

    • QuadTree/ → LinearAlgebra/, QuadTree.Tests → LinearAlgebra.Tests, QuadTree.Benchmark → LinearAlgebra.Benchmark, QuadTree.sln → LinearAlgebra.sln.
    • Units of measure (index, dataLength, nrows, ncols, rowindex, colindex, nvals) move to the representation-neutral LinearAlgebra.Common, so Graph no longer takes units from quad-tree modules.
    • Quad-tree code lives in LinearAlgebra/QuadTree/ as LinearAlgebra.QuadTree.{Common,Vector,Matrix,Operations}; the former LinearAlgebra module (vxm, mxm) is now Operations. Result is LinearAlgebra.Result.
    • Test counts identical before/after (160 / 120 / 26).
  2. feat: COO representation, minimal set for BFS, SSSP and TriangleCount

    • LinearAlgebra/COO/{Common,Vector,Matrix,Operations}.fs: sorted immutable lists, only present values stored (no Dummy, no stored Option), units of measure throughout.
    • Every operation has an ...Unsorted twin for hand-made fusion; sort converts back. Sorted vxm/vxmi_values/mxm reduce in ascending inner index, so they match the quad-tree exactly even for non-commutative op_add (e.g. bfsParent's first-wins).
    • Graph.Impl.COO.{BFS,SSSP,TriangleCount} ops instances; Graph.Impl.Default still points at the quad-tree.
    • Sorted/unsorted pitfalls (sorted op on unsorted data, non-commutative op_add in unsorted reductions, structural equality) are documented in LinearAlgebra/COO/Common.fs and AGENTS.md, and covered by regression tests.

Tests

  • Unit tests per COO module, plus FsCheck properties checking COO == quad-tree for map2, mask, mapi, vxm, vxmi_values, mxm, transpose, getLowerTriangle, foldAssociative, and sort (opUnsorted (shuffled input)) == op input.
  • Graph: fixed BFS/SSSP/TC scenarios on COO, random-graph equivalence with the quad-tree, a hand-fused (never sorting) triangle count, and a check that BFS run entirely on unsorted ops still yields a valid BFS tree.
  • dotnet fantomas --check ., dotnet build, dotnet test green: LinearAlgebra 186, Graph 129, Set 26.

Notes for reviewers

  • LinearAlgebra.Benchmark/Main.fs and LinearAlgebra/LinearAlgebra.fsproj show up as delete + create rather than renames (small files, mostly rewritten).
  • TODO.md: COO item ticked; added COO benchmarks, the quad-tree Vector.fromCoordinateList nvals bug (counts duplicates), and extending COO beyond this minimum.

🤖 Generated with Claude Code

WoWaster and others added 2 commits November 19, 2026 14:35
…ation layout

- QuadTree/ -> LinearAlgebra/, QuadTree.Tests -> LinearAlgebra.Tests,
  QuadTree.Benchmark -> LinearAlgebra.Benchmark, QuadTree.sln -> LinearAlgebra.sln.
- Units of measure move to the representation-neutral LinearAlgebra.Common;
  quad-tree code lives in LinearAlgebra/QuadTree/ as LinearAlgebra.QuadTree.*.
- The quad-tree LinearAlgebra module is renamed to Operations.
- No behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- LinearAlgebra/COO: Common (merge/join/reduce helpers), Vector, Matrix,
  Operations over sorted immutable lists, with units of measure throughout.
- Every operation has an ...Unsorted twin for hand-made fusion; sorted
  vxm/vxmi_values/mxm reduce in ascending inner index so they match the
  quad-tree even for non-commutative op_add.
- Graph.Impl.COO.{BFS,SSSP,TriangleCount} ops instances.
- Unit tests, FsCheck equivalence with the quad-tree, and regression tests
  for the documented sorted/unsorted pitfalls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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