Fix formatting in TransitiveClosureNaive Scala Example

Also actually use termination criterion in TransitivelClosureNaive
Java example.