Ford-fulkerson algorithm on capacities

Assignment Help Data Structure & Algorithms
Reference no: EM13532802

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 *flow)

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 nonnegtive integers; the array element capacity[i][j] 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 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.

Reference no: EM13532802

Questions Cloud

Critically explore any particular aspect of international : Critically explore any particular aspect of international
What is the final temperature of the water mixture : A person tries to heat up the bath water by adding 6.0 L of water at 70ºC to 60 L of water at 30ºC. What is the final temperature of the water mixture
Compare the phytomastigophora with the zoomastigophora : Compare the Phytomastigophora with the Zoomastigophora -- that is, explain how they are similar and how they differ from one another.
What is the difference between tests produced by difflugia : What is the difference between the tests produced by Difflugia and those produced by foraminiferans? How do Amoeba differ from Difflugia and in what ways are they the same?
Ford-fulkerson algorithm on capacities : Write code that finds a maximum flow in a directed graph, using the Ford-Fulkerson algorithm on capacities given as matrix void maximum flow(
What is the change in velocity of the train : A train travels due south at 60 m/s. It reverses its direction and travels due north at 60 m/s. What is the change in velocity of the train
What is the new velocity of the aircraft : A jet airliner moving initially at 300 mi/h due east enters a region where the wind is blowing at 100 mi/h in a direction 28.0° north of east. What is the new velocity of the aircraft
Evaluate the height from which the ball was thrown : A ball is tossed from an upper-story window of a building. The ball is given an initial velocity of 8.90 m/s at an angle of 16.0° below the horizontal. Find the height from which the ball was thrown
What is the free-fall acceleration on the planet : An astronaut on a strange planet finds that she can jump a maximum horizontal distance of 19.0 m if her initial speed is 2.80 m/s. What is the free-fall acceleration on the planet

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Calculate failure and success ratios using fifo page removal

Using FIFO page removal algorithm, do a page trace analysis indicating page faults with asterisks (*). Then calculate the failure and success ratios.

  Creating dataflow diagram

Think about the level of detail involved with creating a dataflow diagram, why should the narrative be prepared? Explain why do we need the questionnaire?

  Explaining augmented red-black tree

Consider T be augmented red-black tree, where each node x has attribute x.size, which is number of internal nodes in subtree rooted at x. Given such augmented red-black tree T.

  Write algorithm to find median value using queries

As queries are expensive, you would like to calculate median using as few queries as possible. Provide the algorithm which finds median value using at most O(log n) queries.

  1 what are the different applications of data structure2

1. what are the different applications of data structure?2. what are the basic limitations of linear array?3.

  Creating an idef1x diagram

Construct an IDEF1X diagram that demonstrate only entities and relationships. Name each relationship and specify its cardinalities.

  Design algorithm determining annual profit for company

Your goal is to solve the following simple programming exercise. You have been asked by your accounting department to design an algorithm determining the annual profit for your company.

  Linked lists give a program to implement the insert

give a program to implement the insert operation and delete operations on a queue using linked

  Creating the table showing decimal value

Assume if the last digit of a 2's complement binary number is 0, then number is even. If the last two digits of a 2's complement binary number are 00

  Conversion with unnormalized relation

Nazca Cinemas is a tiny movie theater that would like you to create a movie scheduling database system for them. The theater has 4-screens. Each screens has its own unique ID

  Describe and implement fft algorithm cooley-tukey

Describe and implement in C++ FFT algorithm "Cooley-Tukey". Also, implement naive DFT and compare naive DFT with FFT using: a sample of the signal x(t) = t

  Question 1write the selection sort algorithm as a template

question 1write the selection sort algorithm as a template function using the less than operator to compare two

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd