Lazy initialization for astar_search#431
Conversation
|
Even a small change in semantics would require changes to unit tests and documentation. If it doesn't break any existing unit tests, then we definitely need to add some that demonstrate the actual semantics. |
|
Thanks, I will add some unit tests for that, if we don't turn to the following way. We have another choice that won't change the semantics though. The reason why we need the color map initialized properly is that the underlying The only problem is that I am not sure whether all vertex types can be a key in |
|
Thanks for raising the design questions early before committing to one. I'll have to reacquaint myself with the existing design, but I feel there must be a way to specify a default value for a property map. |
|
I fixed a bug that crushed the tests. It should be fine now. I believe that a full initialization of the color map is necessary, if we are not to assume that it has Given that in most cases users pass in a properly defaulted color map or simply use the default color map, I think such a restriction is acceptable, as long as we make it clear in the doc. Additionally, I suggest that we should use a Do you think this is good? Or do you know a better way out? |
|
I think the key here is |
This PR fixes #356.
The current
astar_searchimplementation does initialization for all nodes in the graph, which is unnecessary and expensive given that in most cases we only access a small part of the graph. This PR ensures that only the nodes actually explored by the search are initialized, eliminating unnecessary overhead for unused nodes.This PR will add a new constraint on the input color map:
get(color_map, uninitialized_node)must returnwhite_color. The default value,std::vectorandstd::(unordered_)mapsatisfy this constraint, so it should be generally fine.