Bugfixes in UndirFullGraphBase
authoralpar
Sat, 13 Nov 2004 12:24:01 +0000
changeset 985741f3108a90f
parent 984 f7538f6f4c61
child 986 e997802b855c
Bugfixes in UndirFullGraphBase
src/lemon/full_graph.h
     1.1 --- a/src/lemon/full_graph.h	Thu Nov 11 12:12:28 2004 +0000
     1.2 +++ b/src/lemon/full_graph.h	Sat Nov 13 12:24:01 2004 +0000
     1.3 @@ -296,7 +296,7 @@
     1.4      
     1.5        
     1.6      class Node {
     1.7 -      friend class FullGraphBase;
     1.8 +      friend class UndirFullGraphBase;
     1.9  
    1.10      protected:
    1.11        int id;
    1.12 @@ -312,14 +312,14 @@
    1.13  
    1.14  
    1.15      class Edge {
    1.16 -      friend class FullGraphBase;
    1.17 +      friend class UndirFullGraphBase;
    1.18        
    1.19      protected:
    1.20        int id;  // NodeNum * head + tail;
    1.21  
    1.22        Edge(int _id) : id(_id) {}
    1.23  
    1.24 -      Edge(const FullGraphBase& _graph, int tail, int head) 
    1.25 +      Edge(const UndirFullGraphBase& _graph, int tail, int head) 
    1.26  	: id(_graph.NodeNum * head+tail) {}
    1.27      public:
    1.28        Edge() { }
    1.29 @@ -350,22 +350,22 @@
    1.30      }
    1.31  
    1.32      /// \todo with specialized iterators we can make faster iterating
    1.33 -    void nextOut(Edge& edge) const {
    1.34 +    void nextOut(Edge& e) const {
    1.35        int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
    1.36        int head = e.id - (tail) * (tail - 1) / 2; 
    1.37        ++head;
    1.38 -      return head < tail ? tail * (tail - 1) / 2 + head : -1;
    1.39 +      e.id = head < tail ? tail * (tail - 1) / 2 + head : -1;
    1.40      }
    1.41  
    1.42      void firstIn(Edge& edge, const Node& node) const {
    1.43        edge.id = node.id * (node.id + 1) / 2 - 1;
    1.44      }
    1.45      
    1.46 -    void nextIn(Edge& edge) const {
    1.47 +    void nextIn(Edge& e) const {
    1.48        int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
    1.49        int head = e.id - (tail) * (tail - 1) / 2; ++head;
    1.50        ++tail;
    1.51 -      return tail < nodeNum ? tail * (tail - 1) / 2 + head : -1;
    1.52 +      e.id = tail < NodeNum ? tail * (tail - 1) / 2 + head : -1;
    1.53      }
    1.54  
    1.55    };