lemon/full_graph.h
changeset 2386 81b47fc5c444
parent 2384 805c5a2a36dd
child 2391 14a343be7a5a
     1.1 --- a/lemon/full_graph.h	Fri Mar 02 17:56:22 2007 +0000
     1.2 +++ b/lemon/full_graph.h	Fri Mar 02 18:04:28 2007 +0000
     1.3 @@ -56,7 +56,7 @@
     1.4      typedef True NodeNumTag;
     1.5      typedef True EdgeNumTag;
     1.6  
     1.7 -    Node operator()(int index) const { return Node(index); }
     1.8 +    Node operator()(int ix) const { return Node(ix); }
     1.9      int index(const Node& node) const { return node.id; }
    1.10  
    1.11      Edge edge(const Node& u, const Node& v) const { 
    1.12 @@ -129,30 +129,30 @@
    1.13        --node.id;
    1.14      }
    1.15  
    1.16 -    void first(Edge& edge) const {
    1.17 -      edge.id = _edgeNum-1;
    1.18 +    void first(Edge& e) const {
    1.19 +      e.id = _edgeNum-1;
    1.20      }
    1.21  
    1.22 -    static void next(Edge& edge) {
    1.23 -      --edge.id;
    1.24 +    static void next(Edge& e) {
    1.25 +      --e.id;
    1.26      }
    1.27  
    1.28 -    void firstOut(Edge& edge, const Node& node) const {
    1.29 -      edge.id = _edgeNum + node.id - _nodeNum;
    1.30 +    void firstOut(Edge& e, const Node& n) const {
    1.31 +      e.id = _edgeNum + n.id - _nodeNum;
    1.32      }
    1.33  
    1.34 -    void nextOut(Edge& edge) const {
    1.35 -      edge.id -= _nodeNum;
    1.36 -      if (edge.id < 0) edge.id = -1;
    1.37 +    void nextOut(Edge& e) const {
    1.38 +      e.id -= _nodeNum;
    1.39 +      if (e.id < 0) e.id = -1;
    1.40      }
    1.41  
    1.42 -    void firstIn(Edge& edge, const Node& node) const {
    1.43 -      edge.id = node.id * _nodeNum;
    1.44 +    void firstIn(Edge& e, const Node& n) const {
    1.45 +      e.id = n.id * _nodeNum;
    1.46      }
    1.47      
    1.48 -    void nextIn(Edge& edge) const {
    1.49 -      ++edge.id;
    1.50 -      if (edge.id % _nodeNum == 0) edge.id = -1;
    1.51 +    void nextIn(Edge& e) const {
    1.52 +      ++e.id;
    1.53 +      if (e.id % _nodeNum == 0) e.id = -1;
    1.54      }
    1.55  
    1.56    };
    1.57 @@ -207,7 +207,7 @@
    1.58      /// static size graph the node's of the graph can be indiced
    1.59      /// by the range from 0 to \e nodeNum()-1 and the index of
    1.60      /// the node can accessed by the \e index() member.
    1.61 -    Node operator()(int index) const { return Parent::operator()(index); }
    1.62 +    Node operator()(int ix) const { return Parent::operator()(ix); }
    1.63  
    1.64      /// \brief Returns the index of the node.
    1.65      ///
    1.66 @@ -250,7 +250,7 @@
    1.67    public:
    1.68  
    1.69  
    1.70 -    Node operator()(int index) const { return Node(index); }
    1.71 +    Node operator()(int ix) const { return Node(ix); }
    1.72      int index(const Node& node) const { return node.id; }
    1.73  
    1.74      Edge edge(const Node& u, const Node& v) const { 
    1.75 @@ -271,12 +271,12 @@
    1.76  
    1.77      Node source(Edge e) const { 
    1.78        /// \todo we may do it faster
    1.79 -      return Node(((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2);
    1.80 +      return Node((int(sqrt(double(1 + 8 * e.id)) + 1)) / 2);
    1.81      }
    1.82  
    1.83      Node target(Edge e) const { 
    1.84 -      int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
    1.85 -      return Node(e.id - (source) * (source - 1) / 2);
    1.86 +      int s = (int(sqrt(double(1 + 8 * e.id)) + 1)) / 2;
    1.87 +      return Node(e.id - s * (s - 1) / 2);
    1.88      }
    1.89  
    1.90      static int id(Node v) { return v.id; }
    1.91 @@ -322,47 +322,47 @@
    1.92        bool operator<(const Edge edge) const {return id < edge.id;}
    1.93      };
    1.94  
    1.95 -    void first(Node& node) const {
    1.96 -      node.id = _nodeNum - 1;
    1.97 +    void first(Node& n) const {
    1.98 +      n.id = _nodeNum - 1;
    1.99      }
   1.100  
   1.101 -    static void next(Node& node) {
   1.102 -      --node.id;
   1.103 +    static void next(Node& n) {
   1.104 +      --n.id;
   1.105      }
   1.106  
   1.107 -    void first(Edge& edge) const {
   1.108 -      edge.id = _edgeNum - 1;
   1.109 +    void first(Edge& e) const {
   1.110 +      e.id = _edgeNum - 1;
   1.111      }
   1.112  
   1.113 -    static void next(Edge& edge) {
   1.114 -      --edge.id;
   1.115 +    static void next(Edge& e) {
   1.116 +      --e.id;
   1.117      }
   1.118  
   1.119 -    void firstOut(Edge& edge, const Node& node) const {      
   1.120 -      int src = node.id;
   1.121 +    void firstOut(Edge& e, const Node& n) const {      
   1.122 +      int src = n.id;
   1.123        int trg = 0;
   1.124 -      edge.id = (trg < src ? src * (src - 1) / 2 + trg : -1);
   1.125 +      e.id = (trg < src ? src * (src - 1) / 2 + trg : -1);
   1.126      }
   1.127  
   1.128      /// \todo with specialized iterators we can make faster iterating
   1.129 -    void nextOut(Edge& edge) const {
   1.130 -      int src = source(edge).id;
   1.131 -      int trg = target(edge).id;
   1.132 +    void nextOut(Edge& e) const {
   1.133 +      int src = source(e).id;
   1.134 +      int trg = target(e).id;
   1.135        ++trg;
   1.136 -      edge.id = (trg < src ? src * (src - 1) / 2 + trg : -1);
   1.137 +      e.id = (trg < src ? src * (src - 1) / 2 + trg : -1);
   1.138      }
   1.139  
   1.140 -    void firstIn(Edge& edge, const Node& node) const {
   1.141 -      int src = node.id + 1;
   1.142 -      int trg = node.id;
   1.143 -      edge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1);
   1.144 +    void firstIn(Edge& e, const Node& n) const {
   1.145 +      int src = n.id + 1;
   1.146 +      int trg = n.id;
   1.147 +      e.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1);
   1.148      }
   1.149      
   1.150 -    void nextIn(Edge& edge) const {
   1.151 -      int src = source(edge).id;
   1.152 -      int trg = target(edge).id;
   1.153 +    void nextIn(Edge& e) const {
   1.154 +      int src = source(e).id;
   1.155 +      int trg = target(e).id;
   1.156        ++src;
   1.157 -      edge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1);
   1.158 +      e.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1);
   1.159      }
   1.160  
   1.161    };
   1.162 @@ -421,7 +421,7 @@
   1.163      /// static size graph the node's of the graph can be indiced
   1.164      /// by the range from 0 to \e nodeNum()-1 and the index of
   1.165      /// the node can accessed by the \e index() member.
   1.166 -    Node operator()(int index) const { return Parent::operator()(index); }
   1.167 +    Node operator()(int ix) const { return Parent::operator()(ix); }
   1.168  
   1.169      /// \brief Returns the index of the node.
   1.170      ///
   1.171 @@ -478,10 +478,10 @@
   1.172  
   1.173      FullBpUGraphBase() {}
   1.174  
   1.175 -    void construct(int aNodeNum, int bNodeNum) {
   1.176 -      _aNodeNum = aNodeNum;
   1.177 -      _bNodeNum = bNodeNum;
   1.178 -      _edgeNum = aNodeNum * bNodeNum;
   1.179 +    void construct(int ann, int bnn) {
   1.180 +      _aNodeNum = ann;
   1.181 +      _bNodeNum = bnn;
   1.182 +      _edgeNum = ann * bnn;
   1.183      }
   1.184  
   1.185    public:
   1.186 @@ -521,8 +521,8 @@
   1.187        bool operator<(const UEdge i) const {return id<i.id;}
   1.188      };
   1.189  
   1.190 -    Node aNode(int index) const { return Node(index << 1); }
   1.191 -    Node bNode(int index) const { return Node((index << 1) + 1); }
   1.192 +    Node aNode(int ix) const { return Node(ix << 1); }
   1.193 +    Node bNode(int ix) const { return Node((ix << 1) + 1); }
   1.194  
   1.195      int aNodeIndex(const Node& node) const { return node.id >> 1; }
   1.196      int bNodeIndex(const Node& node) const { return node.id >> 1; }
   1.197 @@ -695,8 +695,8 @@
   1.198        Parent::construct(0, 0);
   1.199      }
   1.200  
   1.201 -    FullBpUGraph(int aNodeNum, int bNodeNum) {
   1.202 -      Parent::construct(aNodeNum, bNodeNum);
   1.203 +    FullBpUGraph(int ann, int bnn) {
   1.204 +      Parent::construct(ann, bnn);
   1.205      }
   1.206  
   1.207      /// \brief Resize the graph
   1.208 @@ -737,7 +737,7 @@
   1.209      /// static size graph the node's of the graph can be indiced
   1.210      /// by the range from 0 to \e aNodeNum()-1 and the index of
   1.211      /// the node can accessed by the \e aNodeIndex() member.
   1.212 -    Node aNode(int index) const { return Parent::aNode(index); }
   1.213 +    Node aNode(int ix) const { return Parent::aNode(ix); }
   1.214  
   1.215      /// \brief Returns the B-node with the given index.
   1.216      ///
   1.217 @@ -745,7 +745,7 @@
   1.218      /// static size graph the node's of the graph can be indiced
   1.219      /// by the range from 0 to \e bNodeNum()-1 and the index of
   1.220      /// the node can accessed by the \e bNodeIndex() member.
   1.221 -    Node bNode(int index) const { return Parent::bNode(index); }
   1.222 +    Node bNode(int ix) const { return Parent::bNode(ix); }
   1.223  
   1.224      /// \brief Returns the index of the A-node.
   1.225      ///