1. procedure X, V, P, g, , PLABELS = PSC (Y, max, , , CLABELS)
2. Y//dataset
3. initialize X//initialize at random each particle 0,1
4. initialize //initialize at random each 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.    = 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 ( ) + 2 ( ) + 3 ( )
21.    max, max
22.    ( ) = ( ) + ( )
23.    0, 1
24.  end for
25.  for to
26.   if ( = win )//particles did not
27.     = ω * ( ) + φ 4 (x most_win ( ))
28.     max, max
29.     ( ) = ( ) +
30.   end if
31.  end for
32.  
33.  
34.  Test the stopping criterion
35. end while
36. end procedure
Pseudocode 1: Particle Swarm Clustering (PSC).