Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pert.java: / replace sxa173731 with your netid below import sxa173731.Graph; import sxa173731.Graph.Vertex; import sxa173731.Graph.Edge; import sxa173731.Graph.GraphAlgorithm; import sxa173731.Graph.Factory; import java.io.File; import java.util.LinkedList; import java.util.Scanner; public

image text in transcribedpert.java: / replace sxa173731 with your netid below import sxa173731.Graph; import sxa173731.Graph.Vertex; import sxa173731.Graph.Edge; import sxa173731.Graph.GraphAlgorithm; import sxa173731.Graph.Factory; import java.io.File; import java.util.LinkedList; import java.util.Scanner; public class PERT extends GraphAlgorithm { LinkedList finishList; public static class PERTVertex implements Factory { // Add fields to represent attributes of vertices here public PERTVertex(Vertex u) { } public PERTVertex make(Vertex u) { return new PERTVertex(u); } } // Constructor for PERT is private. Create PERT instances with static method pert(). private PERT(Graph g) { super(g, new PERTVertex(null)); } public void setDuration(Vertex u, int d) { } // Implement the PERT algorithm. Returns false if the graph g is not a DAG. public boolean pert() { return false; } // Find a topological order of g using DFS LinkedList topologicalOrder() { return finishList; } // The following methods are called after calling pert(). // Earliest time at which task u can be completed public int ec(Vertex u) { return 0; } // Latest completion time of u public int lc(Vertex u) { return 0; } // Slack of u public int slack(Vertex u) { return 0; } // Length of a critical path (time taken to complete project) public int criticalPath() { return 0; } // Is u a critical vertex? public boolean critical(Vertex u) { return false; } // Number of critical vertices of g public int numCritical() { return 0; } /* Create a PERT instance on g, runs the algorithm. * Returns PERT instance if successful. Returns null if G is not a DAG. */ public static PERT pert(Graph g, int[] duration) { PERT p = new PERT(g); for(Vertex u: g) { p.setDuration(u, duration[u.getIndex()]); } // Run PERT algorithm. Returns false if g is not a DAG if(p.pert()) { return p; } else { return null; } } public static void main(String[] args) throws Exception { String graph = "10 13 1 2 1 2 4 1 2 5 1 3 5 1 3 6 1 4 7 1 5 7 1 5 8 1 6 8 1 6 9 1 7 10 1 8 10 1 9 10 1 0 3 2 3 2 1 3 2 4 1"; Scanner in; // If there is a command line argument, use it as file from which // input is read, otherwise use input from string. in = args.length > 0 ? new Scanner(new File(args[0])) : new Scanner(graph); Graph g = Graph.readDirectedGraph(in); g.printGraph(false); int[] duration = new int[g.size()]; for(int i=0; i

driver.java:

package sxa173731; import java.util.Scanner; // prints output only if size 0 ? new Scanner(new java.io.File(args[0])) : new Scanner(graph); if(args.length > 1) { details = true; } Graph g = Graph.readDirectedGraph(in); int[] duration = new int[g.size()]; for(int i=0; i Implement the PERT algorithm discussed in class. Starter code (PERT.java) provided. Implement all the methods in the starter code. Write additional methods if needed. Driver code (P4Driver) and test cases are all also provided. (See p4 folder in the shared box folder.) Do not change the name of the class. Do not modify Graph class other than changing the netid. Do not change the signatures of public methods in the starter code. If you need additional classes, define them as nested classes of PERT. You must write the DFS-based algorithm for finding a topological order. Your code should be well structured and commented properly. Please follow format specified in Javadoc. Follow the submission below. IF YOU DID NOT FOLLOW THE SUBMISSION PROCEDURE, 10 POINTS WILL BE DEDUCTED Submission procedure: * Create a folder whose name is your netid (Nid). The name should be in lower case. * Place PERT.java, and Graph.java in that folder. * Use "package Nid;" in all your java files. Nid should be in lower case * package name and folder name should exactly match * Zip the contents into a single zip file. * If the zip file is bigger than 1 MB, you have included unnecessary files. * Delete them and create the zip file again. * Upload the zip file on elearning. * Submission can be revised before the deadline. * The final submission before the deadline will be graded

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions