A single step of DBSCAN algorithm

Input: data set 𝒜 ⊂ (ℝ^n), core point (Subscript[c, p]), MinPts, ϵ-density ϵ(𝒜);
Output: cluster π, border points SSE, outliers SSN;
Submodules: Neps[], EPSILON[]

DBSCAN1[A_,xx_,MinPts_,eps_]:=Module[{B,S,SE,SN,PP},
SE={};
B=A;
S={xx}; SN={};PP={}; 
    Ne=Neps[A,xx,eps];
If[Length[Ne]>1&&Length[Ne]< MinPts,SE=Union[SE,Ne]];
    If[Length[Ne]< MinPts,SN=Union[SN,{xx}],
         S=Union[S,{xx}];
	NeB=Intersection[B,Ne];
        If[NeB≠{},PP=Union[PP,NeB];
	B=Complement[B,NeB]];
	Qu=Complement[Ne,S];
         While[Qu≠{},y=RandomChoice[Qu]; S=Union[S,{y}];
                   Ny=Neps[A,y,eps];
If[Length[Ny]>1&&Length[Ny]< MinPts,SE=Union[SE,Ny]];
                   If[Length[Ny]≥ MinPts,NeB=Intersection[B,Ny];
                        PP=Union[PP,NeB];
		      B=Complement[B,Ny];      
                        SN=Complement[SN,Ny]; 
                        Qu=Union[Qu,Complement[Ny,S]];
                      ];
                    Qu=Complement[Qu,{y}];
                 ];  
      ];
{PP,SE,SN,xx}
]