Medians in Median Graphs and Their Cube Complexes in Linear Time

Authors Laurine Bénéteau, Jérémie Chalopin, Victor Chepoi, Yann Vaxès

Thumbnail PDF


  • Filesize: 0.69 MB
  • 17 pages

Document Identifiers

Author Details

Laurine Bénéteau
  • Aix Marseille Univ, Université de Toulon, CNRS, LIS, Marseille, France
Jérémie Chalopin
  • Aix Marseille Univ, Université de Toulon, CNRS, LIS, Marseille, France
Victor Chepoi
  • Aix Marseille Univ, Université de Toulon, CNRS, LIS, Marseille, France
Yann Vaxès
  • Aix Marseille Univ, Université de Toulon, CNRS, LIS, Marseille, France


The authors are grateful to the anonymous referees for useful remarks that helped improving the presentation of this work.

Cite AsGet BibTex

Laurine Bénéteau, Jérémie Chalopin, Victor Chepoi, and Yann Vaxès. Medians in Median Graphs and Their Cube Complexes in Linear Time. In 47th International Colloquium on Automata, Languages, and Programming (ICALP 2020). Leibniz International Proceedings in Informatics (LIPIcs), Volume 168, pp. 10:1-10:17, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2020)


The median of a set of vertices P of a graph G is the set of all vertices x of G minimizing the sum of distances from x to all vertices of P. In this paper, we present a linear time algorithm to compute medians in median graphs, improving over the existing quadratic time algorithm. We also present a linear time algorithm to compute medians in the 𝓁₁-cube complexes associated with median graphs. Median graphs constitute the principal class of graphs investigated in metric graph theory and have a rich geometric and combinatorial structure. Our algorithm is based on the majority rule characterization of medians in median graphs and on a fast computation of parallelism classes of edges (Θ-classes or hyperplanes) via Lexicographic Breadth First Search (LexBFS). To prove the correctness of our algorithm, we show that any LexBFS ordering of the vertices of G satisfies the following fellow traveler property of independent interest: the parents of any two adjacent vertices of G are also adjacent.

Subject Classification

