COIN-OR::LEMON - Graph Library

Changeset 877:141f9c0db4a3 in lemon-1.2 for lemon/static_graph.h


Ignore:
Timestamp:
03/06/10 15:35:12 (14 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Children:
878:f802439d2b58, 880:38213abd2911, 909:f112c18bc304
Phase:
public
Message:

Unify the sources (#339)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/static_graph.h

    r787 r877  
    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 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3232  public:
    3333
    34     StaticDigraphBase() 
    35       : built(false), node_num(0), arc_num(0), 
     34    StaticDigraphBase()
     35      : built(false), node_num(0), arc_num(0),
    3636        node_first_out(NULL), node_first_in(NULL),
    37         arc_source(NULL), arc_target(NULL), 
     37        arc_source(NULL), arc_target(NULL),
    3838        arc_next_in(NULL), arc_next_out(NULL) {}
    39    
     39
    4040    ~StaticDigraphBase() {
    4141      if (built) {
     
    6363
    6464    class Arc {
    65       friend class StaticDigraphBase;     
     65      friend class StaticDigraphBase;
    6666    protected:
    6767      int id;
     
    8484    static void next(Arc& e) { --e.id; }
    8585
    86     void firstOut(Arc& e, const Node& n) const { 
    87       e.id = node_first_out[n.id] != node_first_out[n.id + 1] ? 
     86    void firstOut(Arc& e, const Node& n) const {
     87      e.id = node_first_out[n.id] != node_first_out[n.id + 1] ?
    8888        node_first_out[n.id] : -1;
    8989    }
     
    114114      typedef typename Digraph::Arc Arc;
    115115
    116       ArcLess(const Digraph &_graph, const NodeRefMap& _nodeRef) 
     116      ArcLess(const Digraph &_graph, const NodeRefMap& _nodeRef)
    117117        : digraph(_graph), nodeRef(_nodeRef) {}
    118      
     118
    119119      bool operator()(const Arc& left, const Arc& right) const {
    120         return nodeRef[digraph.target(left)] < nodeRef[digraph.target(right)];
     120        return nodeRef[digraph.target(left)] < nodeRef[digraph.target(right)];
    121121      }
    122122    private:
     
    124124      const NodeRefMap& nodeRef;
    125125    };
    126    
     126
    127127  public:
    128128
    129129    typedef True BuildTag;
    130    
     130
    131131    void clear() {
    132132      if (built) {
     
    142142      arc_num = 0;
    143143    }
    144    
     144
    145145    template <typename Digraph, typename NodeRefMap, typename ArcRefMap>
    146146    void build(const Digraph& digraph, NodeRefMap& nodeRef, ArcRefMap& arcRef) {
     
    184184            int target = nodeRef[digraph.target(*it)].id;
    185185            arcRef[*it] = Arc(arc_index);
    186             arc_source[arc_index] = source; 
     186            arc_source[arc_index] = source;
    187187            arc_target[arc_index] = target;
    188188            arc_next_in[arc_index] = node_first_in[target];
     
    198198      node_first_out[node_num] = arc_num;
    199199    }
    200    
     200
    201201    template <typename ArcListIterator>
    202202    void build(int n, ArcListIterator first, ArcListIterator last) {
     
    213213      arc_next_out = new int[arc_num];
    214214      arc_next_in = new int[arc_num];
    215      
     215
    216216      for (int i = 0; i != node_num; ++i) {
    217217        node_first_in[i] = -1;
    218       }     
    219      
     218      }
     219
    220220      int arc_index = 0;
    221221      for (int i = 0; i != node_num; ++i) {
     
    283283  /// Since this digraph structure is completely static, its nodes and arcs
    284284  /// can be indexed with integers from the ranges <tt>[0..nodeNum()-1]</tt>
    285   /// and <tt>[0..arcNum()-1]</tt>, respectively. 
     285  /// and <tt>[0..arcNum()-1]</tt>, respectively.
    286286  /// The index of an item is the same as its ID, it can be obtained
    287287  /// using the corresponding \ref index() or \ref concepts::Digraph::id()
     
    300300
    301301    typedef ExtendedStaticDigraphBase Parent;
    302  
     302
    303303  public:
    304  
     304
    305305    /// \brief Constructor
    306306    ///
     
    350350    /// This method also makes possible to copy a digraph to a StaticDigraph
    351351    /// structure using \ref DigraphCopy.
    352     /// 
     352    ///
    353353    /// \param digraph An existing digraph to be copied.
    354354    /// \param nodeRef The node references will be copied into this map.
     
    371371      Parent::build(digraph, nodeRef, arcRef);
    372372    }
    373  
     373
    374374    /// \brief Build the digraph from an arc list.
    375375    ///
     
    422422    using Parent::fastNextOut;
    423423    using Parent::fastLastOut;
    424    
     424
    425425  public:
    426426
     
    433433
    434434      OutArcIt(const StaticDigraph& digraph, const Node& node) {
    435         digraph.fastFirstOut(*this, node);
    436         digraph.fastLastOut(last, node);
     435        digraph.fastFirstOut(*this, node);
     436        digraph.fastLastOut(last, node);
    437437        if (last == *this) *this = INVALID;
    438438      }
     
    444444      }
    445445
    446       OutArcIt& operator++() { 
     446      OutArcIt& operator++() {
    447447        StaticDigraph::fastNextOut(*this);
    448448        if (last == *this) *this = INVALID;
    449         return *this; 
     449        return *this;
    450450      }
    451451
Note: See TracChangeset for help on using the changeset viewer.