2022-12-05 23:45:10 +02:00
2022-12-05 23:45:10 +02:00
2022-10-15 11:55:42 +03:00
2022-12-05 23:44:55 +02:00
2022-04-21 20:29:36 +03:00
2022-04-21 20:07:24 +03:00
2022-04-21 20:29:36 +03:00
2022-07-10 16:47:07 +03:00
2022-10-15 18:10:43 +03:00

Reachability algorithms by Roditty and Zwick

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. In more detail, the algorithms implemented, include a decremental reachability algorithm for the transitive closure of a directed acyclic graph, a decremental reachability algorithm for the transitive closure of a general directed graph, a dynamic reachability algorithm of a directed acyclic graph and a dynami reachability algorithm of a general directed graph. The core algorithm of Roditty and Zwick is a decremental reachability algorithm for the strongly connected components of the general directed graph, on which all reachability algorithms for general directed graphs are based.

A code example

#include "roditty_zwick.h"

int main() {
    // Initialize directed graph G
    graph::Digraph<int> 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<std::pair<int, int>> delEdges( {4, 6}, {5, 6}, {3, 1} );
    for (const auto& [u, v] : delEdges)
      hk.remove(u, v);

    // Insert edges
    std::pair<int, std::vector<int>> 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):

git clone --recurse-submodules https://github.com/stefiosif/dynamic-reachability-algorithms
cd dynamic-reachability-algorithms

Benchmark

References

Description
Collection of decremental and dynamic reachability algorithms.
Readme GPL-3.0 341 KiB
Languages
C++ 94.9%
CMake 3.7%
Shell 1.4%