|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
45 #define OGDF_GT_USE_MAX_ACTIVE_LABEL
49 #define OGDF_GT_USE_PUSH_RELABEL_SECOND_STAGE
59 template<
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()) {
202 dist[x] = dist[w] + 1;
218 if (label < minLabel) {
223 if (minLabel + 1 !=
m_label[v]) {
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()) {
300 const node v = active.front();
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();
360 if (e->
target() == *this->m_t) {
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()) {
387 node v = active.front();
412 #else // USE_PUSH_RELABEL_SECOND_STAGE
419 while (!active.empty()) {
421 if (this->
m_et->
greater(m_ex[v], (TCap)0) && v != *this->m_s && v != *this->m_t) {
422 for (
adjEntry adj = v->firstAdj(); adj; adj = adj->
succ()) {
423 const edge e = adj->theEdge();
428 if (u != *this->
m_s) {
436 #endif // USE_PUSH_RELABEL_SECOND_STAGE
The namespace for all OGDF objects.
void relabel(const node v)
Includes declaration of graph class.
bool isFeasibleInstance() const
Return whether the instance is feasible, i.e. the capacities are non-negative.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Interface for Max Flow Algorithms.
node theNode() const
Returns the node whose adjacency list contains this element.
void popFront()
Removes the first element from the list.
const node * m_t
Pointer to the sink node.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
TCap getCap(const edge e) const
E popFrontRet()
Removes the first element from the list and returns it.
bool isActive(const node v) const
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
void init()
Reinitializes the array to an array with empty index set.
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Class for adjacency list elements.
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.
EpsilonTest * m_et
Pointer to the used EpsilonTest.
void computeFlowAfterValue()
Compute the flow itself after the flow value is already computed. Only used in algorithms with 2 phas...
edge theEdge() const
Returns the edge associated with this adjacency entry.
const node * m_s
Pointer to the source node.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
const Graph * m_G
Pointer to the given graph.
bool isAdmissible(const adjEntry adj) const
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
void push(const adjEntry adj)
int numberOfNodes() const
Returns the number of nodes in the graph.
void setInactive(const node v)
The parameterized class Array implements dynamic arrays of type E.
Decralation of GraphElement and GraphList classes.
adjEntry succ() const
Returns the successor in the adjacency list.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
bool isResidualEdge(const adjEntry adj) const
node firstNode() const
Returns the first node in the list of all nodes.
Array< List< node > > m_activeLabelList
node source() const
Returns the source node of the edge.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
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.
void setLabel(const node v, int label)
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
void relabelStage2(const node v)
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Basic declarations, included by all source files.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
node succ() const
Returns the successor in the list of all nodes.
Declaration and implementation of Array class and Array algorithms.
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
NodeArray< ListIterator< node > > m_activeLabelListPosition
void setActive(const node v)
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
const EdgeArray< TCap > * m_cap
Pointer to the given capacity array.
TCap computeValue(const EdgeArray< TCap > &cap, const node &s, const node &t)
Compute only the value of the flow.
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.
node target() const
Returns the target node of the edge.
Class for the representation of nodes.
EdgeArray< TCap > * m_flow
Pointer to (extern) flow array.
iterator pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
void clear()
Removes all elements from the list.