00001 #include <boost/graph/graph_traits.hpp>
00002 #include <boost/graph/adjacency_matrix.hpp>
00003 #include <boost/graph/adjacency_list.hpp>
00004 #include <boost/graph/graph_concepts.hpp>
00005 #include <boost/type_traits/is_same.hpp>
00006 #include <boost/type_traits/is_base_and_derived.hpp>
00007
00008 #ifndef MIN_CUT_H
00009 #define MIN_CUT_H
00010
00011 using namespace std;
00012 using namespace boost;
00013
00014 namespace SCIL {
00015
00016 template <typename Graph>
00017 class MC {
00018 public:
00019 typedef graph_traits<Graph> GraphTraits;
00020 typedef typename GraphTraits::vertex_descriptor vertex_descriptor;
00021 int value;
00022 list<vertex_descriptor> nodes;
00023 MC()
00024 : value(0)
00025 {};
00026 MC(int val, list<vertex_descriptor> nod)
00027 : value(val) {
00028 nodes = nod;
00029 }
00030 ~MC() {
00031 nodes.clear();
00032 }
00033 MC<Graph>& operator= ( const MC<Graph>& x ) {
00034 value = x.value;
00035 nodes = x.nodes;
00036 }
00037 };
00038
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 template <typename Graph>
00050 class MIN_CUT {
00051
00052 public:
00053 MC<Graph> minCutOfPhase;
00054 MC<Graph> minCut;
00055
00056 private:
00057 typedef graph_traits<Graph> GraphTraits;
00058 typedef typename GraphTraits::vertex_descriptor vertex_descriptor;
00059 typedef typename GraphTraits::edge_descriptor edge_descriptor;
00060 const Graph &G_ref;
00061 Graph G;
00062
00063 map<vertex_descriptor, vertex_descriptor> GtoG_ref;
00065 map<vertex_descriptor, vertex_descriptor> merged_vertex;
00066 map<edge_descriptor, int> w;
00067 set<vertex_descriptor> vertices_of_G;
00068
00070
00071
00072
00073
00074
00075 void MinCutPhase();
00076
00078
00079
00080
00081
00082 void contract(vertex_descriptor s, vertex_descriptor t);
00083
00085
00086
00087
00088 void getCutOfPhase(int w, vertex_descriptor t);
00089
00090 public:
00092
00093
00094
00095
00096
00097 MIN_CUT(const Graph &G_, const map<edge_descriptor, int> &w_);
00098
00100
00101
00102
00103
00104
00105
00106 void run();
00107 };
00108
00109 #include "../../../src/core/min_cut.cc"
00110
00111 }
00112
00113 #endif