We investigate the algorithmic problems of the homophyly phenomenon in networks. Given an undirected graph G = (V, E) and a vertex coloring c : V → {1, 2, · · · , k} of G, we say that a vertex v ∈ V is happy if v shares the same color with all its neighbors, and unhappy, otherwise, and that an edge e ∈ E is happy, if its two endpoints have the same color, and unhappy, otherwise. Supposing c is a partial vertex coloring of G, we define the Maximum Happy Vertices problem (MHV, for short) as to color all the remaining vertices such that the number of happy vertices is maximized, and the Maximum Happy Edges problem (MHE, for short) as to color all the remaining vertices such that the number of happy edges is maximized.Let k be the number of colors allowed in the problems. We show that both MHV and MHE can be solved in polynomial time if k = 2, and that both MHV and MHE are NP-hard if k ≥ 3. We devise a max{1/k, Ω(∆ −3 )}-approximation algorithm for the MHV problem, where ∆ is the maximum degree of vertices in the input graph, and a 1/2-approximation algorithm for the MHE problem. This is the first theoretical progress of these two natural and fundamental new problems.