Graphs.

Slides:



Advertisements
Similar presentations
© 2004 Goodrich, Tamassia Directed Graphs1 JFK BOS MIA ORD LAX DFW SFO.
Advertisements

Directed Graphs Directed Graphs Shortest Path 4/10/ :45 AM BOS
Depth-First Search1 Part-H2 Depth-First Search DB A C E.
1 The Graph Abstract Data Type CS 5050 Chapter 6.
© 2004 Goodrich, Tamassia Directed Graphs1 JFK BOS MIA ORD LAX DFW SFO.
1 Directed Graphs CSC401 – Analysis of Algorithms Lecture Notes 15 Directed Graphs Objectives: Introduce directed graphs and weighted graphs Present algorithms.
TTIT33 Alorithms and Optimization – DALG Lecture 4 Graphs HT TTIT33 Algorithms and optimization Algorithms Lecture 4 Graphs.
Directed Graphs1 JFK BOS MIA ORD LAX DFW SFO. Directed Graphs2 Outline and Reading (§6.4) Reachability (§6.4.1) Directed DFS Strong connectivity Transitive.
TDDB56 DALGOPT-D TDDB57 DALG-C – Lecture 11 – Graphs Graphs HT TDDB56 – DALGOPT-D Algorithms and optimization Lecture 11 Graphs.
Been-Chian Chien, Wei-Pang Yang, and Wen-Yang Lin 6-1 Chapter 6 Graphs Introduction to Data Structure CHAPTER 6 GRAPHS 6.1 The Graph Abstract Data Type.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graphs – ADTs and Implementations ORD DFW SFO LAX
Graphs Chapter 12.
Graphs1 Definitions Examples The Graph ADT LAX PVD LAX DFW FTL STL HNL.
Spring 2007Graphs1 ORD DFW SFO LAX
GRAPHS 1. Outline 2  Undirected Graphs and Directed Graphs  Depth-First Search  Breadth-First Search.
© 2004 Goodrich, Tamasia Recall: Digraphs A digraph is a graph whose edges are all directed Short for “directed graph” Applications one-way streets flights.
Graphs and Paths : Chapter 15 Saurav Karmakar
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: Graphs Data Structures.
1 Digraphs Reachability Connectivity Transitive Closure Floyd-Warshall Algorithm JFK BOS MIA ORD LAX DFW SFO v 2 v 1 v 3 v 4 v 5 v 6 v 7.
CHAPTER 13 GRAPH ALGORITHMS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
Lecture #13. Topics 1.The Graph Abstract Data Type. 2.Graph Representations. 3.Elementary Graph Operations.
Directed Graphs1 JFK BOS MIA ORD LAX DFW SFO. Directed Graphs2 Outline and Reading (§12.4) Reachability (§12.4.1) Directed DFS Strong connectivity Transitive.
Graphs ORD SFO LAX DFW Graphs 1 Graphs Graphs
BCA-II Data Structure Using C Submitted By: Veenu Saini
Data Structures & Algorithm Analysis lec(8):Graph T. Souad alonazi
Graphs 10/24/2017 6:47 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Directed Graphs Directed Graphs Shortest Path 12/7/2017 7:10 AM BOS
Directed Graphs 12/7/2017 7:15 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
14 Graph Algorithms Hongfei Yan June 8, 2016.
Graphs.
Graphs 7/18/2018 7:39 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Searching Graphs ORD SFO LAX DFW Spring 2007
CSE 2331/5331 Topic 9: Basic Graph Alg.
Graphs ORD SFO LAX DFW Graphs Graphs
COMP9024: Data Structures and Algorithms
COMP9024: Data Structures and Algorithms
Chapter 14 Graph Algorithms
Introduction to Graphs
Directed Graphs 9/20/2018 1:45 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
Directed Graphs 5/1/15 12:25:22 PM
Data Structures and Algorithms for Information Processing
Directed Graphs Directed Graphs 1 Shortest Path Shortest Path
Graphs Part 1.
CMSC 341 Lecture 21 Graphs (Introduction)
Directed Graphs (digraphs)
Graphs.
Graphs.
Graphs Graph transversals.
Graph & BFS.
Graphs CSE 2011 Winter November 2018.
Elementary Graph Algorithms
What is a Graph? a b c d e V= {a,b,c,d,e} E= {(a,b),(a,c),(a,d),
Minimum Spanning Tree Section 7.3: Examples {1,2,3,4}
Chapter 11 Graphs.
Graphs ORD SFO LAX DFW Graphs Graphs
Subgraphs, Connected Components, Spanning Trees
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs 4/29/15 01:28:20 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Searching Graphs ORD SFO LAX DFW Spring 2007
What is a Graph? a b c d e V= {a,b,c,d,e} E= {(a,b),(a,c),(a,d),
Directed Graphs Directed Graphs Directed Graphs 2/23/ :12 AM BOS
Graphs Part 1 ORD SFO LAX DFW
Graph Algorithms "A charlatan makes obscure what is clear; a thinker makes clear what is obscure. " - Hugh Kingsmill CLRS, Sections 22.2 – 22.4.
Graphs Chapter 7 Visit for more Learning Resources.
Elementary Graph Algorithms
GRAPHS.
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Graphs

What is a Graph? A graph G = (V,E) is composed of: V: set of vertices E: set of edges connecting the vertices in V An edge e = (u1,u2) is a pair of vertices Examples: Bus routes Transitions in a finite state machine Course prerequisites

What is a Graph? If the elements of E(G) are ordered pairs then G is called a directed graph or digraph; else G is called an undirected graph In an undirected graph, the pairs (u1,u2) and (u2,u1) represent the same edge

What is a Graph? 2 3 1 4 5 2 3 1 4 5 Undirected Graph Directed Graph

Applications Electronic circuits Transportation networks Printed circuit board Integrated circuit Transportation networks Highway network Flight network Computer networks Local area network Internet Web JFK LAX LAX STL HNL DFW

Terminology Adjacent and Incident If (v0, v1) is an edge in an undirected graph, v0 and v1 are adjacent The edge (v0, v1) is incident on vertices v0 and v1 If (v0, v1) is an edge in a directed graph v0 is adjacent to v1, and v1 is adjacent from v0 The edge (v0, v1) is incident on v0 and v1 v0 v1 v0 v1

Terminology (cont.) Degree of a Vertex The degree of a vertex is the number of edges incident to that vertex For directed graph, - the in-degree of a vertex v is the number of edges that have v as the head - the out-degree of a vertex v is the number of edges that have v as the tail if di is the degree of a vertex i in a graph G with n vertices and e edges, the number of edges is Why? Since adjacent vertices each count the adjoining edge, it will be counted twice

Examples 1 2 1 3 2 G1 G2 Undirected Graph Directed Graph 3 in:1, out: 1 3 1 2 1 in: 1, out: 2 3 3 3 2 in: 1, out: 0 G1 G2

Terminology (cont.) Path Simple path Examples P1 X U V W Z Y a c b e d sequence of vertices v1,v2,. . .vk such that consecutive vertices vi and vi+1 are adjacent. Simple path no repeated vertices Examples P1=(V, X, Z) is a simple path P2=(U, W, X, Y, W, V) is a path that is not simple P1 X U V W Z Y a c b e d f g h P2

Terminology (cont.) Cycle Simple cycle Examples C1 X U V W Z Y a c b e circular sequence of vertices, where that the last vertex is the same as the first vertex . Simple cycle simple path, except that the last vertex is the same as the first vertex Examples C1=(V, X, Y, W, U, V) is a simple cycle C2=(U, W, X, Y, W, V, U) is a cycle that is not simple C1 X U V W Z Y a c b e d f g h C2

Terminology (cont.) Subgraph Spanning subgraph A subgraph S of a graph G is a graph such that The vertices of S are a subset of the vertices of G The edges of S are a subset of the edges of G Spanning subgraph A spanning subgraph of G is a subgraph that contains all the vertices of G Subgraph S Spanning subgraph

Subgraphs Examples 1 2 3 G1 1 2 G2 (a) Some of the subgraph of G1 1 2 3 1 2 3 3 1 2 1 2 (i) (ii) (iii) (iv) (a) Some of the subgraph of G1 G1 1 2 1 1 2 1 2 (i) (ii) (iii) (iv) (b) Some of the subgraph of G2 G2

Non connected graph with two connected components Terminology (cont.) Connected graph Non connected graph with two connected components Connected graph there is a path between every pair of vertices Connected component it is the maximal connected subgraph of G

Terminology (cont.) Tree Forest it is a connected graph without cycles // This definition is different from the rooted tree (in chapter 9) Forest collection of trees (i.e. it is an undirected graph without cycles) tree forest

Terminology (cont.) A spanning tree of a connected graph is a spanning subgraph that is a tree A spanning tree is not unique unless the graph is a tree Spanning trees have applications to the design of communication networks A spanning forest of a graph is a spanning subgraph that is a forest Graph Spanning tree

Terminology (cont.) A complete graph is a graph in which all pairs of vertices are adjacent How many total edges in a complete graph? Each of the n vertices is incident to n-1 edges, however, we would have counted each edge twice! Therefore, intuitively, m = n(n -1)/2 edges. Therefore, if a graph is not complete, m < n(n -1)/2 n = 5 m = (5*4)/2

Graph Representation Two standard ways Adjacency-matrix representation Space required O(n2). Adjacency-list representation Space required O(|E|) Depending on problems, both representations are useful.

Adjacency-matrix representation Assume that the nodes are numbered 1, 2, …, n. The adjacency-matrix consists of a |V ||V | matrix A=(aij) such that if (i,j)  E aij= 1 else aij= 0. 1 2 3 4 5 1 2 3 4 5 0 1 0 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0 1 1 1 0 1 0 2 1 5 4 3

Adjacency-matrix representation Space required O(n2) The adjacency matrix for an undirected graph is symmetric. Hence, we may store only lower or upper triangle 1 2 3 4 5 1 2 3 4 5 0 1 0 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0 1 1 1 0 1 0

Examples for Adjacency Matrix 1 2 1 2 3 4 5 6 2 1 3 G2 7 G1 symmetric undirected: n2/2 directed: n2 G3

Adjacency Matrix Analysis Operation Time The degree of a vertex v is O(n) For a digraph (= directed graph), the row sum is the out degree, while the column sum is the in degree Find the edges incident to a given vertex v Check that two vertices v and w are adjacent O(1) Insert (or remove) a Vertex v O(n2) Insert (or remove) and Edge e

Adjacency-list representation Let G=(V, E) be a graph V– set of nodes (vertices) E– set of edges. For each wV, the adjacency list A[w] contains all nodes in V that are adjacent to u. 2 5 / 1 2 1 5 4 3 2 1 5 3 4 / 3 2 4 / 4 2 5 3 / 5 4 1 2 / (a) (b)

Examples for Adjacency List 1 2 3 4 5 6 7 1 2 3 1 2 3 1 2 3 2 3 1 3 1 2 3 4 5 6 7 1 2 1 2 3 3 G1 1 2 1 2 5 1 2 1 4 6 2 5 7 6 G2 G3 An undirected graph with n vertices and e edges ==> n head nodes and 2e list nodes

Adjacency List Analysis Operation Time Find the edges incident to a given vertex v O(degree(v)) Check that two vertices v and w are adjacent O(min (degree(v), degree(w))) Insert a Vertex v O(1) Remove a Vertex v Insert an Edge e

Example Graph in JAVA public class Graph<E> { // 1. The vertex numbers range from 0 to labels.length-1. // 2. For each vertex number i, labels[i] contains the label for vertex i. // 3. For any two vertices i and j, edges[i][j] is true if there is a // vertex from i to j; otherwise edges[i][j] is false. private boolean[ ][ ] edges; private E[ ] labels; : // Graph methods appear here }

Example Graph in JAVA public Graph(int n) { edges = new boolean[n][n]; // All values initially false labels = (E[ ]) new Object[n]; // All values initially null } public void addEdge(int source, int target) edges[source][target] = true;

Example Graph in JAVA public Object getLabel(int vertex) { return labels[vertex]; } public boolean isEdge(int source, int target) return edges[source][target];

Example Graph in JAVA public int[ ] neighbors(int vertex) { int i; int count; int[ ] answer; // First count how many edges have the vertex as their source count = 0; for (i = 0; i < labels.length; i++) if (edges[vertex][i]) count++; } :

Example Graph in JAVA public int[ ] neighbors(int vertex) { : : // Allocate the array for the answer answer = new int[count]; // Fill the array for the answer count = 0; for (i = 0; i < labels.length; i++) { if (edges[vertex][i]) answer[count++] = i; } return answer;

Example Graph in JAVA public void removeEdge(int source, int target) { edges[source][target] = false; } public void setLabel(int vertex, E newLabel) labels[vertex] = newLabel; public int size( ) return labels.length;

Graph Traversals No obvious order of traversal (like trees) No obvious starting point (no root) Traversals may not reach every vertex by following edges (connectedness) Traversals may return to a vertex (cycles) References: Data Structures and Algorithms in JAVA By M. Goodrich and R. Tamassia Chapters 9 & 10

Graph Traversals Traversal Algorithms: References: - Depth-first search DFS. - Breadth-first search BFS. References: Data Structures and Algorithms in JAVA By M. Goodrich and R. Tamassia Chapters 9 & 10

Depth-first search DFS Visits a vertex, then visit a neighbor of the vertex, visit a neighbor of the neighbor, Etc. Advance as possible from the original vertex Then back up by one vertex Considers the next neighbor

Example unexplored vertex visited vertex unexplored edge B A C E A visited vertex unexplored edge discovery edge back edge D B A C E D B A C E

Example (cont.) D B A C E D B A C E D B A C E D B A C E

DFS Algorithm Algorithm DFS( v) Input A vertex v of a graph G Output labeling of the edges of G in the connected component of v as discovery edges and back edges label v as visited for each edge e incident on v do if edge e is unexplored then let w be the other endpoint of e if vertex w is unvisited then Label e as a discovery edge recursively call DFS(w) else label e as a back edge

Data Structures and Algorithms in JAVA, M. Goodrich and R. Tamassia Example 2 (a) (b) (c) (d) (e) (f) Data Structures and Algorithms in JAVA, M. Goodrich and R. Tamassia

Properties of DFS Property 1 Property 2 DFS(G, v) visits all the vertices in the connected component of v Property 2 The discovery edges labeled by DFS(G, v) form a spanning tree of the connected component of v v D B A C E

Properties of DFS Property 3 Let G be a graph with n vertices and m edges. A DFS traversal of G can be performed in time O(n+m). Also, there exist O(n+m) time algorithms based on DFS for the following problems: Computing a spanning tree of G, if G is connected Computing the connected components of G Computing a path from one given vertex to another in G Computing a cycle in G, or reporting that G has no cycles

Breadth-first search BFS Visits a vertex, then visit each of the vertex's neighbors before advancing

Note: BFS subdivides the vertices into levels (L0, L1,….etc.) Example unexplored vertex C B A E D L0 L1 F A visited vertex A unexplored edge discovery edge cross edge L0 L0 A A L1 L1 B C D B C D E F E F Note: BFS subdivides the vertices into levels (L0, L1,….etc.)

Note: BFS subdivides the vertices into levels (L0, L1,….etc.) Example C B A E D L0 L1 F C B A E D L0 L1 F L2 C B A E D L0 L1 F L2 C B A E D L0 L1 F L2 Note: BFS subdivides the vertices into levels (L0, L1,….etc.)

Note: BFS subdivides the vertices into levels (L0, L1,….etc.) Example C B A E D L0 L1 F L2 L0 A L1 B C D L2 E F C B A E D L0 L1 F L2 Note: BFS subdivides the vertices into levels (L0, L1,….etc.)

Breadth-first search BFS Algorithm BFS(v) Input A vertex v of a graph G Output labeling of the edges of G in the connected component of v as discovery edges and cross edges initialize container L0 to contain vertex v i  0 while Li is not empty do create container Li+1 to initially be empty for each vertex v in Li do for each edge e incident on v do if edge e is unexplored then let w be the other endpoint of e if vertex w is unexplored then label e as a discovery edge insert w into Li+1 else label e as a cross edge i  i + 1

Data Structures and Algorithms in JAVA, M. Goodrich and R. Tamassia Example Data Structures and Algorithms in JAVA, M. Goodrich and R. Tamassia

Properties L0 L1 L2 A Property 1 BFS(s) visits all the vertices in the connected component of s Property 2 The discovery edges form a spanning tree Ts of connected component of s Property 3 For each vertex v in Li The path of Ts from s to v has i edges Any other path from s to v in Gs has at least i edges B C D E F L0 A L1 B C D L2 E F

Properties Property 4 Let G be a graph with n vertices and m edges. A BFS traversals of G takes time O(n+m). Also, there exist O(n+m) time algorithms based on BFS for the following problems: Testing whether G is connected Computing a spanning tree of G, if G is connected Computing the connected components of G Computing, for every vertex v of G, the minimum number of edges of any path between s and v

Another Implementation for BFS Algorithm BFS(v) Input A vertex v of a graph G Output processing the vertices of the connected component of v vertexQueue = a new queue to hold vertices as they are visited Mark v as visited vertexQueue.enqueue (v) while (!vertexQueue.isEmpty ()) do frontVertex = vertexQueue.dequeue () //process frontVertex while (frontVertex has a neighbor) do nextNeighbor = next neighbor of frontVertex if (nextNeighbor is not visited) then Mark nextNeighbor as visited vertexQueue.enqueue (nextNeighbor)

Applications: Cycle Finding We can specialize the DFS algorithm to find a simple cycle We use a stack S to keep track of the path between the start vertex and the current vertex As soon as a back edge (v, w) is encountered, we return the cycle as the portion of the stack from the top to vertex w

Applications: Path Finding Find path from source vertex s to destination vertex d Use graph search starting at s and terminating as soon as we reach d Need to remember edges traversed Use depth first search DFS? Use breath first search BFS?

DFS vs. BFS D C B B B A A A A G D B A F B A start DFS Process E G D C destination D Call DFS on D C DFS on C B DFS on B B B Return to call on B A DFS on A A A A found destination - done! Path is implicitly stored in DFS recursion Path is: A, B, D, G G Call DFS on G D B A

DFS vs. BFS A B D C D G F B A start E BFS Process G D C destination rear front rear front rear front rear front A B D C D Initial call to BFS on A Add A to queue Dequeue A Add B Dequeue B Add C, D Dequeue C Nothing to add rear front G found destination - done! Path must be stored separately Dequeue D Add G

Digraphs E D C B A A digraph is a graph whose edges are all directed Short for “directed graph” Applications one-way streets flights task scheduling A graph G=(V,E) such that Each edge goes in one direction: Edge (a,b) goes from a to b, but not b to a. A C E B D

Digraph Application Scheduling: edge (a,b) means task a must be completed before b can be started cs21 cs22 cs23 cs51 cs53 cs52 cs181 cs131 cs141 cs121 cs171 The good life cs151

Reachability Directed Graph rooted at v : vertices reachable from v via directed paths v E D v E D C A C F v A B E D C F A B

Strong Connectivity Each vertex can reach all other vertices a g c d e b e f g

Strong Connectivity Algorithm Pick a vertex v in G. Perform a DFS from v in G. If there’s a w not visited, print “no”. Let G’ be G with edges reversed. Perform a DFS from v in G’. Else, print “yes”. Running time: O(n+m). c d e b f a G’: g c d e b f

Transitive Closure Given a digraph G, the transitive closure of G is the digraph G* such that G* has the same vertices as G if G has a directed path from u to v (u  v), G* has a directed edge from u to v The transitive closure provides reachability information about a digraph B A D C E G B A D C E G*

Computing the Transitive Closure We can perform DFS starting at each vertex Based on the idea that, if there's a way to get from A to B and from B to C, then there's a way to get from A to C. O(n(n+m)) Alternatively ... Use The Floyd-Warshall Algorithm

Floyd-Warshall Transitive Closure Floyd-Warshall’s algorithm numbers the vertices of G as v1 , …, vn and computes a the transitive closure in a series of rounds Initialize G0=G Begin a computation of the rounds, beginning with round 1 In generic round k , we construct Gk as: Gk = Gk-1 Add a directed edge (vi, vj) to Gk , if Gk-1 contains both the edges (vi, vk) and (vk, vj) After n rounds, we have that Gn = G* Running time: O(n3), assuming adjacency matrix representation (i.e. checking whether 2 vertices are adjacent is O(1) )

Floyd-Warshall - Example JFK BOS MIA ORD LAX DFW SFO v 2 1 3 4 5 6 G0=G

Floyd-Warshall - Iteration 1 G1 BOS v ORD 4 JFK v 2 v 6 SFO DFW LAX v 3 v 1 MIA v 5

Floyd-Warshall - Iteration 2 G2 JFK BOS MIA ORD LAX DFW SFO v 2 1 3 4 5 6

Floyd-Warshall - Iteration 3 G3 BOS v ORD 4 JFK v 2 v 6 SFO DFW LAX v v 3 1 MIA v 5

Floyd-Warshall - Iteration 4 G4 BOS v ORD 4 JFK v 2 v 6 SFO DFW LAX v v 3 1 MIA v 5

Floyd-Warshall - Iteration 5 G5 BOS v ORD 4 JFK v 2 v 6 SFO DFW LAX v 3 v 1 MIA v 5

Floyd-Warshall - Iteration 6 JFK MIA ORD LAX DFW SFO v 2 1 3 4 5 6 BOS G6

Floyd-Warshall - Conclusion JFK MIA ORD LAX DFW SFO v 2 1 3 4 5 6 BOS G7

Floyd-Warshall - Algorithm Algorithm FloydWarshall(G) Input digraph G with n vertices Output transitive closure G* of G i := 1 for all v  G denote v as vi i := i + 1 G0 := G for k := 1 to n do Gk := Gk - 1 for i := 1 to n (i  k) do for j := 1 to n (j  i, k) do if both edges (vi, vk) and (vk, vj)  Gk - 1 then add edge (vi, vj) to Gk. (if it is not already present) return Gn

DAGs and Topological Ordering A directed acyclic graph (DAG) is a digraph that has no directed cycles A topological ordering of a digraph is a numbering v1 , …, vn of the vertices such that for every edge (vi , vj), we have i < j Example: in a task scheduling digraph, a topological ordering a task sequence that satisfies the precedence constraints Theorem A digraph might has a topological ordering if and only if it is a DAG B A D C E DAG G Topological ordering of G v1 v2 v3 v4 v5

Topological Sorting Number vertices, so that (u,v) in G implies u < v 1 wake up 2 3 eat study computer sci. A typical student day 4 5 nap more c.s. 7 play 8 write c.s. program 6 9 work out make cookies for professors 10 sleep 11 dream about graphs

Algorithm for Topological Sorting Algorithm TopologicalSort(G) H := G // Temporary copy of G n := the number of vertices in G while H is not empty do Let v be a vertex with no outgoing edges Label v := n n := n - 1 Remove v from H Running time: O(n + m)

Topological Sorting Example

Topological Sorting Example 9

Topological Sorting Example 9

Topological Sorting Example 8 9

Topological Sorting Example 8 9

Topological Sorting Example 7 8 9

Topological Sorting Example 7 8 9

Topological Sorting Example 6 7 8 9

Topological Sorting Example 6 7 8 9

Topological Sorting Example 6 5 7 8 9

Topological Sorting Example 6 5 7 8 9

Topological Sorting Example 4 6 5 7 8 9

Topological Sorting Example 4 6 5 7 8 9

Topological Sorting Example 3 4 6 5 7 8 9

Topological Sorting Example 3 4 6 5 7 8 9

Topological Sorting Example 2 1 3 4 6 5 7 8 9

Topological Sorting Example 2 1 3 4 6 5 7 8 9