Bug fix
authordeba
Thu, 01 Mar 2007 16:47:23 +0000
changeset 23810248790c66ea
parent 2380 7b0558c52de3
child 2382 678bea23ed75
Bug fix
lemon/list_graph.h
lemon/smart_graph.h
lemon/ugraph_adaptor.h
     1.1 --- a/lemon/list_graph.h	Thu Mar 01 16:04:12 2007 +0000
     1.2 +++ b/lemon/list_graph.h	Thu Mar 01 16:47:23 2007 +0000
     1.3 @@ -527,10 +527,11 @@
     1.4            }
     1.5          }
     1.6          virtual void build() {
     1.7 -          NodeNotifier* notifier = getNotifier();
     1.8 +          NodeNotifier* _notifier = notifier();
     1.9            Node node;
    1.10            std::vector<Node> nodes;
    1.11 -          for (notifier->first(node); node != INVALID; notifier->next(node)) {
    1.12 +          for (_notifier->first(node); node != INVALID; 
    1.13 +               _notifier->next(node)) {
    1.14              nodes.push_back(node);
    1.15            }
    1.16            for (int i = nodes.size() - 1; i >= 0; --i) {
    1.17 @@ -538,9 +539,10 @@
    1.18            }
    1.19          }
    1.20          virtual void clear() {
    1.21 -          NodeNotifier* notifier = getNotifier();
    1.22 +          NodeNotifier* _notifier = notifier();
    1.23            Node node;
    1.24 -          for (notifier->first(node); node != INVALID; notifier->next(node)) {
    1.25 +          for (_notifier->first(node); node != INVALID; 
    1.26 +               _notifier->next(node)) {
    1.27              snapshot.eraseNode(node);
    1.28            }
    1.29          }
    1.30 @@ -577,10 +579,11 @@
    1.31            }
    1.32          }
    1.33          virtual void build() {
    1.34 -          EdgeNotifier* notifier = getNotifier();
    1.35 +          EdgeNotifier* _notifier = notifier();
    1.36            Edge edge;
    1.37            std::vector<Edge> edges;
    1.38 -          for (notifier->first(edge); edge != INVALID; notifier->next(edge)) {
    1.39 +          for (_notifier->first(edge); edge != INVALID; 
    1.40 +               _notifier->next(edge)) {
    1.41              edges.push_back(edge);
    1.42            }
    1.43            for (int i = edges.size() - 1; i >= 0; --i) {
    1.44 @@ -588,9 +591,9 @@
    1.45            }
    1.46          }
    1.47          virtual void clear() {
    1.48 -          EdgeNotifier* notifier = getNotifier();
    1.49 +          EdgeNotifier* _notifier = notifier();
    1.50            Edge edge;
    1.51 -          for (notifier->first(edge); edge != INVALID; notifier->next(edge)) {
    1.52 +          for (_notifier->first(edge); edge != INVALID; _notifier->next(edge)) {
    1.53              snapshot.eraseEdge(edge);
    1.54            }
    1.55          }
    1.56 @@ -639,8 +642,8 @@
    1.57  
    1.58        void attach(ListGraph &_graph) {
    1.59  	graph = &_graph;
    1.60 -	node_observer_proxy.attach(graph->getNotifier(Node()));
    1.61 -        edge_observer_proxy.attach(graph->getNotifier(Edge()));
    1.62 +	node_observer_proxy.attach(graph->notifier(Node()));
    1.63 +        edge_observer_proxy.attach(graph->notifier(Edge()));
    1.64        }
    1.65              
    1.66        void detach() {
    1.67 @@ -911,13 +914,23 @@
    1.68  
    1.69      void firstInc(UEdge &e, bool& d, const Node& v) const {
    1.70        int de = nodes[v.id].first_out;
    1.71 -      e.id = de / 2;
    1.72 -      d = ((de & 1) == 1);
    1.73 +      if (de != -1 ) {
    1.74 +        e.id = de / 2;
    1.75 +        d = ((de & 1) == 1);
    1.76 +      } else {
    1.77 +        e.id = -1;
    1.78 +        d = true;
    1.79 +      }
    1.80      }
    1.81      void nextInc(UEdge &e, bool& d) const {
    1.82        int de = (edges[(e.id * 2) | (d ? 1 : 0)].next_out);
    1.83 -      e.id = de / 2;
    1.84 -      d = ((de & 1) == 1);
    1.85 +      if (de != -1 ) {
    1.86 +        e.id = de / 2;
    1.87 +        d = ((de & 1) == 1);
    1.88 +      } else {
    1.89 +        e.id = -1;
    1.90 +        d = true;
    1.91 +      }
    1.92      }
    1.93      
    1.94      static int id(Node v) { return v.id; }
    1.95 @@ -1261,10 +1274,11 @@
    1.96            }
    1.97          }
    1.98          virtual void build() {
    1.99 -          NodeNotifier* notifier = getNotifier();
   1.100 +          NodeNotifier* _notifier = notifier();
   1.101            Node node;
   1.102            std::vector<Node> nodes;
   1.103 -          for (notifier->first(node); node != INVALID; notifier->next(node)) {
   1.104 +          for (_notifier->first(node); node != INVALID; 
   1.105 +               _notifier->next(node)) {
   1.106              nodes.push_back(node);
   1.107            }
   1.108            for (int i = nodes.size() - 1; i >= 0; --i) {
   1.109 @@ -1272,9 +1286,10 @@
   1.110            }
   1.111          }
   1.112          virtual void clear() {
   1.113 -          NodeNotifier* notifier = getNotifier();
   1.114 +          NodeNotifier* _notifier = notifier();
   1.115            Node node;
   1.116 -          for (notifier->first(node); node != INVALID; notifier->next(node)) {
   1.117 +          for (_notifier->first(node); node != INVALID; 
   1.118 +               _notifier->next(node)) {
   1.119              snapshot.eraseNode(node);
   1.120            }
   1.121          }
   1.122 @@ -1311,10 +1326,11 @@
   1.123            }
   1.124          }
   1.125          virtual void build() {
   1.126 -          UEdgeNotifier* notifier = getNotifier();
   1.127 +          UEdgeNotifier* _notifier = notifier();
   1.128            UEdge edge;
   1.129            std::vector<UEdge> edges;
   1.130 -          for (notifier->first(edge); edge != INVALID; notifier->next(edge)) {
   1.131 +          for (_notifier->first(edge); edge != INVALID; 
   1.132 +               _notifier->next(edge)) {
   1.133              edges.push_back(edge);
   1.134            }
   1.135            for (int i = edges.size() - 1; i >= 0; --i) {
   1.136 @@ -1322,9 +1338,10 @@
   1.137            }
   1.138          }
   1.139          virtual void clear() {
   1.140 -          UEdgeNotifier* notifier = getNotifier();
   1.141 +          UEdgeNotifier* _notifier = notifier();
   1.142            UEdge edge;
   1.143 -          for (notifier->first(edge); edge != INVALID; notifier->next(edge)) {
   1.144 +          for (_notifier->first(edge); edge != INVALID; 
   1.145 +               _notifier->next(edge)) {
   1.146              snapshot.eraseUEdge(edge);
   1.147            }
   1.148          }
   1.149 @@ -1373,8 +1390,8 @@
   1.150  
   1.151        void attach(ListUGraph &_graph) {
   1.152  	graph = &_graph;
   1.153 -	node_observer_proxy.attach(graph->getNotifier(Node()));
   1.154 -        edge_observer_proxy.attach(graph->getNotifier(UEdge()));
   1.155 +	node_observer_proxy.attach(graph->notifier(Node()));
   1.156 +        edge_observer_proxy.attach(graph->notifier(UEdge()));
   1.157        }
   1.158              
   1.159        void detach() {
   1.160 @@ -2039,10 +2056,11 @@
   1.161            }
   1.162          }
   1.163          virtual void build() {
   1.164 -          NodeNotifier* notifier = getNotifier();
   1.165 +          NodeNotifier* _notifier = notifier();
   1.166            Node node;
   1.167            std::vector<Node> nodes;
   1.168 -          for (notifier->first(node); node != INVALID; notifier->next(node)) {
   1.169 +          for (_notifier->first(node); node != INVALID; 
   1.170 +               _notifier->next(node)) {
   1.171              nodes.push_back(node);
   1.172            }
   1.173            for (int i = nodes.size() - 1; i >= 0; --i) {
   1.174 @@ -2050,9 +2068,10 @@
   1.175            }
   1.176          }
   1.177          virtual void clear() {
   1.178 -          NodeNotifier* notifier = getNotifier();
   1.179 +          NodeNotifier* _notifier = notifier();
   1.180            Node node;
   1.181 -          for (notifier->first(node); node != INVALID; notifier->next(node)) {
   1.182 +          for (_notifier->first(node); node != INVALID; 
   1.183 +               _notifier->next(node)) {
   1.184              snapshot.eraseNode(node);
   1.185            }
   1.186          }
   1.187 @@ -2089,10 +2108,11 @@
   1.188            }
   1.189          }
   1.190          virtual void build() {
   1.191 -          UEdgeNotifier* notifier = getNotifier();
   1.192 +          UEdgeNotifier* _notifier = notifier();
   1.193            UEdge edge;
   1.194            std::vector<UEdge> edges;
   1.195 -          for (notifier->first(edge); edge != INVALID; notifier->next(edge)) {
   1.196 +          for (_notifier->first(edge); edge != INVALID; 
   1.197 +               _notifier->next(edge)) {
   1.198              edges.push_back(edge);
   1.199            }
   1.200            for (int i = edges.size() - 1; i >= 0; --i) {
   1.201 @@ -2100,9 +2120,10 @@
   1.202            }
   1.203          }
   1.204          virtual void clear() {
   1.205 -          UEdgeNotifier* notifier = getNotifier();
   1.206 +          UEdgeNotifier* _notifier = notifier();
   1.207            UEdge edge;
   1.208 -          for (notifier->first(edge); edge != INVALID; notifier->next(edge)) {
   1.209 +          for (_notifier->first(edge); edge != INVALID; 
   1.210 +               _notifier->next(edge)) {
   1.211              snapshot.eraseUEdge(edge);
   1.212            }
   1.213          }
   1.214 @@ -2151,8 +2172,8 @@
   1.215  
   1.216        void attach(ListBpUGraph &_graph) {
   1.217  	graph = &_graph;
   1.218 -	node_observer_proxy.attach(graph->getNotifier(Node()));
   1.219 -        edge_observer_proxy.attach(graph->getNotifier(UEdge()));
   1.220 +	node_observer_proxy.attach(graph->notifier(Node()));
   1.221 +        edge_observer_proxy.attach(graph->notifier(UEdge()));
   1.222        }
   1.223              
   1.224        void detach() {
     2.1 --- a/lemon/smart_graph.h	Thu Mar 01 16:04:12 2007 +0000
     2.2 +++ b/lemon/smart_graph.h	Thu Mar 01 16:47:23 2007 +0000
     2.3 @@ -286,14 +286,14 @@
     2.4      {
     2.5        while(s.edge_num<edges.size()) {
     2.6          Edge edge = edgeFromId(edges.size()-1);
     2.7 -	Parent::getNotifier(Edge()).erase(edge);
     2.8 +	Parent::notifier(Edge()).erase(edge);
     2.9  	nodes[edges.back().source].first_out=edges.back().next_out;
    2.10  	nodes[edges.back().target].first_in=edges.back().next_in;
    2.11  	edges.pop_back();
    2.12        }
    2.13        while(s.node_num<nodes.size()) {
    2.14          Node node = nodeFromId(nodes.size()-1);
    2.15 -	Parent::getNotifier(Node()).erase(node);
    2.16 +	Parent::notifier(Node()).erase(node);
    2.17  	nodes.pop_back();
    2.18        }
    2.19      }    
    2.20 @@ -505,13 +505,23 @@
    2.21  
    2.22      void firstInc(UEdge &edge, bool& d, const Node& v) const {
    2.23        int de = nodes[v.id].first_out;
    2.24 -      edge.id = de / 2;
    2.25 -      d = ((de & 1) == 1);
    2.26 +      if (de != -1) {
    2.27 +        edge.id = de / 2;
    2.28 +        d = ((de & 1) == 1);
    2.29 +      } else {
    2.30 +        edge.id = -1;
    2.31 +        d = true;
    2.32 +      }
    2.33      }
    2.34      void nextInc(UEdge &edge, bool& d) const {
    2.35        int de = (edges[(edge.id * 2) | (d ? 1 : 0)].next_out);
    2.36 -      edge.id = de / 2;
    2.37 -      d = ((de & 1) == 1);
    2.38 +      if (de != -1) {
    2.39 +        edge.id = de / 2;
    2.40 +        d = ((de & 1) == 1);
    2.41 +      } else {
    2.42 +        edge.id = -1;
    2.43 +        d = true;      
    2.44 +      }
    2.45      }
    2.46      
    2.47      static int id(Node v) { return v.id; }
    2.48 @@ -641,11 +651,11 @@
    2.49        while(s.edge_num<edges.size()) {
    2.50          int n=edges.size()-1;
    2.51          UEdge edge=uEdgeFromId(n/2);
    2.52 -	Parent::getNotifier(UEdge()).erase(edge);
    2.53 +	Parent::notifier(UEdge()).erase(edge);
    2.54          std::vector<Edge> dir;
    2.55          dir.push_back(edgeFromId(n));
    2.56          dir.push_back(edgeFromId(n-1));
    2.57 -	Parent::getNotifier(Edge()).erase(dir);
    2.58 +	Parent::notifier(Edge()).erase(dir);
    2.59  	nodes[edges[n].target].first_out=edges[n].next_out;
    2.60  	nodes[edges[n-1].target].first_out=edges[n-1].next_out;
    2.61  	edges.pop_back();
    2.62 @@ -654,7 +664,7 @@
    2.63        while(s.node_num<nodes.size()) {
    2.64          int n=nodes.size()-1;
    2.65          Node node = nodeFromId(n);
    2.66 -	Parent::getNotifier(Node()).erase(node);
    2.67 +	Parent::notifier(Node()).erase(node);
    2.68  	nodes.pop_back();
    2.69        }
    2.70      }    
    2.71 @@ -1023,25 +1033,25 @@
    2.72      {
    2.73        while(s.edge_num<edges.size()) {
    2.74          UEdge edge = uEdgeFromId(edges.size()-1);
    2.75 -	Parent::getNotifier(UEdge()).erase(edge);
    2.76 +	Parent::notifier(UEdge()).erase(edge);
    2.77          std::vector<Edge> dir;
    2.78          dir.push_back(Parent::direct(edge, true));
    2.79          dir.push_back(Parent::direct(edge, false));
    2.80 -	Parent::getNotifier(Edge()).erase(dir);
    2.81 +	Parent::notifier(Edge()).erase(dir);
    2.82  	aNodes[edges.back().aNode >> 1].first=edges.back().next_out;
    2.83  	bNodes[edges.back().bNode >> 1].first=edges.back().next_in;
    2.84  	edges.pop_back();
    2.85        }
    2.86        while(s.anode_num<aNodes.size()) {
    2.87          Node node = nodeFromANodeId(aNodes.size() - 1);
    2.88 -	Parent::getNotifier(ANode()).erase(node);
    2.89 -	Parent::getNotifier(Node()).erase(node);
    2.90 +	Parent::notifier(ANode()).erase(node);
    2.91 +	Parent::notifier(Node()).erase(node);
    2.92  	aNodes.pop_back();
    2.93        }
    2.94        while(s.bnode_num<bNodes.size()) {
    2.95          Node node = nodeFromBNodeId(bNodes.size() - 1);
    2.96 -	Parent::getNotifier(BNode()).erase(node);
    2.97 -	Parent::getNotifier(Node()).erase(node);
    2.98 +	Parent::notifier(BNode()).erase(node);
    2.99 +	Parent::notifier(Node()).erase(node);
   2.100  	bNodes.pop_back();
   2.101        }
   2.102      }    
     3.1 --- a/lemon/ugraph_adaptor.h	Thu Mar 01 16:04:12 2007 +0000
     3.2 +++ b/lemon/ugraph_adaptor.h	Thu Mar 01 16:47:23 2007 +0000
     3.3 @@ -151,20 +151,20 @@
     3.4  
     3.5      typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
     3.6  
     3.7 -    NodeNotifier& getNotifier(Node) const {
     3.8 -      return graph->getNotifier(Node());
     3.9 +    NodeNotifier& notifier(Node) const {
    3.10 +      return graph->notifier(Node());
    3.11      } 
    3.12  
    3.13      typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier;
    3.14  
    3.15 -    EdgeNotifier& getNotifier(Edge) const {
    3.16 -      return graph->getNotifier(Edge());
    3.17 +    EdgeNotifier& notifier(Edge) const {
    3.18 +      return graph->notifier(Edge());
    3.19      } 
    3.20  
    3.21      typedef typename ItemSetTraits<Graph, UEdge>::ItemNotifier UEdgeNotifier;
    3.22  
    3.23 -    UEdgeNotifier& getNotifier(UEdge) const {
    3.24 -      return graph->getNotifier(UEdge());
    3.25 +    UEdgeNotifier& notifier(UEdge) const {
    3.26 +      return graph->notifier(UEdge());
    3.27      } 
    3.28  
    3.29      template <typename _Value>
    3.30 @@ -311,6 +311,7 @@
    3.31      void firstInc(UEdge& i, bool& d, const Node& n) const { 
    3.32        Parent::firstInc(i, d, n); 
    3.33        while (i!=INVALID && (!(*uedge_filter_map)[i] 
    3.34 +            || !(*node_filter_map)[Parent::source(i)]
    3.35              || !(*node_filter_map)[Parent::target(i)])) Parent::nextInc(i, d); 
    3.36      }
    3.37  
    3.38 @@ -347,8 +348,9 @@
    3.39  
    3.40      void nextInc(UEdge& i, bool& d) const { 
    3.41        Parent::nextInc(i, d); 
    3.42 -      while (i!=INVALID && (!(*uedge_filter_map)[i] 
    3.43 -            || !(*node_filter_map)[Parent::source(i)])) Parent::nextInc(i, d); 
    3.44 +      while (i!=INVALID && (!(*uedge_filter_map)[i]
    3.45 +            || !(*node_filter_map)[Parent::source(i)]
    3.46 +            || !(*node_filter_map)[Parent::target(i)])) Parent::nextInc(i, d); 
    3.47      }
    3.48  
    3.49      /// \brief Hide the given node in the graph.
    3.50 @@ -987,14 +989,14 @@
    3.51  
    3.52      typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
    3.53  
    3.54 -    NodeNotifier& getNotifier(Node) const {
    3.55 -      return graph->getNotifier(Node());
    3.56 +    NodeNotifier& notifier(Node) const {
    3.57 +      return graph->notifier(Node());
    3.58      } 
    3.59  
    3.60      typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier;
    3.61  
    3.62 -    EdgeNotifier& getNotifier(Edge) const {
    3.63 -      return graph->getNotifier(Edge());
    3.64 +    EdgeNotifier& notifier(Edge) const {
    3.65 +      return graph->notifier(Edge());
    3.66      } 
    3.67  
    3.68      template <typename _Value>