Connected Components example Scala API rewrite