function _vcount(a, s) {
    // a arrays
    var aptr = a._ptr;
    var aindex = a._index;
    var asize = a._size; // rows & columns

    var m = asize[0];
    var n = asize[1]; // initialize s arrays

    s.pinv = []; // (m + n)

    s.leftmost = []; // (m)
    // vars

    var parent = s.parent;
    var pinv = s.pinv;
    var leftmost = s.leftmost; // workspace, next: first m entries, head: next n entries, tail: next n entries, nque: next n entries

    var w = []; // (m + 3 * n)

    var next = 0;
    var head = m;
    var tail = m + n;
    var nque = m + 2 * n; // vars

    var i, k, p, p0, p1; // initialize w

    for (k = 0; k < n; k++) {
      // queue k is empty
      w[head + k] = -1;
      w[tail + k] = -1;
      w[nque + k] = 0;
    } // initialize row arrays


    for (i = 0; i < m; i++) {
      leftmost[i] = -1;
    } // loop columns backwards


    for (k = n - 1; k >= 0; k--) {
      // values & index for column k
      for (p0 = aptr[k], p1 = aptr[k + 1], p = p0; p < p1; p++) {
        // leftmost[i] = min(find(A(i,:)))
        leftmost[aindex[p]] = k;
      }
    } // scan rows in reverse order


    for (i = m - 1; i >= 0; i--) {
      // row i is not yet ordered
      pinv[i] = -1;
      k = leftmost[i]; // check row i is empty

      if (k === -1) {
        continue;
      } // first row in queue k


      if (w[nque + k]++ === 0) {
        w[tail + k] = i;
      } // put i at head of queue k


      w[next + i] = w[head + k];
      w[head + k] = i;
    }

    s.lnz = 0;
    s.m2 = m; // find row permutation and nnz(V)

    for (k = 0; k < n; k++) {
      // remove row i from queue k
      i = w[head + k]; // count V(k,k) as nonzero

      s.lnz++; // add a fictitious row

      if (i < 0) {
        i = s.m2++;
      } // associate row i with V(:,k)


      pinv[i] = k; // skip if V(k+1:m,k) is empty

      if (--nque[k] <= 0) {
        continue;
      } // nque[k] is nnz (V(k+1:m,k))


      s.lnz += w[nque + k]; // move all rows to parent of k

      var pa = parent[k];

      if (pa !== -1) {
        if (w[nque + pa] === 0) {
          w[tail + pa] = w[tail + k];
        }

        w[next + w[tail + k]] = w[head + pa];
        w[head + pa] = w[next + i];
        w[nque + pa] += w[nque + k];
      }
    }

    for (i = 0; i < m; i++) {
      if (pinv[i] < 0) {
        pinv[i] = k++;
      }
    }

    return true;
  }
Compute nnz(V) = s.lnz, s.pinv, s.leftmost, s.m2 from A and s.parent