Index: lemon/hypercube_graph.h
===================================================================
--- lemon/hypercube_graph.h	(revision 377)
+++ lemon/hypercube_graph.h	(revision 385)
@@ -51,5 +51,5 @@
       _dim = dim;
       _node_num = 1 << dim;
-      _edge_num = dim * (1 << dim-1);
+      _edge_num = dim * (1 << (dim-1));
     }
 
@@ -77,13 +77,13 @@
 
     Node u(Edge edge) const {
-      int base = edge._id & ((1 << _dim-1) - 1);
-      int k = edge._id >> _dim-1;
-      return ((base >> k) << k+1) | (base & ((1 << k) - 1));
+      int base = edge._id & ((1 << (_dim-1)) - 1);
+      int k = edge._id >> (_dim-1);
+      return ((base >> k) << (k+1)) | (base & ((1 << k) - 1));
     }
 
     Node v(Edge edge) const {
-      int base = edge._id & ((1 << _dim-1) - 1);
-      int k = edge._id >> _dim-1;
-      return ((base >> k) << k+1) | (base & ((1 << k) - 1)) | (1 << k);
+      int base = edge._id & ((1 << (_dim-1)) - 1);
+      int k = edge._id >> (_dim-1);
+      return ((base >> k) << (k+1)) | (base & ((1 << k) - 1)) | (1 << k);
     }
 
@@ -106,5 +106,6 @@
       for ( ; (d & 1) == 0; d >>= 1) ++k;
       if (d >> 1 != 0) return INVALID;
-      return (k << _dim-1) | ((u._id >> k+1) << k) | (u._id & ((1 << k) - 1));
+      return (k << (_dim-1)) | ((u._id >> (k+1)) << k) |
+        (u._id & ((1 << k) - 1));
     }
 
@@ -112,5 +113,5 @@
       Edge edge = findEdge(u, v, prev);
       if (edge == INVALID) return INVALID;
-      int k = edge._id >> _dim-1;
+      int k = edge._id >> (_dim-1);
       return ((u._id >> k) & 1) == 1 ? edge._id << 1 : (edge._id << 1) | 1;
     }
@@ -195,8 +196,8 @@
     void nextInc(Edge& edge, bool& dir) const {
       Node n = dir ? u(edge) : v(edge);
-      int k = (edge._id >> _dim-1) + 1;
+      int k = (edge._id >> (_dim-1)) + 1;
       if (k < _dim) {
-        edge._id = (k << _dim-1) |
-                   ((n._id >> k+1) << k) | (n._id & ((1 << k) - 1));
+        edge._id = (k << (_dim-1)) |
+          ((n._id >> (k+1)) << k) | (n._id & ((1 << k) - 1));
         dir = ((n._id >> k) & 1) == 0;
       } else {
@@ -214,6 +215,6 @@
       int k = (arc._id >> _dim) + 1;
       if (k < _dim) {
-        arc._id = (k << _dim-1) |
-                  ((n._id >> k+1) << k) | (n._id & ((1 << k) - 1));
+        arc._id = (k << (_dim-1)) |
+          ((n._id >> (k+1)) << k) | (n._id & ((1 << k) - 1));
         arc._id = (arc._id << 1) | (~(n._id >> k) & 1);
       } else {
@@ -230,6 +231,6 @@
       int k = (arc._id >> _dim) + 1;
       if (k < _dim) {
-        arc._id = (k << _dim-1) |
-                  ((n._id >> k+1) << k) | (n._id & ((1 << k) - 1));
+        arc._id = (k << (_dim-1)) |
+          ((n._id >> (k+1)) << k) | (n._id & ((1 << k) - 1));
         arc._id = (arc._id << 1) | ((n._id >> k) & 1);
       } else {
@@ -255,5 +256,5 @@
 
     int dimension(Edge edge) const {
-      return edge._id >> _dim-1;
+      return edge._id >> (_dim-1);
     }
 
Index: test/graph_test.cc
===================================================================
--- test/graph_test.cc	(revision 377)
+++ test/graph_test.cc	(revision 385)
@@ -322,5 +322,5 @@
   HypercubeGraph G(dim);
   checkGraphNodeList(G, 1 << dim);
-  checkGraphEdgeList(G, dim * (1 << dim-1));
+  checkGraphEdgeList(G, dim * (1 << (dim-1)));
   checkGraphArcList(G, dim * (1 << dim));
 
@@ -331,7 +331,7 @@
     for (IncEdgeIt e(G, n); e != INVALID; ++e) {
       check( (G.u(e) == n &&
-              G.id(G.v(e)) == G.id(n) ^ (1 << G.dimension(e))) ||
+              G.id(G.v(e)) == (G.id(n) ^ (1 << G.dimension(e)))) ||
              (G.v(e) == n &&
-              G.id(G.u(e)) == G.id(n) ^ (1 << G.dimension(e))),
+              G.id(G.u(e)) == (G.id(n) ^ (1 << G.dimension(e)))),
              "Wrong edge or wrong dimension");
     }
@@ -340,5 +340,5 @@
     for (OutArcIt a(G, n); a != INVALID; ++a) {
       check(G.source(a) == n &&
-            G.id(G.target(a)) == G.id(n) ^ (1 << G.dimension(a)),
+            G.id(G.target(a)) == (G.id(n) ^ (1 << G.dimension(a))),
             "Wrong arc or wrong dimension");
     }
@@ -347,5 +347,5 @@
     for (InArcIt a(G, n); a != INVALID; ++a) {
       check(G.target(a) == n &&
-            G.id(G.source(a)) == G.id(n) ^ (1 << G.dimension(a)),
+            G.id(G.source(a)) == (G.id(n) ^ (1 << G.dimension(a))),
             "Wrong arc or wrong dimension");
     }
@@ -353,5 +353,5 @@
 
   checkGraphConArcList(G, (1 << dim) * dim);
-  checkGraphConEdgeList(G, dim * (1 << dim-1));
+  checkGraphConEdgeList(G, dim * (1 << (dim-1)));
 
   checkArcDirections(G);
