45#define OGDF_GT_USE_MAX_ACTIVE_LABEL
49#define OGDF_GT_USE_PUSH_RELABEL_SECOND_STAGE
59template<
typename TCap>
63#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
68#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
100#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
128#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
129 if (m_labelListPosition[v].valid()) {
131 m_labelListPosition[v]);
133 m_labelListPosition[v] =
134 m_labelList[label].pushBack(v);
136#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
151#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
153# ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
159 for (
int i = 1; i < n - 1; ++i) {
160 if (m_labelList[i].empty()) {
161 for (
int j = i + 1; j < n; ++j) {
162 while (!m_labelList[j].empty()) {
178 (*this->
m_flow)[e] += value;
182 const TCap value = min(
m_ex[v], (*this->
m_flow)[adj]);
184 (*this->
m_flow)[adj] -= value;
186 m_ex[adj->twinNode()] += value;
195 dist[*this->
m_t] = 0;
197 while (!queue.
empty()) {
200 node x = adj->twinNode();
202 dist[x] = dist[w] + 1;
217 const int label =
m_label[adj->twinNode()];
218 if (label < minLabel) {
223 if (minLabel + 1 !=
m_label[v]) {
232 const int label =
m_label[adj->twinNode()];
233 if (label < minLabel) {
254#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
255 m_activeLabelListPosition.
init(*this->
m_G,
nullptr);
259#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
260 m_labelListPosition.
init(*this->
m_G,
nullptr);
267 if (e->source() == *this->
m_s && e->target() != *this->
m_s) {
273 if (*this->
m_t == *this->
m_s) {
279 curr[v] = v->firstAdj();
285#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
294 node w = adj->theEdge()->target();
295 if (w != *this->
m_s) {
299 while (!active.
empty()) {
305#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
314#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
329 if (adj != v->lastAdj()) {
335#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
338# if (OGDF_GT_GRH_STEPS > 1)
339 && relCount % OGDF_GT_GRH_STEPS
359 edge e = adj->theEdge();
361 result += (*this->
m_flow)[e];
363 result -= (*this->
m_flow)[e];
372#ifdef OGDF_GT_USE_PUSH_RELABEL_SECOND_STAGE
375 curr[v] = v->firstAdj();
377 if (this->
m_et->
greater(m_ex[v], (TCap)0) && v != *this->
m_s && v != *this->
m_t) {
381 if (active.
empty()) {
386 while (!active.
empty()) {
419 while (!active.
empty()) {
421 if (this->
m_et->
greater(m_ex[v], (TCap)0) && v != *this->
m_s && v != *this->
m_t) {
423 const edge e = adj->theEdge();
428 if (u != *this->
m_s) {
Declaration and implementation of Array class and Array algorithms.
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Interface for Max Flow Algorithms.
Basic declarations, included by all source files.
Class for adjacency list elements.
adjEntry succ() const
Returns the successor in the adjacency list.
edge theEdge() const
Returns the edge associated with this adjacency entry.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
node theNode() const
Returns the node whose adjacency list contains this element.
The parameterized class Array implements dynamic arrays of type E.
void init()
Reinitializes the array to an array with empty index set.
Class for the representation of edges.
node target() const
Returns the target node of the edge.
node source() const
Returns the source node of the edge.
std::enable_if< std::is_integral< T >::value, bool >::type geq(const T &x, const T &y) const
Compare if x is GEQ to y for integral types.
std::enable_if< std::is_integral< T >::value, bool >::type less(const T &x, const T &y) const
Compare if x is LESS than y for integral types.
std::enable_if< std::is_integral< T >::value, bool >::type greater(const T &x, const T &y) const
Compare if x is GREATER than y for integral types.
int numberOfNodes() const
Returns the number of nodes in the graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
node firstNode() const
Returns the first node in the list of all nodes.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Doubly linked lists (maintaining the length of the list).
void popFront()
Removes the first element from the list.
void clear()
Removes all elements from the list.
iterator pushBack(const E &x)
Adds element x at the end of the list.
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
E popFrontRet()
Removes the first element from the list and returns it.
const_reference front() const
Returns a const reference to the first element.
bool empty() const
Returns true iff the list is empty.
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
void setActive(const node v)
Array< List< node > > m_activeLabelList
bool isActive(const node v) const
void push(const adjEntry adj)
void setLabel(const node v, int label)
bool isAdmissible(const adjEntry adj) const
TCap computeValue(const EdgeArray< TCap > &cap, const node &s, const node &t)
Compute only the value of the flow.
void relabelStage2(const node v)
NodeArray< ListIterator< node > > m_activeLabelListPosition
void relabel(const node v)
bool isResidualEdge(const adjEntry adj) const
TCap getCap(const edge e) const
void setInactive(const node v)
void computeFlowAfterValue()
Compute the flow itself after the flow value is already computed. Only used in algorithms with 2 phas...
const node * m_t
Pointer to the sink node.
virtual void init(const Graph &graph, EdgeArray< TCap > *flow=nullptr)
Initialize the problem with a graph and optional flow array. If no flow array is given,...
EdgeArray< TCap > * m_flow
Pointer to (extern) flow array.
void useEpsilonTest(const double &eps)
Change the used EpsilonTest from StandardEpsilonTest to a user given EpsilonTest.
bool isFeasibleInstance() const
Return whether the instance is feasible, i.e. the capacities are non-negative.
const Graph * m_G
Pointer to the given graph.
const node * m_s
Pointer to the source node.
const EdgeArray< TCap > * m_cap
Pointer to the given capacity array.
MaxFlowModule()
Empty Constructor.
TCap computeFlow(EdgeArray< TCap > &cap, node &s, node &t, EdgeArray< TCap > &flow)
Only a shortcut for computeValue and computeFlowAfterValue.
EpsilonTest * m_et
Pointer to the used EpsilonTest.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
void init(const Base *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)