From aed42bb9d478d57b99d7e0e3f14a5a5698e18caa Mon Sep 17 00:00:00 2001 From: "@8848hg" <53469557+Himalay12@users.noreply.github.com> Date: Tue, 29 Sep 2020 10:23:37 +0530 Subject: [PATCH 1/3] Update hopcroft_karp.cpp Added Global variable as private variable --- graph/hopcroft_karp.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/graph/hopcroft_karp.cpp b/graph/hopcroft_karp.cpp index 882b09224..a12eeb8e2 100644 --- a/graph/hopcroft_karp.cpp +++ b/graph/hopcroft_karp.cpp @@ -52,9 +52,6 @@ #include #include -const int NIL = 0; -const int INF = INT_MAX; - /** * @brief Represents Bipartite graph for * Hopcroft Karp implementation @@ -64,7 +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. // 0 is used for dummy vertex @@ -77,6 +75,7 @@ class BGraph std::vector dist; public: + BGraph(); //Default Constructor BGraph(int m, int n); // Constructor void addEdge(int u, int v); // To add edge @@ -221,10 +220,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 >(m + 1); From d0318d5201cff3e576fc0b7d7b20d8532364dfb1 Mon Sep 17 00:00:00 2001 From: "@8848hg" <53469557+Himalay12@users.noreply.github.com> Date: Tue, 29 Sep 2020 15:27:17 +0530 Subject: [PATCH 2/3] Update hopcroft_karp.cpp --- graph/hopcroft_karp.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/graph/hopcroft_karp.cpp b/graph/hopcroft_karp.cpp index a12eeb8e2..608897c63 100644 --- a/graph/hopcroft_karp.cpp +++ b/graph/hopcroft_karp.cpp @@ -221,13 +221,11 @@ bool BGraph::dfs(int u) return true; } // Default Constructor for initialization -BGraph::BGraph(){ - NIL=0; - INF=INT_MAX; -} +BGraph::BGraph():NIL(0),INF(INT_MAX) +{} // Constructor for initialization -BGraph::BGraph(int m, int n) +BGraph::BGraph(int m, int n):NIL(0),INF(INT_MAX) { this->BGraph(); this->m = m; From aa301ae7367d01571fb42fe7a77db06546e5990f Mon Sep 17 00:00:00 2001 From: "@8848hg" <53469557+Himalay12@users.noreply.github.com> Date: Tue, 29 Sep 2020 15:28:04 +0530 Subject: [PATCH 3/3] Update hopcroft_karp.cpp --- graph/hopcroft_karp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/graph/hopcroft_karp.cpp b/graph/hopcroft_karp.cpp index 608897c63..736ebd386 100644 --- a/graph/hopcroft_karp.cpp +++ b/graph/hopcroft_karp.cpp @@ -226,8 +226,7 @@ BGraph::BGraph():NIL(0),INF(INT_MAX) // Constructor for initialization BGraph::BGraph(int m, int n):NIL(0),INF(INT_MAX) -{ - this->BGraph(); +{ this->m = m; this->n = n; adj = std::vector >(m + 1);