This group contains the algorithms for finding minimum cost spanning trees and arborescences [6]. 
|  | 
| template<typename Graph , typename In , typename Out > | 
| Value | kruskal (const Graph &g, const In &in, Out &out) | 
|  | Kruskal's algorithm for finding a minimum cost spanning tree of a graph.  More... 
 | 
|  | 
| template<typename Digraph , typename CostMap , typename ArborescenceMap > | 
| CostMap::Value | minCostArborescence (const Digraph &digraph, const CostMap &cost, typename Digraph::Node source, ArborescenceMap &arborescence) | 
|  | Function type interface for MinCostArborescence algorithm.  More... 
 | 
|  | 
      
        
          | Value lemon::kruskal | ( | const Graph & | g, | 
        
          |  |  | const In & | in, | 
        
          |  |  | Out & | out | 
        
          |  | ) |  |  | 
      
 
This function runs Kruskal's algorithm to find a minimum cost spanning tree of a graph. Due to some C++ hacking, it accepts various input and output types.
- Parameters
- 
  
    | g | The graph the algorithm runs on. It can be either directed or undirected. If the graph is directed, the algorithm consider it to be undirected by disregarding the direction of the arcs. |  | in | This object is used to describe the arc/edge costs. It can be one of the following choices. 
An STL compatible 'Forward Container' with std::pair<GR::Arc,C>orstd::pair<GR::Edge,C>as itsvalue_type, whereCis the type of the costs. The pairs indicates the arcs/edges along with the assigned cost. They must be in a cost-ascending order.Any readable arc/edge map. The values of the map indicate the arc/edge costs. |  
 
- Return values
- 
  
    | out | Here we also have a choice. 
It can be a writable arc/edge map with boolvalue type. After running the algorithm it will contain the found minimum cost spanning tree: the value of an arc/edge will be set totrueif it belongs to the tree, otherwise it will be set tofalse. The value of each arc/edge will be set exactly once.It can also be an iteraror of an STL Container with GR::ArcorGR::Edgeas itsvalue_type. The algorithm copies the elements of the found tree into this sequence. For example, if we know that the spanning tree of the graphghas say 53 arcs, then we can put its arcs into an STL vectortreewith a code like this.Or if we don't know in advance the size of the tree, we can write this.*  std::vector<Arc> tree (53);* 
*  kruskal (g,cost,std::back_inserter(tree));*  |  
 
- Returns
- The total cost of the found spanning tree.
- Note
- If the input graph is not (weakly) connected, a spanning forest is calculated instead of a spanning tree. 
 
 
      
        
          | CostMap::Value lemon::minCostArborescence | ( | const Digraph & | digraph, | 
        
          |  |  | const CostMap & | cost, | 
        
          |  |  | typename Digraph::Node | source, | 
        
          |  |  | ArborescenceMap & | arborescence | 
        
          |  | ) |  |  | 
      
 
Function type interface for MinCostArborescence algorithm. 
- Parameters
- 
  
    | digraph | The digraph the algorithm runs on. |  | cost | An arc map storing the costs. |  | source | The source node of the arborescence. |  
 
- Return values
- 
  
    | arborescence | An arc map with bool(or convertible) value type that stores the arborescence. |  
 
- Returns
- The total cost of the arborescence.
- See Also
- MinCostArborescence