Skip to content

Commit

Permalink
Better shrinking.
Browse files Browse the repository at this point in the history
  • Loading branch information
antononcube committed Jan 29, 2017
1 parent 5b1ccfa commit 9f086ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Java/TriesWithFrequencies/src/TrieFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,10 @@ protected static Trie shrinkRec(Trie tr, String delimiter, double threshold, int
List<Trie> arr = new ArrayList<Trie>(tr.getChildren().values());
boolean shrinkQ = false;

if (threshold < 0) {
shrinkQ = tr.getValue().equals( arr.get(0).getValue() );
if (threshold < 0 && tr.getValue() >= 1.0 && arr.get(0).getValue() >= 1.0 ) {
shrinkQ = tr.getValue().equals(arr.get(0).getValue());
} else if (threshold < 0 ) {
shrinkQ = arr.get(0).getValue() == 1.0 ;
} else {
shrinkQ = arr.get(0).getValue() >= threshold;
}
Expand Down

0 comments on commit 9f086ff

Please sign in to comment.