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

- Main Page
- Classes
- Files
- Related Pages

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

# ratio_cut_partition Class Reference

Heuristic graph bi-partitioning algorithm (Wei-Cheng). More...

Inheritance diagram for ratio_cut_partition:

[legend]
Collaboration diagram for ratio_cut_partition:

[legend]

List of all members.

## Public Types

typedef int | side_type
typedef short int | fix_type
typedef list< edge > ::const_iterator | cut_edges_iterator
typedef list< node > ::const_iterator | nodes_of_one_side_iterator

## Public Member Functions

| ratio_cut_partition ()
virtual | ~ratio_cut_partition ()
void | set_vars (const graph &G, const node_map< int > &node_weight, const edge_map< int > &edge_weight)
void | set_vars (const graph &G, const node_map< int > &node_weight, const edge_map< int > &edge_weight, const node source_node, const node target_node)
void | set_vars (const graph &G, const node_map< int > &node_weight, const edge_map< int > &edge_weight, const node source_node, const node target_node, const node_map< side_type > &init_side)
void | set_vars (const graph &G, const node_map< int > &node_weight, const edge_map< int > &edge_weight, const node source_node, const node target_node, const node_map< fix_type > &fixed)
void | set_vars (const graph &G, const node_map< int > &node_weight, const edge_map< int > &edge_weight, const node source_node, const node target_node, const node_map< side_type > &init_side, const node_map< fix_type > &fixed)
void | store_cut_edges (const bool set)
void | store_nodesAB (const bool set)
virtual int | check (graph &G)
int | run (graph &G)
int | get_cutsize ()
double | get_cutratio ()
side_type | get_side_of_node (const node &n) const
side_type | operator[] (const node &n) const
int | get_weight_on_sideA (const graph &G) const
int | get_weight_on_sideB (const graph &G) const
cut_edges_iterator | cut_edges_begin () const
cut_edges_iterator | cut_edges_end () const
nodes_of_one_side_iterator | nodes_of_sideA_begin () const
nodes_of_one_side_iterator | nodes_of_sideA_end () const
nodes_of_one_side_iterator | nodes_of_sideB_begin () const
nodes_of_one_side_iterator | nodes_of_sideB_end () const
virtual void | reset ()

## Static Public Attributes

static const side_type | A
static const side_type | B
static const fix_type | FIXA
static const fix_type | FIXB
static const fix_type | UNFIXED

## Detailed Description

Heuristic graph bi-partitioning algorithm (Wei-Cheng).

This class implements a heuristic graph bi-partitioning algorithm using the ratio cut method proposed by Y. C. Wei and C. K. Cheng in 1991.

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

See also:
  fm_partition

## Member Typedef Documentation

typedef int ratio_cut_partition::side_type

Return type of ratio_cut_partition::get_side_of_node.

See also:
  ratio_cut_partition::A

  ratio_cut_partition::B

typedef short int ratio_cut_partition::fix_type

Fix type of each node (needed with ratio_cut_partition::set_vars).

See also:
  ratio_cut_partition::FIXA

  ratio_cut_partition::FIXB

  ratio_cut_partition::UNFIXED

typedef list<edge>::const_iterator ratio_cut_partition::cut_edges_iterator

Iterator type for edges which belong to the cut.

typedef list<node>::const_iterator ratio_cut_partition::nodes_of_one_side_iterator

Iterator type for nodes of a side.

## Constructor & Destructor Documentation

ratio_cut_partition::ratio_cut_partition | ( |  | ) |

Default constructor.

See also:
  algorithm::algorithm

virtual ratio_cut_partition::~ratio_cut_partition | ( |  | ) | `[virtual]`

Destructor.

See also:
  algorithm::~algorithm

## Member Function Documentation

void ratio_cut_partition::set_vars | ( | const graph & | G,
|  | const node_map< int > & | node_weight,
|  | const edge_map< int > & | edge_weight |
| ) |  |  |

Sets variables. Must be executed before ratio_cut_partition::check! `source_node` and `target_node` will be determined automatically.

Parameters:

  | G | undirected graph
  | node_weight | weight of each node
  | edge_weight | weight of each edge.

See also:
  ratio_cut_partition::check

