Immutable implementation of Bellman-Ford single source shortest path

You could use A <: Number.

When you move from mutable state to immutable, your state becomes parameters and return values. I don’t see a way around this.

I might have something along the lines of what you’re looking for.

Vertices.indices.reverse.dropRight(1).foldLeft((Map((source -> 0)), Map())) ...