lemon/full_graph.h
changeset 1644 62548b317e65
parent 1566 12a3101cf3ab
child 1669 66ae78d29f1e
equal deleted inserted replaced
2:7869e243fb03 3:290d055a4012
   123     class Node {
   123     class Node {
   124       friend class FullGraphBase;
   124       friend class FullGraphBase;
   125 
   125 
   126     protected:
   126     protected:
   127       int id;
   127       int id;
   128       Node(int _id) { id = _id;}
   128       Node(int _id) : id(_id) {}
   129     public:
   129     public:
   130       Node() {}
   130       Node() {}
   131       Node (Invalid) { id = -1; }
   131       Node (Invalid) : id(-1) {}
   132       bool operator==(const Node node) const {return id == node.id;}
   132       bool operator==(const Node node) const {return id == node.id;}
   133       bool operator!=(const Node node) const {return id != node.id;}
   133       bool operator!=(const Node node) const {return id != node.id;}
   134       bool operator<(const Node node) const {return id < node.id;}
   134       bool operator<(const Node node) const {return id < node.id;}
   135     };
   135     };
   136     
   136     
   258     ///\sa id(Edge)
   258     ///\sa id(Edge)
   259     int maxId(Edge = INVALID) const { return _edgeNum-1; }
   259     int maxId(Edge = INVALID) const { return _edgeNum-1; }
   260 
   260 
   261     Node source(Edge e) const { 
   261     Node source(Edge e) const { 
   262       /// \todo we may do it faster
   262       /// \todo we may do it faster
   263       return ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2; 
   263       return Node(((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2);
   264     }
   264     }
   265 
   265 
   266     Node target(Edge e) const { 
   266     Node target(Edge e) const { 
   267       int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
   267       int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
   268       return e.id - (source) * (source - 1) / 2; 
   268       return Node(e.id - (source) * (source - 1) / 2);
   269     }
   269     }
   270 
   270 
   271 
   271 
   272     /// Node ID.
   272     /// Node ID.
   273     
   273