add prim algorithm lazy version implementation