00001 #include <boost/graph/adjacency_list.hpp>
00002 #include <scil/core/cutTree.h>
00003 #include<iostream>
00004 #include<fstream>
00005 #include<string>
00006 #include <boost/graph/iteration_macros.hpp>
00007
00008 using namespace boost;
00009
00010 typedef adjacency_list<vecS,vecS,undirectedS> Graph;
00011 typedef graph_traits<Graph>::edge_descriptor edge_descriptor;
00012 typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor;
00013
00014 int main(int argc, char** argv) {
00015 Graph G;
00016
00017 std::map<vertex_descriptor, vertex_descriptor> p;
00018 std::map<vertex_descriptor, double> fl;
00019 std::map<edge_descriptor,double> cap;
00020
00021 computeCutTree<Graph>(G, cap, p, fl );
00022
00023 G = Graph(6);
00024 add_edge(0,1,G); add_edge(0,2,G);
00025 add_edge(0,4,G); add_edge(4,5,G);
00026 add_edge(5,1,G); add_edge(1,3,G);
00027 add_edge(3,2,G);
00028
00029 edge_descriptor e;
00030 BGL_FORALL_EDGES(e,G,Graph)
00031 cap[e] = 1;
00032
00033 computeCutTree(G,cap,p,fl);
00034
00035
00036 cout << "The cut-tree has edges s--t with flow value f" << endl;
00037 cout << " s \t t \t f " << endl;
00038 cout << "----------------------------------" << endl;
00039 vertex_descriptor s;
00040 BGL_FORALL_VERTICES(s,G,Graph)
00041 cout << s << "\t" << p[s] << "\t" << fl[s] << endl;
00042
00043
00044 unsigned int t;
00045 double F[6][6];
00046 for( int s=0;s<6;s++ )
00047 for( int t=0;t<6;t++ )
00048 F[s][t]=0;
00049
00050
00051 for( unsigned int s=1;s<6;s++ ){
00052 t = p[s];
00053 F[s][t] = fl[s];
00054 F[t][s] = fl[s];
00055 for( unsigned int i=0;i<s;i++ ){
00056 if( i!=t ) {
00057 F[s][i] = min(F[s][t], F[t][i]);
00058 F[i][s] = F[s][i];
00059 }
00060 }
00061 }
00062
00063 cout << "\nall Flows:"<<endl;
00064 for( int t=0;t<6;t++ ) cout << "\t" << t;
00065 cout << endl << "\t------------------------------------------" << endl;
00066 for( int s=0;s<6;s++ ){
00067 cout << " "<< s << "\t| ";
00068 for( int t=0;t<6;t++ ){
00069 cout << F[s][t] << "\t";
00070 }
00071 cout << endl;
00072 }
00073
00074
00075 }