- Fix a serious bug in UEulerIt
authoralpar
Tue, 05 Jun 2007 10:57:26 +0000
changeset 2445aaf5787f4d5d
parent 2444 06f3702bf18d
child 2446 dd20d76eed13
- Fix a serious bug in UEulerIt
- Add a conversion to UEdge
- Make some member funtions to be 'const'
lemon/euler.h
     1.1 --- a/lemon/euler.h	Fri May 11 16:03:20 2007 +0000
     1.2 +++ b/lemon/euler.h	Tue Jun 05 10:57:26 2007 +0000
     1.3 @@ -149,6 +149,7 @@
     1.4      typedef typename Graph::Node Node;
     1.5      typedef typename Graph::NodeIt NodeIt;
     1.6      typedef typename Graph::Edge Edge;
     1.7 +    typedef typename Graph::UEdge UEdge;
     1.8      typedef typename Graph::EdgeIt EdgeIt;
     1.9      typedef typename Graph::OutEdgeIt OutEdgeIt;
    1.10      typedef typename Graph::InEdgeIt InEdgeIt;
    1.11 @@ -172,16 +173,22 @@
    1.12        for(NodeIt n(g);n!=INVALID;++n) nedge[n]=OutEdgeIt(g,n);
    1.13        while(nedge[start]!=INVALID) {
    1.14  	euler.push_back(nedge[start]);
    1.15 +	visited[nedge[start]]=true;
    1.16  	Node next=g.target(nedge[start]);
    1.17  	++nedge[start];
    1.18 -	start=next;	while(nedge[start]!=INVALID && visited[nedge[start]]) ++nedge[start];
    1.19 +	start=next;
    1.20 +	while(nedge[start]!=INVALID && visited[nedge[start]]) ++nedge[start];
    1.21        }
    1.22      }
    1.23      
    1.24      ///Edge Conversion
    1.25 -    operator Edge() { return euler.empty()?INVALID:euler.front(); }
    1.26 -    bool operator==(Invalid) { return euler.empty(); }
    1.27 -    bool operator!=(Invalid) { return !euler.empty(); }
    1.28 +    operator Edge() const { return euler.empty()?INVALID:euler.front(); }
    1.29 +    ///Edge Conversion
    1.30 +    operator UEdge() const { return euler.empty()?INVALID:euler.front(); }
    1.31 +    ///\e
    1.32 +    bool operator==(Invalid) const { return euler.empty(); }
    1.33 +    ///\e
    1.34 +    bool operator!=(Invalid) const { return !euler.empty(); }
    1.35      
    1.36      ///Next edge of the tour
    1.37      UEulerIt &operator++() {
    1.38 @@ -194,6 +201,7 @@
    1.39  	if(nedge[s]==INVALID) break;
    1.40  	else {
    1.41  	  euler.insert(next,nedge[s]);
    1.42 +	  visited[nedge[s]]=true;
    1.43  	  Node n=g.target(nedge[s]);
    1.44  	  ++nedge[s];
    1.45  	  s=n;