//
// main.cpp
// Ford-Fulkerson with capacity scaling
//
// Created by Longxiang Lyu on 8/9/16.
// Copyright (c) 2016 Longxiang Lyu. All rights reserved.
//
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
bool bfs(vector<vector<int>> &rGraph, vector<int> &parent, int s, int t, int delta)
{
int V = rGraph.size();
vector<int> visited(V, 0); // mark all vertices as unvisited
queue<int> q;
q.push(s);
visited[s] = 1; // mark source vertex as visited
parent.clear();
parent.resize(V);
parent[s] = -1;
while (!q.empty())
{
int u = q.front(); // get the first element
q.pop();
for (int v = 0; v != V; ++v)
{
if (visited[v] == 0 && rGraph[u][v] >= delta)
{
Ford-Fulkerson algorithm with capacity scaling
最新推荐文章于 2024-01-08 17:57:04 发布