16 bool dfs(
const Graph &graph,
int rnode, std::vector<bool> &seen, std::vector<int> &match)
18 for (
size_t lnode = 0; lnode < graph.size(); lnode++) {
19 if (graph[lnode][rnode] && !seen[lnode]) {
21 if (match[lnode] < 0 ||
dfs(graph, match[lnode], seen, match)) {
38 return std::find(match.begin(), match.end(), -1) == match.end();
49 std::vector<int> match(graph.size(), -1);
50 for (
int rnode = 0; rnode < (int)graph.size(); rnode++) {
51 std::vector<bool> seen(graph.size(),
false);
52 dfs(graph, rnode, seen, match);
std::vector< std::vector< bool > > Graph
A bipartite graph where true booleans represent edges between a left node denoted as the row and a ri...
std::vector< int > match_find(const Graph &graph)
Find a match of the given graph.
bool dfs(const Graph &graph, int rnode, std::vector< bool > &seen, std::vector< int > &match)
Depth first search recursive function which returns true if a matching for right node / rnode is poss...
bool match_exists(const Graph &graph)
Check if there exists a matching for all cards.
This file defines maximum matching algorithm function headers.