Idependent Set algorithm in Scala