I already know how to find the MST of a connected graph. This MST will have the least total weight and will connect all nodes in the graph.
However, this is a problem I have to deal with:
Given a weighted graph $G=\{V,E\}$ and one of its subgraph $H$. Find a subset $E'$ of $E$ such that
If we clear out every edge outside of $E'$, $H$ is still connected.
The total weight of $E'$ is lowest possible.
Note that $E'$ may contain edges that don't join two vertices in $H$, and any two vertices in $H$ may not necessarily be joined by an edge.
It is little different from the MST problem.
Firstly I thought that I only have to run MST algorithm in $H$, but I later found that this only work if any two vertices of $H$ is joined by an edge, not a series of edges.
How can I solve this problem? Thanks in advance.
a--1--b--3--c
toa--4--c
, and so the algorithm is not efficient anymore. $\endgroup$