doc/quicktour.dox
changeset 1610 893dacc1866c
parent 1580 a9e4208cf4e3
child 1640 9c7834ac5e64
equal deleted inserted replaced
17:2aa0089fa8fe 18:fe1f4fa2dfd8
   141 
   141 
   142 
   142 
   143 <li> If you want to design a network and want to minimize the total
   143 <li> If you want to design a network and want to minimize the total
   144 length of wires then you might be looking for a <b>minimum spanning
   144 length of wires then you might be looking for a <b>minimum spanning
   145 tree</b> in an undirected graph. This can be found using the Kruskal
   145 tree</b> in an undirected graph. This can be found using the Kruskal
   146 algorithm: the function \ref lemon::kruskal "LEMON Kruskal " does
   146 algorithm: the function \ref lemon::kruskal "LEMON Kruskal " does this
   147 this job for you.  After we had a graph \c g and a cost map \c
   147 job for you.  
   148 edge_cost_map , the following code fragment shows an example how to get weight of the minmum spanning tree (in this first example the costs are uniform; this is of course not the case in real life applications):
   148 
       
   149 First make a graph \c g and a cost map \c
       
   150 edge_cost_map, then make a bool edgemap \c tree_map or a vector \c
       
   151 tree_edge_vec for the algorithm output. After calling the function it
       
   152 gives back the weight of the minimum spanning tree and the \c tree_map or
       
   153 the \c tree_edge_vec contains the edges of the tree.
       
   154 
       
   155 If you want to store the edges in a bool edgemap, then use the
       
   156 function as follows:
   149 
   157 
   150 \dontinclude kruskal_demo.cc
   158 \dontinclude kruskal_demo.cc
   151 \skip std::cout 
   159 \skip Kruskal with boolmap; 
   152 \until kruskal
   160 \until  std::endl
   153 
   161 
   154 In the variable \c tree_map the function gives back an edge bool map, which contains the edges of the found tree.
   162 And if you rather use a vector instead of a bool map:
   155 
   163 
   156 If the costs are non-uniform, for example  the cost is given by \c
   164 \skip Kruskal with vector; 
   157 edge_cost_map_2 , or the edges of the tree  have to be given in a
   165 \until std::endl
   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 
   166 
   169 See the whole program in \ref kruskal_demo.cc.
   167 See the whole program in \ref kruskal_demo.cc.
   170 
   168 
   171 
   169 
   172 
   170