Skip to content

Commit

Permalink
Use unordered_flat_map, parameterize invariant map
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-grimo committed Apr 12, 2024
1 parent 76d5d6f commit 760aafb
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions include/boost/graph/isomorphism.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <boost/smart_ptr.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/detail/algorithm.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered/unordered_flat_map.hpp>
#include <boost/pending/indirect_cmp.hpp> // for make_indirect_pmap
#include <boost/concept/assert.hpp>

Expand All @@ -32,15 +32,14 @@ namespace detail

template < typename Graph1, typename Graph2, typename IsoMapping,
typename Invariant1, typename Invariant2, typename IndexMap1,
typename IndexMap2 >
typename IndexMap2, typename InvariantCountMap = boost::unordered_flat_map<typename Invariant1::result_type, typename graph_traits< Graph1 >::vertices_size_type > >
class isomorphism_algo
{
typedef typename graph_traits< Graph1 >::vertex_descriptor vertex1_t;
typedef typename graph_traits< Graph2 >::vertex_descriptor vertex2_t;
typedef typename graph_traits< Graph1 >::edge_descriptor edge1_t;
typedef typename graph_traits< Graph1 >::vertices_size_type size_type;
typedef typename Invariant1::result_type invariant_t;
typedef unordered_map< invariant_t, size_type > multiplicity_map;

const Graph1& G1;
const Graph2& G2;
Expand Down Expand Up @@ -81,7 +80,7 @@ namespace detail
friend struct compare_multiplicity;
struct compare_multiplicity
{
compare_multiplicity(Invariant1 invariant1, const multiplicity_map& multiplicity)
compare_multiplicity(Invariant1 invariant1, const InvariantCountMap& multiplicity)
: invariant1(invariant1), multiplicity(&multiplicity)
{
}
Expand All @@ -94,7 +93,7 @@ namespace detail
return *x_multiplicity_iter < *y_multiplicity_iter;
}
Invariant1 invariant1;
const multiplicity_map* multiplicity;
const InvariantCountMap* multiplicity;
};

struct record_dfs_order : default_dfs_visitor
Expand Down Expand Up @@ -163,12 +162,12 @@ namespace detail

// Generates map of invariant multiplicity from sorted invariants
template<typename ForwardIterator>
multiplicity_map multiplicities(ForwardIterator first, const ForwardIterator last)
InvariantCountMap multiplicities(ForwardIterator first, const ForwardIterator last)
{
typedef typename multiplicity_map::iterator invar_map_iter;
typedef typename InvariantCountMap::iterator invar_map_iter;

assert(std::is_sorted(first, last));
multiplicity_map invar_multiplicity;
InvariantCountMap invar_multiplicity;

if(first == last)
return invar_multiplicity;
Expand Down

0 comments on commit 760aafb

Please sign in to comment.