MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / bfs

Method bfs

code/graph/hopcroft_karp.cpp:9–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7 L(new int[N]), R(new int[M]), adj(new vi[N]) {}
8 ~bipartite_graph() { delete[] adj; delete[] L; delete[] R; }
9 bool bfs() {
10 int l = 0, r = 0;
11 rep(v,0,N) if(L[v] == -1) dist(v) = 0, q[r++] = v;
12 else dist(v) = INF;
13 dist(-1) = INF;
14 while(l < r) {
15 int v = q[l++];
16 if(dist(v) < dist(-1)) {
17 iter(u, adj[v]) if(dist(R[*u]) == INF)
18 dist(R[*u]) = dist(v) + 1, q[r++] = R[*u]; } }
19 return dist(-1) != INF; }
20 bool dfs(int v) {
21 if(v != -1) {
22 iter(u, adj[v])

Callers

nothing calls this directly

Calls 1

iterFunction · 0.70

Tested by

no test coverage detected