Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# min_tree Class Reference

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

Inheritance diagram for min_tree:

[legend]
Collaboration diagram for min_tree:

[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< edge > | get_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

- be undirected
- be connected
- have more than 2 nodes

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.

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau