No. Consider a graph that looks like a square, three edges cost 1
, and the remaining one costs 2
. The MST for this graph has cost 3
, but if you start your Dijkstra algorithm on a vertex that contains the expensive edge, that one will be taken as it is the shortest path to the connected node.
Cool ASCII visualization:
1
A------B
| |
1| |1
| |
C------D
2
If you start Dijkstra at C
, CD
is the shortest path from C
to D
but it cannot be contained in the MST.