lemon/smart_graph.h
changeset 2076 10681ee9d8ae
parent 2031 080d51024ac5
child 2111 ea1fa1bc3f6d
     1.1 --- a/lemon/smart_graph.h	Tue May 09 14:28:02 2006 +0000
     1.2 +++ b/lemon/smart_graph.h	Fri May 12 09:51:45 2006 +0000
     1.3 @@ -119,8 +119,16 @@
     1.4      ///\return The ID of the edge \c e. 
     1.5      static int id(Edge e) { return e.n; }
     1.6  
     1.7 +    /// \brief Returns the node from its \c id.
     1.8 +    ///
     1.9 +    /// Returns the node from its \c id. If there is not node
    1.10 +    /// with the given id the effect of the function is undefinied.
    1.11      static Node nodeFromId(int id) { return Node(id);}
    1.12  
    1.13 +    /// \brief Returns the edge from its \c id.
    1.14 +    ///
    1.15 +    /// Returns the edge from its \c id. If there is not edge
    1.16 +    /// with the given id the effect of the function is undefinied.
    1.17      static Edge edgeFromId(int id) { return Edge(id);}
    1.18  
    1.19      Node addNode() {
    1.20 @@ -350,7 +358,7 @@
    1.21  
    1.22    /**************** Undirected List Graph ****************/
    1.23  
    1.24 -  typedef UGraphExtender<UGraphBaseExtender<SmartGraphBase> >
    1.25 +  typedef UGraphExtender<UndirGraphExtender<SmartGraphBase> >
    1.26    ExtendedSmartUGraphBase;
    1.27  
    1.28    /// \ingroup graphs
    1.29 @@ -388,7 +396,7 @@
    1.30        NodeT(int _first) : first(_first) {}
    1.31      };
    1.32  
    1.33 -    struct EdgeT {
    1.34 +    struct UEdgeT {
    1.35        int aNode, next_out;
    1.36        int bNode, next_in;
    1.37      };
    1.38 @@ -396,7 +404,7 @@
    1.39      std::vector<NodeT> aNodes;
    1.40      std::vector<NodeT> bNodes;
    1.41  
    1.42 -    std::vector<EdgeT> edges;
    1.43 +    std::vector<UEdgeT> edges;
    1.44  
    1.45    public:
    1.46    
    1.47 @@ -414,18 +422,18 @@
    1.48        bool operator<(const Node i) const {return id<i.id;}
    1.49      };
    1.50  
    1.51 -    class Edge {
    1.52 +    class UEdge {
    1.53        friend class SmartBpUGraphBase;
    1.54      protected:
    1.55        int id;
    1.56  
    1.57 -      Edge(int _id) { id = _id;}
    1.58 +      UEdge(int _id) { id = _id;}
    1.59      public:
    1.60 -      Edge() {}
    1.61 -      Edge (Invalid) { id = -1; }
    1.62 -      bool operator==(const Edge i) const {return id==i.id;}
    1.63 -      bool operator!=(const Edge i) const {return id!=i.id;}
    1.64 -      bool operator<(const Edge i) const {return id<i.id;}
    1.65 +      UEdge() {}
    1.66 +      UEdge (Invalid) { id = -1; }
    1.67 +      bool operator==(const UEdge i) const {return id==i.id;}
    1.68 +      bool operator!=(const UEdge i) const {return id!=i.id;}
    1.69 +      bool operator<(const UEdge i) const {return id<i.id;}
    1.70      };
    1.71  
    1.72      void firstANode(Node& node) const {
    1.73 @@ -458,26 +466,26 @@
    1.74        }
    1.75      }
    1.76    
    1.77 -    void first(Edge& edge) const {
    1.78 +    void first(UEdge& edge) const {
    1.79        edge.id = edges.size() - 1;
    1.80      }
    1.81 -    void next(Edge& edge) const {
    1.82 +    void next(UEdge& edge) const {
    1.83        --edge.id;
    1.84      }
    1.85  
    1.86 -    void firstOut(Edge& edge, const Node& node) const {
    1.87 +    void firstFromANode(UEdge& edge, const Node& node) const {
    1.88        LEMON_ASSERT((node.id & 1) == 0, NodeSetError());
    1.89        edge.id = aNodes[node.id >> 1].first;
    1.90      }
    1.91 -    void nextOut(Edge& edge) const {
    1.92 +    void nextFromANode(UEdge& edge) const {
    1.93        edge.id = edges[edge.id].next_out;
    1.94      }
    1.95  
    1.96 -    void firstIn(Edge& edge, const Node& node) const {
    1.97 +    void firstFromBNode(UEdge& edge, const Node& node) const {
    1.98        LEMON_ASSERT((node.id & 1) == 1, NodeSetError());
    1.99        edge.id = bNodes[node.id >> 1].first;
   1.100      }
   1.101 -    void nextIn(Edge& edge) const {
   1.102 +    void nextFromBNode(UEdge& edge) const {
   1.103        edge.id = edges[edge.id].next_in;
   1.104      }
   1.105  
   1.106 @@ -492,13 +500,13 @@
   1.107  	aNodes.size() * 2 - 2 : bNodes.size() * 2 - 1;
   1.108      }
   1.109    
   1.110 -    static int id(const Edge& edge) {
   1.111 +    static int id(const UEdge& edge) {
   1.112        return edge.id;
   1.113      }
   1.114 -    static Edge edgeFromId(int id) {
   1.115 -      return Edge(id);
   1.116 +    static UEdge uEdgeFromId(int id) {
   1.117 +      return UEdge(id);
   1.118      }
   1.119 -    int maxEdgeId() const {
   1.120 +    int maxUEdgeId() const {
   1.121        return edges.size();
   1.122      }
   1.123    
   1.124 @@ -522,10 +530,10 @@
   1.125        return bNodes.size();
   1.126      }
   1.127  
   1.128 -    Node aNode(const Edge& edge) const {
   1.129 +    Node aNode(const UEdge& edge) const {
   1.130        return Node(edges[edge.id].aNode);
   1.131      }
   1.132 -    Node bNode(const Edge& edge) const {
   1.133 +    Node bNode(const UEdge& edge) const {
   1.134        return Node(edges[edge.id].bNode);
   1.135      }
   1.136  
   1.137 @@ -551,9 +559,9 @@
   1.138        return Node(bNodes.size() * 2 - 1);
   1.139      }
   1.140  
   1.141 -    Edge addEdge(const Node& source, const Node& target) {
   1.142 +    UEdge addEdge(const Node& source, const Node& target) {
   1.143        LEMON_ASSERT(((source.id ^ target.id) & 1) == 1, NodeSetError());
   1.144 -      EdgeT edgeT;
   1.145 +      UEdgeT edgeT;
   1.146        if ((source.id & 1) == 0) {
   1.147  	edgeT.aNode = source.id;
   1.148  	edgeT.bNode = target.id;
   1.149 @@ -566,7 +574,7 @@
   1.150        edgeT.next_in = bNodes[edgeT.bNode >> 1].first;
   1.151        bNodes[edgeT.bNode >> 1].first = edges.size();
   1.152        edges.push_back(edgeT);
   1.153 -      return Edge(edges.size() - 1);
   1.154 +      return UEdge(edges.size() - 1);
   1.155      }
   1.156  
   1.157      void clear() {
   1.158 @@ -581,13 +589,12 @@
   1.159      int bNodeNum() const { return bNodes.size(); }
   1.160  
   1.161      typedef True EdgeNumTag;
   1.162 -    int edgeNum() const { return edges.size(); }
   1.163 +    int uEdgeNum() const { return edges.size(); }
   1.164  
   1.165    };
   1.166  
   1.167  
   1.168 -  typedef BpUGraphExtender< BpUGraphBaseExtender<
   1.169 -    SmartBpUGraphBase> > ExtendedSmartBpUGraphBase;
   1.170 +  typedef BpUGraphExtender<SmartBpUGraphBase> ExtendedSmartBpUGraphBase;
   1.171  
   1.172    /// \ingroup graphs
   1.173    ///