Krushkal algorithm