void ratio_cut_partition::set_vars | ( | const graph & | G,
|  | const node_map< int > & | node_weight,
|  | const edge_map< int > & | edge_weight,
|  | const node | source_node,
|  | const node | target_node |
| ) |  |  |

Sets variables. Must be executed before ratio_cut_partition::check! In order to get good results, you should take two graph theoretically far away nodes as source and target.

Parameters:

  | G | undirected graph
  | node_weight | weight of each node
  | edge_weight | weight of each edge
  | source_node | start-node, remains on side `A`
  | target_node | end-node, remains on side `B`

See also:
  ratio_cut_partition::check

void ratio_cut_partition::set_vars | ( | const graph & | G,
|  | const node_map< int > & | node_weight,
|  | const edge_map< int > & | edge_weight,
|  | const node | source_node,
|  | const node | target_node,
|  | const node_map< side_type > & | init_side |
| ) |  |  |

Sets variables. Must be executed before ratio_cut_partition::check! In order to get good results, you should take two graph theoretically far away nodes as source and target. Additionally `init_side` should nearly be in balance. `source_node` must be on side `A` in `init_side` and `target_node` on side `B` respectively.

Parameters:

  | G | undirected graph
  | node_weight | weight of each node
  | edge_weight | weight of each edge
  | source_node | start-node, remains on side `A`
  | target_node | end-node, remains on side `B`
  | init_side | initial bi-partitioning

See also:
  ratio_cut_partition::check

void ratio_cut_partition::set_vars | ( | const graph & | G,
|  | const node_map< int > & | node_weight,
|  | const edge_map< int > & | edge_weight,
|  | const node | source_node,
|  | const node | target_node,
|  | const node_map< fix_type > & | fixed |
| ) |  |  |

Sets variables. Must be executed before ratio_cut_partition::check! In order to get good results, you should take two graph theoretically far away nodes as source and target. `source_node` must not be fixed on side `B` . `target_node` must not be fixed on side `A` .

Parameters:

  | G | undirected graph
  | node_weight | weight of each node
  | edge_weight | weight of each edge
  | source_node | start-node, remains on side `A`
  | target_node | end-node, remains on side `B`
  | fixed | fixed nodes

See also:
  ratio_cut_partition::check

void ratio_cut_partition::set_vars | ( | const graph & | G,
|  | const node_map< int > & | node_weight,
|  | const edge_map< int > & | edge_weight,
|  | const node | source_node,
|  | const node | target_node,
|  | const node_map< side_type > & | init_side,
|  | const node_map< fix_type > & | fixed |
| ) |  |  |

Sets variables. Must be executed before ratio_cut_partition::check! In order to get good results, you should take two graph theoretically far away nodes as source and target. Additionally `init_side` should nearly be in balance. Fixed nodes are on their fix side, their initial side is overwritten then. `source_node` must be on side A in `init_side` and `target_node` on side B respectively. `source_node` must not be fixed on side `B` . `target_node` must not be fixed on side `A` .

Parameters:

  | G | undirected graph
  | node_weight | weight of each node
  | edge_weight | weight of each edge
  | source_node | start-node, remains on side `A`
  | target_node | end-node, remains on side `B`
  | init_side | initial bi-partitioning
  | fixed | fixed nodes

See also:
  ratio_cut_partition::check

void ratio_cut_partition::store_cut_edges | ( | const bool | set | ) |

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

Parameters:

  | set | if `true` cut_edges will be stored

See also:
  ratio_cut_partition::cut_edges_begin

  ratio_cut_partition::cut_edges_end

void ratio_cut_partition::store_nodesAB | ( | const bool | set | ) |

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

Parameters:

  | set | if `true` nodes on their side will be stored

See also:
  ratio_cut_partition::nodes_of_sideA_begin

  ratio_cut_partition::nodes_of_sideA_end

  ratio_cut_partition::nodes_of_sideB_begin

  ratio_cut_partition::nodes_of_sideB_end

virtual int ratio_cut_partition::check | ( | graph & | G | ) | `[virtual]`

Checks whether following preconditions are satisfied:

