Give an O(n3 ) algorithm to find the length of the longest simple path in an n-node graph, on the assumption that no cycle has a positive length.
Hint : Adapt Floyd's algorithm for shortest paths (see, e.g., A. V. Aho and J. D. Ullman, Foundations of Computer Science, Computer Science Press, New York, 1992)