ExAlgo is a curated collection of data structures and algorithms implemented in Elixir. This project represents an exploration of classic algorithmic patterns through the lens of functional programming and Elixir's unique primitives.
The primary goal is to serve as an educational resource for implementing algorithms in a functional context. It also serves as a repository for utility algorithms useful for challenges like Advent of Code.
Note
While these implementations are verified with comprehensive tests, many of these algorithms have specialized, production-ready libraries available in the Hex ecosystem. This project is intended for learning and reference rather than as a replacement for established libraries.
Download this repo and get the dependencies with mix deps.get. Go to iex -S mix to try out the algorithms in the REPL.
mix test- Run all testsmix coveralls- Run tests with coverage reportmix coveralls.html- Generate HTML coverage report (opens in browser atcover/excoveralls.html)mix coveralls.detail- Show detailed coverage per file
mix docs- Generate documentation- Documentation will be available at
doc/index.html
Comprehensive API documentation is available via ex_doc. After running mix docs, open doc/index.html in your browser to explore detailed documentation for all modules, including usage examples and type specifications.
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Inductive Graph Model | model.ex | Yes | No | Core Inductive Data Structure | |
| DFS | traversal.ex | Yes | No | Inductive Depth-First Search | |
| BFS | traversal.ex | Yes | No | Inductive Breadth-First Search | |
| Topological Sort | algorithms.ex | Yes | No | Inductive Kahn's Algorithm | |
| Dijkstra's Algorithm | algorithms.ex | Yes | No | Shortest Path | |
| Prim's MST | algorithms.ex | Yes | No | Minimum Spanning Tree | |
| Kosaraju's SCC | algorithms.ex | Yes | No | Strongly Connected Components | |
| Connected Components | analysis.ex | Yes | No | Undirected Components | |
| Tarjan's Connectivity | analysis.ex | Yes | No | Bridges & Articulation Points | |
| Functional Transformations | transform.ex | Yes | No | Higher-order ops (map/filter) | |
| Graph Visualizer | visualizer.ex | Yes | No | Mermaid & Inspect support |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Leftist Heap | leftist_heap.ex | Yes | No | ||
| Pairing Heap | pairing_heap.ex | Yes | No |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Linked List | linked_list.ex | Yes | No | ||
| Circular List | circular_list.ex | Yes | No | ||
| BidirectionalList | bidirectional_list.ex | Yes | No | WIP | |
| Maximum Subarray Sum | algorithms.ex | Yes | No | Kadane's Algorithm |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Queue | queue.ex | Yes | No |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Binary Search | binary_search.ex | Yes | No |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Disjoint Set | disjoint_set.ex | Yes | No |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Sort Interface | sort.ex | No | No | Universal sorting facade | |
| Bubble Sort | exchange.ex | Yes | No | ||
| Insertion Sort | insertion.ex | Yes | No | ||
| Merge Sort | merge.ex | Yes | No | ||
| Pigeonhole Sort | distribution.ex | Yes | No | ||
| Quick Sort | exchange.ex | Yes | No | ||
| Selection Sort | selection.ex | Yes | No |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Stack | stack.ex | Yes | No | ||
| Min-Max Stack | min_max_stack.ex | Yes | No |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Binary Search Tree | binary_search_tree.ex | Yes | No | ||
| Tree Traversals | traversal.ex | Yes | No |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Permutations | combinatorics.ex::permutations | Yes | No | Naive | |
| Combinations | combinatorics.ex::combinations | Yes | No | Naive |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Prefix Trie | prefix_trie.ex | Yes | No | Functional map-based Trie |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Subset Sum | subset_sum.ex | Yes | No | FIXME: Not all subsets are listed. Need to work on that. |
| Name | Implementation | Test | Benchmark | Link | Note |
|---|---|---|---|---|---|
| Chinese Remainder Theorem | chinese_remainder.ex | Yes | No | ||
| Catalan Numbers (Recursive) | catalan.ex::recursive | Yes | No | ||
| Catalan Numbers (Dynamic) | catalan.ex::dp | Yes | No | ||
| Divisors | arithmetics.ex::divisors | Yes | No |
Parts of this repository, including refactoring for academic alignment, documentation enhancements, and several algorithmic implementations (such as the Inductive Graph suite and Prefix Trie), were developed or refined in collaboration with an AI coding assistant (Antigravity). This partnership helped ensure consistent documentation standards, rigorous testing, and adherence to functional programming best practices.