code: private static boolean[] createInitialR(CompRowMatrix A) {
              boolean[] R = new boolean[A.numRows()];
  
              int[] rowptr = A.getRowPointers();
              int[] colind = A.getColumnIndices();
              double[] data = A.getData();
  
              for (int i = 0; i < A.numRows(); ++i) {
                  boolean hasOffDiagonal = false;
  
                  for (int j = rowptr[i]; j < rowptr[i + 1]; ++j)
                      if (colind[j] != i && data[j] != 0) {
                          hasOffDiagonal = true;
                          break;
                      }
  
                  R[i] = hasOffDiagonal;
              }
  
              return R;
          }
docs: Creates the initial R-set by including only the connected nodes