Skip to content

Commit

Permalink
Merge pull request #977 from MatPont/mt_dist_weight_cost
Browse files Browse the repository at this point in the history
[MergeTreeDistance] non-matching weight
  • Loading branch information
julien-tierny authored Oct 5, 2023
2 parents 798fb82 + 5b3bf5c commit b9fdd19
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/base/mergeTreeClustering/MergeTreeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,6 +123,10 @@ namespace ttk {
keepSubtree_ = keepSubtree;
}

void setNonMatchingWeight(double weight) {
nonMatchingWeight_ = weight;
}

void setBarycenterMergeTree(bool imt) {
barycenterMergeTree_ = imt;
}
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);

Expand Down
8 changes: 8 additions & 0 deletions core/vtk/ttkMergeTreeClustering/ttkMergeTreeClustering.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions paraview/xmls/MergeTreeClustering.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,24 @@ Online examples:
<DoubleRangeDomain name="range" min="0" max="1" />
</DoubleVectorProperty>

<DoubleVectorProperty
name="NonMatchingWeight"
command="SetNonMatchingWeight"
label="Non Matching Weight"
number_of_elements="1"
default_values="1"
panel_visibility="advanced">
<Hints>
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="ComputeBarycenter"
value="0" />
</Hints>
<Documentation>
Weight given to the insertion and deletion costs in the distance computation.
</Documentation>
</DoubleVectorProperty>

<!-- Input options -->
<!-- TODO <IntVectorProperty
name="UseMinMaxPair"
Expand Down Expand Up @@ -461,6 +479,7 @@ Online examples:
<Property name="Deterministic"/>
<Property name="Alpha"/>
<Property name="JoinSplitMixtureCoefficient"/>
<Property name="NonMatchingWeight"/>
<!-- <Property name="UseMinMaxPair"/> -->
</PropertyGroup>
${MERGE_TREE_PREPROCESS_WIDGETS}
Expand Down

0 comments on commit b9fdd19

Please sign in to comment.