ACM Subject Classification
  • Mathematics of computing → Graph algorithms
  • Theory of computation → Computational geometry
  • Median Graph
  • CAT(0) Cube Complex
  • Median Problem
  • Linear Time Algorithm
  • LexBFS


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. A. Abboud, F. Grandoni, and V. Vassilevska Williams. Subcubic equivalences between graph centrality problems, APSP and diameter. In SODA 2015, pages 1681-1697. SIAM, 2015. URL:
  2. A. Abboud, V. Vassilevska Williams, and J. R. Wang. Approximation and fixed parameter subquadratic algorithms for radius and diameter in sparse graphs. In SODA 2016, pages 377-391. SIAM, 2016. URL:
  3. F. Ardila, M. Owen, and S. Sullivant. Geodesics in CAT(0) cubical complexes. Adv. in Appl. Math., 48(1):142-163, 2012. URL:
  4. S. P. Avann. Metric ternary distributive semi-lattices. Proc. Amer. Math. Soc., 12(3):407-414, 1961. Google Scholar
  5. M. Bacák. Computing medians and means in Hadamard spaces. SIAM Journal on Optimization, 24(3):1542-1566, 2014. URL:
  6. C. Bajaj. The algebraic degree of geometric optimization problems. Discrete Comput. Geom., 3(2):177-191, 1988. URL:
  7. K. Balakrishnan, B. Brešar, M. Changat, S. Klavžar, M. Kovše, and A. R. Subhamathi. Computing median and antimedian sets in median graphs. Algorithmica, 57(2):207-216, 2010. URL:
  8. H.-J. Bandelt and J.-P. Barthélémy. Medians in median graphs. Discrete Appl. Math., 8(2):131-142, 1984. URL:
  9. H.-J. Bandelt and V. Chepoi. Graphs with connected medians. SIAM J. Discrete Math., 15(2):268-282, 2002. URL:
  10. H.-J. Bandelt and V. Chepoi. Metric graph theory and geometry: a survey. In J. E. Goodman, J. Pach, and R. Pollack, editors, Surveys on Discrete and Computational Geometry: Twenty Years Later, volume 453 of Contemp. Math., pages 49-86. Amer. Math. Soc., Providence, RI, 2008. URL:
  11. H.-J. Bandelt, V. Chepoi, A. W. M. Dress, and J. H. Koolen. Combinatorics of lopsided sets. European J. Combin., 27(5):669-689, 2006. URL:
  12. H.-J. Bandelt, P. Forster, and A. Röhl. Median-joining networks for inferring intraspecific phylogenies. Mol. Biol. Evol., 16(1):37-48, 1999. URL:
  13. J.-P. Barthélemy and J. Constantin. Median graphs, parallelism and posets. Discrete Math., 111(1-3):49-63, 1993. Graph Theory and Combinatorics (Marseille-Luminy, 1990). URL:
  14. A. Bavelas. Communication patterns in task‐oriented groups. J. Acoust. Soc. Am., 22(6):725-730, 1950. URL:
  15. M. A. Beauchamp. An improved index of centrality. Behavorial Science, 10:161-163, 1965. Google Scholar
  16. L. Bénéteau, J. Chalopin, V. Chepoi, and Y. Vaxès. Medians in median graphs in linear time. arXiv preprint, 1907.10398, 2019. URL:
  17. L. J. Billera, S. P. Holmes, and K. Vogtmann. Geometry of the space of phylogenetic trees. Adv. in Appl. Math., 27(4):733-767, 2001. URL:
  18. G. Birkhoff and S. A. Kiss. A ternary operation in distributive lattices. Bull. Amer. Math. Soc., 53:749-752, 1947. URL:
  19. B. Brešar, J. Chalopin, V. Chepoi, T. Gologranc, and D. Osajda. Bucolic complexes. Adv. Math., 243:127-167, 2013. URL:
  20. J. Chalopin and V. Chepoi. A counterexample to Thiagarajan’s conjecture on regular event structures. In ICALP 2017, volume 80 of LIPIcs, pages 101:1-101:14. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2017. URL:
  21. J. Chalopin and V. Chepoi. 1-safe Petri nets and special cube complexes: Equivalence and applications. ACM Trans. Comput. Log., 20(3):17:1-17:49, 2019. URL:
  22. J. Chalopin, V. Chepoi, H. Hirai, and D. Osajda. Weakly modular graphs and nonpositive curvature. Mem. Amer. Math. Soc., 2017. To appear. Google Scholar
  23. V. Chepoi. On distance-preserving and domination elimination orderings. SIAM J. Discrete Math., 11(3):414-436, 1998. URL:
  24. V. Chepoi. Graphs of some CAT(0) complexes. Adv. in Appl. Math., 24(2):125-179, 2000. URL:
  25. V. Chepoi. Nice labeling problem for event structures: a counterexample. SIAM J. Comput., 41(4):715-727, 2012. URL:
  26. M. B. Cohen, Y. T. Lee, G. L. Miller, J. Pachocki, and A. Sidford. Geometric median in nearly linear time. In STOC 2016, pages 9-21. ACM, 2016. URL:
  27. T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. Introduction to Algorithms. MIT Press, 3rd edition, 2009. Google Scholar
  28. D. G. Corneil. Lexicographic breadth first search - A survey. In WG 2004, volume 3353 of Lecture Notes in Computer Science, pages 1-19. Springer, 2004. URL:
  29. D. Ž. Djoković. Distance-preserving subgraphs of hypercubes. J. Combin. Theory Ser. B, 14(3):263-267, 1973. URL:
  30. David Eppstein. Recognizing partial cubes in quadratic time. J. Graph Algorithms Appl., 15(2):269-293, 2011. URL:
  31. D. B. A. Epstein, J. W. Cannon, D. F. Holt, S. V. F. Levy, M. S. Paterson, and W. P. Thurston. Word Processing in Groups. Jones and Bartlett, Boston, MA, 1992. Google Scholar
  32. A. J. Goldman and C. J. Witzgall. A localization theorem for optimal facility placement. Transp. Sci., 4(4):406-409, 1970. URL:
  33. M. Gromov. Hyperbolic groups. In S. M. Gersten, editor, Essays in Group Theory, volume 8 of Math. Sci. Res. Inst. Publ., pages 75-263. Springer, New York, 1987. URL:
  34. J. Hagauer, W. Imrich, and S. Klavžar. Recognizing median graphs in subquadratic time. Theoret. Comput. Sci., 215(1-2):123-136, 1999. URL:
  35. S. L. Hakimi. Optimum locations of switching centers and the absolute centers and medians of a graph. Oper. Res., 12(3):450-459, 1964. URL:
  36. R. Hammack, W. Imrich, and S. Klavšar. Handbook of Product Graphs. Discrete Math. Appl. CRC press, Boca Raton, 2nd edition, 2011. URL:
  37. K. Hayashi. A polynomial time algorithm to compute geodesics in CAT(0) cubical complexes. Discrete Comput. Geom., (to appear), 2019. URL:
  38. C. Jordan. Sur les assemblages de lignes. J. Reine Angew. Math., 70:185-190, 1869. URL:
  39. J. G. Kemeny. Mathematics without numbers. Daedalus, 88(4):577-591, 1959. Google Scholar
  40. J. G. Kemeny and J. L. Snell. Mathematical models in the social sciences. MIT Press, Cambridge, Mass.-London, 1978. Reprint of the 1962 original. Google Scholar
  41. S. Klavžar and H. M. Mulder. Median graphs: Characterizations, location theory and related structures. J. Combin. Math. Combin. Comput., 30:103-127, 1999. Google Scholar
  42. D. E. Knuth. The Art of Computer Programming, Volume 4A, Fascicle 0: Introduction to Combinatorial Algorithms and Boolean Functions. Addison-Wesley, 2008. Google Scholar
  43. R. F. Love, J. G. Morris, and G. O. Wesolowsky. Facilities location: Models and methods, volume 7 of Publ. Oper. Res. Ser. North Holland, Amsterdam, 1988. Google Scholar
  44. F. R. McMorris, H. M. Mulder, and F. S. Roberts. The median procedure on median graphs. Discrete Appl. Math., 84(1-3):165-181, 1998. URL:
  45. H. M. Mulder. The Interval Function of a Graph, volume 132 of Mathematical Centre tracts. Mathematisch Centrum, Amsterdam, 1980. Google Scholar
  46. H. M. Mulder. The expansion procedure for graphs. In Contemporary methods in graph theory, pages 459-477. Bibliographisches Inst., Mannheim, 1990. Google Scholar
  47. H. M. Mulder and B. Novick. A tight axiomatization of the median procedure on median graphs. Discrete Appl. Math., 161(6):838-846, 2013. URL:
  48. H. M. Mulder and A. Schrijver. Median graphs and Helly hypergraphs. Discrete Math., 25(1):41-50, 1979. URL:
  49. L. Nebeský. Median graphs. Comment. Math. Univ. Carolinae, 12:317-325, 1971. Google Scholar
  50. M. Nielsen, G. D. Plotkin, and G. Winskel. Petri nets, event structures and domains, part I. Theoret. Comput. Sci., 13(1):85-108, 1981. URL:
  51. L. M. Ostresh. On the convergence of a class of iterative methods for solving the Weber location problem. Oper. Res., 26(4):597-609, 1978. URL:
  52. M. Owen and J. Scott Provan. A fast algorithm for computing geodesic distances in tree space. IEEE/ACM Trans. Comput. Biology Bioinform., 8(1):2-13, 2011. URL:
  53. C. Puppe and A. Slinko. Condorcet domains, median graphs and the single-crossing property. Econom. Theory, 67(1):285-318, 2019. URL:
  54. M. Roller. Poc sets, median algebras and group actions. Technical report, Univ. of Southampton, 1998. Google Scholar
  55. D. J. Rose, R. E. Tarjan, and G. S. Lueker. Algorithmic aspects of vertex elimination on graphs. SIAM J. Comput., 5(2):266-283, 1976. URL:
  56. B. Rozoy and P. S. Thiagarajan. Event structures and trace monoids. Theoret. Comput. Sci., 91(2):285-313, 1991. URL:
  57. G. Sabidussi. The centrality index of a graph. Psychometrika, 31(4):581-603, 1966. URL:
  58. M. Sageev. Ends of group pairs and non-positively curved cube complexes. Proc. London Math. Soc., s3-71(3):585-617, 1995. URL:
  59. M. Sageev. CAT(0) cube complexes and groups. In M. Bestvina, M. Sageev, and K. Vogtmann, editors, Geometric Group Theory, volume 21 of IAS/Park City Math. Ser., pages 6-53. Amer. Math. Soc., Inst. Adv. Study, 2012. URL:
  60. T. J. Schaefer. The complexity of satisfiability problems. In STOC 1978, pages 216-226. ACM, 1978. URL:
  61. P. S. Soltan and V. D. Chepoĭ. Solution of the Weber problem for discrete median metric spaces. Trudy Tbiliss. Mat. Inst. Razmadze Akad. Nauk Gruzin. SSR, 85:52-76, 1987. Google Scholar
  62. B. C. Tansel, R. L. Francis, and T. J. Lowe. Location on networks: A survey. Part I: The p-center and p-median problems. Manag. Sci., 29(4):482-497, 1983. URL:
  63. P. S. Thiagarajan. Regular event structures and finite Petri nets: A conjecture. In Formal and Natural Computing, volume 2300 of Lecture Notes in Comput. Sci., pages 244-256. Springer, 2002. URL:
  64. P. S. Thiagarajan and S. Yang. Rabin’s theorem in the concurrency setting: a conjecture. Theoret. Comput. Sci., 546:225-236, 2014. URL:
  65. M. van de Vel. Theory of Convex Structures, volume 50 of North-Holland Math. Library. North-Holland Publishing Co., 1993. Google Scholar
  66. E. Weiszfeld. Sur le point pour lequel la somme des distances de n points donnés est minimum. Tohoku Math. J., 43:355-386, 1937. (English transl.: Ann. Oper. Res., 167:7-41, 2009). Google Scholar
  67. D. R. Wood. On the maximum number of cliques in a graph. Graphs Combin., 23(3):337-352, 2007. URL:
  68. A. A. Zykov. On some properties of linear complexes. Mat. Sb. (N.S.), 24(66)(2):163-188, 1949. (English transl.: Amer. Math. Soc. Transl. 79, 1952). Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail