using minimal spanning trees to reduce comp time