title: C++ Boost Graph Library: outputting custom vertex properties
body: <p>I am struggling to get a custom property writer to work with BGL.</p>
  
  <pre><code>struct IkGraph_VertexProperty {
      int id_ ;
      int type_ ;
      std::pair&lt;int,int&gt; gaussians_ ; // Type of Joint, Ids of Gaussians
  };
  
  
  struct IkGraph_VertexPropertyTag
  {
  typedef edge_property_tag kind;
  static std::size_t const num; 
  };
  
  std::size_t const IkGraph_VertexPropertyTag::num = (std::size_t)&amp;IkGraph_VertexPropertyTag::num;
  
  typedef property&lt;IkGraph_VertexPropertyTag, IkGraph_VertexProperty&gt; vertex_info_type;
  </code></pre>
  
  <p>...custom graph defined in method</p>
  
  <pre><code>typedef adjacency_list&lt;setS, vecS, bidirectionalS, vertex_info_type, IkGraph_EdgeProperty&gt; TGraph ;
  TGraph testGraph ;
  std::ofstream outStr(filename) ;
  write_graphviz(outStr, testGraph, OurVertexPropertyWriter&lt;TGraph,IkGraph_VertexPropertyTag, IkGraph_VertexProperty&gt;(testGraph));
  </code></pre>
  
  <p>...</p>
  
  <pre><code>template &lt;class Graph, class VertexPropertyTag, class VertexProperty&gt;
  struct OurVertexPropertyWriter {
  
    OurVertexPropertyWriter(Graph &amp;g_) : g(g_) {}
  
   template &lt;class Vertex&gt;
   void operator() (std::ostream &amp;out, Vertex v) {
  
      VertexProperty p = get (VertexPropertyTag(), g, v);
        out &lt;&lt; "[label=" &lt;&lt; p.gaussians_.first &lt;&lt; "]";
  
    }
  
   Graph &amp;g;
  };
  </code></pre>
  
  <p>This produces a stream of errors.</p>
  
  <p>What I would really like to do (and no idea if this is possible) is to be able to generalize this and be pass which custom properties exist / which I would like outputting.</p>