@HeadShot
how about using prims algorithm modify the algo such that for each iteration, check if the vertices belong the given sets. because we use adjacency list the time complexity would be O((v+e)logv).
Provided Answer :
64.3k questions
77.9k answers
244k comments
80.0k users