48template<
typename TCost>
90 return call(graph, weight, s,
t, edgeList,
e_st);
103 const node source,
const node target);
196 std::unique_ptr<EpsilonTest>
m_et;
217 while (!
queue.empty()) {
220 const node w = adj->twinNode();
221 const edge e = adj->theEdge();
258 markCut(source,
true, origNode);
263 markCut(target,
false, origNode);
278 if (adj->theEdge()->adjTarget() != adj) {
279 stack.push(adj->theEdge());
282 while (!
stack.empty()) {
284 if (visited[origEdge(e)]) {
287 visited[origEdge(e)] =
true;
299 adj = (
m_primaryCut ? adj->cyclicSucc() : adj->cyclicPred())) {
300 if (adj->theEdge()->adjTarget() != adj) {
301 stack.push(adj->theEdge());
309template<
typename TCost>
316 if (
e_st !=
nullptr) {
317 m_gc->delEdge(m_gc->copy(
e_st));
319 node s = m_gc->copy(source);
320 node t = m_gc->copy(target);
322 m_gc->allEdges(edges);
324 for (
edge e : edges) {
325 if (m_treatAsUndirected) {
327 edge revEdge = m_gc->newEdge(e->target(), e->source());
330 originalEdge[
revEdge] = m_gc->original(e);
332 originalEdge[e] = m_gc->original(e);
335 m_flow.
init(*m_gc, -1);
336 m_weight.
init(*m_gc, 1);
337 for (
edge e : m_gc->edges) {
338 edge origEdge = originalEdge[e];
339 m_weight[e] = weight[origEdge];
343 m_mfModule->init(*m_gc);
344 m_mfModule->computeFlow(m_weight, s,
t, m_flow);
347 graph, [&](
edge e) ->
edge {
return originalEdge[e]; },
348 [&](
node v) ->
node {
return m_gc->original(v); }, s,
t, edgeList);
353template<
typename TCost>
362 graph, [&](
edge e) ->
edge {
return e; }, [&](
node v) ->
node {
return v; }, source,
Declaration and implementation of Goldberg-Tarjan max-flow algorithm with global relabeling and gap r...
Template of base class of min-st-cut algorithms.
Class for adjacency list elements.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Dynamic arrays indexed with edges.
void init()
Reinitializes the array. Associates the array with no graph.
Class for the representation of edges.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
node target() const
Returns the target node of the edge.
node source() const
Returns the source node of the edge.
Copies of graphs supporting edge splitting.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
Data type for general directed graphs (adjacency list representation).
int numberOfNodes() const
Returns the number of nodes in the graph.
int numberOfEdges() const
Returns the number of edges in the graph.
Doubly linked lists (maintaining the length of the list).
iterator pushBack(const E &x)
Adds element x at the end of the list.
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
Min-st-cut algorithm, that calculates the cut via maxflow.
void markCut(node startNode, bool frontCut, std::function< node(node)> origNode)
Mark the all nodes which are in the same cut partition as the startNode.
std::unique_ptr< MaxFlowModule< TCost > > m_mfModule
the module used for calculating the maxflow
bool isBackCutEdge(const edge e) const
Returns whether this edge is entering the back cut.
bool isInBackCut(const node v) const
Returns whether this node is part of the back cut.
EdgeArray< TCost > m_flow
std::unique_ptr< EpsilonTest > m_et
virtual bool call(const Graph &graph, node s, node t, List< edge > &edgeList, edge e_st=nullptr) override
The actual algorithm call.
cutType
The three types of cuts.
@ NO_CUT
node is not part of any cut
@ BACK_CUT
node is in back cut
@ FRONT_CUT
node is in front cut
EdgeArray< TCost > m_weight
bool isFrontCutEdge(const edge e) const
Returns whether this edge is leaving the front cut.
bool isOfType(const node v, cutType type) const
Return whether this node is of the specified type.
MinSTCutMaxFlow(bool treatAsUndirected=true, MaxFlowModule< TCost > *mfModule=new MaxFlowGoldbergTarjan< TCost >(), bool primaryCut=true, bool calculateOtherCut=true, EpsilonTest *epsilonTest=new EpsilonTest())
Constructor.
NodeArray< cutType > m_nodeSet
void computeCut(const Graph &graph, std::function< edge(edge)> origEdge, std::function< node(node)> origNode, const node source, const node target, List< edge > &edgeList)
Partitions the nodes to front and back cut.
void setEpsilonTest(EpsilonTest *et)
Assigns a new epsilon test.
bool m_treatAsUndirected
states whether or not edges are considered undirected while calculating the maxflow
virtual bool call(const Graph &graph, const EdgeArray< TCost > &weight, node s, node t, List< edge > &edgeList, edge e_st=nullptr) override
The actual algorithm call.
bool frontCutIsComplementOfBackCut() const
Returns whether the front cut is the complement of the backcut.
bool m_calculateOtherCut
iff true, the other (near to s for primaryCut == false, near to t for primaryCut == true) cut should ...
bool m_primaryCut
true if the algorithm should search for the mincut nearest to s, false if it should be near to t.
bool isInFrontCut(const node v) const
Returns whether this node is part of the front cut.
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.
NodeElement * node
The type of nodes.
EdgeElement * edge
The type of edges.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.