chiark / gitweb /
remove dead wood; reenable graph_layout_cost
[moebius2.git] / bgl.cpp
diff --git a/bgl.cpp b/bgl.cpp
index 30a1767b175dae8c9f863501675b58798d9d0da7..193a75a97fac5eac1b901aa2afcb7ff511a572cf 100644 (file)
--- a/bgl.cpp
+++ b/bgl.cpp
@@ -47,8 +47,6 @@ extern "C" {
 #define VMASK (YMASK|XMASK)
 #define ESHIFT (YBITS+XBITS)
 
-class Graph { }; // this is a dummy as our graph has no actual representation
-
 using namespace boost;
 
 /*
@@ -98,13 +96,15 @@ class OutEdgeIterator :
   }
 
   static int voe_min(int _v) { return (_v & YMASK) ? 2 : 3; }
-  static int voe_max(int _v) { return (~_v & YMASK) ? V6 : 4; }
+  static int voe_max(int _v) { return (_v & YMASK)==(Y-1) ? V6 : 4; }
   static int voe_degree(int _v) { return RIM_VERTEX_P(_v) ? 4 : V6; }
 };
  
 typedef counting_iterator<int> VertexIterator;
 
 namespace boost {
+  class Graph { }; // this is a dummy as our graph has no actual representation
+
   // We make Graph a model of various BGL Graph concepts.
   // This mainly means that graph_traits<Graph> has lots of stuff.
 
@@ -115,6 +115,7 @@ namespace boost {
     public virtual vertex_list_graph_tag,
     public virtual edge_list_graph_tag { };
 
+  template<>
   struct graph_traits<Graph> {
     // Concept Graph:
     typedef int vertex_descriptor; /* vertex number, -1 => none */
@@ -152,7 +153,8 @@ namespace boost {
   }
 
   // Concept VertexListGraph:
-  inline std::pair<VertexIterator,VertexIterator> vertices(const Graph&) {
+  inline
+  std::pair<VertexIterator,VertexIterator> vertices(const Graph&) {
     return std::make_pair(VertexIterator(0), VertexIterator(N));
   }
   inline unsigned num_vertices(const Graph&) { return N; }
@@ -188,7 +190,7 @@ double graph_layout_cost(const Vertices v, const double vertex_areas[N]) {
    */
   static const double d2_epsilon= 1e-6;
   
-  double edge_weights[N*V6], vertex_distances[N], total_cost=0;
+  double edge_weights[V6<<ESHIFT], vertex_distances[N], total_cost=0;
   int v1,v2,e,f;
 
   FOR_VERTEX(v1)