Linear Time Algorithms for Happy Vertex Coloring Problems for Trees

  • N. R. Aravind
  • Subrahmanyam Kalyanasundaram
  • Anjeneya Swami KareEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9843)


Given an undirected graph \(G = (V, E)\) with \(|V| = n\) and a vertex coloring, a vertex v is happy if v and all its neighbors have the same color. An edge is happy if its end vertices have the same color. Given a partial coloring of the vertices of the graph using k colors, the Maximum Happy Vertices (also called k-MHV) problem asks to color the remaining vertices such that the number of happy vertices is maximized. The Maximum Happy Edges (also called k-MHE) problem asks to color the remaining vertices such that the number of happy edges is maximized. For arbitrary graphs, k-MHV and k-MHE are NP-Hard for \(k \ge 3\). In this paper we study these problems for trees. For a fixed k we present linear time algorithms for both the problems. In general, for any k the proposed algorithms take \(O(nk \log k)\) and O(nk) time respectively.


Happy vertex Happy edge Graph coloring Coloring trees 



We thank the anonymous reviewers for their detailed reviews and suggestions.


  1. 1.
    Chopra, S., Rao, M.R.: On the multiway cut polyhedron. Networks 21(1), 51–89 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Dahlhaus, E., Johnson, D.S., Papadimitriou, C.H., Seymour, P.D., Yannakakis, M.: The complexity of multiway cuts (extended abstract). In: Proceedings of the Twenty-fourth Annual ACM Symposium on Theory of Computing, STOC 1992, pp. 241–251 (1992)Google Scholar
  3. 3.
    Deng, X., Lin, B., Zhang, C.: Multi-multiway cut problem on graphs of bounded branch width. In: Fellows, M., Tan, X., Zhu, B. (eds.) FAW-AAIM 2013. LNCS, vol. 7924, pp. 315–324. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  4. 4.
    Easley, D., Kleinberg, J.: Networks, Crowds, and Markets: Reasoning About a Highly Connected World. Cambridge University Press, New York (2010)CrossRefzbMATHGoogle Scholar
  5. 5.
    Even, S., Tarjan, R.E.: Network flow and testing graph connectivity. SIAM J. Comput. 4(4), 507–518 (1975)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Iwata, S., Fleischer, L., Fujishige, S.: A combinatorial strongly polynomial algorithm for minimizing submodular functions. J. ACM 48(4), 761–777 (2001)MathSciNetCrossRefzbMATHGoogle Scholar
  7. 7.
    Langberg, M., Rabani, Y., Swamy, C.: Approximation algorithms for graph homomorphism problems. In: Díaz, J., Jansen, K., Rolim, J.D.P., Zwick, U. (eds.) APPROX 2006 and RANDOM 2006. LNCS, vol. 4110, pp. 176–187. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  8. 8.
    Robertson, N., Seymour, P.: Graph minors. X. Obstructions to tree-decomposition. J. Comb. Theory, Ser. B 52(2), 153–190 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Zhang, P., Jiang, T., Li, A.: Improved approximation algorithms for the maximum happy vertices and edges problems. In: Xu, D., Du, D., Du, D. (eds.) COCOON 2015. LNCS, vol. 9198, pp. 159–170. Springer, Heidelberg (2015)CrossRefGoogle Scholar
  10. 10.
    Zhang, P., Li, A.: Algorithmic aspects of homophyly of networks. Theor. Comput. Sci. 593, 117–131 (2015)MathSciNetCrossRefzbMATHGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2016

Authors and Affiliations

  • N. R. Aravind
    • 1
  • Subrahmanyam Kalyanasundaram
    • 1
  • Anjeneya Swami Kare
    • 1
    Email author
  1. 1.Department of Computer Science and Engineering Indian Institute of TechnologyHyderabadIndia

Personalised recommendations