Implementing the boruvka algorithm