Open
Graph Drawing
Framework

 v.2012.05
 

MinimumCut.h
Go to the documentation of this file.
00001 /*
00002  * $Revision: 2299 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 
00007  ***************************************************************/
00008  
00045 #ifdef _MSC_VER
00046 #pragma once
00047 #endif
00048 
00049 #ifndef OGDF_MINIMUM_CUT_H
00050 #define OGDF_MINIMUM_CUT_H
00051 
00052 #include <ogdf/basic/EdgeArray.h>
00053 #include <ogdf/basic/NodeArray.h>
00054 #include <ogdf/basic/GraphCopy.h>
00055 #include <ogdf/basic/simple_graph_alg.h>
00056 
00057 namespace ogdf {
00058     
00059 
00060 class OGDF_EXPORT MinCut {
00061     
00062 public:
00063     //Todo: Shift parameters to the call!
00064     //m_minCut is only initialized once!!!
00065     MinCut(Graph &G, EdgeArray<double> &w);
00066     ~MinCut();
00067     
00068     // implements the main loop that computes the minimum cut by invoking function
00069     // minimumCutPhase() in each iteration. Returns the mincut value.
00070     double minimumCut();
00071     
00072     // returns the edges defining the computed mincut in list \a edges.
00073     void cutEdges(List<edge> &edges, Graph &G);
00074     
00075     // returns list of nodes belonging to one side of the bipartition in list \a nodes.
00076     void partition(List<node> &nodes);
00077     
00078     double const minCutValue() {return m_minCut;}
00079     
00080 private:
00081 
00082     // stores the value of the minimum cut
00083     double m_minCut;
00084     
00085     // GraphCopy of the corresponding Graph. Used for the computation in order not 
00086     // to destroy the original Graph.
00087     GraphCopy m_GC;
00088     
00089     // an EdgeArray containing the corresponding edge weights.
00090     EdgeArray<double> m_w;
00091     
00092     // the two node lists corresponding to the node contraction
00093     List<node> m_contraction1, m_contraction2;
00094     
00095     // store one side of the computed bipartition.
00096     List<node> m_partition;
00097     
00098     // the list of edges defining the cut
00099     List<edge> m_cutEdges;
00100     
00101     // each node has a list containing the nodes with which it has been contracted. 
00102     // Because the GraphCopy \a m_GC is destroyed during the algorithm, this is
00103     // necessary to be able to determine the original nodes in the end.
00104     NodeArray<List<node> > m_contractedNodes;
00105     
00106     // computes and returns the value of the minimum cut of the current phase (itertion).
00107     double minimumCutPhase();
00108     
00109     // Contracts the nodes \a s and \a t, i.e \a s is collapsed to \a t.
00110     // The edge (if existing) between \a s and \t s is deleted. Edges incident to \a s are redirected to \t.
00111     // If parallel edges occur, one of them is deleted and its weight is added to the other one.
00112     void contraction(node t, node s);
00113     
00114 };
00115 
00116 }// end namespace
00117 
00118 #endif