diff --git a/core/base/mergeTreeClustering/MergeTreeBase.h b/core/base/mergeTreeClustering/MergeTreeBase.h index 2e49b35000..64a1b0b49f 100644 --- a/core/base/mergeTreeClustering/MergeTreeBase.h +++ b/core/base/mergeTreeClustering/MergeTreeBase.h @@ -40,6 +40,7 @@ namespace ttk { int wassersteinPower_ = 2; bool normalizedWasserstein_ = true; bool keepSubtree_ = false; + double nonMatchingWeight_ = 1.0; bool distanceSquaredRoot_ = true; // squared root bool useFullMerge_ = false; @@ -122,6 +123,10 @@ namespace ttk { keepSubtree_ = keepSubtree; } + void setNonMatchingWeight(double weight) { + nonMatchingWeight_ = weight; + } + void setBarycenterMergeTree(bool imt) { barycenterMergeTree_ = imt; } @@ -1128,6 +1133,7 @@ namespace ttk { // Divide cost by two if not branch decomposition and not merged /*if(! branchDecomposition_ and ! tree->isNodeMerged(nodeId)) cost /= 2;*/ + cost *= nonMatchingWeight_; return cost; } diff --git a/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp b/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp index aa6b19949a..d0384c9dbe 100644 --- a/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp +++ b/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp @@ -265,6 +265,7 @@ int ttkMergeTreeClustering::runCompute( mergeTreeDistance.setDeleteMultiPersPairs(DeleteMultiPersPairs); mergeTreeDistance.setEpsilon1UseFarthestSaddle(Epsilon1UseFarthestSaddle); mergeTreeDistance.setIsPersistenceDiagram(IsPersistenceDiagram); + mergeTreeDistance.setNonMatchingWeight(NonMatchingWeight); mergeTreeDistance.setThreadNumber(this->threadNumber_); mergeTreeDistance.setDebugLevel(this->debugLevel_); diff --git a/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.h b/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.h index 10378862d4..6496db0504 100644 --- a/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.h +++ b/core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.h @@ -96,6 +96,7 @@ class TTKMERGETREECLUSTERING_EXPORT ttkMergeTreeClustering int pathMetric = 0; int branchMetric = 0; int baseModule = 0; + double NonMatchingWeight = 1.0; // Output Options bool OutputTrees = true; @@ -341,6 +342,13 @@ class TTKMERGETREECLUSTERING_EXPORT ttkMergeTreeClustering Modified(); } + void SetNonMatchingWeight(double weight) { + NonMatchingWeight = weight; + Modified(); + resetDataVisualization(); + } + vtkGetMacro(NonMatchingWeight, double); + // Output Options vtkSetMacro(BarycenterPositionAlpha, bool); vtkGetMacro(BarycenterPositionAlpha, bool); diff --git a/paraview/xmls/MergeTreeClustering.xml b/paraview/xmls/MergeTreeClustering.xml index 2057ad241a..b9c688e1ef 100644 --- a/paraview/xmls/MergeTreeClustering.xml +++ b/paraview/xmls/MergeTreeClustering.xml @@ -305,6 +305,24 @@ Online examples: + + + + + + Weight given to the insertion and deletion costs in the distance computation. + + + ${MERGE_TREE_PREPROCESS_WIDGETS}