Construct a minimum spanning tree covering a specific subset of the vertices

前端 未结 3 1047
萌比男神i
萌比男神i 2020-12-13 00:22

I have an undirected, positive-edge-weight graph (V,E) for which I want a minimum spanning tree covering a subset k of vertices V (the Steiner tre

3条回答
  •  有刺的猬
    2020-12-13 00:50

    Run Prim's algorithm on the restricted graph (k, E') where E' = {(x, y) ∈ V : xk and yk}). Constructing that graph takes O(|E|).

提交回复
热议问题