1. Procedure  X, V, P, g, , PLABELS = cPSC (Y, , , max, , CLABELS)
2. Y//dataset
3. initialize X//initialize at random only one particle
4. initialize V//initialize at random, max, max
5. initialize dist
6.
7. while stopping criterion is not met
8.  for to //for each input datum
9.   for to //for each particle
10.     dist ( ) = distance ( )
11.  end for
12.   I = index (min (dist))
13.    PLABELS = label ( , CLABELS ( ))//predicted label
14.   if distance ( ) < distance ( )
15.      =
16.   end if
17.   if distance ( ) < distance ( )
18.     
19.   end if
20.    = + φ 1 ( ) + ( ) + ( )
21.    max, max
22.    ( ) = ( ) + ( )
23.    0,1
24.  end for
25.  if mod ( )==0
26.   Eliminate particles from the swarm if necessary
27.   Test the stopping criterion
28.   Clone particles if necessary
29.  end if
30.  
31.  
32. end while
33. end procedure
Pseudocode 2: Constructive particle swarm clustering.