Add global 'all_paths' cost function and looping over number of swaps.

@wronk