# Reachability algorithms by Roditty and Zwick The goal of this repository is to implement a collection of decremental/dynamic reachability algorithms, inspired by "Improved Dynamic Reachability Algorithms for Directed Graphs" by Liam Roditty and Uri Zwick. ## A code example ```cpp #include "roditty_zwick.h" int main() { // Initialize directed graph G graph::Digraph G( {1, {2}}, {2, {3, 4}}, {3, {1, 5, 9}}, {4, {5, 6}}, {5, {6, 7}}, {6, {8}}, {7, {8, 9}}, {8, {9}}, {9, {5}} ); // Initialize dynamic reachability algorithm for general directed graphs auto hk = new algo::HenzingerKing(G); hk->init(); // Remove edges std::vector> delEdges( {4, 6}, {5, 6}, {3, 1} ); for (const auto& [u, v] : delEdges) hk.remove(u, v); // Insert edges std::pair> addEdges( { 1 , {2, 3, 4, 5} } ); hk.insert(u, addEdges); // Search query std::cout << "Path from 4 to 8 exists: " << hk.query(4, 8) << '\n'; return 0; } ``` ## Run locally Clone the repository with submodules (doctest/nanobench): ```bash git clone --recurse-submodules https://github.com/stefiosif/dynamic-reachability-algorithms cd dynamic-reachability-algorithms ./build_project.sh ``` ## References * [Improved Dynamic Reachability Algorithms for Directed Graphs](https://ieeexplore.ieee.org/document/1181993)