This project has both theoretical and practical aspects. In this repository only the pratical aspects are shown.
In this project you must both implement a trivial solution based on recomputing the transitive closure from scratch upon each change using the Floyd-Warshall algorithm, and you must implement a truly dynamic algorithm that uses Sankowskis randomized reduction of dynamic transitive closure to dynamic matrix adjoint combined with the Sherman-Morrison formula for maintaining matrix inverse (and determinant) under rank one updates. Finally you should make experimental comparisons of the two implementations and comment on the results.
All solutions implements the class TC (Transitive Closure) with the following functions:
init(int n)
ins(int i, int j)
del(int i, int j)
query()
get_name()
Compile the code by running make
. Since the Performance class uses linux/perf_event.h
the code will only compile on Linux kernels version 2.6.31 or higher. The Makefile
ensures that needed folders are present.
Execute the main binary file to run the experiments, e.g. ./bin/main ./input/changefile3.txt
, which outputs the following files:
- changefile3-del.stat - Timings of calls for
del(int i, int j)
on all algorithms - changefile3-ins.stat - Timings of calls for
ins(int i, int j)
on all algoruthms - changefile3-query.stat - Timings of calls for
query()
on all algorihms - changefile(name).out - Output of
query()
, where (name) is replaced byget_name()
Executing the Python script ./cmp_changefile.py
prints the following if everything is correct:
All output files have been compared!
while an error might yield
=========== ERROR IN changefile3 ===========
Eager DFS and Lazy DFS mismatches
Lazy Floyd-Warshall and Lazy DFS mismatches
Lazy DFS and Eager Floyd-Warshall mismatches
============================================
All output files have been compared!
indicating that Lazy DFS is incorrect on changefile3 compared to Eager DFS and Lazy Floyd-Warshall