kruskal:minimum spanning tree. how to do?

M

_mario.lat

kruskal:minimum spanning tree. how to do?
I'd like to find the minimum spanning tree with kruskal algorithm.
There is a code (in C++) written?
which contenitor do you suggest (Vector, set, ...)?
How can I do?
Thank you in advance, Mario.
 
D

Dietmar Kuehl

_mario.lat said:
kruskal:minimum spanning tree. how to do?

Just do it! Kruskals algorithms is actually pretty simple. You just get a
list of all edges with their weights and 'std::sort()' them (especially for
graphs with high densities it is heuristically often benefitial to only
partially sort the edges and get an order on the next 10% or so of the
edges: typically you get a spanning tree out of only a fraction of all
edges). The interesting thing is only the union/find data structure which
is also extremely simple: just store a pointer to the representing node
with each node, initialize it to '0' and update it at the correct strategic
points.
There is a code (in C++) written?

The Boost Graph Library (see <http://www.boost.org/>) provides a generic
implementation, i.e. one operating on arbitrary representations of the
graph. You just need to supply the entities abstracting the data structure,
i.e. some iterators and property maps - or use one of the sample graph data
structures also provided.
which contenitor do you suggest (Vector, set, ...)?

(s/contenitor/container/, I guess) Who cares? Use whatever is appropriate
to your situation. The idea of generic algorithms is to operate on any
reasonable representation and this certainly applies to the BGL
implementation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top