3#include "MorphologicalTree.hpp"
4#include "../utils/Altitude.hpp"
23template<AltitudeValue T>
28 std::size_t topologyMutationVersion_ = 0;
33 void validateAltitudeBufferShape()
const {
35 throw std::runtime_error(
"WeightedTreeView altitude size must match the dense internal-node domain.");
51 validateAltitudeBufferShape();
62 validateAltitudeBufferShape();
95 if (
nodeId < 0 ||
static_cast<std::size_t
>(
nodeId) >= altitude_.size()) {
96 throw std::invalid_argument(
"WeightedTreeView::getAltitude requires a valid internal NodeId.");
98 return altitude_[
static_cast<std::size_t
>(
nodeId)];
110 throw std::invalid_argument(
"WeightedTreeView::getNodeResidue requires a live internal NodeId.");
constexpr NodeId InvalidNode
Sentinel value used to denote an invalid node identifier.
Mutable morphological tree built directly on proper parts and dense node ids.
int getNumInternalNodeSlots() const
Returns the size of the dense internal-node id domain.
bool isAlive(NodeId nodeId) const
Tests whether a node slot currently represents a live node.
NodeId getNodeParent(NodeId nodeId) const
Returns the direct parent of nodeId.
Non-owning view pairing a topology with an external altitude span.
const MorphologicalTree & topology() const noexcept
Returns the borrowed tree topology.
T getAltitude(NodeId nodeId) const
Returns the altitude associated with an internal node id.
AltitudeDiff< T > getNodeResidue(NodeId nodeId) const
Returns the altitude difference between a live node and its parent.
WeightedTreeView(const MorphologicalTree &topology, const AltitudeBuffer< T > &altitude)
Builds a view over a caller-owned altitude buffer.
void requireTopologyUnchanged(const char *context) const
Throws if the borrowed topology changed since view construction.
WeightedTreeView(const MorphologicalTree &topology, AltitudeSpan< T > altitude)
Builds a view over caller-owned topology and altitude storage.
WeightedTreeView(const MorphologicalTree &, AltitudeBuffer< T > &&)=delete
Rejects temporary altitude buffers that would leave a dangling span.
AltitudeSpan< T > altitude() const noexcept
Returns the borrowed altitude span indexed by internal NodeId.
Owning result for one computed scalar attribute layout and buffer.