Thanks in advance.
> Thanks in advance.
What is the question? And what is the c++-related question?
You are supposed to do your homework yourself, not ask others to do it
for you.
Enumerate all combinations of arcs in G into a sequence,
all_arc_combinations. Copy the combinations that are spanning trees
into a new sequence, all_spanning_trees. [1] Sort the spanning trees by
total weight, and return the least element of the sorted sequence.
Make sure you run your code to completion on a graph with at least a few
hundred nodes, so you'll know it's working.
[1] To tell whether a given combination of arcs is a spanning tree: A
priori (for efficiency), enumerate all combinations of nodes in G into a
set, all_node_combinations. Copy both nodes from each arc in the
arc-combination into a node-combination,
nodes_in_potential_spanning_tree. (Be careful to preserve duplicate
nodes, or else you might mis-identify a cyclic subgraph as a tree.) If
all_node_combinations contains nodes_in_potential_spanning_tree, the
arc-combinations is a spanning tree of G.
A complete answer can be found here:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2
Hope that helps.
Jeff_Schwab, is your algorithm efficient? Thanks!
No. The algorithm I posted is so remarkably inefficient that it is
completely impractical. That's sort of why I posted it; you haven't
made any apparent effort to even think about solutions to the problem.
This isn't really the right place to ask a pure CS question, anyway.
Good luck.
T' = T
> Thanks in advance.
Your welcome.
--
Erik Wikström