Isomorphism: Remove invariant contiguous range requirement#349
Conversation
|
Thanks for finishing this off! I might not be able to merge this until I fix the modernization issues that are causing our CI builds to fail. |
|
Oh, I thought that was me! No worries, I'm not in a hurry. |
|
Btw, we generally put the |
|
Can you merge |
5aa3d3b to
0464a57
Compare
|
I've forgotten where I was up to on this. :\ |
include/boost/graph/isomorphism.hpp
Outdated
| typedef typename Invariant1::result_type invar1_value; | ||
| typedef typename Invariant2::result_type invar2_value; | ||
| typedef typename Invariant1::result_type invariant_t; | ||
| typedef unordered_map< invariant_t, size_type > multiplicity_map; |
There was a problem hiding this comment.
It's important to let the user choose this type, so it needs to become a template parameter with a default value, like:
template < typename Graph1, typename Graph2, typename IsoMapping,
typename Invariant1, typename Invariant2, typename IndexMap1,
typename IndexMap2, typename InvariantCountMap = boost::unordered_flat_map< typename Invariant1::result_type, typename graph_traits< Graph1 >::vertices_size_type > >
Note that I've used boost::unordered_flat_map, which generally blows boost::unordered_map out of the water. (See here.)
There was a problem hiding this comment.
This is the only change left, then it's good to merge!
|
@jan-grimo , do you still have time to finish this off? I'd like to get it done before I merge |
760aafb to
b1ce4d6
Compare
|
I don't understand what's wrong 🙈 |
Strange, I don't know either. It may simply be that MSVC 14.0 is broken and I should take it out of the list. |
|
I removed it, so please merge develop into your branch and try again. |
Invariant contiguous range requirement removal - Vertex invariants for use in isomorphism algorithm must no longer have low upper bounds due to a hidden allocation linear in the maximum encountered vertex invariant. - Vertex invariants must no longer be convertible to `size_t`, but can be any comparable and hashable types - Build `unordered_map`-backed invariant multiplicity map efficiently from sorted vertex invariants
Avoid requiring invariant default-constructibility - Refactor concept checking with boost type_traits
b1ce4d6 to
044c7d6
Compare
|
Thanks for persisting with it, @jan-grimo ! |
|
You're welcome! Thank you for helping me get it over the line @jeremy-murphy |
|
Are you able to quantify how the space efficiency changed? I mean, previously it was allocating a sequence container (vector) of size I just want to accurately document the change in the release notes. Thanks! |
|
Space efficiency hasn't changed for the general use case without custom invariants or the already feasible approaches with custom invariants that output a contiguous or small output domain on 0..N. But now arbitrary vertex invariants over vertex properties are feasible without incurring enormous memory allocations. I had a use case with many vertex properties where I had set up a perfect hash function as an invariant, but then ran into the hidden memory allocation, which in the case of a 64-bit hash caused an OOM abort. I circumvented it by mapping the hashes for both graphs from their distribution over 0..2^64-1 down onto 0..N (where N is the number of unique hashes for the two graphs being compared). But I was irked by the hidden allocation and the odd invariant functor interface and thought it could be easier, hence the MRs that came from #203. |
|
Cool, thanks. |
Fix multiplicity value comparison - Replacement of at() in 8f3139b as part of boostorg#349 was faulty: Iterator deref is a (key, value) pair, but only the value should be compared
Fix multiplicity value comparison - Replacement of at() in 8f3139b as part of boostorg#349 was faulty: Iterator deref is a (key, value) pair, but only the value should be compared
Completes isomorphism invariant improvements outlined in #203
Invariant contiguous range requirement removal
size_t, but can be any comparable and hashable typesunordered_map-backed invariant multiplicity map efficiently from sorted vertex invariants