public Graph(Integer[][] matrix) {
        adjacencyList = new ArrayList<>();
        int n = matrix.length;

        if (n != 0) {
            //create list for 0 vertex
            adjacencyList.add(new ArrayList<Integer>());

            for (int i = 1; i < n; i++) {
                //create list for i-th vertex
                adjacencyList.add(new ArrayList<Integer>());
                for (int j = 0; j < i; j++) {
                    if (matrix[i][j] == 1) {
                        adjacencyList.get(i).add(j);
                        adjacencyList.get(j).add(i);
                    }
                }
            }
        }
    }