Start internal support for dynamic component-tree algorithms#294
Start internal support for dynamic component-tree algorithms#294wonderalexandre wants to merge 10 commits into
Conversation
Introduce a mutable internal backend for component-tree algorithms under higra/detail/hierarchy. The new DynamicComponentTree separates internal-node storage from proper-part ownership, provides structural mutation operations, and exposes lazy traversal ranges with debug-only fail-fast checks. This commit also adds unit tests covering construction, topology updates, proper-part moves, pruning, merging, traversals, and iterator invalidation.
Move the type to hg::detail::hierarchy. Remove altitude storage and altitude-dependent API from the tree. Replace graph/image construction with parent/tree constructors. Preserve stable node ids under pure topology updates. Update dynamic component-tree tests to the new API.
|
|
Next small step in the series: incremental attribute computation for The commit also adds concrete computers for area and bounding-box-derived attributes ( |
4204649 to
c4d691b
Compare
This detail-only backend updates the dual dynamic tree after subtree pruning.
c4d691b to
a605d8c
Compare
|
This commit contains the last internal backend piece needed for CASF. The next step will be the public C++ CASF interface, which I currently expect to expose a small API centered on:
namespace hg {
enum class ComponentTreeCasfAttribute {
area,
bounding_box_width,
bounding_box_height,
bounding_box_diagonal
};
template<typename altitude_t, typename graph_t>
class ComponentTreeCasf {
public:
ComponentTreeCasf(const graph_t &graph,
const array_1d<altitude_t> &image,
ComponentTreeCasfAttribute attribute = ComponentTreeCasfAttribute::area);
array_1d<altitude_t> filter(const std::vector<double> &thresholds);
auto exportMaxTree() const;
auto exportMinTree() const;
};
} // namespace hg
The export methods are expected to return the tree, altitude array, and attribute array for the current max-tree and min-tree, respectively, using Higra's usual static representation. |
|
Hi, I just have a few quick suggestions/questions (haven't read everything in detail).
|
|
Hi Benjamin, thank you for your suggestions. Below are my answers to your questions.
I agree that Since this class exposes So
I do not have a robust study yet for images beyond the For For So these results do not suggest extending the dense path to If reducing implementation complexity is preferable, I think it would also be reasonable to keep only the sparse bucket backend.
At first I kept them external to preserve the separation between topology and attached data, and to keep the incremental attribute logic reusable. But I agree that at the public API level it is better to own them inside the CASF class. In the current version (not committed yet), |
…ures, and expose child traversal helpers
Add a public C++ ComponentTreeCasf interface on over of the internal dynamic component-tree backend. The class supports area and bounding-box attributes, applies threshold sequences, reconstructs the filtered image, and exports the current min-tree and max-tree in Higra's static representation. Add tests for export correctness, supported attributes, empty thresholds, determinism across independent instances, naive area and bounding-box references, candidate selection, and stress behaviour.
Add the CASF benchmark implementation and its synthetic benchmark cases. CMake integration is left for a separate change.
|
At this point, I have finalized the C++ backend, including:
The next step is to implement the public Python interface: vertex_weights_out = connected_alternating_sequential_filter(
graph,
vertex_weights,
ATTR_TYPE,
thresholds
) |
Introduce one incremental attribute computer per dynamic tree in the CASF pipeline. Add explicit structural update hooks for proper-part moves and node removal, and switch attribute refreshes to selective marked recomputation instead of broader node recalculation. This commit establishes the correctness and performance foundation required by the Python public API layer.
Add the public connected_alternating_sequential_filter entry point, keep the low-level binding internal, and cover the new API with Python regression tests.
|
Small update: this PR now also includes the consolidation of the incremental CASF attribute-update contract in the internal backend, together with the first public Python entry point, At this point the implementation is stable on the covered cases, and the incremental update design already gives good practical performance. |
This PR follows the direction discussed in #293 and is being built incrementally.
Its goal is to introduce support for dynamic component-tree algorithms in Higra while keeping the low-level machinery internal until the design stabilizes.
The first commit adds an internal mutable component-tree backend under
higra/detail/hierarchy, with unit tests covering structural invariants, mutations, traversals, and iterator invalidation.Further commits in this PR will build on top of this backend.