title: Boost directed graph: comparing edges of a vertex
body: <p>A brief background:
  I'm building a semantic graph, using BGL directed graphs with an adjacency list:</p>
  
  <pre><code>class SemanticGraph
  {
    public:
      typedef std::shared_ptr&lt; Node &gt; Node_ptr;
      typedef boost::adjacency_list&lt; boost::vecS, boost::vecS, boost::directedS, Node_ptr &gt; Graph;
      typedef boost::graph_traits&lt; Graph &gt;::vertex_descriptor Vertex;
      typedef boost::graph_traits&lt; Graph &gt;::edge_descriptor Edge;
  </code></pre>
  
  <p>One of the things I need to be able to do, is process a smaller graph (a subgraph) into my main graph.</p>
  
  <p>Doing so, involves copying the Node pointers if needed, copying the vertices from the subgraph into the main graph if they don't already exist, and most importantly, copying the edges for each vertex found in the subgraph, into the main one, if not already established.</p>
  
  <p>The first two tasks are not that complicated. 
  However, I cannot for the life of me, find a way to compare two edges:</p>
  
  <pre><code> void AddSubGraph( SemanticGraph subgraph )
   {
        typename boost::graph_traits&lt;Graph&gt;::vertex_iterator it, end;
        Vertex vertex;
  
        for ( auto node : subgraph._nodes )
        {
          if ( !findNode( node ) )
             _nodes.push_back( node );
  
          boost::tie( it, end ) = boost::vertices( _graph );
          std::find_if( it, end, [&amp;]( const Vertex vertex ){ return _graph[*it]-&gt;Hash() == node-&gt;Hash(); });
  
          if ( it == end )
            vertex = boost::add_vertex( node, _graph );
          else
            vertex = boost::vertex( *it, _graph );
  
          boost::tie( it, end ) = boost::vertices( subgraph._graph );
          std::find_if( it, end, [&amp;]( const Vertex vertex ){ return subgraph._graph[*it]-&gt;Hash() == node-&gt;Hash(); });
  
          auto subgraph_vertex = boost::vertex( *it, subgraph._graph );
          typename boost::graph_traits&lt;Graph&gt;::out_edge_iterator a, z;
  
          // Iterate subgraph's vertex out edges
          for ( boost::tie ( a, z ) = boost::out_edges( subgraph_vertex, subgraph._graph );
                a != z;
                ++a )
          {
             typename boost::graph_traits&lt;Graph&gt;::out_edge_iterator my_edge, edge_end;
             boost::tie ( my_edge, edge_end ) = boost::out_edges( vertex, _graph );
             // How can I see if the same edge as the one pointed by edge iterator a, exists in my vertex's edges?
             std::find_if( my_edge, edge_end, [&amp;]( const Edge edge ){ return edge == a; });
          }
        }
      }
  </code></pre>
  
  <p>The compiler throws a warning at the last std::find_if above ^^:</p>
  
  <pre><code>‘const Edge {aka const boost::detail::edge_desc_impl&lt;boost::directed_tag, long unsigned int&gt;}’ is not derived from ‘const std::pair&lt;_T1, _T2&gt;’
  </code></pre>
  
  <p>Hinting that my lambda captured parameter should be a pair (I'm guessing an actual edge?).</p>
  
  <p>So, my question is:
  <strong>How can I find if that similar edge exists in my vertex's out edges?</strong></p>