Added Prim MST implementation from Castflow code.