This paper proposes a novel Modularized Nonnegative Matrix Factorization (M-NMF) model for network embedding that preserves both the microscopic structure (first- and second-order proximities) and mesoscopic community structure. The model incorporates the community structure into network embedding by jointly optimizing a nonnegative matrix factorization (NMF) based representation learning model and a modularity based community detection model in a unified framework. The model uses the consensus relationship between node representations and community structure to ensure that the learned representations preserve both the microscopic and community structures. Efficient updating rules are provided to infer the parameters of the model, along with correctness and convergence guarantees. Extensive experimental results on various real-world networks show that the proposed method outperforms state-of-the-art methods in node clustering and classification tasks. The model is also shown to be robust to parameter settings and the number of communities. The M-NMF model is effective in preserving both the microscopic and mesoscopic structures of networks, leading to more discriminative node representations. The model is evaluated on nine real networks and two network analysis tasks, demonstrating its effectiveness and robustness to model parameters. The model's performance is validated through extensive experiments and parameter analysis, showing that it outperforms other methods in node clustering and classification tasks. The model's convergence is also demonstrated through empirical analysis.This paper proposes a novel Modularized Nonnegative Matrix Factorization (M-NMF) model for network embedding that preserves both the microscopic structure (first- and second-order proximities) and mesoscopic community structure. The model incorporates the community structure into network embedding by jointly optimizing a nonnegative matrix factorization (NMF) based representation learning model and a modularity based community detection model in a unified framework. The model uses the consensus relationship between node representations and community structure to ensure that the learned representations preserve both the microscopic and community structures. Efficient updating rules are provided to infer the parameters of the model, along with correctness and convergence guarantees. Extensive experimental results on various real-world networks show that the proposed method outperforms state-of-the-art methods in node clustering and classification tasks. The model is also shown to be robust to parameter settings and the number of communities. The M-NMF model is effective in preserving both the microscopic and mesoscopic structures of networks, leading to more discriminative node representations. The model is evaluated on nine real networks and two network analysis tasks, demonstrating its effectiveness and robustness to model parameters. The model's performance is validated through extensive experiments and parameter analysis, showing that it outperforms other methods in node clustering and classification tasks. The model's convergence is also demonstrated through empirical analysis.