-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fast cofaces for insert_batch_vertices #971
Fix fast cofaces for insert_batch_vertices #971
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try a simple loop with if(!x.is_linked()) update(x);
, it will be less likely to go wrong.
std::vector<Vertex_handle> old_members(root_.members().size()); | ||
if constexpr (Options::link_nodes_by_label) { | ||
for (auto sh = root_.members().begin(); sh != root_.members().end(); sh++) | ||
old_members.emplace_back(sh->first); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You create old_members that contains n copies of 0 then append the rest to it? Did you mean to use reserve instead?
root_.members_.insert(boost::begin(verts), boost::end(verts)); | ||
if (dimension_ < 0 && !root_.members_.empty()) dimension_ = 0; | ||
for (auto sh = root_.members().begin(); sh != root_.members().end(); sh++) { | ||
if constexpr (Options::link_nodes_by_label) { | ||
if (std::find(old_members.begin(), old_members.end(), sh->first) == std::end(old_members)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, using std::find yields a quadratic cost, whereas both vectors are sorted so it would be possible to walk on both at the same time in linear time.
if (std::find(old_members.begin(), old_members.end(), sh->first) == std::end(old_members)) | ||
update_simplex_tree_after_node_insertion(sh); | ||
} else { | ||
update_simplex_tree_after_node_insertion(sh); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this appears in both branches, but with a test in one branch?
@@ -1321,6 +1321,12 @@ class Simplex_tree { | |||
return Dit_value_t(v, Node(&root_, filt)); }); | |||
root_.members_.insert(boost::begin(verts), boost::end(verts)); | |||
if (dimension_ < 0 && !root_.members_.empty()) dimension_ = 0; | |||
if constexpr (Options::link_nodes_by_label) { | |||
for (auto sh = root_.members().begin(); sh != root_.members().end(); sh++) { | |||
if (nodes_label_to_list_.find(sh->first) == nodes_label_to_list_.end()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or something like
if (nodes_label_to_list_.find(sh->first) == nodes_label_to_list_.end()) | |
if (!sh->second.list_max_vertex_hook_.is_linked()) |
?
Fix #970
To be discussed if storing information in a
std::vector<Vertex_handle>
is a good idea or not.