コード例 #1
0
ファイル: dblock.c プロジェクト: H2Lib/H2Lib
pdblock
build_dblock(pdcluster rc, pdcluster cc, uint l,
	     bool(*admissible) (pdcluster rc, pdcluster cc, uint l,
				uint * rd, uint * cd, void *data), void *data)
{
  pdblock   b;
  uint      rd, cd;
  uint      i, j;

  b = 0;
  if (admissible(rc, cc, l, &rd, &cd, data)) {
    b = new_dblock(rc, cc, rd, cd, 0, 0);
    b->adm = true;
  }
  else if (rc->sons == 0 || cc->sons == 0) {
    b = new_dblock(rc, cc, 0, 0, 0, 0);
  }
  else {
    assert(rc->sons > 0);
    assert(cc->sons > 0);

    b = new_dblock(rc, cc, 0, 0, rc->sons, cc->sons);
    for (j = 0; j < cc->sons; j++)
      for (i = 0; i < rc->sons; i++)
	b->son[i + j * rc->sons] = build_dblock(rc->son[i], cc->son[j], l + 1,
						admissible, data);
  }

  update_dblock(b);

  return b;
}
コード例 #2
0
ファイル: adjlist.cpp プロジェクト: Ewanderer/KombOpti
void AdjList::push_relabel(unsigned int s, unsigned int t) {
    for (auto a : _list[s]) {
        _list[a.first][s] = a.second;
        a.second = 0;
    }
    std::map<unsigned int, int> psi;
    for (auto v : _list)
        psi[v.first] = 0;
    psi[s] = psi.size();



    for (auto v = active(t); v.second > 0; v = active(t)) {
        unsigned int a;
        if ((a = admissible(psi, v.first)) == std::numeric_limits<unsigned int>::max())
            relabel(psi, v.first);
        else
            push(std::make_pair<unsigned int&, unsigned int&>(v.first, a), v.second);
    }
}