Skip to content
William Fiset edited this page Jan 6, 2026 · 20 revisions

Contributing

If you're an algorithms enthusiast and want to add or improve an algorithm your contribution is welcome! Please be sure to include tests in your PR

Adding a new algorithm

The procedure to add a new algorithm or snippet of code is:

  1. If there doesn't already exist an issue, then file a new issue explaining the algorithm/change you want to do.
  2. Make sure the algorithm doesn't already exist! We don't want duplicate algorithms 😬
  3. Identify the category folder your algorithm belongs to. For example, a matrix multiplication snippet would belong to the src/main/java/com/williamfiset/algorithms/linearalgebra folder. You may also create a new category folder if appropriate.
  4. Add the algorithm implementation to: src/main/java/com/williamfiset/algorithms/category/FooAlgorithm.java
  5. Add tests for FooAlgorithm in: src/test/java/com/williamfiset/algorithms/category/FooAlgorithmTest.java
  6. Test your algorithm thoroughly (see testing section below)
  7. Send pull request for review 😮

Testing

This repository places a large emphasis on good testing practice to ensure that published algorithms are bug free and high quality. You will not be able to submit your pull request without providing tests to prove your algorithm's functionality. Testing is done using the Mockito and the Google Truth frameworks.

To run all test execute:

bazel test //src/test/...

However, when developing you likely do not want to run all tests but only a subset of them. For example, if you want to run the FloydWarshallSolverTest.java file under src/main/test/com/williamfiset/algorithms/graphtheory/FloydWarshallSolverTest.java you can execute:

bazel test //src/test/java/com/williamfiset/algorithms/graphtheory:FloydWarshallSolverTest

You can also run all tests in a specific package:

bazel test //src/test/java/com/williamfiset/algorithms/graphtheory:all

Clone this wiki locally