Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write code that finds a maximum flow in a directed graph, using the Ford-Fulkerson algorithm on capacities given as matrix void maximum.flow(int n, int s,

image text in transcribed

Write code that finds a maximum flow in a directed graph, using the Ford-Fulkerson algorithm on capacities given as matrix void maximum.flow(int n, int s, int t, int capacity, int *low) Your function has the following arguments: n: the number of vertices of the graph, - s: the start vertex - t: the target vertex capacity: the matrix of edge capacities. - flow: the matrix used to return the maximum flow. The vertices are numbered from 0 to n-1, so s and t are numbers in that range. capacity, flow are a pointers to n n matrices of non negtive integers, the array el- ement capacity[i] [jl is the capacity of the edge from i to j, and can be accessed as (capacity + i*n j). Your function should return in the matrix flow the flow values of the maximum flow from s to t. The flow variable of your function points to space allocated for the flow matrix. Your function will need at least the following auxiliary arrays: -an n n matrix to hold the current flow, -an n n matrix to hold the current residual capacities, - an array to maintain which vertices are already visited in the search of an augmenting path from s to t with positive residual capacity. You have to allocate the auxiliary arrays. You can use either BFS or DFS for the search of the augmenting path Write code that finds a maximum flow in a directed graph, using the Ford-Fulkerson algorithm on capacities given as matrix void maximum.flow(int n, int s, int t, int capacity, int *low) Your function has the following arguments: n: the number of vertices of the graph, - s: the start vertex - t: the target vertex capacity: the matrix of edge capacities. - flow: the matrix used to return the maximum flow. The vertices are numbered from 0 to n-1, so s and t are numbers in that range. capacity, flow are a pointers to n n matrices of non negtive integers, the array el- ement capacity[i] [jl is the capacity of the edge from i to j, and can be accessed as (capacity + i*n j). Your function should return in the matrix flow the flow values of the maximum flow from s to t. The flow variable of your function points to space allocated for the flow matrix. Your function will need at least the following auxiliary arrays: -an n n matrix to hold the current flow, -an n n matrix to hold the current residual capacities, - an array to maintain which vertices are already visited in the search of an augmenting path from s to t with positive residual capacity. You have to allocate the auxiliary arrays. You can use either BFS or DFS for the search of the augmenting path

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

4. Who should be invited to attend?

Answered: 1 week ago

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago