makefile: tobb include konyvtar, jobb depend keszites
authorklao
Thu, 26 Feb 2004 16:07:40 +0000
changeset 1321ac27e476e25
parent 131 9aca797b87e8
child 133 0631992fe7a1
makefile: tobb include konyvtar, jobb depend keszites
flow_test.cc: torolve, mert a depend-et megakasztja, igy gondolom nem is fordul
src/work/flow_test.cc
src/work/makefile
     1.1 --- a/src/work/flow_test.cc	Thu Feb 26 11:38:51 2004 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,247 +0,0 @@
     1.4 -#include <iostream>
     1.5 -#include <vector>
     1.6 -#include <string>
     1.7 -
     1.8 -#include <marci_list_graph.hh>
     1.9 -#include <marci_graph_traits.hh>
    1.10 -#include <marci_property_vector.hh>
    1.11 -#include <preflow_push_hl.hh>
    1.12 -#include <preflow_push_max_flow.hh>
    1.13 -#include <reverse_bfs.hh>
    1.14 -#include <dijkstra.hh>
    1.15 -
    1.16 -using namespace hugo;
    1.17 -
    1.18 -
    1.19 -int main (int, char*[])
    1.20 -{
    1.21 -  typedef graph_traits<list_graph>::node_iterator node_iterator;
    1.22 -  typedef graph_traits<list_graph>::edge_iterator edge_iterator;
    1.23 -  typedef graph_traits<list_graph>::each_node_iterator each_node_iterator;
    1.24 -  typedef graph_traits<list_graph>::each_edge_iterator each_edge_iterator;
    1.25 -  typedef graph_traits<list_graph>::out_edge_iterator out_edge_iterator;
    1.26 -  typedef graph_traits<list_graph>::in_edge_iterator in_edge_iterator;
    1.27 -  typedef graph_traits<list_graph>::sym_edge_iterator sym_edge_iterator;
    1.28 -
    1.29 -  list_graph flow_test;
    1.30 - 
    1.31 -    //Ahuja könyv példája, maxflowvalue=13
    1.32 -  node_iterator s=flow_test.add_node();
    1.33 -  node_iterator v1=flow_test.add_node();
    1.34 -  node_iterator v2=flow_test.add_node();
    1.35 -  node_iterator v3=flow_test.add_node();
    1.36 -  node_iterator v4=flow_test.add_node();
    1.37 -  node_iterator v5=flow_test.add_node();
    1.38 -  node_iterator t=flow_test.add_node();
    1.39 -  
    1.40 -  node_property_vector<list_graph, std::string> node_name(flow_test);
    1.41 -  node_name.put(s, "s");
    1.42 -  node_name.put(v1, "v1");
    1.43 -  node_name.put(v2, "v2");
    1.44 -  node_name.put(v3, "v3");
    1.45 -  node_name.put(v4, "v4");
    1.46 -  node_name.put(v5, "v5");
    1.47 -  node_name.put(t, "t");
    1.48 -
    1.49 -  edge_iterator s_v1=flow_test.add_edge(s, v1);
    1.50 -  edge_iterator s_v2=flow_test.add_edge(s, v2);
    1.51 -  edge_iterator s_v3=flow_test.add_edge(s, v3);
    1.52 -  edge_iterator v2_v4=flow_test.add_edge(v2, v4);
    1.53 -  edge_iterator v2_v5=flow_test.add_edge(v2, v5);
    1.54 -  edge_iterator v3_v5=flow_test.add_edge(v3, v5);
    1.55 -  edge_iterator v4_t=flow_test.add_edge(v4, t);
    1.56 -  edge_iterator v5_t=flow_test.add_edge(v5, t);
    1.57 -  edge_iterator v2_s=flow_test.add_edge(v2, s);
    1.58 -  
    1.59 -  edge_property_vector<list_graph, int> cap(flow_test);  
    1.60 -  cap.put(s_v1, 0);
    1.61 -  cap.put(s_v2, 10);
    1.62 -  cap.put(s_v3, 10);
    1.63 -  cap.put(v2_v4, 5);
    1.64 -  cap.put(v2_v5, 8);
    1.65 -  cap.put(v3_v5, 5);
    1.66 -  cap.put(v4_t, 8);
    1.67 -  cap.put(v5_t, 8);
    1.68 -  cap.put(v2_s, 0);
    1.69 -
    1.70 -
    1.71 -  
    1.72 -  //Marci példája, maxflowvalue=23
    1.73 -  /*  node_iterator s=flow_test.add_node();
    1.74 -  node_iterator v1=flow_test.add_node();
    1.75 -  node_iterator v2=flow_test.add_node();
    1.76 -  node_iterator v3=flow_test.add_node();
    1.77 -  node_iterator v4=flow_test.add_node();
    1.78 -  node_iterator t=flow_test.add_node();
    1.79 -  node_iterator w=flow_test.add_node();
    1.80 -
    1.81 -  
    1.82 -  node_property_vector<list_graph, std::string> node_name(flow_test);
    1.83 -  node_name.put(s, "s");
    1.84 -  node_name.put(v1, "v1");
    1.85 -  node_name.put(v2, "v2");
    1.86 -  node_name.put(v3, "v3");
    1.87 -  node_name.put(v4, "v4");
    1.88 -  node_name.put(t, "t");
    1.89 -  node_name.put(w, "w");
    1.90 -
    1.91 -  edge_iterator s_v1=flow_test.add_edge(s, v1);
    1.92 -  edge_iterator s_v2=flow_test.add_edge(s, v2);
    1.93 -  edge_iterator v1_v2=flow_test.add_edge(v1, v2);
    1.94 -  edge_iterator v2_v1=flow_test.add_edge(v2, v1);
    1.95 -  edge_iterator v1_v3=flow_test.add_edge(v1, v3);
    1.96 -  edge_iterator v3_v2=flow_test.add_edge(v3, v2);
    1.97 -  edge_iterator v2_v4=flow_test.add_edge(v2, v4);
    1.98 -  edge_iterator v4_v3=flow_test.add_edge(v4, v3);
    1.99 -  edge_iterator v3_t=flow_test.add_edge(v3, t);
   1.100 -  edge_iterator v4_t=flow_test.add_edge(v4, t);
   1.101 -  edge_iterator v3_v3=flow_test.add_edge(v3, v3);
   1.102 -  edge_iterator s_w=flow_test.add_edge(s, w);
   1.103 -  //  edge_iterator v2_s=flow_test.add_edge(v2, s);
   1.104 -  
   1.105 -
   1.106 -
   1.107 -  edge_property_vector<list_graph, int> cap(flow_test);  //serves as length in dijkstra
   1.108 -  cap.put(s_v1, 16);
   1.109 -  cap.put(s_v2, 13);
   1.110 -  cap.put(v1_v2, 10);
   1.111 -  cap.put(v2_v1, 4);
   1.112 -  cap.put(v1_v3, 12);
   1.113 -  cap.put(v3_v2, 9);
   1.114 -  cap.put(v2_v4, 14);
   1.115 -  cap.put(v4_v3, 7);
   1.116 -  cap.put(v3_t, 20);
   1.117 -  cap.put(v4_t, 4);
   1.118 -  cap.put(v3_v3, 4);
   1.119 -  cap.put(s_w, 4);
   1.120 -  //  cap.put(v2_s, 0);
   1.121 -
   1.122 -*/
   1.123 -
   1.124 -  //pelda 3, maxflowvalue=4
   1.125 -  /*      node_iterator s=flow_test.add_node();
   1.126 -  node_iterator v1=flow_test.add_node();
   1.127 -  node_iterator v2=flow_test.add_node();
   1.128 -  node_iterator t=flow_test.add_node();
   1.129 -  node_iterator w=flow_test.add_node();
   1.130 -  
   1.131 -  node_property_vector<list_graph, std::string> node_name(flow_test);
   1.132 -  node_name.put(s, "s");
   1.133 -  node_name.put(v1, "v1");
   1.134 -  node_name.put(v2, "v2");
   1.135 -  node_name.put(t, "t");
   1.136 -  node_name.put(w, "w");
   1.137 -
   1.138 -  edge_iterator s_v1=flow_test.add_edge(s, v1);
   1.139 -  edge_iterator v1_v2=flow_test.add_edge(v1, v2);
   1.140 -  edge_iterator v2_t=flow_test.add_edge(v2, t);
   1.141 -  edge_iterator v1_v1=flow_test.add_edge(v1, v1);
   1.142 -  edge_iterator s_w=flow_test.add_edge(s, w);
   1.143 -
   1.144 -
   1.145 -  edge_property_vector<list_graph, int> cap(flow_test); 
   1.146 -    
   1.147 -  cap.put(s_v1, 16);
   1.148 -  cap.put(v1_v2, 10);
   1.149 -  cap.put(v2_t, 4);
   1.150 -  cap.put(v1_v1, 3);
   1.151 -  cap.put(s_w, 5);
   1.152 -  */
   1.153 -  
   1.154 -
   1.155 -
   1.156 -
   1.157 -  std::cout << "Testing reverse_bfs..." << std::endl;
   1.158 -  
   1.159 -  reverse_bfs<list_graph> bfs_test(flow_test, t);
   1.160 -
   1.161 -  bfs_test.run();
   1.162 -
   1.163 -  for (each_node_iterator w=flow_test.first_node(); w.valid(); ++w) {
   1.164 -    std::cout <<"The distance of " << w << " is " << bfs_test.dist(w) <<std::endl;
   1.165 -    }
   1.166 -
   1.167 -
   1.168 -
   1.169 -
   1.170 -
   1.171 -  std::cout << "Testing preflow_push_hl..." << std::endl;
   1.172 -  
   1.173 -  preflow_push_hl<list_graph, int> preflow_push_test(flow_test, s, t, cap);
   1.174 -
   1.175 -  preflow_push_test.run();
   1.176 -
   1.177 -  std::cout << "Maximum flow value is: " << preflow_push_test.maxflow() << "."<<std::endl;
   1.178 -
   1.179 -  std::cout<< "The flow on edge s-v1 is "<< preflow_push_test.flowonedge(s_v1) << "."<<std::endl;
   1.180 -
   1.181 -  edge_property_vector<list_graph, int> flow=preflow_push_test.allflow();  
   1.182 -  for (each_edge_iterator e=flow_test.first_edge(); e.valid(); ++e) {
   1.183 -    std::cout <<"Flow on edge " << flow_test.tail(e) <<"-" << flow_test.head(e)<< " is " <<flow.get(e) <<std::endl;
   1.184 -    }
   1.185 -
   1.186 -  std::cout << "A minimum cut: " <<std::endl;  
   1.187 -  node_property_vector<list_graph, bool> mincut=preflow_push_test.mincut();
   1.188 -
   1.189 -  for (each_node_iterator v=flow_test.first_node(); v.valid(); ++v) {
   1.190 -      if (mincut.get(v)) std::cout <<node_name.get(v)<< " ";
   1.191 -    }
   1.192 -  
   1.193 -  std::cout<<"\n\n"<<std::endl;
   1.194 -
   1.195 -
   1.196 -
   1.197 -
   1.198 -  std::cout << "Testing preflow_push_max_flow..." << std::endl;
   1.199 - 
   1.200 -  preflow_push_max_flow<list_graph, int> max_flow_test(flow_test, s, t, cap);
   1.201 -
   1.202 -  max_flow_test.run();
   1.203 -
   1.204 -  std::cout << "Maximum flow value is: " << max_flow_test.maxflow() << "."<< std::endl;
   1.205 -
   1.206 -  std::cout << "A minimum cut: " <<std::endl;  
   1.207 -  node_property_vector<list_graph, bool> mincut2=max_flow_test.mincut();
   1.208 -
   1.209 -  for (each_node_iterator v=flow_test.first_node(); v.valid(); ++v) {
   1.210 -    if (mincut2.get(v)) std::cout <<node_name.get(v)<< " ";
   1.211 -  }
   1.212 -  
   1.213 -  std::cout << std::endl <<std::endl;
   1.214 -
   1.215 -
   1.216 -
   1.217 -    std::cout << "Testing dijkstra..." << std::endl;
   1.218 -  
   1.219 -    node_iterator root=v2;
   1.220 -
   1.221 -    dijkstra<list_graph, int> dijkstra_test(flow_test, root, cap);
   1.222 -
   1.223 -    dijkstra_test.run();
   1.224 -
   1.225 -    for (each_node_iterator w=flow_test.first_node(); w.valid(); ++w) {
   1.226 -      if (dijkstra_test.reach(w)) {
   1.227 -      std::cout <<"The distance of " << w << " is " << dijkstra_test.dist(w);
   1.228 -      if (dijkstra_test.pred(w).valid()) {
   1.229 -      std::cout <<", a shortest path from the root ends with edge " << dijkstra_test.pred(w) <<std::endl; 
   1.230 -      } else {
   1.231 -       std::cout <<", this is the root."<<std::endl; }
   1.232 -      
   1.233 -      } else {
   1.234 -	cout << w << " is not reachable from " << root <<std::endl;
   1.235 -      }
   1.236 -    }
   1.237 -
   1.238 -
   1.239 -
   1.240 -  return 0;
   1.241 -}
   1.242 -
   1.243 -
   1.244 -
   1.245 -
   1.246 -
   1.247 -
   1.248 -
   1.249 -
   1.250 -
     2.1 --- a/src/work/makefile	Thu Feb 26 11:38:51 2004 +0000
     2.2 +++ b/src/work/makefile	Thu Feb 26 16:07:40 2004 +0000
     2.3 @@ -1,4 +1,4 @@
     2.4 -INCLUDEDIRS=-I../include -I. -I./jacint -I./marci
     2.5 +INCLUDEDIRS=-I../include -I. -I./{marci,jacint,alpar,klao,akos}
     2.6  CXXFLAGS=-g -O -Wall $(INCLUDEDIRS) -ansi -pedantic
     2.7  
     2.8  BINARIES = bin_heap_demo marci_graph_demo iterator_bfs_dfs_demo graphdemo bfsdemo bfsdemo2
     2.9 @@ -21,10 +21,9 @@
    2.10  
    2.11  ################
    2.12  
    2.13 -dep depend:
    2.14 -	$(CXX) $(CXXFLAGS) -M *.cc > .depend
    2.15 -.depend:
    2.16 -	$(CXX) $(CXXFLAGS) -M *.cc > .depend
    2.17 +
    2.18 +.depend dep depend:
    2.19 +	-$(CXX) $(CXXFLAGS) -M *.cc > .depend
    2.20  
    2.21  makefile: .depend
    2.22  sinclude .depend