Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Topological Sorting of a DAG Using Graph's DFS In this programming assignment, you will implement the topological sorting of a directed acyclic graph ( DAG

Topological Sorting of a DAG Using Graph's DFS
In this programming assignment, you will implement the topological sorting of a directed acyclic graph (DAG) using the graph's depth first search (DFS). Please refer to the lecture slides and book chapter for the algorithm that solves this problem.
Specification
The Java class that has the main function needs to be named as "TopoSort". That is, the name of the source file that contains the main function should be "TopoSort.java".
The input of your program is a text file that represents a given DAG in its list representation. For example, suppose the following is the DAG, for which you need to do the topological sorting:
1
then, the given file, whose name shall be supplied by the grader as a command line parameter, may contain the following content:
0:1,2,3
1:3
2:
3:2
In particular, the input file has multiple lines, where each line has two parts separated by a colon: the first part represents a graph vertex; the second part is the collection of the vertex's next hop neighbors separated by commas.
You are guaranteed that all the vertices in the graph are named as 0,1,dots,n-1, where n is the number of vertices in the graph. However, remind that a given graph can also be represented by other different input text files. For example, the same example graph above can also be represented by the following two text files.
\table[[1:3,1:3
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Describe effectiveness of reading at night?

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago