Implements Warshall Algorithm