139 example you can run it step by step and gain full control of the |
139 example you can run it step by step and gain full control of the |
140 execution. For a detailed description, see the documentation of the |
140 execution. For a detailed description, see the documentation of the |
141 \ref lemon::Dijkstra "LEMON Dijkstra class". |
141 \ref lemon::Dijkstra "LEMON Dijkstra class". |
142 |
142 |
143 |
143 |
144 <li> If you want to design a network and want to minimize the total length |
144 <li> If you want to design a network and want to minimize the total |
145 of wires then you might be looking for a <b>minimum spanning tree</b> in |
145 length of wires then you might be looking for a <b>minimum spanning |
146 an undirected graph. This can be found using the Kruskal algorithm: the |
146 tree</b> in an undirected graph. This can be found using the Kruskal |
147 function \ref lemon::kruskal "LEMON Kruskal ..." does this job for you. |
147 algorithm: the function \ref lemon::kruskal "LEMON Kruskal " does |
148 The following code fragment shows an example: |
148 this job for you. After we had a graph \c g and a cost map \c |
149 |
149 edge_cost_map , the following code fragment shows an example how to get weight of the minmum spanning tree, if the costs are uniform: |
150 Ide Zsuzska fog irni! |
150 |
|
151 \dontinclude kruskal_demo.cc |
|
152 \skip std::cout |
|
153 \until kruskal |
|
154 |
|
155 It gives back a edge bool map, which contains the edges of the tree. |
|
156 If the costs are non-uniform, for example the cost is given by \c |
|
157 edge_cost_map_2 , or the edges of the tree are have to be given in a |
|
158 vector, then we can give to the kruskal a vector \c tree_edge_vec , instead of |
|
159 an edge bool map: |
|
160 |
|
161 \skip edge_cost_map_2 |
|
162 \until edge_cost_map_2, std::back_inserter |
|
163 |
|
164 And finally the next fragment shows how to use the functions \c makeKruskalMapInput and \c makeKruskalSequenceOutPut: |
|
165 |
|
166 \skip makeKruskalSequenceOutput |
|
167 \until tree_edge_vec |
|
168 |
|
169 See the whole program in \ref kruskal_demo.cc. |
|
170 |
|
171 |
151 |
172 |
152 <li>Many problems in network optimization can be formalized by means |
173 <li>Many problems in network optimization can be formalized by means |
153 of a linear programming problem (LP problem, for short). In our |
174 of a linear programming problem (LP problem, for short). In our |
154 library we decided not to write an LP solver, since such packages are |
175 library we decided not to write an LP solver, since such packages are |
155 available in the commercial world just as well as in the open source |
176 available in the commercial world just as well as in the open source |