- One of the ratio_cut_partition::set_vars procedures has been executed before.
- graph `G` is undirected.
- if applied, `source_node` and `target_node` are 2 distinct nodes with node weights > 0.
- only node_weights >= 0 are applied.
- only edge_weights >= 0 are applied.
- if `G` has more than 2 nodes, then at least two of them have a weight > 0.
- if applied fixed source node, `fixed[source_node]` is `FIXA`.
- if applied fixed target node, `fixed[target_node]` is `FIXB`.

Parameters:

  | G | graph

Returns:
  `algorithm::GTL_OK` on success, `algorithm::GTL_ERROR` otherwise

See also:
  ratio_cut_partition::set_vars

  algorithm::check

Implements algorithm.

int ratio_cut_partition::run | ( | graph & | G | ) | `[virtual]`

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

Parameters:

  | G | graph

Returns:
  `algorithm::GTL_OK` on success, `algorithm::GTL_ERROR` otherwise

See also:
  algorithm::run

Implements algorithm.

int ratio_cut_partition::get_cutsize | ( |  | ) |

Gets the size of the cut after bi-partitioning.

Returns:
  cutsize

double ratio_cut_partition::get_cutratio | ( |  | ) |

Gets the ratio of the cut after bi-partitioning as defined in [WeiChe91].

Returns:
  cutratio

side_type ratio_cut_partition::get_side_of_node | ( | const node & | n | ) | const

Gets side of the node after bi-partitioning.

Parameters:

  | n | node of graph G

Returns:
  `ratio_cut_partition::A` if `n` lies on side `A`, `ratio_cut_partition::B` otherwise

side_type ratio_cut_partition::operator[] | ( | const node & | n | ) | const

Gets side of the node after bi-partitioning.

Parameters:

  | n | node of graph G

Returns:
  `ratio_cut_partition::A` if `n` lies on side `A`, `ratio_cut_partition::B` otherwise

See also:
  ratio_cut_partition::get_side_of_node

int ratio_cut_partition::get_weight_on_sideA | ( | const graph & | G | ) | const

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

Parameters:

  | G | graph

Returns:
  `node_weight_on_sideA`

int ratio_cut_partition::get_weight_on_sideB | ( | const graph & | G | ) | const

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

Parameters:

  | G | graph

Returns:
  `node_weight_on_sideB`

cut_edges_iterator ratio_cut_partition::cut_edges_begin | ( |  | ) | const

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 ratio_cut_partition::store_cut_edges before.

Returns:
  start for iteration through all cut edges

cut_edges_iterator ratio_cut_partition::cut_edges_end | ( |  | ) | const

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

Returns:
  end for iteration through all cut-edges

nodes_of_one_side_iterator ratio_cut_partition::nodes_of_sideA_begin | ( |  | ) | const

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

Returns:
  start for iteration through all nodes on `A`

nodes_of_one_side_iterator ratio_cut_partition::nodes_of_sideA_end | ( |  | ) | const

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

Returns:
  end for iteration through all nodes on `A`

nodes_of_one_side_iterator ratio_cut_partition::nodes_of_sideB_begin | ( |  | ) | const

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

Returns:
  start for iteration through all nodes on `B`

nodes_of_one_side_iterator ratio_cut_partition::nodes_of_sideB_end | ( |  | ) | const

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

Returns:
  end for iteration through all nodes on `B`

virtual void ratio_cut_partition::reset | ( |  | ) | `[virtual]`

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

See also:
  algorithm::reset

Implements algorithm.

## Member Data Documentation

const side_type ratio_cut_partition::A `[static]`

`A` means the node is on side A.

See also:
  ratio_cut_partition::side_type

const side_type ratio_cut_partition::B `[static]`

`B` means the node is on side B.

See also:
  ratio_cut_partition::side_type

const fix_type ratio_cut_partition::FIXA `[static]`

`FIXA` means fix node on side `A`.

See also:
  ratio_cut_partition::set_vars

const fix_type ratio_cut_partition::FIXB `[static]`

`FIXB` means fix node on side `B`.

See also:
  ratio_cut_partition::fixe_type

const fix_type ratio_cut_partition::UNFIXED `[static]`

`UNFIXED` means node is free.

See also:
  ratio_cut_partition::fixe_type

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau