File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
src/main/java/com/apporiented/algorithm/clustering Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,39 @@ public void toConsole(int indent)
196
196
child .toConsole (indent + 1 );
197
197
}
198
198
}
199
+
200
+ public String toNewickString (int indent )
201
+ {
202
+ String cdtString = "" ;
203
+ if (!isLeaf ()) cdtString +="(" ;
204
+
205
+ for (int i = 0 ; i < indent ; i ++) cdtString +=" " ;
206
+
207
+
208
+ if (isLeaf ()) {
209
+ cdtString +=getName ();
210
+ }
211
+
212
+ List <Cluster > children = getChildren ();
213
+
214
+ boolean firstChild = true ;
215
+ for (Cluster child : children )
216
+ {
217
+ cdtString +=child .toNewickString (indent );
218
+ String distanceString = distance .getDistance ().toString ().replace ("," , "." );
219
+ String weightString = distance .getWeight ().toString ().replace ("," , "." );
220
+ if (firstChild ) cdtString +=":" +distanceString +"," ;
221
+ else cdtString +=":" +weightString ;
222
+
223
+ firstChild =false ;
224
+ }
225
+
226
+ for (int i = 0 ; i < indent ; i ++) cdtString +=" " ;
227
+
228
+ if (!isLeaf ()) cdtString +=")" ;
229
+
230
+ return cdtString ;
231
+ }
199
232
200
233
public double getTotalDistance ()
201
234
{
You can’t perform that action at this time.
0 commit comments