class_body
{ "{"
block_comment "/** Strategies to use for replacing an empty cluster. */"
enum_declaration (+24 nodes collapsed)
block_comment "/** Random generator for choosing initial centers. */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Random"
variable_declarator
identifier "random"
; ";"
block_comment "/** Selected strategy for empty clusters. */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "EmptyClusterStrategy"
variable_declarator
identifier "emptyStrategy"
; ";"
block_comment "/** Build a clusterer.\n * <p>\n * The default strateg"...
constructor_declaration (+27 nodes collapsed)
block_comment "/** Build a clusterer.\n * @param random random generator"...
constructor_declaration (+39 nodes collapsed)
block_comment "/**\n * Runs the K-means++ clustering algorithm.\n *\n "...
method_declaration (+419 nodes collapsed)
block_comment "/**\n * Adds the given points to the closest {@link Clust"...
method_declaration (+93 nodes collapsed)
block_comment "/**\n * Use K-means++ to choose the initial centers.\n "...
method_declaration
modifiers
private "private"
static "static"
type_parameters
< "<"
type_parameter
type_identifier "T"
type_bound
extends "extends"
generic_type
type_identifier "Clusterable"
type_arguments
< "<"
type_identifier "T"
> ">"
> ">"
generic_type
type_identifier "List"
type_arguments
< "<"
generic_type
type_identifier "Cluster"
type_arguments
< "<"
type_identifier "T"
> ">"
> ">"
identifier "chooseInitialCenters"
formal_parameters (+26 nodes collapsed)
block
{ "{"
local_variable_declaration (+25 nodes collapsed)
local_variable_declaration (+34 nodes collapsed)
line_comment "// Choose one center uniformly at random from among the data"...
local_variable_declaration (+29 nodes collapsed)
expression_statement (+21 nodes collapsed)
local_variable_declaration (+27 nodes collapsed)
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "resultSet"
. "."
identifier "size"
argument_list
( "("
) ")"
< "<"
identifier "k"
) ")"
block
{ "{"
line_comment "// For each data point x, compute D(x), the distance between"...
line_comment "// the nearest center that has already been chosen."
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "sum"
= "="
decimal_integer_literal "0"
; ";"
for_statement (+108 nodes collapsed)
line_comment "// Add one new data point as a center. Each point x is chose"...
line_comment "// probability proportional to D(x)2"
local_variable_declaration
modifiers
final "final"
floating_point_type
double "double"
variable_declarator
identifier "r"
= "="
binary_expression
method_invocation
identifier "random"
. "."
identifier "nextDouble"
argument_list
( "("
) ")"
* "*"
identifier "sum"
; ";"
for_statement (+82 nodes collapsed)
} "}"
return_statement
return "return"
identifier "resultSet"
; ";"
} "}"
block_comment "/**\n * Get a random point from the {@link Cluster} with "...
method_declaration (+268 nodes collapsed)
block_comment "/**\n * Get a random point from the {@link Cluster} with "...
method_declaration (+183 nodes collapsed)
block_comment "/**\n * Get the point farthest to its cluster center\n "...
method_declaration (+239 nodes collapsed)
block_comment "/**\n * Returns the nearest {@link Cluster} to the given "...
method_declaration (+143 nodes collapsed)
} "}"