Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Would you help to solve this problem, please This is the continuation of the problem solved here( https://www.chegg.com/homework-help/questions-and-answers/import-javaio-import-javautil-class-deliva-work-deliverable-deliva-prog340-public-class-de-q66624065 ) . Specification: Start with your Java

Would you help to solve this problem, please

This is the continuation of the problem solved here( https://www.chegg.com/homework-help/questions-and-answers/import-javaio-import-javautil-class-deliva-work-deliverable-deliva-prog340-public-class-de-q66624065).

Specification:

Start with your Java program prog340 which implements DeliverableA( https://www.chegg.com/homework-help/questions-and-answers/import-javaio-import-javautil-class-deliva-work-deliverable-deliva-prog340-public-class-de-q66624065).

Do a Depth-first search of the directed graph, starting at the node with value S (not case sensitive). List

the starting and finishing times of each Node, and the class of each Edge (tree edge, forward edge, back edge, cross edge). Make the starting time of the source node time 1. At many points in the search, you may have to choose which node to explore next. Here are the rules to do so:

  1. If you have a choice among two or more unexplored Nodes to explore next, there are two cases:
  1. If the values of all Edges are all integers, choose the Edge with the lowest value. If there is a tie, choose the Edge to the Node whose name comes first in lexicographic order. (All node names are unique.)
  2. Otherwise, if the values of the Edges are not all integers (at least one general alphabetical character or non-positive integer), choose the Edge to the Node whose name comes first in lexicographic order.
  1. If you have explored as far as possible from the starting node without exploring every node of the graph, continue from the Node whose name comes first lexicographically from among all unexplored Nodes.

Dont Break Existing Functionality

Running Deliverable A on the test files should still work. Actually, it should always work for any test file in any deliverable.

Administrative Details

The prog340 handout describes the format of the input file for this and all program deliverables.

As before, try to minimize disruption to the existing codebase, although you will have to do some machinations to deal with Graphs having Edges with positive integral values differently from more general edges.

The output for this file should be:

image text in transcribed

Here the Code:

import java.io.*; import java.util.Scanner;

// Class DelivB does the work for deliverable DelivB of the Prog340

public class DelivB {

File inputFile; File outputFile; PrintWriter output; Graph g; public DelivB( File in, Graph gr ) { inputFile = in; g = gr; // Get output file name. String inputFileName = inputFile.toString(); String baseFileName = inputFileName.substring( 0, inputFileName.length()-4 ); // Strip off ".txt" String outputFileName = baseFileName.concat( "_out.txt" ); outputFile = new File( outputFileName ); if ( outputFile.exists() ) { // For re-tests outputFile.delete(); } try { output = new PrintWriter(outputFile); } catch (Exception x ) { System.err.format("Exception: %s%n", x); System.exit(0); } System.out.println( "DelivB: To be implemented"); output.println( "DelivB: To be implemented"); } }

The output for this file should be: Node Alpha Bravo Charlie Delta Echo Start Time 1 2 3 4 5 End Time 10 9 8 7 6 Edge AAA-BB AAA-DDD AAA-EEE BB-AAA BB-BB BB-C BB-DDD BB-E C-BB C-DDD C-E DDD-AAA DDD-BB DDD-C DDD-E E-DDD E-E Type T F F B B F F B T F B B The output for this file should be: Node Alpha Bravo Charlie Delta Echo Start Time 1 2 3 4 5 End Time 10 9 8 7 6 Edge AAA-BB AAA-DDD AAA-EEE BB-AAA BB-BB BB-C BB-DDD BB-E C-BB C-DDD C-E DDD-AAA DDD-BB DDD-C DDD-E E-DDD E-E Type T F F B B F F B T F B B

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago