45 template<
typename TCost>
65 bool primaryCut =
true,
bool calculateOtherCut =
true,
82 return call(graph, weight, s, t, edgeList, e_st);
198 std::unique_ptr<EpsilonTest>
m_et;
217 frontCut ? m_frontCutCount++ : m_backCutCount++;
219 while (!queue.
empty()) {
226 m_et->less(m_flow[e], m_weight[e]))
227 || ((frontCut ? e->target() : e->source()) == v &&
228 m_et->greater(m_flow[e], TCost(0))))) {
231 frontCut ? m_frontCutCount++ : m_backCutCount++;
257 if(m_primaryCut || m_calculateOtherCut) {
259 markCut(source,
true, origNode);
262 if(!m_primaryCut || m_calculateOtherCut) {
264 markCut(target,
false, origNode);
269 node startNode = (m_primaryCut ? source : target);
271 if (startAdj ==
nullptr) {
279 adj = (m_primaryCut ? adj->cyclicSucc() : adj->cyclicPred()))
281 if (adj->theEdge()->adjTarget() != adj) {
282 stack.
push(adj->theEdge());
285 while (!stack.
empty()) {
287 if (visited[origEdge(e)]) {
290 visited[origEdge(e)] =
true;
302 adj = (m_primaryCut ? adj->cyclicSucc() : adj->cyclicPred()))
304 if (adj->theEdge()->adjTarget() != adj) {
305 stack.
push(adj->theEdge());
313 template<
typename TCost>
320 if (e_st !=
nullptr) {
328 for (
edge e : edges) {
329 if (m_treatAsUndirected) {
341 edge origEdge = originalEdge[e];
342 m_weight[e] = weight[origEdge];
346 m_mfModule->init(*
m_gc);
347 m_mfModule->computeFlow(m_weight, s, t, m_flow);
350 [&](
edge e) ->
edge {
return originalEdge[e];},
357 template<
typename TCost>
361 const node source,
const node target) {
370 source, target, edgeList);
node target() const
Returns the target node of the edge.
void move(edge e, adjEntry adjSrc, Direction dirSrc, adjEntry adjTgt, Direction dirTgt)
Moves edge e to a different adjacency list.
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.
EdgeArray< TCost > m_weight
EdgeElement * edge
The type of edges.
std::unique_ptr< EpsilonTest > m_et
void setEpsilonTest(EpsilonTest *et)
Assigns a new epsilon test.
bool isBackCutEdge(const edge e) const
Returns whether this edge is entering the back cut.
edge theEdge() const
Returns the edge associated with this adjacency entry.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
bool frontCutIsComplementOfBackCut() const
Returns whether the front cut is the complement of the backcut.
void init()
Reinitializes the array. Associates the array with no graph.
iterator pushBack(const E &x)
Adds element x at the end of the list.
Data type for general directed graphs (adjacency list representation).
bool m_calculateOtherCut
iff true, the other (near to s for primaryCut == false, near to t for primaryCut == true) cut should ...
void init()
Reinitializes the array. Associates the array with no graph.
Min-st-cut algorithm, that calculates the cut via maxflow.
void push(E e)
Puts a new element in the buffer.
cutType
The three types of cuts.
bool m_primaryCut
true if the algorithm should search for the mincut nearest to s, false if it should be near to t...
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
EdgeArray< TCost > m_flow
Declaration and implementation of Goldberg-Tarjan max-flow algorithm with global relabeling and gap r...
edge newEdge(edge eOrig)
Creates a new edge (v,w) with original edge eOrig.
bool isOfType(const node v, cutType type) const
Return whether this node is of the specified type.
virtual void delEdge(edge e) override
Removes edge e and clears the list of edges corresponding to e's original edge.
bool isInFrontCut(const node v) const
Returns whether this node is part of the front cut.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
int numberOfEdges() const
Returns the number of edges in the graph.
bool empty() const
Returns true if the buffer is empty, false otherwise.
virtual bool call(const Graph &graph, node s, node t, List< edge > &edgeList, edge e_st=nullptr) override
The actual algorithm call.
NodeArray< cutType > m_nodeSet
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Class for the representation of edges.
E popFrontRet()
Removes the first element from the list and returns it.
Copies of graphs supporting edge splitting.
NodeElement * node
The type of nodes.
Class for the representation of nodes.
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 isFrontCutEdge(const edge e) const
Returns whether this edge is leaving the front cut.
const Graph & original() const
Returns a reference to the original graph.
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
bool m_treatAsUndirected
states whether or not edges are considered undirected while calculating the maxflow ...
E popRet()
Removes the newest element from the buffer and returns it.
node is not part of any cut
node source() const
Returns the source node of the edge.
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.
bool isInBackCut(const node v) const
Returns whether this node is part of the back cut.
The namespace for all OGDF objects.
void allEdges(CONTAINER &edgeContainer) const
Returns a container with all edges of the graph.
int numberOfNodes() const
Returns the number of nodes in the graph.
Template of base class of min-st-cut algorithms.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
MinSTCutMaxFlow(bool treatAsUndirected=true, MaxFlowModule< TCost > *mfModule=new MaxFlowGoldbergTarjan< TCost >(), bool primaryCut=true, bool calculateOtherCut=true, EpsilonTest *epsilonTest=new EpsilonTest())
Constructor.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
bool empty() const
Returns true iff the list is empty.
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
Class for adjacency list elements.
std::unique_ptr< MaxFlowModule< TCost > > m_mfModule
the module used for calculating the maxflow
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.