Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Specification: Using Java programming language, do a Depth-first search of the directed graph, starting at the node with the value S (not case sensitive).
Problem Specification:
Using Java programming language, do a Depth-first search of the directed graph, starting at the node with the 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:
- If you have a choice among two or more unexplored Node to explore next, there are two cases:
- 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.)
- 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.
- 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.
Sample input
The program read the input from the textile.
The program read the input from textfile
AAA BB val S 67 DDD 99 0 E fig > 999 == Alfa Bravo Charlie Delta Echo -42 4 22 yz 4e 3 2 X 9 != 2 33 2 yes d>e 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 F F B B T F F B F B B B T B B AAA BB val S 67 DDD 99 0 E fig > 999 == Alfa Bravo Charlie Delta Echo -42 4 22 yz 4e 3 2 X 9 != 2 33 2 yes d>e 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 F F B B T F F B F B B B T B BStep 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