return the cost of the path in the result

I'm using this to do graph layout in a grid based enviroment (the terminal)
I'm using the cost of the paths to evaluate how good the graph it self is.
But I bet that the cost of the path could be useful in other applications also.