Is it possible to quickly find a common MST between two graphs?

Правка en6, от shsh, 2026-04-23 22:10:08

Given two weighted, undirected graphs on $$$n$$$ nodes $$$G_1$$$ and $$$G_2$$$, is it possible to efficiently find a tree on these $$$n$$$ nodes that is an MST of both $$$G_1$$$ and $$$G_2$$$?

UPD: Building on chromate00's comments, it turns out that we can simply construct a new graph $$$G$$$ where the weight of each edge is the sum of that edge's weights in $$$G_1$$$ and $$$G_2$$$, and find the MST on this graph (in chromate00's notation here, this means we can actually just always set $$$C = 1$$$). If a common MST exists, we can guarantee that this algorithm will always find it.

Proof. Let $$$W_1$$$, $$$W_2$$$, and $$$W$$$ denote the total weight of MSTs for $$$G_1$$$, $$$G_2$$$, and $$$G$$$ respectively.

  • Note that $$$W_1 + W_2 \leq W$$$.
  • Also note that the weight of any spanning tree in $$$G_1$$$ is at least $$$W_1$$$, and similarly for $$$G_2$$$. Therefore, if we find a spanning tree $$$T$$$ with exactly $$$W = W_1 + W_2$$$, it must follow that $$$T$$$ has exactly weight $$$W_1$$$ in $$$G_1$$$ and exactly weight $$$W_2$$$ in $$$G_2$$$, since these are the minimum possible.

Here's a problem that uses this idea: 1054G - New Road Network

Hint
Solution

(This writeup is also available on my personal blog!)

Теги mst, spanning tree, tree

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en6 Английский shsh 2026-04-23 22:10:08 2 Tiny change: 'tively. \n- Note t' -> 'tively. \n\n- Note t'
en5 Английский shsh 2026-04-23 09:32:59 192
en4 Английский shsh 2026-04-23 09:31:03 1913 Tiny change: ' possible.' -> ' possible.\n\nHere's a problem that uses this idea: [problem:1054G]'
en3 Английский shsh 2025-07-20 09:35:23 8
en2 Английский shsh 2025-07-20 09:34:43 1 Tiny change: ' both $G_1 and $G_2$' -> ' both $G_1$ and $G_2$'
en1 Английский shsh 2025-07-20 09:34:01 222 Initial revision (published)