# Thread: Question about Prim's Algorithm

1. ## Question about Prim's Algorithm

Let's say from a vertex there are two surrounding vertices. But they both have the same weight (or cost) as each other. Which do you choose?
For example...

On step C, the edge going from B to E has the same weight as the edge going from A to H. Why did this example choose to go from B to C? Is there any reason? Or do we just pick one or the other in this situation?

2. ## Re: Question about Prim's Algorithm

"Choose"? What criteria are you using to choose one of these over the others?

3. ## Re: Question about Prim's Algorithm

the pseudocode I just looked at chooses the first min weight edge it finds during it's search at each step

one could modify that to create a list of all min weight edges available per step and randomly choose one.

If you wanted to be more clever you could do an n-step search that looks for the min weight path of n edges.

n in this case should be very small in relation to the overall size of the graph.

4. ## Re: Question about Prim's Algorithm

Do you see the edge that connects A to H? And another one that connects from B to C. They both have the same edge weight of 8. Why did that picture connect B to C rather than A to H on the third step?

5. ## Re: Question about Prim's Algorithm

Originally Posted by HallsofIvy
"Choose"? What criteria are you using to choose one of these over the others?
Do you see the edge that connects A to H? And another one that connects from B to C. They both have the same edge weight of 8. Why did that picture connect B to C rather than A to H on the third step?

### ques for prim's algorithm

Click on a term to search for related topics.