public static void main(String[] args) {
        // fill distances with max value at the beginning
        Arrays.fill(distances, Integer.MAX_VALUE);

        // set distances to direct children of the node
        for (int i = 0; i < GRAPH_SIZE; i++) {
            if (graph[NODE][i] > 0) {
                // set the distance to children
                distances[i] = graph[NODE][i];
            }
        }
        // initialization phase finished

        for (int k = 0; k < GRAPH_SIZE - 2; k++) {
            // repeat triangle inequality GRAPH_SIZE - 2 times in order to reach
            // the longest possible distance
            for (int i = 0; i < GRAPH_SIZE; i++) {
                if (i == NODE) {
                    // do not want to find a path to itself
                    continue;
                }

                for (int j = 0; j < GRAPH_SIZE; j++) {
                    if (distances[j] < Integer.MAX_VALUE && graph[j][i] > 0 // there is a path to i through j
                            && distances[i] > distances[j] + graph[j][i]) {
                        // there is a path through j which is shorter
                        distances[i] = distances[j] + graph[j][i];
                    }
                }
            }
        }

        System.out.println(Arrays.toString(distances));
    }