Changeset 385:7b6466ed488a in lemon for lemon/hypercube_graph.h
 Timestamp:
 11/07/08 14:04:54 (16 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/hypercube_graph.h
r377 r385 51 51 _dim = dim; 52 52 _node_num = 1 << dim; 53 _edge_num = dim * (1 << dim1);53 _edge_num = dim * (1 << (dim1)); 54 54 } 55 55 … … 77 77 78 78 Node u(Edge edge) const { 79 int base = edge._id & ((1 << _dim1)  1);80 int k = edge._id >> _dim1;81 return ((base >> k) << k+1)  (base & ((1 << k)  1));79 int base = edge._id & ((1 << (_dim1))  1); 80 int k = edge._id >> (_dim1); 81 return ((base >> k) << (k+1))  (base & ((1 << k)  1)); 82 82 } 83 83 84 84 Node v(Edge edge) const { 85 int base = edge._id & ((1 << _dim1)  1);86 int k = edge._id >> _dim1;87 return ((base >> k) << k+1)  (base & ((1 << k)  1))  (1 << k);85 int base = edge._id & ((1 << (_dim1))  1); 86 int k = edge._id >> (_dim1); 87 return ((base >> k) << (k+1))  (base & ((1 << k)  1))  (1 << k); 88 88 } 89 89 … … 106 106 for ( ; (d & 1) == 0; d >>= 1) ++k; 107 107 if (d >> 1 != 0) return INVALID; 108 return (k << _dim1)  ((u._id >> k+1) << k)  (u._id & ((1 << k)  1)); 108 return (k << (_dim1))  ((u._id >> (k+1)) << k)  109 (u._id & ((1 << k)  1)); 109 110 } 110 111 … … 112 113 Edge edge = findEdge(u, v, prev); 113 114 if (edge == INVALID) return INVALID; 114 int k = edge._id >> _dim1;115 int k = edge._id >> (_dim1); 115 116 return ((u._id >> k) & 1) == 1 ? edge._id << 1 : (edge._id << 1)  1; 116 117 } … … 195 196 void nextInc(Edge& edge, bool& dir) const { 196 197 Node n = dir ? u(edge) : v(edge); 197 int k = (edge._id >> _dim1) + 1;198 int k = (edge._id >> (_dim1)) + 1; 198 199 if (k < _dim) { 199 edge._id = (k << _dim1) 200 ((n._id >> k+1) << k)  (n._id & ((1 << k)  1));200 edge._id = (k << (_dim1))  201 ((n._id >> (k+1)) << k)  (n._id & ((1 << k)  1)); 201 202 dir = ((n._id >> k) & 1) == 0; 202 203 } else { … … 214 215 int k = (arc._id >> _dim) + 1; 215 216 if (k < _dim) { 216 arc._id = (k << _dim1) 217 ((n._id >> k+1) << k)  (n._id & ((1 << k)  1));217 arc._id = (k << (_dim1))  218 ((n._id >> (k+1)) << k)  (n._id & ((1 << k)  1)); 218 219 arc._id = (arc._id << 1)  (~(n._id >> k) & 1); 219 220 } else { … … 230 231 int k = (arc._id >> _dim) + 1; 231 232 if (k < _dim) { 232 arc._id = (k << _dim1) 233 ((n._id >> k+1) << k)  (n._id & ((1 << k)  1));233 arc._id = (k << (_dim1))  234 ((n._id >> (k+1)) << k)  (n._id & ((1 << k)  1)); 234 235 arc._id = (arc._id << 1)  ((n._id >> k) & 1); 235 236 } else { … … 255 256 256 257 int dimension(Edge edge) const { 257 return edge._id >> _dim1;258 return edge._id >> (_dim1); 258 259 } 259 260
Note: See TracChangeset
for help on using the changeset viewer.