Add some checks, add Prim's algo.