Prim's algorithm uses heap instead of stack