COIN-OR::LEMON - Graph Library

Changeset 2076:10681ee9d8ae in lemon-0.x for lemon/smart_graph.h


Ignore:
Timestamp:
05/12/06 11:51:45 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2739
Message:

Extenders modified

UGraphBaseExtender => UndirGraphExtender?
BpUGraphBaseExtender merged into BpUGraphExtender

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/smart_graph.h

    r2031 r2076  
    120120    static int id(Edge e) { return e.n; }
    121121
     122    /// \brief Returns the node from its \c id.
     123    ///
     124    /// Returns the node from its \c id. If there is not node
     125    /// with the given id the effect of the function is undefinied.
    122126    static Node nodeFromId(int id) { return Node(id);}
    123127
     128    /// \brief Returns the edge from its \c id.
     129    ///
     130    /// Returns the edge from its \c id. If there is not edge
     131    /// with the given id the effect of the function is undefinied.
    124132    static Edge edgeFromId(int id) { return Edge(id);}
    125133
     
    351359  /**************** Undirected List Graph ****************/
    352360
    353   typedef UGraphExtender<UGraphBaseExtender<SmartGraphBase> >
     361  typedef UGraphExtender<UndirGraphExtender<SmartGraphBase> >
    354362  ExtendedSmartUGraphBase;
    355363
     
    389397    };
    390398
    391     struct EdgeT {
     399    struct UEdgeT {
    392400      int aNode, next_out;
    393401      int bNode, next_in;
     
    397405    std::vector<NodeT> bNodes;
    398406
    399     std::vector<EdgeT> edges;
     407    std::vector<UEdgeT> edges;
    400408
    401409  public:
     
    415423    };
    416424
    417     class Edge {
     425    class UEdge {
    418426      friend class SmartBpUGraphBase;
    419427    protected:
    420428      int id;
    421429
    422       Edge(int _id) { id = _id;}
     430      UEdge(int _id) { id = _id;}
    423431    public:
    424       Edge() {}
    425       Edge (Invalid) { id = -1; }
    426       bool operator==(const Edge i) const {return id==i.id;}
    427       bool operator!=(const Edge i) const {return id!=i.id;}
    428       bool operator<(const Edge i) const {return id<i.id;}
     432      UEdge() {}
     433      UEdge (Invalid) { id = -1; }
     434      bool operator==(const UEdge i) const {return id==i.id;}
     435      bool operator!=(const UEdge i) const {return id!=i.id;}
     436      bool operator<(const UEdge i) const {return id<i.id;}
    429437    };
    430438
     
    459467    }
    460468 
    461     void first(Edge& edge) const {
     469    void first(UEdge& edge) const {
    462470      edge.id = edges.size() - 1;
    463471    }
    464     void next(Edge& edge) const {
     472    void next(UEdge& edge) const {
    465473      --edge.id;
    466474    }
    467475
    468     void firstOut(Edge& edge, const Node& node) const {
     476    void firstFromANode(UEdge& edge, const Node& node) const {
    469477      LEMON_ASSERT((node.id & 1) == 0, NodeSetError());
    470478      edge.id = aNodes[node.id >> 1].first;
    471479    }
    472     void nextOut(Edge& edge) const {
     480    void nextFromANode(UEdge& edge) const {
    473481      edge.id = edges[edge.id].next_out;
    474482    }
    475483
    476     void firstIn(Edge& edge, const Node& node) const {
     484    void firstFromBNode(UEdge& edge, const Node& node) const {
    477485      LEMON_ASSERT((node.id & 1) == 1, NodeSetError());
    478486      edge.id = bNodes[node.id >> 1].first;
    479487    }
    480     void nextIn(Edge& edge) const {
     488    void nextFromBNode(UEdge& edge) const {
    481489      edge.id = edges[edge.id].next_in;
    482490    }
     
    493501    }
    494502 
    495     static int id(const Edge& edge) {
     503    static int id(const UEdge& edge) {
    496504      return edge.id;
    497505    }
    498     static Edge edgeFromId(int id) {
    499       return Edge(id);
    500     }
    501     int maxEdgeId() const {
     506    static UEdge uEdgeFromId(int id) {
     507      return UEdge(id);
     508    }
     509    int maxUEdgeId() const {
    502510      return edges.size();
    503511    }
     
    523531    }
    524532
    525     Node aNode(const Edge& edge) const {
     533    Node aNode(const UEdge& edge) const {
    526534      return Node(edges[edge.id].aNode);
    527535    }
    528     Node bNode(const Edge& edge) const {
     536    Node bNode(const UEdge& edge) const {
    529537      return Node(edges[edge.id].bNode);
    530538    }
     
    552560    }
    553561
    554     Edge addEdge(const Node& source, const Node& target) {
     562    UEdge addEdge(const Node& source, const Node& target) {
    555563      LEMON_ASSERT(((source.id ^ target.id) & 1) == 1, NodeSetError());
    556       EdgeT edgeT;
     564      UEdgeT edgeT;
    557565      if ((source.id & 1) == 0) {
    558566        edgeT.aNode = source.id;
     
    567575      bNodes[edgeT.bNode >> 1].first = edges.size();
    568576      edges.push_back(edgeT);
    569       return Edge(edges.size() - 1);
     577      return UEdge(edges.size() - 1);
    570578    }
    571579
     
    582590
    583591    typedef True EdgeNumTag;
    584     int edgeNum() const { return edges.size(); }
     592    int uEdgeNum() const { return edges.size(); }
    585593
    586594  };
    587595
    588596
    589   typedef BpUGraphExtender< BpUGraphBaseExtender<
    590     SmartBpUGraphBase> > ExtendedSmartBpUGraphBase;
     597  typedef BpUGraphExtender<SmartBpUGraphBase> ExtendedSmartBpUGraphBase;
    591598
    592599  /// \ingroup graphs
Note: See TracChangeset for help on using the changeset viewer.