A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d1/d9a/hopcroft__karp_8cpp_source.html below:

TheAlgorithms/C++: graph/hopcroft_karp.cpp Source File

Go to the documentation of this file. 71 const int INF

{INT_MAX};

73

std::vector<std::list<int> >

adj

;

100 pair_u

= std::vector<int>(

m

+ 1,NIL);

104 pair_v

= std::vector<int>(

n

+ 1,NIL);

106 dist

= std::vector<int>(

m

+ 1);

114 for

(

int

u = 1; u <=

m

; u++){

138 for

(

int

u = 1; u <=

m

; u++)

165

std::list<int>::iterator it;

166 for

(it =

adj

[u].begin(); it !=

adj

[u].end(); ++it)

182 return

(

dist

[NIL] != INF);

195

std::list<int>::iterator it;

196 for

(it =

adj

[u].begin(); it !=

adj

[u].end(); ++it)

234 adj

= std::vector<std::list<int> >(

m

+ 1);

244 adj

[u].push_back(v);

257 int

v1a = 3, v1b = 5;

263 int

expected_res1 = 0;

266

assert(res1 == expected_res1);

269 int

v2a = 4, v2b = 4;

279 int

expected_res2 = 0;

282

assert(res2 == expected_res2);

285 int

v3a = 6, v3b = 6;

293 int

expected_res3 = 0;

296

assert(res3 == expected_res3);

310 int

v1 = 0, v2 = 0, e = 0;

311

std::cin >> v1 >> v2 >> e;

314 for

(

int

i = 0; i < e; ++i)

320 int

res = g.hopcroftKarpAlgorithm();

321

std::cout <<

"Maximum matching is "

<< res <<

"\n"

;

constexpr int64_t INF

for assert

Represents Bipartite graph for Hopcroft Karp implementation.

std::vector< std::list< int > > adj

adj[u] stores adjacents of left side and 0 is used for dummy vertex

void addEdge(int u, int v)

function to add edge from u to v

int m

m is the number of vertices on left side of Bipartite Graph

std::vector< int > dist

dist represents the distance between vertex 'u' and vertex 'v'

int n

n is the number of vertices on right side of Bipartite Graph

bool bfs()

This function checks for the possibility of augmented path availability.

std::vector< int > pair_u

value of vertex 'u' ranges from 1 to m

std::vector< int > pair_v

value of vertex 'v' ranges from 1 to n

int hopcroftKarpAlgorithm()

This function counts the number of augmenting paths between left and right sides of the Bipartite gra...

bool dfs(int u)

This functions checks whether an augmenting path is available exists beginning with free vertex u.

HKGraph()

Default Constructor for initialization.

int main()

Main function.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4