modified AdjacencyListGraph.prototype.forestPrim()