The 1-median problem (1MP) on undirected weighted graphs seeks to find a facility location minimizing the total weighted distance to all customer nodes. Although the 1MP can be solved exactly by computing the single-source shortest paths from each customer node, such approaches become computationally expensive on large-scale graphs with millions of nodes. In many real-world applications, such as recommendation systems based on large-scale knowledge graphs, the number of nodes (i.e., potential facility locations) is enormous, whereas the number of customer nodes is relatively small and spatially concentrated. In such cases, exhaustive graph exploration is not only inefficient but also unnecessary. Leveraging this observation, we propose three approximation algorithms that reduce computation by terminating Dijkstra's algorithm early. We provide theoretical analysis showing that one of the proposed algorithms guarantees an approximation ratio of 2, whereas the other two improve this ratio to 1.618. We demonstrate that the lower bound of the approximation ratio is 1.2 by presenting a specific instance. Moreover, we show that all proposed algorithms return optimal solutions when the number of customer nodes is less than or equal to three. Extensive experiments demonstrate that our algorithms significantly outperform baseline exact methods in runtime while maintaining near-optimal accuracy across all tested graph types. Notably, on grid graphs with 10 million nodes, our algorithms obtains all optimal solutions within 1 millisecond, whereas the baseline exact method requires over 70 seconds on average.
排序问题的两个最突出的解决方案是Quicksort和Mergesort。虽然快速排序平均速度非常快,但合并排序还提供了最坏情况的保证,但需要额外的空间来存储线性数量的元素。然而,最坏情况下的有效就地排序仍然是一个挑战:标准解决方案Heapsort存在缓存行为不佳的问题,并且对于缓存内实例来说也不是太快。在这项工作中,我们提出了中位数的中位数QuickMergesort(MoMQuickMergesort),QuickMergesort的一个新的变种,它结合了Quicksort与Mergesort允许后者实施到位。我们的新变体应用中位数的中位数算法选择枢轴,以规避二次最坏的情况。事实上,我们表明,它最多使用$n \log n + 1.6n$比较$n$足够大。我们通过实验证实了理论估计,并表明新算法的性能优于堆排序,并且仅比Introsort(stdlibc++的std::sort实现)慢10%左右,这对最坏情况的保证相当差。我们还模拟了最坏的情况,它只比平均情况慢10%左右。特别是,新算法是一个自然的候选人,以取代堆排序作为一个最坏情况下的塞子在Introsort。