SUBROUTINE EQUICL(NC,N,LISTJK,M) ! equivalence classes * Elements are numbered 1 ... N and result is in array NC(N). * Input is LISTJK(2,M) with M pairs of equivalent elements, * for example: LISTJK(1,7)=1 LISTJK(2,7)=3 means: * elements 1 and 3 are equivalent. * Result is in array NC(N): NC(I) is the equivalence class number * for element I, and all equivalent elements will have the same * equivalence class number. INTEGER NC(N),LISTJK(2,M),J,K,L,M,N DO K=1,N NC(K)=K ! initialize classes END DO DO L=1,M ! loop on pairs J=LISTJK(1,L) 10 IF(NC(J).NE.J) THEN J=NC(J) GOTO 10 END IF K=LISTJK(2,L) 20 IF(NC(K).NE.K) THEN K=NC(K) GOTO 20 END IF IF(J.NE.K) NC(J)=K END DO DO J=1,N 30 IF(NC(J).NE.NC(NC(J))) THEN NC(J)=NC(NC(J)) GOTO 30 END IF END DO END