fm_partition Class Reference

[Index] [Hierarchy] [Headers]


Heuristic graph bi-partitioning algorithm (Fiduccia-Mattheyses). More...

#include <GTL/fm_partition.h>

Inherits: algorithm

Public Members


Detailed Description

This class implements a heuristic graph bi-partitioning algorithm, based on iterative movement, proposed by C. M. Fiduccia and R. M. Mattheyses in 1982.

In the case E is the set of edges of the graph, the algorithm needs O(|E|) time to proceed.

See Also: ratio_cut_partition


enum side_type (A = 0, B = 1) [public]

Return type of fm_partition::get_side_of_node

enum fix_type (FIXA = 0, FIXB = 1, UNFIXED = 2) [public]

Fix type of each node. FIXA means fixed on side A, FIXB on side B and UNFIXED means not fixed on any side.

See Also:
fm_partition::set_vars

fm_partition() [public]

Default constructor.

See Also:
algorithm::algorithm

~fm_partition() [public virtual]

Destructor.

See Also:
algorithm::~algorithm

void set_vars(const graph& G, const node_map<int>& node_weight, const edge_map<int>& edge_weight) [public]

Sets variables. Must be executed before fm_partition::check

Parameters:
G undirected graph.
edge_weight weight of each edge.
node_weight weight of each node.
See Also:
fm_partition::check

void set_vars(const graph& G, const node_map<int>& node_weight, const edge_map<int>& edge_weight, const node_map<side_type> init_side) [public]

Sets variables. Must be executed before fm_partition::check In order to get good results, init_side should almost be in balance.

Parameters:
G undirected graph.
init_side initial bi-partitioning.
edge_weight weight of each edge.
node_weight weight of each node.
See Also:
fm_partition::check

void set_vars(const graph& G, const node_map<int>& node_weight, const edge_map<int>& edge_weight, const node_map<fix_type> fixed) [public]

Sets variables. Must be executed before fm_partition::check

Parameters:
G undirected graph.
fixed fixed nodes.
edge_weight weight of each edge.
node_weight weight of each node.
See Also:
fm_partition::check

void set_vars(const graph& G, const node_map<int>& node_weight, const edge_map<int>& edge_weight, const node_map<side_type> init_side, const node_map<fix_type> fixed) [public]

Sets variables. Must be executed before fm_partition::check In order to get good results, init_side should almost be in balance. Fixed nodes are on their fix side, their initial side is overwritten then.

Parameters:
G undirected graph.
fixed fixed nodes.
init_side initial bi-partitioning.
edge_weight weight of each edge.
node_weight weight of each node.
See Also:
fm_partition::check

void store_cut_edges(const bool set) [public]

Enables the storing of cut-edges. If enabled the list of cut-edges can be traversed using fm_partition:: cut_edges_iterator.

Parameters:
set if true cut_edges will be stored.
See Also:
fm_partition::cut_edges_begin, fm_partition::cut_edges_end

void store_nodesAB(const bool set) [public]

Enables the storing of nodes on their side. If enabled the nodes of each side can be traversed using fm_partition:: nodes_on_one_side_iterator.

Parameters:
set if true nodes will be stored on their sides.
See Also:
fm_partition::nodes_of_sideA_begin, fm_partition::nodes_of_sideA_end, fm_partition::nodes_of_sideB_begin, fm_partition::nodes_of_sideB_end

int check(graph& G) [public virtual]

Checks whether following preconditions are satisfied:

Parameters:
G graph
Returns:
algorithm::GTL_OK on success, algorithm::GTL_ERROR otherwise.
See Also:
fm_partition::set_vars, algorithm::check

int run(graph& G) [public]

Computes a partitioning with G, that means a division of its vertices in two sides fm_partition::A and fm_partition::B.

Parameters:
G graph
Returns:
algorithm::GTL_OK on success, algorithm::GTL_ERROR otherwise.
See Also:
algorithm::run

int get_cutsize() [public]

Gets the size of the cut after bi-partitioning.

Returns:
cutsize

int get_needed_passes() [public]

Gets the number of passes needed to create a bi-partition with this heuristic.

Returns:
number of passes

side_type get_side_of_node(const node& n) const [public]

Gets side of the node after bi-partitioning.

Parameters:
n node of graph G.
Returns:
fm_partition::A if n lies on side A, fm_partition::B otherwise.

side_type operator [](const node& n) const [public]

Gets side of the node after bi-partitioning.

Parameters:
n node of graph G.
Returns:
fm_partition::A if n lies on side A, fm_partition::B otherwise.
See Also:
fm_partition::get_side_of_node

int get_weight_on_sideA(const graph& G) const [public]

Gets the sum of all node weights from nodes on side A.

Parameters:
G graph
Returns:
node_weight_on_sideA

int get_weight_on_sideB(const graph& G) const [public]

Gets the sum of all node weights from nodes on side B.

Parameters:
G graph
Returns:
node_weight_on_sideB

typedef list<edge>::const_iterator cut_edges_iterator [public]

Iterator type for edges which belong to the cut.

cut_edges_iterator cut_edges_begin() const [public]

Iterate through all edges which belong to the cut, that means all edges with end-nodes on different sides. It is only valid if enabled with fm_partition:: store_cut_edges before.

Returns:
start for iteration through all cut edges.

cut_edges_iterator cut_edges_end() const [public]

End-Iterator for iteration through all edges which belong to the cut. It is only valid if enabled with fm_partition:: store_cut_edges before.

Returns:
end for iteration through all cut-edges.

typedef list<node>::const_iterator nodes_of_one_side_iterator [public]

Iterator type of nodes of a side.

nodes_of_one_side_iterator nodes_of_sideA_begin() const [public]

Iterate through all nodes which belong to side A. It is only valid if enabled with fm_partition:: store_nodesAB before.

Returns:
start for iteration through all nodes on A.

nodes_of_one_side_iterator nodes_of_sideA_end() const [public]

End-Iterator for iteration through all nodes which belong to side A. It is only valid if enabled with fm_partition:: store_nodesAB before.

Returns:
end for iteration through all nodes on A.

nodes_of_one_side_iterator nodes_of_sideB_begin() const [public]

Iterate through all nodes which belong to side B, It is only valid if enabled with fm_partition:: store_nodesAB before.

Returns:
start for iteration through all nodes on B.

nodes_of_one_side_iterator nodes_of_sideB_end() const [public]

End-Iterator for iteration through all nodes which belong to side B, It is only valid if enabled with fm_partition:: store_nodesAB before.

Returns:
end for iteration through all nodes on B.

void reset() [public virtual]

Resets fm_partition, i.e. prepares the algorithm to be applied to another graph.

See Also:
algorithm::reset

Kdoc