Tight query complexity bounds for learning graph partitions