Fix: npe if affinityPropagation is called without seed

parent 1c45718a
......@@ -29,7 +29,7 @@ public class AffinityPropagationAlgorithm implements ClusteringAlgorithm {
RealMatrix mat = new Array2DRowRealMatrix(clusteringInput.getAdjacencyMatrix());
AffinityPropagation clustering;
if(args.length == 2 && args[0] == AffinityPropagationBuilder.AffinityPropagationParameters.SEED){
if (args != null && args.length == 2 && args[0] == AffinityPropagationBuilder.AffinityPropagationParameters.SEED) {
clustering = new AffinityPropagationParameters().setSeed(new Random((Long) args[1])).fitNewModel(mat);
}else{
clustering = new AffinityPropagationParameters().fitNewModel(mat);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment