CS31005: Algorithms-II Programming - Consider a Flow Problem - IT Assignment Help

Download Solution Order New Solution
Assignment Task:

Task: 

Consider a flow problem where, unlike the maximum-flow problem you have seen so far, there are no special vertices s (source) and t (sink). However, each vertex may produce some amount of an item or consume some amount of the item. In addition, the vertices allow items to flow through them for distribution to other vertices. Let n(i) denote the amount that a vertex i produces or consumes. Thus, if n(i) = 0, the vertex is neither a producer nor a consumer, the vertex is a consumer if n(i) > 0, and the vertex is a producer if n(i) < 0. The items produced are shipped along the edges to satisfy the needs of the consumers. The flow assignments along the edges should be such that in addition to the standard capacity constraints, if vertex i is a producer then its total outflow must be greater than its total inflow by |n(i)| at any time, if vertex i is a consumer then its total inflow must be greater than its total outflow by |n(i)| at any time, and the total inflow must be equal to the total outflow for all other vertices.
 

Your input is:

A directed graph with non-negative integral capacities on every edge, and need n(i) on every vertex i. The graph will be given in a file in a specific format that your program will first read into an adjacency list. You can assume that the n(i) values will be positive or negative integers or 0.

Your program should output:

An assignment of flow f on every edge subject to the above conditions if possible, or say that it is not possible. For example, as a trivial case, if all n(i) are positive, no flow assignment is possible satisfying the above conditions (as there are no producers for the consumers).

 

Your program should contain the following types/functions etc. Please adhere strictly to the type/function names, function prototypes etc. so that your program runs properly when TAs test it. Do not use the structure field names for any other variable names in your program.

1. Define a C type called EDGE that represents one edge of a flow network. The structure that you typedef should store 4 fields: an integer y storing the endpoint vertex y of an edge (x, y) (edge from x to y), an integer c storing the capacity of the edge, an integer f storing the flow value to be assigned on the edge, and a next field pointing to an EDGE type node (for creating a linked list of edges).

2. Define a C type called VERTEX to represent one vertex of the flow network. The structure that you typedef should contain 3 fields, an integer x storing the id of the vertex, an integer n storing the need value of the vertex, and a pointer p storing a pointer to an EDGE node (basically p will point to the first node in the adjacency list of the vertex).

3. Define a C type called GRAPH that stores the directed graph. The graph will be stored as an adjacency list. The C structure that you typedef should store 3 things: an integer V storing the number of vertices, an integer E storing the number of edge, and a pointer H storing a pointer to an array of VERTEX nodes (basically H stores a pointer to an array containing the vertices of the adjacency list, with each vertex pointing to its edge list).

 


This IT Assignment has been solved by our IT Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics.Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

 

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.