예제 #1
0
void PushRelabel::run()
{
  initPreflow();
  bool discharged = true;

  uint32_t nOfVertices = network_->getNOfVertices();
  uint32_t source = network_->getSource();

  while (discharged)
  {
    discharged = false;

    for (uint32_t curVertex = 0; curVertex < nOfVertices; curVertex++)
    {
      if (isSaturated (curVertex))
      {
        discharge (curVertex);
        discharged = true;
      }
    }
  }

  for (uint32_t curVertex = 0; curVertex < nOfVertices; curVertex++)
  {
    if (curVertex != source)
    {
      network_->addNetworkFlow (network_->getTubes()(source, curVertex).getFlow());
    }
  }
}
예제 #2
0
inline void hlppa() {
  int v;
  list<int>::iterator it;
  initPreflow();
  while(htodo>=0) {
    if(!ovque[htodo].size()) {
      htodo--; continue;
    }
    v=ovque[htodo].front();
    ovque[htodo].pop();
    inque[v]=0;
    discharge(v);
  }
}