Ticket #7845: isomorphism.patch

File isomorphism.patch, 3.9 KB (added by tiago@…, 10 years ago)

Proposed patch

  • isomorphism.hpp

    old new  
    222222        recur:
    223223        if (iter != ordered_edges.end()) {
    224224          i = source(*iter, G1);
    225           j = target(*iter, G2);
     225          j = target(*iter, G1);
    226226          if (dfs_num[i] > dfs_num_k) {
    227227            G2_verts = vertices(G2);
    228228            while (G2_verts.first != G2_verts.second) {
     
    310310          if (k.empty()) return false;
    311311          const match_continuation& this_k = k.back();
    312312          switch (this_k.position) {
    313             case match_continuation::pos_G2_vertex_loop: {G2_verts = this_k.G2_verts; iter = this_k.iter; dfs_num_k = this_k.dfs_num_k; k.pop_back(); in_S[*G2_verts.first] = false; i = source(*iter, G1); j = target(*iter, G2); goto G2_loop_k;}
    314             case match_continuation::pos_fi_adj_loop: {fi_adj = this_k.fi_adj; iter = this_k.iter; dfs_num_k = this_k.dfs_num_k; k.pop_back(); in_S[*fi_adj.first] = false; i = source(*iter, G1); j = target(*iter, G2); goto fi_adj_loop_k;}
     313            case match_continuation::pos_G2_vertex_loop: {G2_verts = this_k.G2_verts; iter = this_k.iter; dfs_num_k = this_k.dfs_num_k; k.pop_back(); in_S[*G2_verts.first] = false; i = source(*iter, G1); j = target(*iter, G1); goto G2_loop_k;}
     314            case match_continuation::pos_fi_adj_loop: {fi_adj = this_k.fi_adj; iter = this_k.iter; dfs_num_k = this_k.dfs_num_k; k.pop_back(); in_S[*fi_adj.first] = false; i = source(*iter, G1); j = target(*iter, G1); goto fi_adj_loop_k;}
    315315            case match_continuation::pos_dfs_num: {k.pop_back(); goto return_point_false;}
    316316            default: {
    317317              BOOST_ASSERT(!"Bad position");
     
    378378    const Graph& m_g;
    379379  };
    380380
     381  template <typename Graph>
     382  size_t get_num_vertices(const Graph& g)
     383  {
     384      size_t n = 0;
     385      typename boost::graph_traits<Graph>::vertex_iterator v, v_end;
     386      for(tie(v, v_end) = vertices(g); v != v_end; ++v)
     387          n++;
     388      return n;
     389  }
     390
     391  template <typename Graph>
     392  size_t get_num_edges(const Graph& g)
     393  {
     394      size_t n = 0;
     395      typename boost::graph_traits<Graph>::edge_iterator e, e_end;
     396      for(tie(e, e_end) = edges(g); e != e_end; ++e)
     397          n++;
     398      return n;
     399  }
    381400
    382401  template <typename Graph1, typename Graph2, typename IsoMapping,
    383402    typename Invariant1, typename Invariant2,
     
    392411    BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph1> ));
    393412    BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph1> ));
    394413    BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph2> ));
    395     BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept<Graph2> ));
     414    //BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept<Graph2> ));
    396415   
    397416    typedef typename graph_traits<Graph1>::vertex_descriptor vertex1_t;
    398417    typedef typename graph_traits<Graph2>::vertex_descriptor vertex2_t;
     
    407426    // Property map requirements
    408427    BOOST_CONCEPT_ASSERT(( ReadWritePropertyMapConcept<IsoMapping, vertex1_t> ));
    409428    typedef typename property_traits<IsoMapping>::value_type IsoMappingValue;
    410     BOOST_STATIC_ASSERT((is_same<IsoMappingValue, vertex2_t>::value));
     429    BOOST_STATIC_ASSERT((is_convertible<IsoMappingValue, vertex2_t>::value));
    411430   
    412431    BOOST_CONCEPT_ASSERT(( ReadablePropertyMapConcept<IndexMap1, vertex1_t> ));
    413432    typedef typename property_traits<IndexMap1>::value_type IndexMap1Value;
     
    417436    typedef typename property_traits<IndexMap2>::value_type IndexMap2Value;
    418437    BOOST_STATIC_ASSERT((is_convertible<IndexMap2Value, size_type>::value));
    419438   
    420     if (num_vertices(G1) != num_vertices(G2))
     439    if (get_num_vertices(G1) != get_num_vertices(G2))
    421440      return false;
    422     if (num_vertices(G1) == 0 && num_vertices(G2) == 0)
     441    if (get_num_vertices(G1) == 0 && get_num_vertices(G2) == 0)
    423442      return true;
    424443   
    425444    detail::isomorphism_algo<Graph1, Graph2, IsoMapping, Invariant1,