Linkgraph: Add support for aborting MCF passes early.

This commit is contained in:
Jonathan G Rennison
2017-02-08 18:20:26 +00:00
parent 2080daab8d
commit 3f2c561867
2 changed files with 4 additions and 3 deletions

View File

@@ -74,10 +74,11 @@ protected:
void EraseFlows(NodeID from); void EraseFlows(NodeID from);
void JoinThread(); void JoinThread();
void SetJobGroup(std::shared_ptr<LinkGraphJobGroup> group); void SetJobGroup(std::shared_ptr<LinkGraphJobGroup> group);
bool IsJobAborted() const;
public: public:
bool IsJobAborted() const;
/** /**
* A job edge. Wraps a link graph edge and an edge annotation. The * A job edge. Wraps a link graph edge and an edge annotation. The
* annotation can be modified, the edge is constant. * annotation can be modified, the edge is constant.

View File

@@ -638,7 +638,7 @@ MCF1stPass::MCF1stPass(LinkGraphJob &job) : MultiCommodityFlow(job)
} }
this->CleanupPaths(source, paths); this->CleanupPaths(source, paths);
} }
} while (more_loops || this->EliminateCycles()); } while ((more_loops || this->EliminateCycles()) && !job.IsJobAborted());
} }
/** /**
@@ -653,7 +653,7 @@ MCF2ndPass::MCF2ndPass(LinkGraphJob &job) : MultiCommodityFlow(job)
uint size = job.Size(); uint size = job.Size();
uint accuracy = job.Settings().accuracy; uint accuracy = job.Settings().accuracy;
bool demand_left = true; bool demand_left = true;
while (demand_left) { while (demand_left && !job.IsJobAborted()) {
demand_left = false; demand_left = false;
for (NodeID source = 0; source < size; ++source) { for (NodeID source = 0; source < size; ++source) {
this->Dijkstra<CapacityAnnotation, FlowEdgeIterator>(source, paths); this->Dijkstra<CapacityAnnotation, FlowEdgeIterator>(source, paths);