Question
Start with your Java program prog340 which implements Deliverable A. Do a Depth-first search of the directed graph, starting at the node with value S
Start with your Java program prog340 which implements Deliverable A.
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:
a. 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.)
b. 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.
2. 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
CODE IS IN COMMENTS
---CODE TO BE CHANGED---
import java.io.*;
// 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 retests 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"); }}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started