Floyd's Algiorithm implementation