WarshallFloyd algorithm speedup