Class Matching

Class Documentation

class Matching

Public Functions

Matching(count z = 0)

Construct new Matching.

Parameters:

z[in] Maximum number of nodes.

void match(node u, node v)

Set two nodes u and v as each others matching partners.

Parameters:
  • u[in] node.

  • v[in] node.

void unmatch(node u, node v)

Reset the two nodes u and v to unmatched.

Parameters:
  • u[in] node.

  • v[in] node.

bool isMatched(node u) const

Check if node is matched.

Parameters:

u[in] node.

Returns:

true if u is matched.

bool areMatched(node u, node v) const

Check if the two nodes u and v are matched together.

Parameters:
  • u[in] node.

  • v[in] node.

Returns:

true if u and v are matched together.

bool isProper(const Graph &G) const

Check whether this is a proper matching in the graph, i.e. no two matched edges are adjacent.

Parameters:

G[in] A graph.

Returns:

true if this is a proper matching.

count size(const Graph &G) const

Get the number of edges in this matching.

Parameters:

G[in] A graph.

Returns:

Number of edges in matching.

index mate(node v) const

Get the matched neighbor of v if it exists, otherwise none.

Parameters:

v[in] node.

Returns:

Mate of v if it exists, otherwise none.

edgeweight weight(const Graph &G) const

Get total weight of edges in this matching.

Parameters:

g[in] The corresponding graph.

Returns:

Total weight of edges in this matching.

Partition toPartition(const Graph &G) const

Convert matching to a Partition object where matched nodes belong to the same subset and unmatched nodes belong to a singleton subset.

Returns:

Partition

std::vector<node> getVector() const

Get the actual vector storing the data.

Returns:

vector

Protected Attributes

std::vector<node> data

storage of matching nodes