
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 $\ell_1$-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, due to their bijections with CAT(0) cube complexes and domains of event structures. 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. Using the fast computation of the $��$-classes, we also compute the Wiener index (total distance) of $G$ in linear time and the distance matrix in optimal quadratic time.
FOS: Computer and information sciences, Median Problem, Discrete Mathematics (cs.DM), CAT(0) Cube Complex, Linear Time Algorithm, 004, 510, Median Graph, Computer Science - Data Structures and Algorithms, LexBFS, FOS: Mathematics, Mathematics - Combinatorics, Data Structures and Algorithms (cs.DS), Combinatorics (math.CO), Computer Science - Discrete Mathematics, ddc: ddc:004
FOS: Computer and information sciences, Median Problem, Discrete Mathematics (cs.DM), CAT(0) Cube Complex, Linear Time Algorithm, 004, 510, Median Graph, Computer Science - Data Structures and Algorithms, LexBFS, FOS: Mathematics, Mathematics - Combinatorics, Data Structures and Algorithms (cs.DS), Combinatorics (math.CO), Computer Science - Discrete Mathematics, ddc: ddc:004
| selected citations These citations are derived from selected sources. This is an alternative to the "Influence" indicator, which also reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically). | 8 | |
| popularity This indicator reflects the "current" impact/attention (the "hype") of an article in the research community at large, based on the underlying citation network. | Top 10% | |
| influence This indicator reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically). | Average | |
| impulse This indicator reflects the initial momentum of an article directly after its publication, based on the underlying citation network. | Top 10% |
