implemented both connected and no heuristic