Reputation: 313
I'm having trouble finding an example algorithm for Dijkstra's Minimum Spanning tree. I already know about Dijkstra's Single Shortest Path algorithm, but not the spanning tree. I have the simple explanation from class which is this:
For each edge, add it to the tree. If a cycle is detected, remove the heaviest edge.
I've scoured the Internet and I couldn't find an algorithm for it.
I might need to just code it for myself, but I thought I would ask if anyone has a good example.
Can anyone help?
Upvotes: 4
Views: 1479
Reputation: 17712
Here is a simple example:
The algorithm works as follows:
If you are marking the visiting nodes, circle detection is easy. To find the heaviest edge of a detected circle, you use a common search algorithm for circles.
Note: Picture (5) demonstrates why it is necessary to visit all edges, because (3) already contains a Spanning Tree. But it is not minimal.
Upvotes: 5