misc
authormarci
Sat, 24 Apr 2004 15:19:17 +0000
changeset 3934535f78639e2
parent 392 b8d635e1672d
child 394 3a34c5626e52
misc
src/work/makefile
src/work/marci/bipartite_graph_wrapper_test.cc
src/work/marci/graph_wrapper.h
     1.1 --- a/src/work/makefile	Sat Apr 24 14:25:03 2004 +0000
     1.2 +++ b/src/work/makefile	Sat Apr 24 15:19:17 2004 +0000
     1.3 @@ -1,12 +1,12 @@
     1.4  INCLUDEDIRS ?= -I../include -I. -I./{marci,jacint,alpar,klao,akos}
     1.5 -CXXFLAGS = -g -O3 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
     1.6 +CXXFLAGS = -g -O0 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
     1.7  
     1.8  BINARIES ?= bin_heap_demo
     1.9  
    1.10  # Hat, ez elismerem, hogy nagyon ronda, de mukodik minden altalam
    1.11  # ismert rendszeren :-)  (Misi)
    1.12 -CXX := $(shell type -p g++-3.4 || type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
    1.13 -#CXX := $(shell type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
    1.14 +#CXX := $(shell type -p g++-3.4 || type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
    1.15 +CXX := $(shell type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
    1.16  CC := $(CXX)
    1.17  
    1.18  
     2.1 --- a/src/work/marci/bipartite_graph_wrapper_test.cc	Sat Apr 24 14:25:03 2004 +0000
     2.2 +++ b/src/work/marci/bipartite_graph_wrapper_test.cc	Sat Apr 24 15:19:17 2004 +0000
     2.3 @@ -72,6 +72,9 @@
     2.4    MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
     2.5      max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
     2.6    max_flow_test.augmentOnShortestPath();
     2.7 +  max_flow_test.augmentOnShortestPath();
     2.8 +
     2.9 +  std::cout << max_flow_test.flowValue() << std::endl;
    2.10  
    2.11    return 0;
    2.12  }
     3.1 --- a/src/work/marci/graph_wrapper.h	Sat Apr 24 14:25:03 2004 +0000
     3.2 +++ b/src/work/marci/graph_wrapper.h	Sat Apr 24 15:19:17 2004 +0000
     3.3 @@ -918,7 +918,7 @@
     3.4      typedef IterableBoolMap< typename Graph::template NodeMap<int> > 
     3.5      SFalseTTrueMap;
     3.6      SFalseTTrueMap* s_false_t_true_map;
     3.7 -    
     3.8 +
     3.9    public:
    3.10      static const bool S_CLASS=false;
    3.11      static const bool T_CLASS=true;
    3.12 @@ -930,7 +930,15 @@
    3.13      //using GraphWrapper<Graph>::NodeIt;
    3.14      typedef typename GraphWrapper<Graph>::Edge Edge;
    3.15      //using GraphWrapper<Graph>::EdgeIt;
    3.16 +    class ClassNodeIt;
    3.17 +    friend class ClassNodeIt;
    3.18 +    class OutEdgeIt;
    3.19 +    friend class OutEdgeIt;
    3.20 +    class InEdgeIt;
    3.21 +    friend class InEdgeIt;
    3.22      class ClassNodeIt {
    3.23 +      friend class BipartiteGraphWrapper<Graph>;
    3.24 +    protected:
    3.25        Node n;
    3.26      public:
    3.27        ClassNodeIt() { }
    3.28 @@ -963,8 +971,8 @@
    3.29  //       operator Node() const { return n; }
    3.30  //     };
    3.31      class OutEdgeIt { 
    3.32 -    public:
    3.33 -
    3.34 +      friend class BipartiteGraphWrapper<Graph>;
    3.35 +    protected:
    3.36        typename Graph::OutEdgeIt e;
    3.37      public:
    3.38        OutEdgeIt() { }
    3.39 @@ -978,7 +986,8 @@
    3.40        operator Edge() const { return Edge(typename Graph::Edge(e)); }
    3.41      };
    3.42      class InEdgeIt { 
    3.43 -    public:
    3.44 +      friend class BipartiteGraphWrapper<Graph>;
    3.45 +    protected:
    3.46        typename Graph::InEdgeIt e;
    3.47      public:
    3.48        InEdgeIt() { }
    3.49 @@ -994,7 +1003,7 @@
    3.50  
    3.51      using GraphWrapper<Graph>::first;
    3.52      ClassNodeIt& first(ClassNodeIt& n, bool _class) const { 
    3.53 -      n=SNodeIt(*this, _class) ; return n; }
    3.54 +      n=ClassNodeIt(*this, _class) ; return n; }
    3.55  //    SNodeIt& first(SNodeIt& n) const { n=SNodeIt(*this); return n; }
    3.56  //    TNodeIt& first(TNodeIt& n) const { n=TNodeIt(*this); return n; }
    3.57      OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
    3.58 @@ -1006,7 +1015,7 @@
    3.59  
    3.60      using GraphWrapper<Graph>::next;
    3.61      ClassNodeIt& next(ClassNodeIt& n) const { 
    3.62 -      this->s_false_t_true_map->next(n); return n; 
    3.63 +      this->s_false_t_true_map->next(n.n); return n; 
    3.64      }
    3.65  //     SNodeIt& next(SNodeIt& n) const { 
    3.66  //       this->s_false_t_true_map->next(n); return n; 
    3.67 @@ -1319,9 +1328,10 @@
    3.68        return i; 
    3.69      }
    3.70      OutEdgeIt& next(OutEdgeIt& i) const { 
    3.71 +      typename Graph::Node v;
    3.72        switch (i.spec) {
    3.73  	case 0: //normal edge
    3.74 -	  typename Graph::Node v=this->graph->aNode(i.e);
    3.75 +	  this->graph->aNode(i.e);
    3.76  	  this->graph->next(i.e);
    3.77  	  if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
    3.78  	    if (this->graph->inSClass(v)) { //S, nincs kiel
    3.79 @@ -1345,9 +1355,10 @@
    3.80        return i; 
    3.81      }
    3.82      InEdgeIt& next(InEdgeIt& i) const { 
    3.83 +      typename Graph::Node v;
    3.84        switch (i.spec) {
    3.85  	case 0: //normal edge
    3.86 -	  typename Graph::Node v=this->graph->aNode(i.e);
    3.87 +	  v=this->graph->aNode(i.e);
    3.88  	  this->graph->next(i.e);
    3.89  	  if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
    3.90  	    if (this->graph->inTClass(v)) { //S, nincs beel
    3.91 @@ -1403,28 +1414,30 @@
    3.92  
    3.93      Node tail(const Edge& e) const { 
    3.94        switch (e.spec) {
    3.95 -	case 0: 
    3.96 -	  return Node(this->graph->tail(e));
    3.97 -	  break;
    3.98 -	case 1:
    3.99 -	  return S_NODE;
   3.100 -	  break;
   3.101 -	case 2:
   3.102 -	  return Node(e.n);
   3.103 -	  break;
   3.104 +      case 0: 
   3.105 +	return Node(this->graph->tail(e));
   3.106 +	break;
   3.107 +      case 1:
   3.108 +	return S_NODE;
   3.109 +	break;
   3.110 +      case 2:
   3.111 +      default:
   3.112 +	return Node(e.n);
   3.113 +	break;
   3.114        }
   3.115      }
   3.116      Node head(const Edge& e) const { 
   3.117        switch (e.spec) {
   3.118 -	case 0: 
   3.119 -	  return Node(this->graph->head(e));
   3.120 -	  break;
   3.121 -	case 1:
   3.122 -	  return Node(e.n);
   3.123 -	  break;
   3.124 -	case 2:
   3.125 -	  return T_NODE;
   3.126 -	  break;
   3.127 +      case 0: 
   3.128 +	return Node(this->graph->head(e));
   3.129 +	break;
   3.130 +      case 1:
   3.131 +	return Node(e.n);
   3.132 +	break;
   3.133 +      case 2:
   3.134 +      default:
   3.135 +	return T_NODE;
   3.136 +	break;
   3.137        }
   3.138      }
   3.139  
   3.140 @@ -1458,64 +1471,68 @@
   3.141  						      t_value(a) { }
   3.142        T operator[](const Node& n) const { 
   3.143  	switch (n.spec) {
   3.144 -	  case 0: 
   3.145 -	    return (*this)[n];
   3.146 -	    break;
   3.147 -	  case 1:
   3.148 -	    return s_value;
   3.149 -	    break;
   3.150 -	  case 2:
   3.151 -	    return t_value;
   3.152 -	    break;
   3.153 +	case 0: 
   3.154 +	  return Parent::operator[](n);
   3.155 +	  break;
   3.156 +	case 1:
   3.157 +	  return s_value;
   3.158 +	  break;
   3.159 +	case 2: 
   3.160 +	default:
   3.161 +	  return t_value;
   3.162 +	  break;
   3.163  	}
   3.164        }
   3.165        void set(const Node& n, T t) { 
   3.166  	switch (n.spec) {
   3.167 -	  case 0: 
   3.168 -	    GraphWrapper<Graph>::template NodeMap<T>::set(n, t);
   3.169 -	    break;
   3.170 -	  case 1:
   3.171 -	    s_value=t;
   3.172 -	    break;
   3.173 -	  case 2:
   3.174 -	    t_value=t;
   3.175 -	    break;
   3.176 +	case 0: 
   3.177 +	  GraphWrapper<Graph>::template NodeMap<T>::set(n, t);
   3.178 +	  break;
   3.179 +	case 1:
   3.180 +	  s_value=t;
   3.181 +	  break;
   3.182 +	case 2:
   3.183 +	default:
   3.184 +	  t_value=t;
   3.185 +	  break;
   3.186  	}
   3.187        }
   3.188      };
   3.189  
   3.190      template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> { 
   3.191 -      typedef typename Graph::template NodeMap<T> Parent;
   3.192 +      typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
   3.193        typename GraphWrapper<Graph>::template NodeMap<T> node_value;
   3.194      public:
   3.195 -      EdgeMap(const stGraphWrapper<Graph>& _G) :  Parent(_G), 
   3.196 -						  node_value(_G) { }
   3.197 +      EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G), 
   3.198 +						 node_value(_G) { }
   3.199        EdgeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a), 
   3.200  						      node_value(_G, a) { }
   3.201        T operator[](const Edge& e) const { 
   3.202  	switch (e.spec) {
   3.203 -	  case 0: 
   3.204 -	    return (*this)[e];
   3.205 -	    break;
   3.206 -	  case 1:
   3.207 -	    return node_value[e.n];
   3.208 -	    break;
   3.209 -	  case 2:
   3.210 -	    return node_value[e.n];
   3.211 -	    break;
   3.212 +	case 0: 
   3.213 +	  return Parent::operator[](e);
   3.214 +	  break;
   3.215 +	case 1:
   3.216 +	  return node_value[e.n];
   3.217 +	  break;
   3.218 +	case 2:
   3.219 +	default:
   3.220 +	  return node_value[e.n];
   3.221 +	  break;
   3.222  	}
   3.223        }
   3.224        void set(const Edge& e, T t) { 
   3.225  	switch (e.spec) {
   3.226 -	  case 0: 
   3.227 -	    GraphWrapper<Graph>::set(e, t);
   3.228 -	    break;
   3.229 -	  case 1:
   3.230 -	    node_value.set(e, t);
   3.231 -	    break;
   3.232 -	  case 2:
   3.233 -	    node_value.set(e, t);
   3.234 -	    break;
   3.235 +	case 0: 
   3.236 +	  GraphWrapper<Graph>::template EdgeMap<T>::set(e, t);
   3.237 +	  break;
   3.238 +	case 1:
   3.239 +	  node_value.set(e.n, t);
   3.240 +	  break;
   3.241 +	case 2:
   3.242 +	default:
   3.243 +	  node_value.set(e.n, t);
   3.244 +	  break;
   3.245  	}
   3.246        }
   3.247      };