We present a theoretical study of the structural and electronic properties of graphene monolayer functionalized with boron and nitrogen atoms substituting carbon atoms. Our study is based on the ab initio calculations in the framework of the density functional theory. We calculate the binding energies of the functionalized systems, changes in the morphology caused by functionalization, and further the band gap energy as a function of the concentration of dopants. Moreover, we address the problem of possible clustering of dopants at a given concentration. We define the clustering parameter to quantify the dependence of the properties of the functionalized systems on the distribution of B/N atoms. We show that clustering of B/N atoms in graphene is energetically unfavorable in comparison to the homogenous distribution of dopants. For most of the structures, we observe a nonzero energy gap that is only slightly dependent on the concentration of the substituent atoms.