1.1 --- a/src/lemon/full_graph.h Sat Nov 13 12:24:01 2004 +0000
1.2 +++ b/src/lemon/full_graph.h Sat Nov 13 12:53:28 2004 +0000
1.3 @@ -78,8 +78,8 @@
1.4 ///\sa id(Edge)
1.5 int maxId(Edge = INVALID) const { return EdgeNum-1; }
1.6
1.7 - Node tail(Edge e) const { return e.id % NodeNum; }
1.8 - Node head(Edge e) const { return e.id / NodeNum; }
1.9 + Node source(Edge e) const { return e.id % NodeNum; }
1.10 + Node target(Edge e) const { return e.id / NodeNum; }
1.11
1.12
1.13 /// Node ID.
1.14 @@ -136,12 +136,12 @@
1.15 friend class FullGraphBase;
1.16
1.17 protected:
1.18 - int id; // NodeNum * head + tail;
1.19 + int id; // NodeNum * target + source;
1.20
1.21 Edge(int _id) : id(_id) {}
1.22
1.23 - Edge(const FullGraphBase& _graph, int tail, int head)
1.24 - : id(_graph.NodeNum * head+tail) {}
1.25 + Edge(const FullGraphBase& _graph, int source, int target)
1.26 + : id(_graph.NodeNum * target+source) {}
1.27 public:
1.28 Edge() { }
1.29 Edge (Invalid) { id = -1; }
1.30 @@ -250,14 +250,14 @@
1.31 ///\sa id(Edge)
1.32 int maxId(Edge = INVALID) const { return EdgeNum-1; }
1.33
1.34 - Node tail(Edge e) const {
1.35 + Node source(Edge e) const {
1.36 /// \todo we may do it faster
1.37 return ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;
1.38 }
1.39
1.40 - Node head(Edge e) const {
1.41 - int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
1.42 - return e.id - (tail) * (tail - 1) / 2;
1.43 + Node target(Edge e) const {
1.44 + int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
1.45 + return e.id - (source) * (source - 1) / 2;
1.46 }
1.47
1.48
1.49 @@ -315,12 +315,12 @@
1.50 friend class UndirFullGraphBase;
1.51
1.52 protected:
1.53 - int id; // NodeNum * head + tail;
1.54 + int id; // NodeNum * target + source;
1.55
1.56 Edge(int _id) : id(_id) {}
1.57
1.58 - Edge(const UndirFullGraphBase& _graph, int tail, int head)
1.59 - : id(_graph.NodeNum * head+tail) {}
1.60 + Edge(const UndirFullGraphBase& _graph, int source, int target)
1.61 + : id(_graph.NodeNum * target+source) {}
1.62 public:
1.63 Edge() { }
1.64 Edge (Invalid) { id = -1; }
1.65 @@ -351,10 +351,10 @@
1.66
1.67 /// \todo with specialized iterators we can make faster iterating
1.68 void nextOut(Edge& e) const {
1.69 - int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
1.70 - int head = e.id - (tail) * (tail - 1) / 2;
1.71 - ++head;
1.72 - e.id = head < tail ? tail * (tail - 1) / 2 + head : -1;
1.73 + int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
1.74 + int target = e.id - (source) * (source - 1) / 2;
1.75 + ++target;
1.76 + e.id = target < source ? source * (source - 1) / 2 + target : -1;
1.77 }
1.78
1.79 void firstIn(Edge& edge, const Node& node) const {
1.80 @@ -362,10 +362,10 @@
1.81 }
1.82
1.83 void nextIn(Edge& e) const {
1.84 - int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
1.85 - int head = e.id - (tail) * (tail - 1) / 2; ++head;
1.86 - ++tail;
1.87 - e.id = tail < NodeNum ? tail * (tail - 1) / 2 + head : -1;
1.88 + int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
1.89 + int target = e.id - (source) * (source - 1) / 2; ++target;
1.90 + ++source;
1.91 + e.id = source < NodeNum ? source * (source - 1) / 2 + target : -1;
1.92 }
1.93
1.94 };