Calculate the maximum flow of a directed weighted graph

Assignment Help JAVA Programming
Reference no: EM131442082

1. We will implement the Ford-Fulkerson algorithm to calculate the Maximum Flow of a directed weighted graph. Here, you will use the files WGraph.java and FordFulker-son.java, which are available on the course website. Your role will be to complete two methods in the template FordFulkerson.java.

The ?le WGraph.java is the similar to the file that you used in your previous assignment to build graphs. The only differences are the addition of setters and getters methods for the Edges and the addition of the parameters "source" and "destination". There is also an additional constructor that will allow the creation of a graph cloning a WGraph object. Graphs are also encoded using a similar format than the one used in the previous assignment. The only difference is that now the first line corresponds to two integers, separated by one space, that represent the "source" and the "destination" nodes. An example of such file can be found on the course website with the file ff2.txt. These files will be used as an input in the program FordFulkerson.java to initialize the graphs. This graph corresponds to the same graph depicted in [CLRS2009] page 727.

Your task will be to complete the two staticmethods fordfulkerson(Integer source, Integer destination, WGraph graph, String filePath) and pathDFS(Integer source, Integer destination, WGraph graph). The secondmethod pathDFS finds a path through a Depth First Search (DFS) between the nodes "source" and "destination" in the "graph". You must return an ArrayList of Integers with the list of unique nodes belonging to the path found by the DFS. The first element in the list must correspond to the "source" node, the second element in the list must be the second node in the path, and so on until the last element (i.e., the "destination" node) is stored. The method fordfulkerson must compute an integer corresponding to the max ?ow of the "graph" and the graph itself.

The method fordfulkerson has a variable called myMcGillID, which must be initialized with your McGill ID number.

Once completed, compile all the java ?les and run the command line java FordFulkerson ff2.txt. Your program must use the function writeAnswer to save your output in a ?le. An example of the expected output file is available in the file ff226000000.txt. This output keeps the same format than the file used to build the graph; the only difference is that the first line represents now the maximum flow (instead of the "source" and "destination" nodes). The other lines represent the same graph with the weights updated with the values that represent the maximum flow. The file ff226000000.txt represent the answer of the example showed in [CLRS2009] Pag 727. You are invited to run other examples of your own to verify that your program is correct.

2. We want to implement the Bellman-Ford algorithm for finding the shortest path in a graph where edge can have negative weights. This question extends the previous question on the implementation of the Dijkstra's algorithm done in the assignment 2. You will need to execute this program to use the same auxiliary class Wgraph used in question 1. Your task is to fill the method BellmanFord(WGraph g, int source) and shortestPath(int destination) in the file BellmanFord.java. The method BellmanFord takes a object WGraph named g as an input (See Assignment 2) and an integer that indicates the source of the paths. If the input graph g contains a negative cycle, then the method should through an exception. Otherwise, it will return an object BellmanFord that contains the shortest path estimates (the private array of integers distances), and for each node its predecessor in the shortest path from the source (the private array of integers predecessors).

The method shortestPath will return the list of nodes as an array of integers along the shortest path from the source to the node destination. If this path does not exists, the method should throw an exception.

Input graphs are available on the course webpage to test your program. Nonetheless, we invite you to also make your own graphs to test your program.

3. Give an O(n lg n) time algorithm to find the longest monotonically increasing subsequence of a sequence of n numbers. (Hint: Observe that the last element of a candidate subsequence of length i is at least as large as the last element of a candidate subsequence of length i   1. Maintain candidate subsequences by linking them through the input sequence.) We do not ask you to prove your algorithm, but a complete exact proof will receive a bonus.

4. Apply the Neddleman-Wunch algorithm to find the optimal sequence alignment between the sequences !1 = AACT and !1 = GAT. We set all the substitution, deletion and insertion costs at 1, and the match score to -1. Here, your goal will be to compute the alignment with the minimum score. Show the complete dynamic programming table filled by the algorithm, and show the path(s) corresponding to the optimal sequence alignment. Write down the alignment and its cost. (Note: Alternatively, you can choose to use the edit scores used in class and maximize the score.)

Attachment:- Assignment Files.rar

Reference no: EM131442082

Questions Cloud

