If we cannot find a vertex with in degree zero we

Info icon This preview shows pages 16–26. Sign up to view the full content.

View Full Document Right Arrow Icon
If we cannot find a vertex with in-degree zero, we will show there must be a cycle Start with any vertex and define a list L = ( v ) Then iterate this loop |V | times: The first vertex 1 in the list L does not have in-degree zero So we can find a vertex w such that ( w , 1 ) is an edge Add w to the list: L = ( w , 1 , …, k ) By the pigeon-hole principle, at least one vertex must appear twice This forms a cycle; hence a contradiction, as this is a DAG
Image of page 16

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Topological Sort First, we need a two lemmas: Any sub-graph of a DAG is a DAG Proof: If a sub-graph has a cycle, that same cycle must appear in the super- graph We assumed the super-graph was a DAG This is a contradiction the sub-graph must be a DAG
Image of page 17
Topological Sort We will start with showing a b : If a graph is a DAG, it has a topological sort Proof by induction: A graph with one vertex is a DAG and it has a topological sort Assume a DAG with n vertices has a topological sort A DAG with n + 1 vertices must have at least one vertex v of in-degree zero Removing the vertex v and consider the vertex-induced sub-graph with the remaining n vertices If this sub-graph has a cycle, so would the original graph—contradiction Thus, the graph with n vertices is also a DAG, therefore it has a topological sort Add the vertex v to the start of the topological sort to get one for the graph of size n + 1
Image of page 18

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Topological Sort Next, we will show that b a : If a graph has a topological ordering, it must be a DAG We will show this by showing the contrapositive: ¬ a ¬ b : If a graph is not a DAG, it does not have a topological sort By definition, it has a cycle: ( v 1 , v 2 , v 3 , …, v k , v 1 ) In any topological sort, v 1 must appear before v 2 , because ( v 1 , v 2 ) is a path However, there is also a path from v 2 to v 1 : ( v 2 , v 3 , …, v k , v 1 ) Therefore, v 2 must appear in the topological sort before v 1 This is a contradiction, therefore the graph cannot have a topological sort a b : A graph is a DAG if and only if it has a topological sorting
Image of page 19
Outline Topological sorting Definitions Algorithm Finding the critical path
Image of page 20

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Topological Sort Idea: Given a DAG V , iterate: Find a vertex v in V with in-degree zero Let v be the next vertex in the topological sort Continue iterating with the vertex-induced sub-graph V \ { v }
Image of page 21
Example On this graph, iterate the following |V| = 12 times Choose a vertex v that has in-degree zero Let v be the next vertex in our topological sort Remove v and all edges connected to it
Image of page 22

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Example Let’s step through this algorithm with this example Which task can we start with?
Image of page 23
Example Of Tasks C or H, choose Task C
Image of page 24

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Example Having completed Task C, which vertices have in-degree zero?
Image of page 25
Image of page 26
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern