Fixed bugs in the tree calculation such that the generated spanning trees are actually minimal.