Explain secondary and credible sources such as cnn money : Explain Secondary and credible sources such as CNN Money, The Wall Street Journal, trade journals, and publications in EBSCOhost (Grantham University Online Library).
Company to engage in a nonequity joint venture : Discuss the advantages and risks for Ford Motor Company to engage in a nonequity joint venture.
Important to the company selected : For this assignment, select a company/organization of any type (for profit, non-profit) and complete the following using screenshots, images or diagram of sample products, processes, etc. to illustrate and address the items below (you may also con..
Write a proposal allowing firms interest on the losses : There have been proposals to allow firms interest on the losses they carry forward on their tax returns from one year to the next. That is, if a firm has a loss this year of $100,000, and the interest rate is 10 percent.
Calculate the maximum flow of a directed weighted graph : Comp 251 Assignment. We will implement the Ford-Fulkerson algorithm to calculate the Maximum Flow of a directed weighted graph. Here, you will use the files WGraph.java and FordFulker-son.java, which are available on the course website. Your role ..
Identify specific traits or characteristics of the leader : Identify specific traits or characteristics of the leader and relate them to relevant theories we discuss in class and/or that are found in the book.
Accused of unethical practices : These contracts while written in ink are set in stone. Many multinationals have been charged with unethical behaviors. HP company was accused of unethical practices write about what led up to the accusation and recommendations to the company.
Why can some material that would normally be forbidden : The constitutional rights of prisoners may be held in abeyance during the time they are on probation or parole. They do not have the opportunity to interact with others who are also on probation and parole. The inmate, although on probation or par..
Conduct a mean reading score analysis : A. Conduct a mean reading score analysis. B. Conduct a proportional analysis on reading scores. C. Convert the attendance variable to a numerical variable and conduct a linear regression.

Reviews

len1442082

3/27/2017 7:15:35 AM

Detailed Question: Need help with 1 and 2 mostly. Written answers and programming questions must be returned in separate submission folders on MyCourse. Do not submit a compressed files (e.g. zip files). Upload instead each PDF or text file individually. The clarity and presentation of your answers is part of the grading. Be neat! The only format accepted for written answers are PDF or text files (e.g. .txt or .rtf). PDF files must open on SOCS computers. Any additional files (e.g. images) must be included in the PDF. When applicable, your pseudo-code should be commented and indented.

Write a Review

JAVA Programming Questions & Answers

  Create a web application for sheridan restaurant

Create a web application for Sheridan Restaurant Reviews that contains the following functionality - Display a table of all restaurants based on the city entered by the user

  1 what makes a program easy to modify2 describe the order

1. what makes a program easy to modify?2. describe the order of magnitude of the following code section using bigo

  Implement a lexical and syntax analyzer

Implement a lexical and syntax analyzer based on the following grammar. Your analyzer should read an input test program from a file and then determine if it contains a syntax error.

  Servlet to find the sum of all digits of an input integer

1) Write a Web application using servlet to find the sum of all the digits of an input integer.2) Write a servlet which counts the number of digits into an integer received as parameter. Give the necessary web.xml file to deploy the servlet.

  Definition of constant initialization arrays

You have to extend the definition of constant initialization arrays to multi-dimensional arrays

  Write an employee payroll program

Write an employee payroll program that uses polymorphism to calculate and print the weekly payroll for your company. There are three types of employees - hourly, salaried, and salaried plus commission. Each type of employee gets paid using a diffe..

  Create class account with id balance person and datecreated

Create class Account with id, balance, Person, and dateCreated. Use a static class variable to store the annualInterestRate for all account holders. Provide constructors, setter and getter for the Account class.

  Pacman style game with clara

The major assignment involves producing a Pacman style game with Clara using the Greenfoot files that are given to you.

  Create at least two vectors and demonstrate the use of each

Create a separate class, VectorTest, that will demonstrate the use of your Vector class. You must create at least two vectors, and demonstrate the use of each method. When you demonstrate the use of each method, print the results to the console ..

  Develop a java program that simulates the queues in a bank

Develop a java program that simulates the queues in a bank. Implement the event-driven simulation of a bank. A queue of arrival events will represent the line of customers in the bank.

  Assume that you are developing a java program which uses

suppose that youre developing a java program that uses decimal numbers and youd like to control the formatting of your

  The class date was designed and implemented

In Programming Exercise 2, the class Date was designed and implemented to keep track of a date, but it has very limited operations. Redefine the class date so that, it addition to the operations already defined, it can perform the following operation..

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