public void printPath(int[][] path, int start, int end) {
        if(start < 0 || end < 0 || start >= path.length || end >= path.length) {
            throw new IllegalArgumentException();
        }

        System.out.println("Actual path - between " + start + " " + end);
        Deque<Integer> stack = new LinkedList<>();
        stack.addFirst(end);
        while (true) {
            end = path[start][end];
            if(end == -1) {
                return;
            }
            stack.addFirst(end);
            if(end == start) {
                break;
            }
        }

        while (!stack.isEmpty()) {
            System.out.print(stack.pollFirst() + " ");
        }

        System.out.println();
    }
Date 11/02/2015
@author Tushar Roy

Floyd-Warshall Algorithm for finding all pair shortest path.

Time complexity - O(V^3)
Space complexity - O(V^2)

References
https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm
src/com/interview/graph/FloydWarshallAllPairShortestPath.java