C++ implementation of Dendrix Algorithm