By using Pólya's theorem of enumeration and de Bruijn's generalization of Pólya's theorem, we obtain the numbers of various weak equivalence classes of functions in R D relative to permutation groups G and H where R D is the set of all functions from a finite set D to a finite set R , G acts on D and H acts on R . We present an algorithm for obtaining the equivalence classes of functions counted in de Bruijn's theorem, i.e., to determine which functions belong to the same equivalence class. We also use our algorithm to construct the family of non-isomorphic f m -graphs relative to a given group.