Implement naive (Floyd-Warshall) solution