38#define OGDF_GT_USE_MAX_ACTIVE_LABEL
39#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
42#define OGDF_GT_USE_PUSH_RELABEL_SECOND_STAGE
52template<
typename TCap>
56#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
61#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
93#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
121#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
129#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
144#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
146# ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
152 for (
int i = 1; i < n - 1; ++i) {
154 for (
int j = i + 1;
j < n; ++
j) {
171 (*this->
m_flow)[e] += value;
177 (*this->
m_flow)[adj] -= value;
179 m_ex[adj->twinNode()] += value;
190 while (!queue.
empty()) {
193 node x = adj->twinNode();
210 const int label =
m_label[adj->twinNode()];
225 const int label =
m_label[adj->twinNode()];
247#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
248 m_activeLabelListPosition.
init(*this->
m_G,
nullptr);
252#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
260 if (e->source() == *this->
m_s && e->target() != *this->
m_s) {
266 if (*this->
m_t == *this->
m_s) {
272 curr[v] = v->firstAdj();
278#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
287 node w = adj->theEdge()->target();
288 if (w != *this->
m_s) {
292 while (!active.
empty()) {
298#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
307#ifdef OGDF_GT_USE_MAX_ACTIVE_LABEL
322 if (adj != v->lastAdj()) {
328#ifdef OGDF_GT_USE_GAP_RELABEL_HEURISTIC
352 edge e = adj->theEdge();
354 result += (*this->
m_flow)[e];
356 result -= (*this->
m_flow)[e];
365#ifdef OGDF_GT_USE_PUSH_RELABEL_SECOND_STAGE
368 curr[v] = v->firstAdj();
374 if (active.
empty()) {
379 while (!active.
empty()) {
412 while (!active.
empty()) {
416 const edge e = adj->theEdge();
421 if (u != *this->
m_s) {
Interface for Max Flow Algorithms.
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.
Dynamic arrays indexed with edges.
void init()
Reinitializes the array. Associates the array with no graph.
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.
Dynamic arrays indexed with nodes.
void init()
Reinitializes the array. Associates the array with no graph.
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.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.