SlideShare a Scribd company logo
Introduction
Topological sorting is a common operation performed on
directed acyclic graphs (dags). It arises in numerous
applications including task scheduling, serialization and
dependency determinations, and graph drawing. The goal of this
project is to manipulate graph representations, perform
topological sorting on a dag, and use the topological numbers in
a longest path computation as well as in a heuristic solving a
scheduling problem.
Degree-based Topological Sort
Given is a dag G=(V,E), V={0, 1, … ,n-1}, having n vertices
and m edges. The graph is represented in the form of adjacency
lists. For each vertex u, Aout[u] points to a list containing all
vertices v such that <u,v> is an edge from u to v and Ain[u]
points to a list containing all vertices v such that <v,u> is an
edge from v to u. The length of list Aout[u] is the out-degree of
node u and the length of list Ain[u] is the in-degree of node u.
In any dag there exists at least one vertex having in-degree 0
(called the sources) and at least one vertex with out-degree 0
(called the sinks). The dags used in the project can have an
arbitrary number of sources, but will always have one sink. The
dag shown in Figure 1 has two sources (vertices A and G) and
one sink (vertex F).
Figure 1: A 7-vertex dag with two sources and one sink.
Topological sorting assigns to each vertex an integer (also
called its topological number). See Chapter 4.2 in the text for
details. The topological numbers represent a linear ordering of
the vertices such that for every edge <u,v> vertex u appears
before v in the ordering. For the graph in Figure 1, the ordering
A G B D C E F is a topological ordering and the topological
numbers are A=0, B=2, C=4, D=3, E=5, F=6, G=1. Note that
topological orderings are not unique.
We note that the textbook presents topological sorting as an
application of DFS (Algorithm 4.5 in Chapter 4.2). Another
approach is a non-recursive implementation based on a degree-
driven graph exploration. In this project you need to implement
the degree-based topological sorting approach described below.
All source vertices are ready to be placed. For Figure 1, vertices
A and G can be placed right away. Once a vertex u has all the
vertices incident to its incoming edges placed, u can be placed.
This observation forms the basis of degree-based topological
sorting algorithm.
The algorithm uses a queue TSQ. Whether one uses a FIFO or a
LIFO (i.e., stack) queue does not matter for determining a
topological ordering (different queues will produce different
orderings). The topological numbers are maintained in an array,
say array T.
The high-level description of the degree-driven algorithm is as
follows:
1 Make all initializations; includes a variable count set to 0 and
placing all sources in queue TSQ.
2 u = dequeue() and we set T[u]=count
3 All of u’s out-going edges are examined. For each edge <u,v>,
reduce the number of edges into v by 1. Once all incoming
edges of vertex v have received topological numbers, this count
would be zero and v is placed into TSQ.
4 Repeat steps 2 to 3 until TSQ is empty.
The needed book-keeping details are yours to work out. In
particular, you need to decide how to manage the counts into
vertices used in step 3. Keep in mind that the running time of
step 3 needs to be proportional to the number of v's outgoing
edges.
You can assume that all sinks can be reached from at least one
source. The algorithm implementation needs to run in O(n+m)
time.
Longest Path Computation and Scheduling
Assume the dag describes a manufacturing process and each
vertex corresponds to one production step. Production step u
cannot start until all production steps associated with the
incoming edges incident to u have been completed. A
topological ordering now represents one possible production
sequence. Manufacturing times at different production steps
vary in applications, but in this project we assume that every
production step takes the same amount of time.
When there is no limit on the number of production steps that
can be carried out simultaneously, what is the minimum time in
which all production steps can be completed? We refer to the
time needed to complete a manufacturing process as the
production span. The production span cannot be shorter than the
length of the longest path from any source to the sink, plus 1
(because the longest path counts the number of edges).
The longest paths is also called the critical path length (critical
as reducing the production span needs to shorten the length of
the longest paths in the dag.) You need to determine the length
of the longest path in the dag and a manufacturing schedule
which achieving minimum production span. The number of
production steps that can execute at the same time is not
limited.
Figure 2: A 8-vertex dag with a longest path of 3.
The DAG in Figure 2 has a longest path of length of 3. This
means that it is possible to schedule the eight production steps
in a production span of 4. Here is a possible schedule: A, (B, C,
D), (E, F, G), H. At time 0, production step A is the only one
executing; at time 1, three production steps are executing
simultaneously, etc. At any point, no more than 3 stations are
used simultaneously (and thus no more than 3 production steps
execute simultaneously).
Algorithm 4.10 in Section 4.4 of the text presents an O(n+m)
time shortest path algorithm for a DAG. By changing the vertex
relaxation, the algorithm can be changed into the needed longest
path algorithm. See your class notes for more detail.
Scheduling with k Stations
Assume now that at most k manufacturing stations can be used
at any time. You have already developed solutions for two
cases: when k=1 and when the value of k can be as large as
needed. Assume k>1. It turns out that generating a schedule
using at most k stations simultaneously and minimizing the
production span is not an easy problem. You will implement an
algorithm that is a natural generalization of the two earlier
algorithms. The algorithm will never use more than k
manufacturing stations, but the resulting production span may
not be the smallest possible (for k stations). This means that the
algorithm will make decisions on which production steps to
assign to stations at times steps that may to not result in the
best possible production span. However, your algorithm will be
be fast - run in O(n+m) time - and will never use more than k
stations.
You are asked to develop an O(n+m) time algorithm for
scheduling the n manufacturing steps when at any time at most
k stations are available. Thus, k tasks can execute
simultaneously at any time. The value of k is given. Your
algorithm should assign to each vertex u a level number L(u)
such that
· every level contains at most k vertices, and
· for every edge <u,v>, we have L(u)<L(v).
The largest level represents the achieved production span.
You need to work out a number of implementation details in
your scheduling algorithm. Make sure it runs in O(n+m) time.
Your algorithm should be based on the following approach:
1 The vertices are considered in topological order. For each
vertex v, assign v to a level p if (i) level p is at least one level
higher than the largest level assigned to any of v’s incoming
edges, and (ii) level p does not already have k vertices assigned
to it. If more than one vertex qualifies for placement, an
arbitrary one is chosen.
2 Repeat the process until all vertices have been scheduled.
3 Report the schedule and the achieved production span.
Summary of Tasks
This project asks you to implement the following tasks. Each
task needs to have an O(n+m) time implementation.
1 For a given dag G, determine the topological number of each
vertex using the degree-based topological sorting algorithm.
2 For a given dag G, determine for the length of the longest
path.
3 For a given dag G, use the topological numbers and the
longest paths entries to generate a schedule that completes all
manufacturing steps in the shortest production span. Return the
schedule.
4 For a given dag G and an integer k, 1< k < n, use the
topological numbers to determine a schedule using at most k
stations. Return the schedule.
For those interested in using graph visualization tools, we
provide the following links to resources:
· Network Workbench - http://nwb.cns.iu.edu/index.html
· graphviz -
http://www.linuxdevcenter.com/pub/a/linux/2004/05/06/graphvi
z_dot.html
· Cytoscape - http://www.cytoscape.org/
Programming Assignment
The skeleton code contains a number example dags. Each dag
file has the following format:
<number of vertices> vertices, <number of edges> edges
0:
In: <incoming edges for vertice>
Out: <outgoing edges for vertice>
1:
In: <incoming edges for vertice>
Out: <outgoing edges for vertice>
...
n:
In: <incoming edges for vertice>
Out: <outgoing edges for vertice>
For example, for a 4-vertex dag the input can look like:
4 vertices, 6 edges
0:
In: 2
Out: 1 3
1:
In: 0 2
Out: 3
2:
In:
Out: 3 0 1
3:
In: 2 0 1
Out:
Represent each dag so that it maintains for each vertex the list
of out-edges as well as in-edges. You need to define a class
Digraph that you can adapt from the one given from Princeton
library. Add additional entries as needed.
For tasks 3 and 4, the generated schedule is represented as
described in Schedule.java. The data structure resembles the
structure of adjacency lists: it is an array of lists. The size of
the array equals the production span and the list at the j-th entry
of the array contains the steps executing simultaneously at time
j (listed in arbitrary order). Do not modify Schedule.java. You
can use methods in Schedule.java to construct a schedule.
You must implement the following methods of the DagUtilities
class:
· public static int[] topologicalSort(Digraph G)
· perform topological sort on dag G and assign topological
numbers.
· public static int longestPath(Digraph G)
· return the length of the longest path in the dag G.
· public static Schedule minProdSpanSchedule(Digraph G)
· for dag G, return a schedule minimizing the production span.
· public static Schedule spanKStations(Digraph G, int k)
· for dag G and integer k, return a schedule using at most k
stations.
· public static Digraph readGraphFromFile(File file)
· Read a dag from input file and return the dag
Testing
You have been provided with several example trees which you
should use to test your code. To run our main function, use the
following command:
$ java -cp <colon separated path(s) to classes> Project5Test
[Graph_File_Path]
If you want to specify the number of stations for task 4, use the
following command:
$ java -cp <colon separated path(s) to classes> Project5Test
[Graph_File_Path] -s [Number_Of_Stations]
Analysis Questions
Your report must answer each question briefly and clearly.
1 State and explain the asymptotic performance of your
algorithm determining the topological numbers.
2 State and explain the asymptotic performance of your
algorithm determining the longest path in the dag.
3 State and explain the asymptotic performance of your
algorithm determining a schedule achieving minimum
production span.
4 State and explain the asymptotic performance of your
algorithm determining a schedule using no more than k stations.
5 Give an example of a dag consisting of at least 15 vertices on
which your k-station algorithm fails to find a schedule
minimizing the production span for k>1. Explain at what point
your algorithm makes the wrong decision.
6 Give an example of a dag consisting of at least 15 vertices on
which your k-station algorithm generates a schedule achieving
minimum production span, k>1.
7 For the dag you used in question 6: Does your algorithm
produce a schedule achieving minimum production span when
the topological ordering used is the one generated by executing
a DFS on the dag? Explain and illustrate your answer.
For the dag in file dagQ8.txt(400 vertices, 850 edges) create a
plot having k on the x-axis (starting with k=1) and the resulting
production span on the y-axis. Note that the dag has a longest
path length of 17 and thus the minimum production span
possible is 18 (it requires 107 stations). Discuss your plot.
Project 5: Implement four tasks on dags, each having O(n+m)
time performance.
1.For a given dag G, determine the topological number of each
vertex using the degree-based topological sorting algorithm.
• Do not use the DFS approach, but the described degree-based
approach
2.For a given dag G, determine for the length of the longest
path.
• Use the topological numbers and edge relaxation(on max)
17
· Longest path of length is3
· Shortest production span is4
· Possible schedule:
A, (B, C, D), (E, F, G), H
· Possible schedules if only two
stations are available:
A, (B,C), (D,E), (F,G), H A, (B,D), (C,F), (E,G, H
18
Project 5: implement four tasks on dags, each having O(n+m)
time performance.
3. For a given dag G, use the topological numbers and the
longest paths entries to generate a schedule that completes all
manufacturing steps in the shortest production span. Return the
schedule.
4. For a given dag G and an integer k, 1< k < n, use the
topological numbers to determine a schedule using at most k
stations. Return the schedule.
· The schedule for k=1 is the topological order
· No benefit when having more stations than long
·
About the dags and schedules
Take a careful look at the input format
Dags can have multiple sources, but have only one sink
Determine what is needed in class Digraph on entries and
methods
Class schedule cannot be changed
There are other representations of schedule, but you need to
use the one given
20
Analysis question 5
Give an example of a dag consisting of at least 15 vertices on
which your k-station algorithm fails to find a schedule
minimizing the production span for k>1.
Explain at what point your algorithm makes the wrong decision.
feasible and whether it generates minimum production span.
whether your schedule is feasible. However, determining
whether it produces minimum production span is not easy.
algorithm makes a mistake.You have to do more than find a
counterexample. The example has to fool your algorithm!
21
About the schedules
The graph were generated by a dag library and they seem to
be “schedule friendly”
For k>1, two students may generate schedules having a
different production span.
For every production span, there generally exist a number
of valid schedules.
Finding an example where your algorithm fails corresponds
IntroductionTopological sorting is a common operation performed .docx

More Related Content

Similar to IntroductionTopological sorting is a common operation performed .docx

Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
SigSegVSquad
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
To Sum It Up
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
2022cspaawan12556
 
Lecture13
Lecture13Lecture13
Lecture13
vaishali_singh
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and data
vijipersonal2012
 
Performance analysis and randamized agoritham
Performance analysis and randamized agorithamPerformance analysis and randamized agoritham
Performance analysis and randamized agoritham
lilyMalar1
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapter
Savit Chandra
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
Tribhuvan University
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
Sreedhar Chowdam
 
Scribed lec8
Scribed lec8Scribed lec8
Scribed lec8
Praveen Kumar
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
whittemorelucilla
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
DeepakYadav656387
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study Notes
Haitham El-Ghareeb
 
Robust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping AlgorithmsRobust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping Algorithms
Vincenzo De Florio
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
Programming Homework Help
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
Akhil Kaushik
 
Programming in python
Programming in pythonProgramming in python
Programming in python
Ivan Rojas
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
NishaS88
 
Project Management Techniques
Project Management TechniquesProject Management Techniques
Project Management Techniques
project management
 

Similar to IntroductionTopological sorting is a common operation performed .docx (20)

Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
 
Lecture13
Lecture13Lecture13
Lecture13
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and data
 
Performance analysis and randamized agoritham
Performance analysis and randamized agorithamPerformance analysis and randamized agoritham
Performance analysis and randamized agoritham
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapter
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
 
Scribed lec8
Scribed lec8Scribed lec8
Scribed lec8
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study Notes
 
Robust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping AlgorithmsRobust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping Algorithms
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
Programming in python
Programming in pythonProgramming in python
Programming in python
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
 
Project Management Techniques
Project Management TechniquesProject Management Techniques
Project Management Techniques
 

More from mariuse18nolet

IRM 3305 Risk Management Theory and PracticeFall 2014Proje.docx
IRM 3305 Risk Management Theory and PracticeFall 2014Proje.docxIRM 3305 Risk Management Theory and PracticeFall 2014Proje.docx
IRM 3305 Risk Management Theory and PracticeFall 2014Proje.docx
mariuse18nolet
 
Ironwood Company manufactures cast-iron barbeque cookware. During .docx
Ironwood Company manufactures cast-iron barbeque cookware. During .docxIronwood Company manufactures cast-iron barbeque cookware. During .docx
Ironwood Company manufactures cast-iron barbeque cookware. During .docx
mariuse18nolet
 
IRM 3305 Risk Management Theory and PracticeGroup Project.docx
IRM 3305 Risk Management Theory and PracticeGroup Project.docxIRM 3305 Risk Management Theory and PracticeGroup Project.docx
IRM 3305 Risk Management Theory and PracticeGroup Project.docx
mariuse18nolet
 
Iranian Women and GenderRelations in Los AngelesNAYEREH .docx
Iranian Women and GenderRelations in Los AngelesNAYEREH .docxIranian Women and GenderRelations in Los AngelesNAYEREH .docx
Iranian Women and GenderRelations in Los AngelesNAYEREH .docx
mariuse18nolet
 
IRB HANDBOOK IRB A-Z Handbook E.docx
IRB HANDBOOK IRB A-Z Handbook  E.docxIRB HANDBOOK IRB A-Z Handbook  E.docx
IRB HANDBOOK IRB A-Z Handbook E.docx
mariuse18nolet
 
IQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docx
IQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docxIQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docx
IQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docx
mariuse18nolet
 
iPython 2For Beginners OnlyVersion 1.0Matthew .docx
iPython 2For Beginners OnlyVersion 1.0Matthew .docxiPython 2For Beginners OnlyVersion 1.0Matthew .docx
iPython 2For Beginners OnlyVersion 1.0Matthew .docx
mariuse18nolet
 
Iranian Journal of Military Medicine Spring 2011, Volume 13, .docx
Iranian Journal of Military Medicine  Spring 2011, Volume 13, .docxIranian Journal of Military Medicine  Spring 2011, Volume 13, .docx
Iranian Journal of Military Medicine Spring 2011, Volume 13, .docx
mariuse18nolet
 
IoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docx
IoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docxIoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docx
IoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docx
mariuse18nolet
 
IP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docx
IP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docxIP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docx
IP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docx
mariuse18nolet
 
IranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docx
IranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docxIranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docx
IranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docx
mariuse18nolet
 
ipopulation monitoring in radiation emergencies a gui.docx
ipopulation monitoring in radiation emergencies a gui.docxipopulation monitoring in radiation emergencies a gui.docx
ipopulation monitoring in radiation emergencies a gui.docx
mariuse18nolet
 
In Innovation as Usual How to Help Your People Bring Great Ideas .docx
In Innovation as Usual How to Help Your People Bring Great Ideas .docxIn Innovation as Usual How to Help Your People Bring Great Ideas .docx
In Innovation as Usual How to Help Your People Bring Great Ideas .docx
mariuse18nolet
 
Investor’s Business Daily – Investors.comBloomberg Business – Blo.docx
Investor’s Business Daily –  Investors.comBloomberg Business – Blo.docxInvestor’s Business Daily –  Investors.comBloomberg Business – Blo.docx
Investor’s Business Daily – Investors.comBloomberg Business – Blo.docx
mariuse18nolet
 
Invitation to Public Speaking, Fifth EditionChapter 8 Introdu.docx
Invitation to Public Speaking, Fifth EditionChapter 8 Introdu.docxInvitation to Public Speaking, Fifth EditionChapter 8 Introdu.docx
Invitation to Public Speaking, Fifth EditionChapter 8 Introdu.docx
mariuse18nolet
 
Invitation to the Life SpanRead chapters 13 and 14.Objectives.docx
Invitation to the Life SpanRead chapters 13 and 14.Objectives.docxInvitation to the Life SpanRead chapters 13 and 14.Objectives.docx
Invitation to the Life SpanRead chapters 13 and 14.Objectives.docx
mariuse18nolet
 
IOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docx
IOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docxIOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docx
IOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docx
mariuse18nolet
 
INVITATION TO Computer Science 1 1 Chapter 17 Making .docx
INVITATION TO  Computer Science 1 1 Chapter 17 Making .docxINVITATION TO  Computer Science 1 1 Chapter 17 Making .docx
INVITATION TO Computer Science 1 1 Chapter 17 Making .docx
mariuse18nolet
 
Investment Analysis & Portfolio Management AD 717 OLHomework E.docx
Investment Analysis & Portfolio Management AD 717 OLHomework E.docxInvestment Analysis & Portfolio Management AD 717 OLHomework E.docx
Investment Analysis & Portfolio Management AD 717 OLHomework E.docx
mariuse18nolet
 
Investment BAFI 1042 Kevin Dorr 3195598 GOODMAN .docx
Investment BAFI 1042  Kevin Dorr 3195598  GOODMAN .docxInvestment BAFI 1042  Kevin Dorr 3195598  GOODMAN .docx
Investment BAFI 1042 Kevin Dorr 3195598 GOODMAN .docx
mariuse18nolet
 

More from mariuse18nolet (20)

IRM 3305 Risk Management Theory and PracticeFall 2014Proje.docx
IRM 3305 Risk Management Theory and PracticeFall 2014Proje.docxIRM 3305 Risk Management Theory and PracticeFall 2014Proje.docx
IRM 3305 Risk Management Theory and PracticeFall 2014Proje.docx
 
Ironwood Company manufactures cast-iron barbeque cookware. During .docx
Ironwood Company manufactures cast-iron barbeque cookware. During .docxIronwood Company manufactures cast-iron barbeque cookware. During .docx
Ironwood Company manufactures cast-iron barbeque cookware. During .docx
 
IRM 3305 Risk Management Theory and PracticeGroup Project.docx
IRM 3305 Risk Management Theory and PracticeGroup Project.docxIRM 3305 Risk Management Theory and PracticeGroup Project.docx
IRM 3305 Risk Management Theory and PracticeGroup Project.docx
 
Iranian Women and GenderRelations in Los AngelesNAYEREH .docx
Iranian Women and GenderRelations in Los AngelesNAYEREH .docxIranian Women and GenderRelations in Los AngelesNAYEREH .docx
Iranian Women and GenderRelations in Los AngelesNAYEREH .docx
 
IRB HANDBOOK IRB A-Z Handbook E.docx
IRB HANDBOOK IRB A-Z Handbook  E.docxIRB HANDBOOK IRB A-Z Handbook  E.docx
IRB HANDBOOK IRB A-Z Handbook E.docx
 
IQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docx
IQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docxIQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docx
IQuiz # II-Emerson QuizGeneral For Emerson, truth (or.docx
 
iPython 2For Beginners OnlyVersion 1.0Matthew .docx
iPython 2For Beginners OnlyVersion 1.0Matthew .docxiPython 2For Beginners OnlyVersion 1.0Matthew .docx
iPython 2For Beginners OnlyVersion 1.0Matthew .docx
 
Iranian Journal of Military Medicine Spring 2011, Volume 13, .docx
Iranian Journal of Military Medicine  Spring 2011, Volume 13, .docxIranian Journal of Military Medicine  Spring 2011, Volume 13, .docx
Iranian Journal of Military Medicine Spring 2011, Volume 13, .docx
 
IoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docx
IoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docxIoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docx
IoT Referenceshttpswww.techrepublic.comarticlehow-to-secur.docx
 
IP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docx
IP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docxIP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docx
IP Subnet Design Project- ONLY QUALITY ASSIGNMENTS AND 0 PLAG.docx
 
IranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docx
IranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docxIranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docx
IranAyatollahTheocracyTwelver ShiismVilayat-e Faghih (jur.docx
 
ipopulation monitoring in radiation emergencies a gui.docx
ipopulation monitoring in radiation emergencies a gui.docxipopulation monitoring in radiation emergencies a gui.docx
ipopulation monitoring in radiation emergencies a gui.docx
 
In Innovation as Usual How to Help Your People Bring Great Ideas .docx
In Innovation as Usual How to Help Your People Bring Great Ideas .docxIn Innovation as Usual How to Help Your People Bring Great Ideas .docx
In Innovation as Usual How to Help Your People Bring Great Ideas .docx
 
Investor’s Business Daily – Investors.comBloomberg Business – Blo.docx
Investor’s Business Daily –  Investors.comBloomberg Business – Blo.docxInvestor’s Business Daily –  Investors.comBloomberg Business – Blo.docx
Investor’s Business Daily – Investors.comBloomberg Business – Blo.docx
 
Invitation to Public Speaking, Fifth EditionChapter 8 Introdu.docx
Invitation to Public Speaking, Fifth EditionChapter 8 Introdu.docxInvitation to Public Speaking, Fifth EditionChapter 8 Introdu.docx
Invitation to Public Speaking, Fifth EditionChapter 8 Introdu.docx
 
Invitation to the Life SpanRead chapters 13 and 14.Objectives.docx
Invitation to the Life SpanRead chapters 13 and 14.Objectives.docxInvitation to the Life SpanRead chapters 13 and 14.Objectives.docx
Invitation to the Life SpanRead chapters 13 and 14.Objectives.docx
 
IOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docx
IOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docxIOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docx
IOBOARD Week 2 Lab BPage 2 of 4Name _________________ Gr.docx
 
INVITATION TO Computer Science 1 1 Chapter 17 Making .docx
INVITATION TO  Computer Science 1 1 Chapter 17 Making .docxINVITATION TO  Computer Science 1 1 Chapter 17 Making .docx
INVITATION TO Computer Science 1 1 Chapter 17 Making .docx
 
Investment Analysis & Portfolio Management AD 717 OLHomework E.docx
Investment Analysis & Portfolio Management AD 717 OLHomework E.docxInvestment Analysis & Portfolio Management AD 717 OLHomework E.docx
Investment Analysis & Portfolio Management AD 717 OLHomework E.docx
 
Investment BAFI 1042 Kevin Dorr 3195598 GOODMAN .docx
Investment BAFI 1042  Kevin Dorr 3195598  GOODMAN .docxInvestment BAFI 1042  Kevin Dorr 3195598  GOODMAN .docx
Investment BAFI 1042 Kevin Dorr 3195598 GOODMAN .docx
 

Recently uploaded

Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 

Recently uploaded (20)

Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 

IntroductionTopological sorting is a common operation performed .docx

  • 1. Introduction Topological sorting is a common operation performed on directed acyclic graphs (dags). It arises in numerous applications including task scheduling, serialization and dependency determinations, and graph drawing. The goal of this project is to manipulate graph representations, perform topological sorting on a dag, and use the topological numbers in a longest path computation as well as in a heuristic solving a scheduling problem. Degree-based Topological Sort Given is a dag G=(V,E), V={0, 1, … ,n-1}, having n vertices and m edges. The graph is represented in the form of adjacency lists. For each vertex u, Aout[u] points to a list containing all vertices v such that <u,v> is an edge from u to v and Ain[u] points to a list containing all vertices v such that <v,u> is an edge from v to u. The length of list Aout[u] is the out-degree of node u and the length of list Ain[u] is the in-degree of node u. In any dag there exists at least one vertex having in-degree 0 (called the sources) and at least one vertex with out-degree 0 (called the sinks). The dags used in the project can have an arbitrary number of sources, but will always have one sink. The dag shown in Figure 1 has two sources (vertices A and G) and one sink (vertex F). Figure 1: A 7-vertex dag with two sources and one sink. Topological sorting assigns to each vertex an integer (also called its topological number). See Chapter 4.2 in the text for details. The topological numbers represent a linear ordering of the vertices such that for every edge <u,v> vertex u appears before v in the ordering. For the graph in Figure 1, the ordering A G B D C E F is a topological ordering and the topological numbers are A=0, B=2, C=4, D=3, E=5, F=6, G=1. Note that topological orderings are not unique. We note that the textbook presents topological sorting as an application of DFS (Algorithm 4.5 in Chapter 4.2). Another
  • 2. approach is a non-recursive implementation based on a degree- driven graph exploration. In this project you need to implement the degree-based topological sorting approach described below. All source vertices are ready to be placed. For Figure 1, vertices A and G can be placed right away. Once a vertex u has all the vertices incident to its incoming edges placed, u can be placed. This observation forms the basis of degree-based topological sorting algorithm. The algorithm uses a queue TSQ. Whether one uses a FIFO or a LIFO (i.e., stack) queue does not matter for determining a topological ordering (different queues will produce different orderings). The topological numbers are maintained in an array, say array T. The high-level description of the degree-driven algorithm is as follows: 1 Make all initializations; includes a variable count set to 0 and placing all sources in queue TSQ. 2 u = dequeue() and we set T[u]=count 3 All of u’s out-going edges are examined. For each edge <u,v>, reduce the number of edges into v by 1. Once all incoming edges of vertex v have received topological numbers, this count would be zero and v is placed into TSQ. 4 Repeat steps 2 to 3 until TSQ is empty. The needed book-keeping details are yours to work out. In particular, you need to decide how to manage the counts into vertices used in step 3. Keep in mind that the running time of step 3 needs to be proportional to the number of v's outgoing edges. You can assume that all sinks can be reached from at least one source. The algorithm implementation needs to run in O(n+m) time. Longest Path Computation and Scheduling Assume the dag describes a manufacturing process and each vertex corresponds to one production step. Production step u cannot start until all production steps associated with the incoming edges incident to u have been completed. A
  • 3. topological ordering now represents one possible production sequence. Manufacturing times at different production steps vary in applications, but in this project we assume that every production step takes the same amount of time. When there is no limit on the number of production steps that can be carried out simultaneously, what is the minimum time in which all production steps can be completed? We refer to the time needed to complete a manufacturing process as the production span. The production span cannot be shorter than the length of the longest path from any source to the sink, plus 1 (because the longest path counts the number of edges). The longest paths is also called the critical path length (critical as reducing the production span needs to shorten the length of the longest paths in the dag.) You need to determine the length of the longest path in the dag and a manufacturing schedule which achieving minimum production span. The number of production steps that can execute at the same time is not limited. Figure 2: A 8-vertex dag with a longest path of 3. The DAG in Figure 2 has a longest path of length of 3. This means that it is possible to schedule the eight production steps in a production span of 4. Here is a possible schedule: A, (B, C, D), (E, F, G), H. At time 0, production step A is the only one executing; at time 1, three production steps are executing simultaneously, etc. At any point, no more than 3 stations are used simultaneously (and thus no more than 3 production steps execute simultaneously). Algorithm 4.10 in Section 4.4 of the text presents an O(n+m) time shortest path algorithm for a DAG. By changing the vertex relaxation, the algorithm can be changed into the needed longest path algorithm. See your class notes for more detail. Scheduling with k Stations Assume now that at most k manufacturing stations can be used at any time. You have already developed solutions for two cases: when k=1 and when the value of k can be as large as
  • 4. needed. Assume k>1. It turns out that generating a schedule using at most k stations simultaneously and minimizing the production span is not an easy problem. You will implement an algorithm that is a natural generalization of the two earlier algorithms. The algorithm will never use more than k manufacturing stations, but the resulting production span may not be the smallest possible (for k stations). This means that the algorithm will make decisions on which production steps to assign to stations at times steps that may to not result in the best possible production span. However, your algorithm will be be fast - run in O(n+m) time - and will never use more than k stations. You are asked to develop an O(n+m) time algorithm for scheduling the n manufacturing steps when at any time at most k stations are available. Thus, k tasks can execute simultaneously at any time. The value of k is given. Your algorithm should assign to each vertex u a level number L(u) such that · every level contains at most k vertices, and · for every edge <u,v>, we have L(u)<L(v). The largest level represents the achieved production span. You need to work out a number of implementation details in your scheduling algorithm. Make sure it runs in O(n+m) time. Your algorithm should be based on the following approach: 1 The vertices are considered in topological order. For each vertex v, assign v to a level p if (i) level p is at least one level higher than the largest level assigned to any of v’s incoming edges, and (ii) level p does not already have k vertices assigned to it. If more than one vertex qualifies for placement, an arbitrary one is chosen. 2 Repeat the process until all vertices have been scheduled. 3 Report the schedule and the achieved production span. Summary of Tasks This project asks you to implement the following tasks. Each task needs to have an O(n+m) time implementation. 1 For a given dag G, determine the topological number of each
  • 5. vertex using the degree-based topological sorting algorithm. 2 For a given dag G, determine for the length of the longest path. 3 For a given dag G, use the topological numbers and the longest paths entries to generate a schedule that completes all manufacturing steps in the shortest production span. Return the schedule. 4 For a given dag G and an integer k, 1< k < n, use the topological numbers to determine a schedule using at most k stations. Return the schedule. For those interested in using graph visualization tools, we provide the following links to resources: · Network Workbench - http://nwb.cns.iu.edu/index.html · graphviz - http://www.linuxdevcenter.com/pub/a/linux/2004/05/06/graphvi z_dot.html · Cytoscape - http://www.cytoscape.org/ Programming Assignment The skeleton code contains a number example dags. Each dag file has the following format: <number of vertices> vertices, <number of edges> edges 0: In: <incoming edges for vertice> Out: <outgoing edges for vertice> 1: In: <incoming edges for vertice> Out: <outgoing edges for vertice> ... n: In: <incoming edges for vertice> Out: <outgoing edges for vertice> For example, for a 4-vertex dag the input can look like: 4 vertices, 6 edges 0: In: 2 Out: 1 3
  • 6. 1: In: 0 2 Out: 3 2: In: Out: 3 0 1 3: In: 2 0 1 Out: Represent each dag so that it maintains for each vertex the list of out-edges as well as in-edges. You need to define a class Digraph that you can adapt from the one given from Princeton library. Add additional entries as needed. For tasks 3 and 4, the generated schedule is represented as described in Schedule.java. The data structure resembles the structure of adjacency lists: it is an array of lists. The size of the array equals the production span and the list at the j-th entry of the array contains the steps executing simultaneously at time j (listed in arbitrary order). Do not modify Schedule.java. You can use methods in Schedule.java to construct a schedule. You must implement the following methods of the DagUtilities class: · public static int[] topologicalSort(Digraph G) · perform topological sort on dag G and assign topological numbers. · public static int longestPath(Digraph G) · return the length of the longest path in the dag G. · public static Schedule minProdSpanSchedule(Digraph G) · for dag G, return a schedule minimizing the production span. · public static Schedule spanKStations(Digraph G, int k) · for dag G and integer k, return a schedule using at most k stations. · public static Digraph readGraphFromFile(File file) · Read a dag from input file and return the dag Testing You have been provided with several example trees which you
  • 7. should use to test your code. To run our main function, use the following command: $ java -cp <colon separated path(s) to classes> Project5Test [Graph_File_Path] If you want to specify the number of stations for task 4, use the following command: $ java -cp <colon separated path(s) to classes> Project5Test [Graph_File_Path] -s [Number_Of_Stations] Analysis Questions Your report must answer each question briefly and clearly. 1 State and explain the asymptotic performance of your algorithm determining the topological numbers. 2 State and explain the asymptotic performance of your algorithm determining the longest path in the dag. 3 State and explain the asymptotic performance of your algorithm determining a schedule achieving minimum production span. 4 State and explain the asymptotic performance of your algorithm determining a schedule using no more than k stations. 5 Give an example of a dag consisting of at least 15 vertices on which your k-station algorithm fails to find a schedule minimizing the production span for k>1. Explain at what point your algorithm makes the wrong decision. 6 Give an example of a dag consisting of at least 15 vertices on which your k-station algorithm generates a schedule achieving minimum production span, k>1. 7 For the dag you used in question 6: Does your algorithm produce a schedule achieving minimum production span when the topological ordering used is the one generated by executing a DFS on the dag? Explain and illustrate your answer. For the dag in file dagQ8.txt(400 vertices, 850 edges) create a plot having k on the x-axis (starting with k=1) and the resulting production span on the y-axis. Note that the dag has a longest path length of 17 and thus the minimum production span possible is 18 (it requires 107 stations). Discuss your plot.
  • 8. Project 5: Implement four tasks on dags, each having O(n+m) time performance. 1.For a given dag G, determine the topological number of each vertex using the degree-based topological sorting algorithm. • Do not use the DFS approach, but the described degree-based approach 2.For a given dag G, determine for the length of the longest path. • Use the topological numbers and edge relaxation(on max) 17 · Longest path of length is3 · Shortest production span is4 · Possible schedule: A, (B, C, D), (E, F, G), H · Possible schedules if only two stations are available: A, (B,C), (D,E), (F,G), H A, (B,D), (C,F), (E,G, H 18 Project 5: implement four tasks on dags, each having O(n+m) time performance. 3. For a given dag G, use the topological numbers and the longest paths entries to generate a schedule that completes all manufacturing steps in the shortest production span. Return the schedule. 4. For a given dag G and an integer k, 1< k < n, use the topological numbers to determine a schedule using at most k stations. Return the schedule. · The schedule for k=1 is the topological order · No benefit when having more stations than long · About the dags and schedules Take a careful look at the input format Dags can have multiple sources, but have only one sink
  • 9. Determine what is needed in class Digraph on entries and methods Class schedule cannot be changed There are other representations of schedule, but you need to use the one given 20 Analysis question 5 Give an example of a dag consisting of at least 15 vertices on which your k-station algorithm fails to find a schedule minimizing the production span for k>1. Explain at what point your algorithm makes the wrong decision. feasible and whether it generates minimum production span. whether your schedule is feasible. However, determining whether it produces minimum production span is not easy. algorithm makes a mistake.You have to do more than find a counterexample. The example has to fool your algorithm! 21 About the schedules The graph were generated by a dag library and they seem to be “schedule friendly” For k>1, two students may generate schedules having a different production span. For every production span, there generally exist a number of valid schedules. Finding an example where your algorithm fails corresponds