Implement simple all-pairs shortest paths problem