From 285109277bbdcdae74d9453bfd73443f3d33255d Mon Sep 17 00:00:00 2001 From: stefiosif Date: Tue, 11 Oct 2022 15:50:22 +0300 Subject: [PATCH] Upload README draft --- README.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/README.md b/README.md index e69de29..3ef8bb1 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,70 @@ +# Dynamic Reachability Algorithms +The goal of this project is to implement a collection of dynamic +reachability algorithms covered in "Improved Dynamic Reachability +Algorithms for Directed Graphs" by Liam Roditty and Uri Zwick. + +## Usage/Examples +```cpp +#include "roditty_zwick.h" + +int main() { + // Initialize a 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 graphs + algo::HenzingerKing hk(G); + hk.init(); + + // Query + std::cout << "Path from 4 to 8 exists: " << dr.query(4, 8); + + std::vector> edges( + {4, 6}, {5, 6}, {3, 1} + ); + + // Remove edges + for (const auto& [u, v] : edges) + dk.remove(u, v); + + std::cout << "Path from 4 to 8 exists: " << dr.query(4, 8); + + + // Insert edges + for (const auto& [u, v] : edges) + dk.insert(u, v); + + std::cout << "Path from 4 to 8 exists: " << dr.query(4, 8); + + return 0; +} +``` + +## Run Locally + +Clone the repository with submodules (doctest/nanobench): + +```bash +git clone --recurse-submodules https://github.com/stefiosif/dynamic-reachability-algorithms +``` + +Run with CMake: + +``` bash +> mkdir build && cd build +> cmake .. +> make +> ./main +``` + +## References +* [Improved Dynamic Reachability Algorithms for Directed Graphs](www.google.com)