min_tree Class Reference

Kruskal's algorithm for finding minimal spanning tree of a graph. More...

Inheritance diagram for min_tree:

Inheritance graph
[legend]
Collaboration diagram for min_tree:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 min_tree ()
 Constructor.
virtual ~min_tree ()
 Destructor.
int check (graph &g)
 Checks whether algorithm can be applied.
int run (graph &g)
 Applies algorithm to graph g.
virtual void reset ()
 Resets algorithm.
void set_distances (const edge_map< int > &dist)
 Sets edge weights.
set< edgeget_min_tree ()
 Edges of minimal spanning tree calculated in the last call of min_tree::run.
int get_min_tree_length ()
 Weight of minimal spanning tree.


Detailed Description

Kruskal's algorithm for finding minimal spanning tree of a graph.

Author:
Marcus Raitner

Member Function Documentation

int min_tree::check ( graph g  )  [virtual]

Checks whether algorithm can be applied.

The graph must

Additionally the weights of the edges must have been set in advance using min_tree::set_distances.

Parameters:
g graph
Returns:
algorithm::GTL_OK if algorithm can be applied algorithm::GTL_ERROR otherwise.

Implements algorithm.

int min_tree::run ( graph g  )  [virtual]

Applies algorithm to graph g.

Parameters:
g graph
Return values:
algorithm::GTL_OK on success
algorithm::GTL_ERROR otherwise

Implements algorithm.

virtual void min_tree::reset (  )  [virtual]

Resets algorithm.

Prepares the algorithm to be applied to another graph. Please note: The options an algorithm may support do not get reset by this. It is just to reset internally used datastructures.

Implements algorithm.

void min_tree::set_distances ( const edge_map< int > &  dist  ) 

Sets edge weights.

Setting of edge weights must be done before calling min_tree::check and min_tree::run.

Parameters:
dist edge weigths.

set<edge> min_tree::get_min_tree (  ) 

Edges of minimal spanning tree calculated in the last call of min_tree::run.

Returns:
Set of edges of representing the minimal spanning tree

int min_tree::get_min_tree_length (  ) 

Weight of minimal spanning tree.

Returns:
weight of minimal spanning tree.