Add prim algorithm