|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
59 template<
typename TCost>
81 bool primaryCut =
true,
bool calculateOtherCut =
true,
87 ,
m_et(epsilonTest) { }
99 edge e_st =
nullptr)
override {
101 return call(graph, weight, s, t, edgeList, e_st);
114 const node source,
const node target);
207 std::unique_ptr<EpsilonTest>
m_et;
228 while (!queue.empty()) {
236 || ((frontCut ? e->target() : e->source()) == v
269 markCut(source,
true, origNode);
274 markCut(target,
false, origNode);
281 if (startAdj ==
nullptr) {
288 adj != startAdj; adj = (
m_primaryCut ? adj->cyclicSucc() : adj->cyclicPred())) {
289 if (adj->theEdge()->adjTarget() != adj) {
290 stack.
push(adj->theEdge());
293 while (!stack.
empty()) {
295 if (visited[origEdge(e)]) {
298 visited[origEdge(e)] =
true;
310 adj = (
m_primaryCut ? adj->cyclicSucc() : adj->cyclicPred())) {
311 if (adj->theEdge()->adjTarget() != adj) {
312 stack.
push(adj->theEdge());
320 template<
typename TCost>
327 if (e_st !=
nullptr) {
328 m_gc->delEdge(m_gc->copy(e_st));
330 node s = m_gc->copy(source);
331 node t = m_gc->copy(target);
333 m_gc->allEdges(edges);
335 for (
edge e : edges) {
336 if (m_treatAsUndirected) {
338 edge revEdge = m_gc->newEdge(e->target(), e->source());
341 originalEdge[revEdge] = m_gc->original(e);
343 originalEdge[e] = m_gc->original(e);
346 m_flow.
init(*m_gc, -1);
347 m_weight.
init(*m_gc, 1);
348 for (
edge e : m_gc->edges) {
349 edge origEdge = originalEdge[e];
350 m_weight[e] = weight[origEdge];
354 m_mfModule->init(*m_gc);
355 m_mfModule->computeFlow(m_weight, s, t, m_flow);
358 graph, [&](
edge e) ->
edge {
return originalEdge[e]; },
359 [&](
node v) ->
node {
return m_gc->original(v); }, s, t, edgeList);
364 template<
typename TCost>
373 graph, [&](
edge e) ->
edge {
return e; }, [&](
node v) ->
node {
return v; }, source,
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
The namespace for all OGDF objects.
Declaration and implementation of ArrayBuffer class.
void setEpsilonTest(EpsilonTest *et)
Assigns a new epsilon test.
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Includes declaration of graph class.
bool isFrontCutEdge(const edge e) const
Returns whether this edge is leaving the front cut.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
bool empty() const
Returns true if the buffer is empty, false otherwise.
NodeArray< cutType > m_nodeSet
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
E popFrontRet()
Removes the first element from the list and returns it.
bool frontCutIsComplementOfBackCut() const
Returns whether the front cut is the complement of the backcut.
std::unique_ptr< EpsilonTest > m_et
bool isBackCutEdge(const edge e) const
Returns whether this edge is entering the back cut.
Copies of graphs supporting edge splitting.
EdgeArray< TCost > m_flow
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
MinSTCutMaxFlow(bool treatAsUndirected=true, MaxFlowModule< TCost > *mfModule=new MaxFlowGoldbergTarjan< TCost >(), bool primaryCut=true, bool calculateOtherCut=true, EpsilonTest *epsilonTest=new EpsilonTest())
Constructor.
E popRet()
Removes the newest element from the buffer and returns it.
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 m_calculateOtherCut
iff true, the other (near to s for primaryCut == false, near to t for primaryCut == true) cut should ...
Class for adjacency list elements.
EdgeElement * edge
The type of edges.
edge theEdge() const
Returns the edge associated with this adjacency entry.
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.
int numberOfEdges() const
Returns the number of edges in the graph.
Declaration and implementation of Goldberg-Tarjan max-flow algorithm with global relabeling and gap r...
int numberOfNodes() const
Returns the number of nodes in the graph.
Decralation of GraphElement and GraphList classes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
@ BACK_CUT
node is in back cut
bool m_primaryCut
true if the algorithm should search for the mincut nearest to s, false if it should be near to t.
void push(E e)
Puts a new element in the buffer.
node source() const
Returns the source node of the edge.
NodeElement * node
The type of nodes.
Declaration of graph copy classes.
RegisteredArray for nodes, edges and adjEntries of a graph.
Data type for general directed graphs (adjacency list representation).
virtual bool call(const Graph &graph, node s, node t, List< edge > &edgeList, edge e_st=nullptr) override
The actual algorithm call.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
@ FRONT_CUT
node is in front cut
@ NO_CUT
node is not part of any cut
cutType
The three types of cuts.
Basic declarations, included by all source files.
bool isOfType(const node v, cutType type) const
Return whether this node is of the specified type.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
std::unique_ptr< MaxFlowModule< TCost > > m_mfModule
the module used for calculating the maxflow
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
EdgeArray< TCost > m_weight
bool m_treatAsUndirected
states whether or not edges are considered undirected while calculating the maxflow
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
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.
bool isInBackCut(const node v) const
Returns whether this node is part of the back cut.
node target() const
Returns the target node of the edge.
Template of base class of min-st-cut algorithms.
Class for the representation of nodes.
Min-st-cut algorithm, that calculates the cut via maxflow.
iterator pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
bool isInFrontCut(const node v) const
Returns whether this node is part of the front cut.