private int getUnvisitedChildNode(final int n, final Graph g) {
        for (int j = 0; j < g.getNumberOfNodes(); j++) {
            if (g.getAdjMatrix()[n][j] > 0 && !visited[j]) {
                return j;
            }
        }
        return -1;
    }