Update hopcroft_karp.cpp

This commit is contained in:
Krishna Pal Deora
2020-09-29 14:40:46 +05:30
committed by GitHub
parent f1f4117623
commit 76c279ca53

View File

@@ -52,9 +52,6 @@
#include <climits>
#include <memory>
const int NIL = 0;
const int INF = INT_MAX;
/**
* @brief Represents Bipartite graph for
* Hopcroft Karp implementation
@@ -64,6 +61,8 @@ class BGraph
// m and n are number of vertices on left
// and right sides of Bipartite Graph
int m, n;
const int NIL;
const int INF;
// adj[u] stores adjacents of left side
// vertex 'u'. The value of u ranges from 1 to m.
@@ -77,6 +76,7 @@ class BGraph
std::vector<int> dist;
public:
BGraph(); //Default Constructor
BGraph(int m, int n); // Constructor
void addEdge(int u, int v); // To add edge
@@ -222,9 +222,16 @@ bool BGraph::dfs(int u)
return true;
}
// Default Constructor for initialization
BGraph::BGraph(){
NIL=0;
INF=INT_MAX;
}
// Constructor for initialization
BGraph::BGraph(int m, int n)
{
this->BGraph();
this->m = m;
this->n = n;
adj = std::vector<std::list<int> >(m + 1);
@@ -236,22 +243,6 @@ void BGraph::addEdge(int u, int v)
adj[u].push_back(v); // Add v to us list.
}
/*
Test case :
Input:
// vertices of left and right side and total edges
// B-Graph shown in the above example
4 4 6
1 1
1 3
2 3
3 4
4 3
4 2
Output:
// size of maximum matching
Maximum matching is 4
*/
int main()
{