Changeset 986:e997802b855c in lemon0.x for src/lemon/full_graph.h
 Timestamp:
 11/13/04 13:53:28 (19 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1376
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/full_graph.h
r985 r986 79 79 int maxId(Edge = INVALID) const { return EdgeNum1; } 80 80 81 Node tail(Edge e) const { return e.id % NodeNum; }82 Node head(Edge e) const { return e.id / NodeNum; }81 Node source(Edge e) const { return e.id % NodeNum; } 82 Node target(Edge e) const { return e.id / NodeNum; } 83 83 84 84 … … 137 137 138 138 protected: 139 int id; // NodeNum * head + tail;139 int id; // NodeNum * target + source; 140 140 141 141 Edge(int _id) : id(_id) {} 142 142 143 Edge(const FullGraphBase& _graph, int tail, int head)144 : id(_graph.NodeNum * head+tail) {}143 Edge(const FullGraphBase& _graph, int source, int target) 144 : id(_graph.NodeNum * target+source) {} 145 145 public: 146 146 Edge() { } … … 251 251 int maxId(Edge = INVALID) const { return EdgeNum1; } 252 252 253 Node tail(Edge e) const {253 Node source(Edge e) const { 254 254 /// \todo we may do it faster 255 255 return ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2; 256 256 } 257 257 258 Node head(Edge e) const {259 int tail= ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;260 return e.id  ( tail) * (tail 1) / 2;258 Node target(Edge e) const { 259 int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;; 260 return e.id  (source) * (source  1) / 2; 261 261 } 262 262 … … 316 316 317 317 protected: 318 int id; // NodeNum * head + tail;318 int id; // NodeNum * target + source; 319 319 320 320 Edge(int _id) : id(_id) {} 321 321 322 Edge(const UndirFullGraphBase& _graph, int tail, int head)323 : id(_graph.NodeNum * head+tail) {}322 Edge(const UndirFullGraphBase& _graph, int source, int target) 323 : id(_graph.NodeNum * target+source) {} 324 324 public: 325 325 Edge() { } … … 352 352 /// \todo with specialized iterators we can make faster iterating 353 353 void nextOut(Edge& e) const { 354 int tail= ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;355 int head = e.id  (tail) * (tail 1) / 2;356 ++ head;357 e.id = head < tail ? tail * (tail  1) / 2 + head: 1;354 int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;; 355 int target = e.id  (source) * (source  1) / 2; 356 ++target; 357 e.id = target < source ? source * (source  1) / 2 + target : 1; 358 358 } 359 359 … … 363 363 364 364 void nextIn(Edge& e) const { 365 int tail= ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;366 int head = e.id  (tail) * (tail  1) / 2; ++head;367 ++ tail;368 e.id = tail < NodeNum ? tail * (tail  1) / 2 + head: 1;365 int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;; 366 int target = e.id  (source) * (source  1) / 2; ++target; 367 ++source; 368 e.id = source < NodeNum ? source * (source  1) / 2 + target : 1; 369 369 } 370 370
Note: See TracChangeset
for help on using the changeset viewer.