PRIM Algorithm
Prim's algorithm selects the minimum weighted edge between a vertex we have not yet
accepted, and a vertex that we have accepted. We use a bit array to
track the vertex numbers we've accepted, and simply search weight-sorted
edge list for the first entry where one vertex is accepted, and the
other is not. This is an O(V 2 ), where V is the number of
vertices. We could also contract the list after each accepted edge, but
that doesn't change the overall time complexity.