public int[][] floyd(int[][] g) {
        int[][] x = getG();
        for (int[] x1 : x) {
            for (int j = 0; j < x.length; j++) {
                if (x1[j] == 0) {
                    x1[j] = -1;
                }
            }
        }
        for (int k = 0; k < g.length; k++) {
            for (int i = 0; i < g.length; i++) {
                for (int j = 0; j < g.length; j++) {
                    if (i != j) {
                        if (x[i][k] != -1 && x[k][j] != -1) {
                            x[i][j] = Math.min(x[i][j], x[i][k] + x[k][j]);
                        }
                    }
                }
            }
        }
        return x;
    }