You wouldn't gain that much. The life of the intermediate Graph object is extremely short so they should be not real impact re: GC.

It's possible that the foldLeft prevents the JVM from doing escape analysis in this case though.