Prim’s Minimum Cost Spanning Tree algorithm