A C++ implementation for an Expected Linear-Time Minimum Spanning Tree Algorithm(Karger-Klein-Tarjan + Hagerup Minimum Spanning Tree Verification as a sub-routine)
This was the product of my CS undergraduate thesis. I was studying randomized algorithms and I couldn't find any reasonable implementation of Karger-Klein-Tarjan algorithm (at least a public one), so I decided to implement it myself and make it public.
The objectives of this projects are the following:
- Provide a C++ implementation of Karger, Klein & Tarjan algorithm for finding MSTs in expected linear time available.
- Benchmark the implementation against standard MST methods (Kruskal, Prim, Boruvka)
- All implementations of this project assume that the edge weights are unique, this is mentioned on the KKT paper as a requirement and it simplifies the design/analysis of the algorithm.
- We are at all times dealing with undirected graphs!!
-
Install Bazel
-
Run the following command on your command line:
$ bazel build :all
-
Build the project in the way described above
-
Run the following command at your command line:
$ bazel test :all --cache_test_results=no
-
Build the project as described above
-
Run the following command at your command line:
$ bazel run benchmark:mst_benchmark -c opt
All MST algorithms have been tested with random undirected connected graphs with unique discrete edge weights. The runtime complexity has been estimated automatically by using google/benchmark
- The KKT implementation provided has a linear behavior in practice (in the datasets tested). See results in the benchmark.txt file for the repo.
- All the other tested algorithms don't have linear complexity in theory and this is also true for the benchmark graph instances.
- The KKT algorithm still performed poorly compared to the other algorithms, because of a huge constant factor.