Skip to content

Commit 08aad13

Browse files
williamfisetclaude
andauthored
Add CLAUDE.md with build commands and architecture guide (williamfiset#1249)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 90a2364 commit 08aad13

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build System
6+
7+
This project uses **Bazel** as its build system (requires JDK 8+). Dependencies are managed via Maven through `rules_jvm_external` and declared in `MODULE.bazel`.
8+
9+
## Commands
10+
11+
**Run all tests:**
12+
```bash
13+
bazel test //src/test/...
14+
```
15+
16+
**Run tests for a specific package:**
17+
```bash
18+
bazel test //src/test/java/com/williamfiset/algorithms/graphtheory:all
19+
bazel test //src/test/java/com/williamfiset/algorithms/sorting:all
20+
```
21+
22+
**Run a single test class:**
23+
```bash
24+
bazel test //src/test/java/com/williamfiset/algorithms/graphtheory:BoruvkasTest
25+
```
26+
27+
**Run a specific algorithm (with `main` method):**
28+
```bash
29+
bazel run //src/main/java/com/williamfiset/algorithms/graphtheory:BinarySearch
30+
bazel run //src/main/java/com/williamfiset/algorithms/search:BinarySearch
31+
```
32+
33+
**Alternative (without Bazel):**
34+
```bash
35+
mkdir classes
36+
javac -sourcepath src/main/java -d classes src/main/java/com/williamfiset/algorithms/search/BinarySearch.java
37+
java -cp classes com.williamfiset.algorithms.search.BinarySearch
38+
```
39+
40+
## Project Structure
41+
42+
```
43+
src/
44+
main/java/com/williamfiset/algorithms/
45+
datastructures/ # Data structure implementations
46+
dp/ # Dynamic programming algorithms + examples/
47+
geometry/ # Computational geometry
48+
graphtheory/ # Graph algorithms
49+
networkflow/ # Max flow, min cost flow, bipartite matching
50+
treealgorithms/ # Tree-specific algorithms (LCA, rooting, isomorphism)
51+
linearalgebra/ # Matrix operations
52+
math/ # Number theory, primes, FFT
53+
other/ # Miscellaneous (bit manipulation, permutations, etc.)
54+
search/ # Search algorithms
55+
sorting/ # Sorting algorithms
56+
strings/ # String algorithms
57+
utils/ # Shared utilities
58+
graphutils/ # Graph construction helpers
59+
60+
test/java/com/williamfiset/algorithms/
61+
<mirrors main structure>
62+
```
63+
64+
## Architecture Patterns
65+
66+
**BUILD files:** Every package has a Bazel `BUILD` file. The main source `BUILD` files define a `java_library` target (named after the package, e.g., `graphtheory`) plus individual `java_binary` targets per class. Test `BUILD` files define `java_test` targets per test class using JUnit 5 via `ConsoleLauncher`.
67+
68+
**Test framework:** Tests use JUnit 5 (Jupiter) with some legacy JUnit 4. New tests should use JUnit 5.
69+
70+
**Graph representation:** Most graph algorithms accept adjacency lists built with `List<List<Edge>>` or similar structures. Many solvers are implemented as classes where you construct the solver, add edges, then call a `solve()` method.
71+
72+
**Network flow base:** Flow algorithms in `networkflow/` share a common abstract solver pattern — `NetworkFlowSolverBase` is extended by concrete implementations (Dinic's, Ford-Fulkerson, etc.).
73+
74+
**When adding a new algorithm:**
75+
1. Add the `.java` file in the appropriate `src/main/java/...` package
76+
2. Add a `java_binary` entry in that package's `BUILD` file
77+
3. Add a test file in the corresponding `src/test/java/...` package
78+
4. Add a `java_test` entry in the test `BUILD` file
79+
5. Update `README.md` with the new algorithm entry

0 commit comments

Comments
 (0)