Transitive closure Warshall algorithm