COIN-OR::LEMON - Graph Library

Changeset 905:5be029d19c98 in lemon-0.x


Ignore:
Timestamp:
09/23/04 16:40:45 (15 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1215
Message:

Some code cleaning in id related stuffs

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/hcube.cc

    r840 r905  
    6767   
    6868    //  for(EdgeIt e(G);G.valid(e);G.next(e)) map[e]=P();
    69     for(int i=0;i<dim*(1<<dim);i++)
     69    Edge te;
     70    for(int i=0;i<dim*(1<<dim);i++) {
     71      te.setToId(((long long int)(i)*93505)%(dim*(1<<dim)));
    7072      //    map[Edge(((long long int)(i)*2987)%(dim*(1<<dim)))]=P();
    71       map[Edge(((long long int)(i)*93505)%(dim*(1<<dim)))]=P();
    72  
     73      map[te]=P();
     74    }
     75   
    7376//     for(int i=0;i<(1<<dim);i++) {
    7477//       int mul= (1<<(numOfZeros(i,dim)/4));
  • src/hugo/list_graph.h

    r904 r905  
    7777    // Create map registries.
    7878    CREATE_MAP_REGISTRIES;
    79     /// Create node and edge maps.
     79    // Create node and edge maps.
    8080    CREATE_MAPS(ArrayMap);
    8181
     
    322322      template <typename T> friend class EdgeMap;
    323323
    324       //template <typename T> friend class SymListGraph::SymEdgeMap;     
    325       //friend Edge SymListGraph::opposite(Edge) const;
     324      friend class SymListGraph;
    326325     
    327326      friend class Node;
     
    343342      bool operator!=(const Edge i) const {return n!=i.n;}
    344343      bool operator<(const Edge i) const {return n<i.n;}
    345       ///\bug This is a workaround until somebody tells me how to
    346       ///make class \c SymListGraph::SymEdgeMap friend of Edge
    347       int &idref() {return n;}
    348       const int &idref() const {return n;}
    349344      //      ///Validity check
    350345      //      operator bool() { return n!=-1; }
     
    364359      EdgeIt(const ListGraph& _G, Edge e) : Edge(e), G(&_G) { }
    365360      EdgeIt() : Edge() { }
    366       ///\bug This is a workaround until somebody tells me how to
    367       ///make class \c SymListGraph::SymEdgeMap friend of Edge
    368       int &idref() {return n;}
    369361      EdgeIt &operator++() {
    370362        if(G->edges[n].next_in!=-1) n=G->edges[n].next_in;
     
    466458    {
    467459      Edge f;
    468       f.idref() = e.idref() - 2*(e.idref()%2) + 1;
     460      f.n = e.n - 2*(e.n%2) + 1;
    469461      return f;
    470462    }
     
    605597    /// The ID of the \ref INVALID node is -1.
    606598    ///\return The ID of the node \c v.
    607     int id(Node v) const { return v.n; }
     599    static int id(Node v) { return v.n; }
    608600    /// Edge ID.
    609601   
     
    614606    /// The ID of the \ref INVALID edge is -1.
    615607    ///\return The ID of the edge \c e.
    616     int id(Edge e) const { return -1; }
     608    static int id(Edge e) { return -1; }
    617609
    618610    /// Adds a new node to the graph.
     
    684676    protected:
    685677      int n;
    686       friend int NodeSet::id(Node v) const;
     678      friend int NodeSet::id(Node v);
    687679      Node(int nn) {n=nn;}
    688680    public:
     
    709701
    710702    class Edge {
    711       //friend class NodeSet;
    712       //template <typename T> friend class EdgeMap;
    713 
    714       //template <typename T> friend class SymNodeSet::SymEdgeMap;     
    715       //friend Edge SymNodeSet::opposite(Edge) const;
    716      
    717       //      friend class Node;
    718       //      friend class NodeIt;
    719     protected:
    720       //friend int NodeSet::id(Edge e) const;
    721       //      Edge(int nn) {}
    722703    public:
    723704      Edge() { }
     
    726707      bool operator!=(const Edge i) const {return false;}
    727708      bool operator<(const Edge i) const {return false;}
    728       ///\bug This is a workaround until somebody tells me how to
    729       ///make class \c SymNodeSet::SymEdgeMap friend of Edge
    730       //      int idref() {return -1;}
    731       //      int idref() const {return -1;}
    732709    };
    733710   
    734711    class EdgeIt : public Edge {
    735       //friend class NodeSet;
    736712    public:
    737713      EdgeIt(const NodeSet& G) : Edge() { }
     
    739715      EdgeIt (Invalid i) : Edge(i) { }
    740716      EdgeIt() : Edge() { }
    741       ///\bug This is a workaround until somebody tells me how to
    742       ///make class \c SymNodeSet::SymEdgeMap friend of Edge
    743       //      int idref() {return -1;}
    744717      EdgeIt operator++() { return INVALID; }
    745718    };
     
    811784    class Node : public NodeGraphType::Node {
    812785      friend class EdgeSet;
    813       //      template <typename T> friend class NodeMap;
    814786     
    815787      friend class Edge;
     
    820792    public:
    821793      friend int EdgeSet::id(Node v) const;
    822       //      Node(int nn) {n=nn;}
    823794    public:
    824795      Node() : NodeGraphType::Node() {}
     
    947918    /// The ID of the \ref INVALID edge is -1.
    948919    ///\return The ID of the edge \c e.
    949     int id(Edge e) const { return e.n; }
     920    static int id(Edge e) { return e.n; }
    950921
    951922    /// Adds a new node to the graph.
     
    1024995  public:
    1025996
    1026 //     void erase(Node nn) {
    1027 //       int n=nn.n;
    1028 //       int m;
    1029 //       while((m=nodes[n].first_in)!=-1) eraseEdge(m);
    1030 //       while((m=nodes[n].first_out)!=-1) eraseEdge(m);
    1031 //     }
    1032    
    1033997    void erase(Edge e) { eraseEdge(e.n); }
    1034998
     
    10481012      friend class Node;
    10491013      friend class NodeIt;
    1050     public:
    1051       ///\bug It should be at least protected
    1052       ///
     1014    protected:
    10531015      int n;
    1054     protected:
    10551016      friend int EdgeSet::id(Edge e) const;
    10561017
     
    10621023      bool operator!=(const Edge i) const {return n!=i.n;}
    10631024      bool operator<(const Edge i) const {return n<i.n;}
    1064       ///\bug This is a workaround until somebody tells me how to
    1065       ///make class \c SymEdgeSet::SymEdgeMap friend of Edge
    1066       int &idref() {return n;}
    1067       const int &idref() const {return n;}
    10681025    };
    10691026   
     
    10751032    public:
    10761033      EdgeIt(const EdgeSet& _G) : Edge(), G(&_G) {
    1077         //              typename NodeGraphType::Node m;
    10781034        NodeIt m;
    10791035        for(G->first(m);
     
    10921048        return *this;
    10931049      }
    1094        ///\bug This is a workaround until somebody tells me how to
    1095       ///make class \c SymEdgeSet::SymEdgeMap friend of Edge
    1096       int &idref() {return this->n;}
    10971050    };
    10981051   
  • src/hugo/smart_graph.h

    r904 r905  
    218218      template <typename T> friend class EdgeMap;
    219219
    220       //template <typename T> friend class SymSmartGraph::SymEdgeMap;     
    221       //friend Edge SymSmartGraph::opposite(Edge) const;
     220      friend class SymSmartGraph;
    222221     
    223222      friend class Node;
     
    226225      int n;
    227226      friend int SmartGraph::id(Edge e);
    228 
     227      Edge(int nn) {n=nn;}
    229228    public:
    230229      /// An Edge with id \c n.
    231230
    232       /// \bug It should be
    233       /// obtained by a member function of the Graph.
    234       Edge(int nn) {n=nn;}
    235231      Edge() { }
    236232      Edge (Invalid) { n=-1; }
     
    238234      bool operator!=(const Edge i) const {return n!=i.n;}
    239235      bool operator<(const Edge i) const {return n<i.n;}
    240       ///\bug This is a workaround until somebody tells me how to
    241       ///make class \c SymSmartGraph::SymEdgeMap friend of Edge
    242       int &idref() {return n;}
    243       const int &idref() const {return n;}
    244236//       ///Validity check
    245237//       operator bool() { return n!=-1; }
     238
     239      ///Set the edge to that have ID \c ID.
     240      void setToId(int id) { n=id; }
    246241   };
    247242   
     
    254249      EdgeIt (Invalid i) : Edge(i) { }
    255250      EdgeIt() : Edge() { }
    256       ///\bug This is a workaround until somebody tells me how to
    257       ///make class \c SymSmartGraph::SymEdgeMap friend of Edge
    258       int &idref() {return n;}
    259251      EdgeIt &operator++() { --n; return *this; }
    260252//       ///Validity check
     
    343335    {
    344336      Edge f;
    345       f.idref() = e.idref() - 2*(e.idref()%2) + 1;
     337      f.n = e.n - 2*(e.n%2) + 1;
    346338      return f;
    347339    }
Note: See TracChangeset for help on using the changeset viewer.