COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
07/13/08 20:51:02 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Phase:
public
Message:

Apply unify-sources.sh to the source tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/base_extender.h

    r107 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    6464
    6565      bool operator==(const Arc &that) const {
    66         return forward==that.forward && Edge(*this)==Edge(that);
     66        return forward==that.forward && Edge(*this)==Edge(that);
    6767      }
    6868      bool operator!=(const Arc &that) const {
    69         return forward!=that.forward || Edge(*this)!=Edge(that);
     69        return forward!=that.forward || Edge(*this)!=Edge(that);
    7070      }
    7171      bool operator<(const Arc &that) const {
    72         return forward<that.forward ||
    73           (!(that.forward<forward) && Edge(*this)<Edge(that));
     72        return forward<that.forward ||
     73          (!(that.forward<forward) && Edge(*this)<Edge(that));
    7474      }
    7575    };
     
    118118    void next(Arc &e) const {
    119119      if( e.forward ) {
    120         e.forward = false;
     120        e.forward = false;
    121121      }
    122122      else {
    123         Parent::next(e);
    124         e.forward = true;
     123        Parent::next(e);
     124        e.forward = true;
    125125      }
    126126    }
     
    129129      Parent::firstIn(e,n);
    130130      if( Edge(e) != INVALID ) {
    131         e.forward = false;
     131        e.forward = false;
    132132      }
    133133      else {
    134         Parent::firstOut(e,n);
    135         e.forward = true;
     134        Parent::firstOut(e,n);
     135        e.forward = true;
    136136      }
    137137    }
    138138    void nextOut(Arc &e) const {
    139139      if( ! e.forward ) {
    140         Node n = Parent::target(e);
    141         Parent::nextIn(e);
    142         if( Edge(e) == INVALID ) {
    143           Parent::firstOut(e, n);
    144           e.forward = true;
    145         }
     140        Node n = Parent::target(e);
     141        Parent::nextIn(e);
     142        if( Edge(e) == INVALID ) {
     143          Parent::firstOut(e, n);
     144          e.forward = true;
     145        }
    146146      }
    147147      else {
    148         Parent::nextOut(e);
     148        Parent::nextOut(e);
    149149      }
    150150    }
     
    153153      Parent::firstOut(e,n);
    154154      if( Edge(e) != INVALID ) {
    155         e.forward = false;
     155        e.forward = false;
    156156      }
    157157      else {
    158         Parent::firstIn(e,n);
    159         e.forward = true;
     158        Parent::firstIn(e,n);
     159        e.forward = true;
    160160      }
    161161    }
    162162    void nextIn(Arc &e) const {
    163163      if( ! e.forward ) {
    164         Node n = Parent::source(e);
    165         Parent::nextOut(e);
    166         if( Edge(e) == INVALID ) {
    167           Parent::firstIn(e, n);
    168           e.forward = true;
    169         }
     164        Node n = Parent::source(e);
     165        Parent::nextOut(e);
     166        if( Edge(e) == INVALID ) {
     167          Parent::firstIn(e, n);
     168          e.forward = true;
     169        }
    170170      }
    171171      else {
    172         Parent::nextIn(e);
     172        Parent::nextIn(e);
    173173      }
    174174    }
     
    184184    void nextInc(Edge &e, bool &d) const {
    185185      if (d) {
    186         Node s = Parent::source(e);
    187         Parent::nextOut(e);
    188         if (e != INVALID) return;
    189         d = false;
    190         Parent::firstIn(e, s);
    191       } else {
    192         Parent::nextIn(e);
     186        Node s = Parent::source(e);
     187        Parent::nextOut(e);
     188        if (e != INVALID) return;
     189        d = false;
     190        Parent::firstIn(e, s);
     191      } else {
     192        Parent::nextIn(e);
    193193      }
    194194    }
     
    241241    Arc findArc(Node s, Node t, Arc p = INVALID) const {
    242242      if (p == INVALID) {
    243         Edge arc = Parent::findArc(s, t);
    244         if (arc != INVALID) return direct(arc, true);
    245         arc = Parent::findArc(t, s);
    246         if (arc != INVALID) return direct(arc, false);
     243        Edge arc = Parent::findArc(s, t);
     244        if (arc != INVALID) return direct(arc, true);
     245        arc = Parent::findArc(t, s);
     246        if (arc != INVALID) return direct(arc, false);
    247247      } else if (direction(p)) {
    248         Edge arc = Parent::findArc(s, t, p);
    249         if (arc != INVALID) return direct(arc, true);
    250         arc = Parent::findArc(t, s);
    251         if (arc != INVALID) return direct(arc, false); 
    252       } else {
    253         Edge arc = Parent::findArc(t, s, p);
    254         if (arc != INVALID) return direct(arc, false);       
     248        Edge arc = Parent::findArc(s, t, p);
     249        if (arc != INVALID) return direct(arc, true);
     250        arc = Parent::findArc(t, s);
     251        if (arc != INVALID) return direct(arc, false);
     252      } else {
     253        Edge arc = Parent::findArc(t, s, p);
     254        if (arc != INVALID) return direct(arc, false);
    255255      }
    256256      return INVALID;
     
    268268          if (arc != INVALID) return arc;
    269269          arc = Parent::findArc(t, s);
    270           if (arc != INVALID) return arc;       
     270          if (arc != INVALID) return arc;
    271271        } else {
    272272          Edge arc = Parent::findArc(t, s, p);
    273           if (arc != INVALID) return arc;             
     273          if (arc != INVALID) return arc;
    274274        }
    275275      } else {
     
    300300      Red() {}
    301301      Red(const Node& node) : Node(node) {
    302         LEMON_ASSERT(Parent::red(node) || node == INVALID,
    303                      typename Parent::NodeSetError());
     302        LEMON_ASSERT(Parent::red(node) || node == INVALID,
     303                     typename Parent::NodeSetError());
    304304      }
    305305      Red& operator=(const Node& node) {
    306         LEMON_ASSERT(Parent::red(node) || node == INVALID,
    307                      typename Parent::NodeSetError());
     306        LEMON_ASSERT(Parent::red(node) || node == INVALID,
     307                     typename Parent::NodeSetError());
    308308        Node::operator=(node);
    309309        return *this;
     
    332332      Blue() {}
    333333      Blue(const Node& node) : Node(node) {
    334         LEMON_ASSERT(Parent::blue(node) || node == INVALID,
    335                      typename Parent::NodeSetError());
     334        LEMON_ASSERT(Parent::blue(node) || node == INVALID,
     335                     typename Parent::NodeSetError());
    336336      }
    337337      Blue& operator=(const Node& node) {
    338         LEMON_ASSERT(Parent::blue(node) || node == INVALID,
    339                      typename Parent::NodeSetError());
     338        LEMON_ASSERT(Parent::blue(node) || node == INVALID,
     339                     typename Parent::NodeSetError());
    340340        Node::operator=(node);
    341341        return *this;
     
    354354      Parent::nextBlue(static_cast<Node&>(node));
    355355    }
    356  
     356
    357357    int id(const Blue& node) const {
    358358      return Parent::redId(node);
     
    368368    void firstInc(Edge& arc, bool& dir, const Node& node) const {
    369369      if (Parent::red(node)) {
    370         Parent::firstFromRed(arc, node);
    371         dir = true;
    372       } else {
    373         Parent::firstFromBlue(arc, node);
    374         dir = static_cast<Edge&>(arc) == INVALID;
     370        Parent::firstFromRed(arc, node);
     371        dir = true;
     372      } else {
     373        Parent::firstFromBlue(arc, node);
     374        dir = static_cast<Edge&>(arc) == INVALID;
    375375      }
    376376    }
    377377    void nextInc(Edge& arc, bool& dir) const {
    378378      if (dir) {
    379         Parent::nextFromRed(arc);
    380       } else {
    381         Parent::nextFromBlue(arc);
    382         if (arc == INVALID) dir = true;
     379        Parent::nextFromRed(arc);
     380      } else {
     381        Parent::nextFromBlue(arc);
     382        if (arc == INVALID) dir = true;
    383383      }
    384384    }
     
    390390
    391391      Arc(const Edge& arc, bool _forward)
    392         : Edge(arc), forward(_forward) {}
     392        : Edge(arc), forward(_forward) {}
    393393
    394394    public:
     
    396396      Arc (Invalid) : Edge(INVALID), forward(true) {}
    397397      bool operator==(const Arc& i) const {
    398         return Edge::operator==(i) && forward == i.forward;
     398        return Edge::operator==(i) && forward == i.forward;
    399399      }
    400400      bool operator!=(const Arc& i) const {
    401         return Edge::operator!=(i) || forward != i.forward;
     401        return Edge::operator!=(i) || forward != i.forward;
    402402      }
    403403      bool operator<(const Arc& i) const {
    404         return Edge::operator<(i) ||
    405           (!(i.forward<forward) && Edge(*this)<Edge(i));
     404        return Edge::operator<(i) ||
     405          (!(i.forward<forward) && Edge(*this)<Edge(i));
    406406      }
    407407    };
     
    414414    void next(Arc& arc) const {
    415415      if (!arc.forward) {
    416         Parent::next(static_cast<Edge&>(arc));
     416        Parent::next(static_cast<Edge&>(arc));
    417417      }
    418418      arc.forward = !arc.forward;
     
    421421    void firstOut(Arc& arc, const Node& node) const {
    422422      if (Parent::red(node)) {
    423         Parent::firstFromRed(arc, node);
    424         arc.forward = true;
    425       } else {
    426         Parent::firstFromBlue(arc, node);
    427         arc.forward = static_cast<Edge&>(arc) == INVALID;
     423        Parent::firstFromRed(arc, node);
     424        arc.forward = true;
     425      } else {
     426        Parent::firstFromBlue(arc, node);
     427        arc.forward = static_cast<Edge&>(arc) == INVALID;
    428428      }
    429429    }
    430430    void nextOut(Arc& arc) const {
    431431      if (arc.forward) {
    432         Parent::nextFromRed(arc);
    433       } else {
    434         Parent::nextFromBlue(arc);
     432        Parent::nextFromRed(arc);
     433      } else {
     434        Parent::nextFromBlue(arc);
    435435        arc.forward = static_cast<Edge&>(arc) == INVALID;
    436436      }
     
    439439    void firstIn(Arc& arc, const Node& node) const {
    440440      if (Parent::blue(node)) {
    441         Parent::firstFromBlue(arc, node);
    442         arc.forward = true;     
    443       } else {
    444         Parent::firstFromRed(arc, node);
    445         arc.forward = static_cast<Edge&>(arc) == INVALID;
     441        Parent::firstFromBlue(arc, node);
     442        arc.forward = true;
     443      } else {
     444        Parent::firstFromRed(arc, node);
     445        arc.forward = static_cast<Edge&>(arc) == INVALID;
    446446      }
    447447    }
    448448    void nextIn(Arc& arc) const {
    449449      if (arc.forward) {
    450         Parent::nextFromBlue(arc);
    451       } else {
    452         Parent::nextFromRed(arc);
    453         arc.forward = static_cast<Edge&>(arc) == INVALID;
     450        Parent::nextFromBlue(arc);
     451      } else {
     452        Parent::nextFromRed(arc);
     453        arc.forward = static_cast<Edge&>(arc) == INVALID;
    454454      }
    455455    }
     
    463463
    464464    int id(const Arc& arc) const {
    465       return (Parent::id(static_cast<const Edge&>(arc)) << 1) + 
     465      return (Parent::id(static_cast<const Edge&>(arc)) << 1) +
    466466        (arc.forward ? 0 : 1);
    467467    }
Note: See TracChangeset for help on using the changeset viewer.