58template<
typename T =
double>
63 return call(G, weights);
68 m_minCut = std::numeric_limits<T>::max();
99 inPartition[v] =
true;
103 for (
adjEntry adj : v->adjEntries) {
104 if (!inPartition[adj->twinNode()]) {
167 m_contractedNodes[t].conc(m_contractedNodes(s));
171 edge e = adj->theEdge();
172 if (e->source() == t || e->target() == t) {
174 }
else if (e->source() == s) {
175 m_GC.moveSource(e, t);
177 m_GC.moveTarget(e, t);
187 node v {adj->twinNode()};
189 edge e {adj->theEdge()};
190 edge& f {incident[v]};
215 for (
node v : m_GC.nodes) {
218 std::function<void(
node)> updatePQ {[&](
node currentNode) {
220 for (
adjEntry adj : currentNode->adjEntries) {
221 node v {adj->twinNode()};
224 T newPriority {pq.
priority(v) - m_w[adj->theEdge()]};
226 pq.
decrease(adj->twinNode(), newPriority);
240 while (!pq.
empty()) {
250 updatePQ(currentNode);
255 for (
adjEntry adj : t->adjEntries) {
256 edge e {adj->theEdge()};
257 if (!e->isSelfLoop()) {
258 phaseCut += m_w[adj->theEdge()];
264 if (phaseCut < m_minCut) {
266 for (
node v : m_contractedNodes[t]) {
Declaration and implementation of ArrayBuffer class.
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Declaration of ogdf::MinimumCutModule.
Priority queue interface wrapping various heaps.
Basic declarations, included by all source files.
Class for adjacency list elements.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
void clear()
Clears the buffer.
void push(E e)
Puts a new element in the buffer.
bool empty() const
Returns true if the buffer is empty, false otherwise.
Class for the representation of edges.
void init(const Graph &G)
Re-initializes the copy using G, creating copies for all nodes and edges in G.
const Graph & original() const
Returns a reference to the original graph.
Copies of graphs supporting edge splitting.
Data type for general directed graphs (adjacency list representation).
int numberOfNodes() const
Returns the number of nodes in the graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Serves as an interface for various methods to compute minimum cuts with or without edge weights.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Prioritized queue interface wrapper for heaps.
bool empty() const
Checks whether the queue is empty.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
void decrease(const E &element, const P &priority)
Decreases the priority of the given element.
bool contains(const E &element) const
Returns whether this queue contains that key.
void pop()
Removes the topmost element from the queue.
void push(const E &element, const P &priority)
Adds a new element to the queue.
const P & priority(const E &element) const
const E & topElement() const
Returns the topmost element in the queue.
AdjElement * adjEntry
The type of adjacency entries.
EdgeElement * edge
The type of edges.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
void updateMin(T &min, const T &newValue)
Stores the minimum of min and newValue in min.
The namespace for all OGDF objects.
void safeForEach(CONTAINER &container, std::function< void(typename CONTAINER::value_type)> func)
Calls (possibly destructive) func for each element of container.
Computes a minimum cut in a graph.
void contraction(node t, node s)
Contracts the nodes s and t, i.e., s is collapsed to t. The edge (if existing) between s and t is del...
ArrayBuffer< node > m_partition
Store one side of the computed bipartition.
virtual T call(const Graph &G, const EdgeArray< T > &weights) override
Computes a minimum cut on graph G with non-negative weights on edges.
GraphCopy m_GC
The modifiable version of the input graph (used for contractions)
EdgeArray< T > m_w
An EdgeArray containing the corresponding edge weights.
ArrayBuffer< edge > m_cutEdges
Store cut edges if computed.
NodeArray< List< node > > m_contractedNodes
Each node has a list containing the nodes with which it has been contracted. Because the GraphCopy m_...
void mainLoop()
Computes minimum cut by invoking minimumCutPhase() O(|V|) times.
virtual const ArrayBuffer< node > & nodes() override
Returns a const-reference to the list of nodes belonging to one side of the bipartition.
T m_minCut
Stores the value of the minimum cut.
T minimumCutPhase()
Computes and returns the value of the minimum cut of the current phase (iteration).
virtual const ArrayBuffer< edge > & edges() override
Computes the edges defining the computed mincut and returns them.
virtual T value() const override
Returns the value of the last minimum cut computation.
virtual T call(const Graph &G) override
Computes a minimum cut on graph G.