Advanced algorithms. strongly connected components algorithms, Euler trail, Hamiltonian path. Jiří Vyskočil, Radek Mařík 2012

Size: px
Start display at page:

Download "Advanced algorithms. strongly connected components algorithms, Euler trail, Hamiltonian path. Jiří Vyskočil, Radek Mařík 2012"

Transcription

1 strongly connected components algorithms, Euler trail, Hamiltonian path Jiří Vyskočil, Radek Mařík 2012

2 Connected component A connected component of graph G =(V,E ) with regard to vertex v is a set C(v ) = {u V there exists a path in G from u to v }. In other words: If a graph is disconnected, then parts from which is composed from and that are themselves connected, are called connected components. c b a C(a)=C(b)={a,b} e d C(c) =C(d) =C(e)={c,d,e} 2 / 107

3 Strongly Connected Components A directed graph G =(V,E ) is called strongly connected if there is a path in each direction between every couple of vertices in the graph. The strongly connected components of a directed graph G are its maximal strongly connected subgraphs. SCC(v ) = {u V there exists a path in G from u to v and a path in G from v to u} a b c d e f g h 3 / 107

4 Kosaraju-Sharir Algorithm input: graph G = (V, E ) output: set of strongly connected components (sets of vertices) 1. S = empty stack; 2. while S does not contain all vertices do Choose an arbitrary vertex v not in S; DFS-Walk (v ) and each time that DFS finishes expanding a vertex u, push u onto S; 3. Reverse the directions of all arcs to obtain the transpose graph; 4. while S is nonempty do v = pop(s); if v is UNVISITED then DFS-Walk(v ); The set of visited vertices will give the strongly connected component containing v; 4 / 107

5 input: Graph G. 1) procedure DFS-Walk(Vertex u ) { 2) state[u ] = OPEN; d[u ] = ++time; 3) for each Vertex v in succ(u ) 4) if (state[v ] == UNVISITED) then {p[v ] = u; DFS-Walk(v ); } 5) state[u ] = CLOSED; f[u ] = ++time; 6) } DFS-Walk 7) procedure DFS-Walk (Vertex u ) { 8) state[u ] = OPEN; d[u ] = ++time; 9) for each Vertex v in succ(u ) 10) if (state[v ] == UNVISITED) then {p[v ] = u; DFS-Walk (v ); } 11) state[u ] = CLOSED; f[u ] = ++time; push u to S; 12) } output: array p pointing to predecessor vertex, array d with times of vertex opening and array f with time of vertex closing. 5 / 107

6 input: Graph G. 1) procedure DFS-Walk(Vertex u ) { 2) state[u ] = OPEN; 3) for each Vertex v in succ(u ) 4) if (state[v ] == UNVISITED) then DFS-Walk(v ); 5) state[u ] = CLOSED; 6) } DFS-Walk - optimized 7) procedure DFS-Walk (Vertex u ) { 8) state[u ] = OPEN; 9) for each Vertex v in succ(u ) 10) if (state[v ] == UNVISITED) then DFS-Walk (v ); 11) state[u ] = CLOSED; push u to S; 12) } 6 / 107

7 Kosaraju-Sharir Algorithm a b c d e f g h OPEN CLOSED UNVISITED 7 / 107

8 Kosaraju-Sharir Algorithm a b c d e f g h OPEN CLOSED UNVISITED 8 / 107

9 Kosaraju-Sharir Algorithm a b c d e f g h OPEN CLOSED UNVISITED 9 / 107

10 Kosaraju-Sharir Algorithm a b c d e f g h OPEN CLOSED UNVISITED 10 / 107

11 Kosaraju-Sharir Algorithm a b c d e f g h OPEN CLOSED UNVISITED 11 / 107

12 Kosaraju-Sharir Algorithm a b c d e f g h g OPEN CLOSED UNVISITED 12 / 107

13 Kosaraju-Sharir Algorithm a b c d e f g h f g OPEN CLOSED UNVISITED 13 / 107

14 Kosaraju-Sharir Algorithm a b c d e f g h f g OPEN CLOSED UNVISITED 14 / 107

15 Kosaraju-Sharir Algorithm a b c d e f g h f g OPEN CLOSED UNVISITED 15 / 107

16 Kosaraju-Sharir Algorithm a b c d e f g h e f g OPEN CLOSED UNVISITED 16 / 107

17 Kosaraju-Sharir Algorithm a b c d e f g h e f g OPEN CLOSED UNVISITED 17 / 107

18 Kosaraju-Sharir Algorithm a b c d e f g h e f g OPEN CLOSED UNVISITED 18 / 107

19 Kosaraju-Sharir Algorithm a b c d e f g h e f g OPEN CLOSED UNVISITED 19 / 107

20 Kosaraju-Sharir Algorithm a b c d e f g h e f g OPEN CLOSED UNVISITED 20 / 107

21 Kosaraju-Sharir Algorithm a b c d e f g h h e f g OPEN CLOSED UNVISITED 21 / 107

22 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 22 / 107

23 Kosaraju-Sharir Algorithm a b c d e f g h c d h e f g OPEN CLOSED UNVISITED 23 / 107

24 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 24 / 107

25 Kosaraju-Sharir Algorithm a b c d e f g h a b c d h e f g OPEN CLOSED UNVISITED 25 / 107

26 Kosaraju-Sharir Algorithm a b c d e f g h a b c d h e f g OPEN CLOSED UNVISITED 26 / 107

27 Kosaraju-Sharir Algorithm a b c d e f g h a b c d h e f g OPEN CLOSED UNVISITED 27 / 107

28 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 28 / 107

29 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 29 / 107

30 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 30 / 107

31 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 31 / 107

32 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 32 / 107

33 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 33 / 107

34 Kosaraju-Sharir Algorithm a b c d e f g h b c d h e f g OPEN CLOSED UNVISITED 34 / 107

35 Kosaraju-Sharir Algorithm a b c d e f g h c d h e f g OPEN CLOSED UNVISITED 35 / 107

36 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 36 / 107

37 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 37 / 107

38 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 38 / 107

39 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 39 / 107

40 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 40 / 107

41 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 41 / 107

42 Kosaraju-Sharir Algorithm a b c d e f g h d h e f g OPEN CLOSED UNVISITED 42 / 107

43 Kosaraju-Sharir Algorithm a b c d e f g h h e f g OPEN CLOSED UNVISITED 43 / 107

44 Kosaraju-Sharir Algorithm a b c d e f g h e f g OPEN CLOSED UNVISITED 44 / 107

45 Kosaraju-Sharir Algorithm a b c d e f g h f g OPEN CLOSED UNVISITED 45 / 107

46 Kosaraju-Sharir Algorithm a b c d e f g h g OPEN CLOSED UNVISITED 46 / 107

47 Kosaraju-Sharir Algorithm a b c d e f g h g OPEN CLOSED UNVISITED 47 / 107

48 Kosaraju-Sharir Algorithm a b c d e f g h g OPEN CLOSED UNVISITED 48 / 107

49 Kosaraju-Sharir Algorithm a b c d e f g h g OPEN CLOSED UNVISITED 49 / 107

50 Kosaraju-Sharir Algorithm a b c d e f g h g OPEN CLOSED UNVISITED 50 / 107

51 Kosaraju-Sharir Algorithm a b c d e f g h OPEN CLOSED UNVISITED 51 / 107

52 Kosaraju-Sharir Algorithm a b c d e f g h OPEN CLOSED UNVISITED 52 / 107

53 Kosaraju-Sharir Algorithm Complexity: The Kosaraju-Sharir algorithm performs two complete traversals of the graph. If the graph is represented as an adjacency list then the algorithm runs in Θ( V + E ) time (linear time). If the graph is represented as an adjacency matrix then the algorithm runs in O( V 2 ) time. 53 / 107

54 Tarjan's Algorithm input: graph G = (V, E) output: set of strongly connected components // every node has following fields: // index: a unique number to ID node // lowlink: ties node to others in SCC // pred: pointer to stack predecessor // instack: true if node is in stack procedure push( v ) // stack may be null v.pred = S; v.instack = true; S = v; end push; function pop( v ) // val param v is stack copy S = v.pred; v.pred = null; v.instack = false; return v; end pop; procedure find_scc( v ) v.index = v.lowlink = ++index; push( v ); foreach node w in succ( v ) do if w.index = 0 then // not yet visited find_scc( w ); v.lowlink = min( v.lowlink, w.lowlink ); elsif w.instack then v.lowlink = min( v.lowlink, w.index ); end if end foreach if v.lowlink = v.index then // v: head of SCC SCC++ // track how many SCCs found repeat x = pop( S ); add x to current strongly connected component; until x = v; output the current strongly connected component; end if end find_scc; index = 0; // unique node number > 0 S = null; // pointer to node stack SCC = 0; // number of SCCs in G foreach node v in V do if v.index = 0 then // yet unvisited find_scc( v ); end if end foreach; 54 / 107

55 Tarjan's Algorithm S pred instack = true instack = false 55 / 107

56 Tarjan's Algorithm S 1 1 pred instack = true instack = false 56 / 107

57 Tarjan's Algorithm S pred instack = true instack = false 57 / 107

58 Tarjan's Algorithm S pred instack = true instack = false 58 / 107

59 Tarjan's Algorithm S pred instack = true instack = false 59 / 107

60 Tarjan's Algorithm S pred instack = true instack = false 60 / 107

61 Tarjan's Algorithm S pred instack = true instack = false 61 / 107

62 Tarjan's Algorithm S pred instack = true instack = false 62 / 107

63 Tarjan's Algorithm S pred instack = true instack = false 63 / 107

64 Tarjan's Algorithm S pred instack = true instack = false 64 / 107

65 Tarjan's Algorithm S pred instack = true instack = false 65 / 107

66 Tarjan's Algorithm S pred instack = true instack = false 66 / 107

67 Tarjan's Algorithm S pred instack = true instack = false 67 / 107

68 Tarjan's Algorithm S pred instack = true instack = false 68 / 107

69 Tarjan's Algorithm S pred instack = true instack = false 69 / 107

70 Tarjan's Algorithm S pred instack = true instack = false 70 / 107

71 Tarjan's Algorithm S pred instack = true instack = false 71 / 107

72 Tarjan's Algorithm S pred instack = true instack = false 72 / 107

73 Tarjan's Algorithm S pred instack = true instack = false 73 / 107

74 Tarjan's Algorithm S pred instack = true instack = false 74 / 107

75 Tarjan's Algorithm S pred instack = true instack = false 75 / 107

76 Tarjan's Algorithm S pred instack = true instack = false 76 / 107

77 Tarjan's Algorithm S pred instack = true instack = false 77 / 107

78 Tarjan's Algorithm S pred instack = true instack = false 78 / 107

79 Tarjan's Algorithm S pred instack = true instack = false 79 / 107

80 Complexity: Tarjan's Algorithm The Tarjan's algorithm performs only one complete traversal of the graph. If the graph is represented as an adjacency list then the algorithm runs in Θ( V + E ) time (linear time). If the graph is represented as an adjacency matrix then the algorithm runs in O( V 2 ) time. The Tarjan's algorithm runs faster than the Kosaraju- Sharir algorithm. 80 / 107

81 Euler Trail Problem: Euler Trail Does a (directed or undirected) graph G contain a trail (trail is similar to path but vertices can repeat and edges cannot repeat) that visits every edge exactly once? 81 / 107

82 Euler Trail - Properties Theorem: A graph G has an Euler trail if and only if it is connected and has 0 or 2 vertices of odd degree. We can distinguish two cases: 1. Euler trail starts and ends in the same vertex. (Eulerian Tour) Every vertex must have even degree. 2. Euler trail starts and ends in the different vertices. The starting and ending vertex must have odd degree and the others have even degree. 82 / 107

83 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 83 / 107

84 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 84 / 107

85 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 85 / 107

86 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 86 / 107

87 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 87 / 107

88 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 88 / 107

89 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 89 / 107

90 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 90 / 107

91 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 91 / 107

92 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 92 / 107

93 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 93 / 107

94 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 94 / 107

95 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 95 / 107

96 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 96 / 107

97 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 97 / 107

98 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 98 / 107

99 input: graph G = (V, E ) output: trail (as a stack with edges) Euler Trail procedure euler-trail(vertex v); { foreach vertex u in succ(v) do { remove edge(v,u) from graph; euler-trail(u); push(edge(v,u)); } } 99 / 107

100 Euler Trail Complexity: The Euler trail algorithm performs only one complete traversal of the graph. If the graph is represented as an adjacency list then the algorithm runs in Θ( V + E ) time (linear time). If the graph is represented as an adjacency matrix then the algorithm runs in O( V 2 ) time. 100 / 107

101 Hamiltonian Path Hamiltonian Path Problem: Does a (directed or undirected) graph G contain a path that visits every node exactly once? start target 101 / 107

102 Hamiltonian Path Why is the Hamiltonian Path problem so hard (NPC)? Reduction Idea: Suppose we have a black box to solve Hamiltonian Path. We already know that SAT is hard NP-Complete (Cook 1971). If we can do a polynomial time transformation of an arbitrary input SAT instance to some instance for our black box in such a way, that our black box solution will directly represent SAT solution for the input, then If we solve our black box in polynomial time then we can solve even SAT in polynomial time. 102 / 107

103 Hamiltonian Path High level structure: x 1 S... c 1 x 2... c 2 c x n... c k T 103 / 107

104 Internal structure of variable x i : Hamiltonian Path A number of occurrences of variable x i in the whole SAT exactly corresponds to the number of pairs in yellow ovals. x i Direction we travel along this chain represents whether to set the variable to false.... Direction we travel along this chain represents whether to set the variable to true. 104 / 107

105 Internal structure of variable x i : If the clause c j contains the positive literal: x i Hamiltonian Path c j x i / 107

106 Internal structure of variable x i : If the clause c j contains the negative literal: x i Hamiltonian Path c j x i / 107

107 References Matoušek, J.; Nešetřil, J. Kapitoly z diskrétní matematiky. Karolinum. Praha ISBN Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford (2001). Introduction to Algorithms (2nd ed.). MIT Press and McGraw-Hill. ISBN Tarjan, R. E. (1972). Depth-first search and linear graph algorithms, SIAM Journal on Computing 1 (2): , doi: / / 107

Advanced algorithms. topological ordering, minimum spanning tree, Union-Find problem. Jiří Vyskočil, Radek Mařík 2012

Advanced algorithms. topological ordering, minimum spanning tree, Union-Find problem. Jiří Vyskočil, Radek Mařík 2012 topological ordering, minimum spanning tree, Union-Find problem Jiří Vyskočil, Radek Mařík 2012 Subgraph subgraph A graph H is a subgraph of a graph G, if the following two inclusions are satisfied: 2

More information

Lecture 10: Strongly Connected Components, Biconnected Graphs

Lecture 10: Strongly Connected Components, Biconnected Graphs 15-750: Graduate Algorithms February 8, 2016 Lecture 10: Strongly Connected Components, Biconnected Graphs Lecturer: David Witmer Scribe: Zhong Zhou 1 DFS Continued We have introduced Depth-First Search

More information

Outline. Graphs. Divide and Conquer.

Outline. Graphs. Divide and Conquer. GRAPHS COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges books. Outline Graphs.

More information

Data Structures and Algorithms. Chapter 7. Graphs

Data Structures and Algorithms. Chapter 7. Graphs 1 Data Structures and Algorithms Chapter 7 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples

More information

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs 2011 Pearson Addison-Wesley. All rights reserved 14 A-1 Terminology G = {V, E} A graph G consists of two sets A set V of vertices, or nodes A set E of edges A subgraph Consists of a subset

More information

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions Introduction Chapter 9 Graph Algorithms graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 2 Definitions an undirected graph G = (V, E) is

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)

More information

Let G = (V, E) be a graph. If u, v V, then u is adjacent to v if {u, v} E. We also use the notation u v to denote that u is adjacent to v.

Let G = (V, E) be a graph. If u, v V, then u is adjacent to v if {u, v} E. We also use the notation u v to denote that u is adjacent to v. Graph Adjacent Endpoint of an edge Incident Neighbors of a vertex Degree of a vertex Theorem Graph relation Order of a graph Size of a graph Maximum and minimum degree Let G = (V, E) be a graph. If u,

More information

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a

More information

Algorithms and Theory of Computation. Lecture 3: Graph Algorithms

Algorithms and Theory of Computation. Lecture 3: Graph Algorithms Algorithms and Theory of Computation Lecture 3: Graph Algorithms Xiaohui Bei MAS 714 August 20, 2018 Nanyang Technological University MAS 714 August 20, 2018 1 / 18 Connectivity In a undirected graph G

More information

NP-complete Reductions

NP-complete Reductions NP-complete Reductions 1. Prove that 3SAT P DOUBLE-SAT, i.e., show DOUBLE-SAT is NP-complete by reduction from 3SAT. The 3-SAT problem consists of a conjunction of clauses over n Boolean variables, where

More information

A Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components

A Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components A Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components Ingo Wegener FB Informatik, LS2, Univ. Dortmund, 44221 Dortmund, Germany wegener@ls2.cs.uni-dortmund.de

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CS 5311 Lecture 19 Topological Sort Junzhou Huang, Ph.D. Department of Computer Science and ngineering CS5311 Design and Analysis of Algorithms 1 Topological Sort Want

More information

Homework Assignment #3 Graph

Homework Assignment #3 Graph CISC 4080 Computer Algorithms Spring, 2019 Homework Assignment #3 Graph Some of the problems are adapted from problems in the book Introduction to Algorithms by Cormen, Leiserson and Rivest, and some are

More information

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck Theory of Computing Lecture 10 MAS 714 Hartmut Klauck Seven Bridges of Königsberg Can one take a walk that crosses each bridge exactly once? Seven Bridges of Königsberg Model as a graph Is there a path

More information

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices Hard Problems Euler-Tour Problem Undirected graph G=(V,E) An Euler Tour is a path where every edge appears exactly once. The Euler-Tour Problem: does graph G have an Euler Path? Answerable in O(E) time.

More information

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang Efficient Algorithms So far, we have developed algorithms for finding shortest paths in graphs, minimum spanning trees in

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures Graphs 3: Finding Connected Components Marius Kloft Content of this Lecture Finding Connected Components in Undirected Graphs Finding Strongly Connected Components in Directed

More information

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS DR. ANDREW SCHWARTZ, PH.D. 10.1 Graphs and Graph Models (1) A graph G = (V, E) consists of V, a nonempty set of vertices (or nodes)

More information

Crossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia)

Crossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia) 15-251 Great Ideas in Theoretical Computer Science Lecture 12: Graphs I: The Basics February 22nd, 2018 Crossing bridges Königsberg (Prussia) Now Kaliningrad (Russia) Is there a way to walk through the

More information

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R

More information

NP-Completeness. Algorithms

NP-Completeness. Algorithms NP-Completeness Algorithms The NP-Completeness Theory Objective: Identify a class of problems that are hard to solve. Exponential time is hard. Polynomial time is easy. Why: Do not try to find efficient

More information

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang Efficient Algorithms So far, we have developed algorithms for finding shortest paths in graphs, minimum spanning trees

More information

(Re)Introduction to Graphs and Some Algorithms

(Re)Introduction to Graphs and Some Algorithms (Re)Introduction to Graphs and Some Algorithms Graph Terminology (I) A graph is defined by a set of vertices V and a set of edges E. The edge set must work over the defined vertices in the vertex set.

More information

Lecture 7 Data Structures (DAT037) Ramona Enache (with slides from Nick Smallbone and Nils Anders Danielsson)

Lecture 7 Data Structures (DAT037) Ramona Enache (with slides from Nick Smallbone and Nils Anders Danielsson) Lecture 7 Data Structures (DAT037) Ramona Enache (with slides from Nick Smallbone and Nils Anders Danielsson) Directed Acyclic Graphs A DAG is a directed graph without cycles. That means: once you follow

More information

Coping with NP-Completeness

Coping with NP-Completeness Coping with NP-Completeness Siddhartha Sen Questions: sssix@cs.princeton.edu Some figures obtained from Introduction to Algorithms, nd ed., by CLRS Coping with intractability Many NPC problems are important

More information

Graph Algorithms Using Depth First Search

Graph Algorithms Using Depth First Search Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth

More information

2 Approximation Algorithms for Metric TSP

2 Approximation Algorithms for Metric TSP Comp260: Advanced Algorithms Tufts University, Spring 2002 Professor Lenore Cowen Scribe: Stephanie Tauber Lecture 3: The Travelling Salesman Problem (TSP) 1 Introduction A salesman wishes to visit every

More information

Varying Applications (examples)

Varying Applications (examples) Graph Theory Varying Applications (examples) Computer networks Distinguish between two chemical compounds with the same molecular formula but different structures Solve shortest path problems between cities

More information

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur Lecture : Graphs Rajat Mittal IIT Kanpur Combinatorial graphs provide a natural way to model connections between different objects. They are very useful in depicting communication networks, social networks

More information

Advanced algorithms. binary heap, d-ary heap, binomial heap, amortized analysis, Fibonacci heap. Jiří Vyskočil, Radek Mařík 2013

Advanced algorithms. binary heap, d-ary heap, binomial heap, amortized analysis, Fibonacci heap. Jiří Vyskočil, Radek Mařík 2013 binary heap, d-ary heap, binomial heap, amortized analysis, Fibonacci heap Jiří Vyskočil, Radek Mařík 2013 heap Heaps [haldy] a heap is a specialized data structure (usually tree-based) that satisfies

More information

Assignment 4 Solutions of graph problems

Assignment 4 Solutions of graph problems Assignment 4 Solutions of graph problems 1. Let us assume that G is not a cycle. Consider the maximal path in the graph. Let the end points of the path be denoted as v 1, v k respectively. If either of

More information

Data Structures and Algorithms. Werner Nutt

Data Structures and Algorithms. Werner Nutt Data Structures and Algorithms Werner Nutt nutt@inf.unibz.it http://www.inf.unibz/it/~nutt Part 9 Academic Year 2011-2012 1 Acknowledgements & Copyright Notice These slides are built on top of slides developed

More information

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open)

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open) Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open) circuit : vertices my repeat, edges cannot repeat (closed) path

More information

CSCE 350: Chin-Tser Huang. University of South Carolina

CSCE 350: Chin-Tser Huang. University of South Carolina CSCE 350: Data Structures and Algorithms Chin-Tser Huang huangct@cse.sc.edu University of South Carolina Announcement Homework 2 will be returned on Thursday; solution will be available on class website

More information

Lecture 22 Tuesday, April 10

Lecture 22 Tuesday, April 10 CIS 160 - Spring 2018 (instructor Val Tannen) Lecture 22 Tuesday, April 10 GRAPH THEORY Directed Graphs Directed graphs (a.k.a. digraphs) are an important mathematical modeling tool in Computer Science,

More information

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch] NP Completeness Andreas Klappenecker [partially based on slides by Jennifer Welch] Overview We already know the following examples of NPC problems: SAT 3SAT We are going to show that the following are

More information

Graphs and Algorithms

Graphs and Algorithms Graphs and Algorithms Graphs are a mathematical concept readily adapted into computer programming. Graphs are not just data structures, that is, they are not solutions to simple data storage problems.

More information

CS490: Problem Solving in Computer Science Lecture 6: Introductory Graph Theory

CS490: Problem Solving in Computer Science Lecture 6: Introductory Graph Theory CS490: Problem Solving in Computer Science Lecture 6: Introductory Graph Theory Dustin Tseng Mike Li Wednesday January 16, 2006 Dustin Tseng Mike Li: CS490: Problem Solving in Computer Science, Lecture

More information

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies Graph Chapter 9 Outline Introduction Definitions and Basic Terminologies Representations of Graphs Graph Traversals Breadth first traversal Depth first traversal Applications Single source shortest path

More information

Graph Representation

Graph Representation Graph Representation Adjacency list representation of G = (V, E) An array of V lists, one for each vertex in V Each list Adj[u] contains all the vertices v such that there is an edge between u and v Adj[u]

More information

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?) P vs. NP What now? Attribution These slides were prepared for the New Jersey Governor s School course The Math Behind the Machine taught in the summer of 2011 by Grant Schoenebeck Large parts of these

More information

Algorithmic Aspects of Communication Networks

Algorithmic Aspects of Communication Networks Algorithmic Aspects of Communication Networks Chapter 5 Network Resilience Algorithmic Aspects of ComNets (WS 16/17): 05 Network Resilience 1 Introduction and Motivation Network resilience denotes the

More information

Unweighted Graphs & Algorithms

Unweighted Graphs & Algorithms Unweighted Graphs & Algorithms Zachary Friggstad Programming Club Meeting References Chapter 4: Graph (Section 4.2) Chapter 22: Elementary Graph Algorithms Graphs Features: vertices/nodes/dots and edges/links/lines

More information

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge. 1 Graph Basics What is a graph? Graph: a graph G consists of a set of vertices, denoted V (G), a set of edges, denoted E(G), and a relation called incidence so that each edge is incident with either one

More information

Unit 2: Algorithmic Graph Theory

Unit 2: Algorithmic Graph Theory Unit 2: Algorithmic Graph Theory Course contents: Introduction to graph theory Basic graph algorithms Reading Chapter 3 Reference: Cormen, Leiserson, and Rivest, Introduction to Algorithms, 2 nd Ed., McGraw

More information

Graph Algorithms: Chapters Part 1: Introductory graph concepts

Graph Algorithms: Chapters Part 1: Introductory graph concepts UMass Lowell Computer Science 91.503 Algorithms Dr. Haim Levkowitz Fall, 2007 Graph Algorithms: Chapters 22-25 Part 1: Introductory graph concepts 1 91.404 Graph Review Elementary Graph Algorithms Minimum

More information

CS521 \ Notes for the Final Exam

CS521 \ Notes for the Final Exam CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )

More information

Fundamental Properties of Graphs

Fundamental Properties of Graphs Chapter three In many real-life situations we need to know how robust a graph that represents a certain network is, how edges or vertices can be removed without completely destroying the overall connectivity,

More information

Maximum flows & Maximum Matchings

Maximum flows & Maximum Matchings Chapter 9 Maximum flows & Maximum Matchings This chapter analyzes flows and matchings. We will define flows and maximum flows and present an algorithm that solves the maximum flow problem. Then matchings

More information

Reference Sheet for CO142.2 Discrete Mathematics II

Reference Sheet for CO142.2 Discrete Mathematics II Reference Sheet for CO14. Discrete Mathematics II Spring 017 1 Graphs Defintions 1. Graph: set of N nodes and A arcs such that each a A is associated with an unordered pair of nodes.. Simple graph: no

More information

Minimal Equation Sets for Output Computation in Object-Oriented Models

Minimal Equation Sets for Output Computation in Object-Oriented Models Minimal Equation Sets for Output Computation in Object-Oriented Models Vincenzo Manzoni Francesco Casella Dipartimento di Elettronica e Informazione, Politecnico di Milano Piazza Leonardo da Vinci 3, 033

More information

Graph Algorithms. Definition

Graph Algorithms. Definition Graph Algorithms Many problems in CS can be modeled as graph problems. Algorithms for solving graph problems are fundamental to the field of algorithm design. Definition A graph G = (V, E) consists of

More information

CS Elementary Graph Algorithms

CS Elementary Graph Algorithms CS43-09 Elementary Graph Algorithms Outline Representation of Graphs Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 1:30pm - 2:30pm or by appointments lifei@cs.gmu.edu with subject: CS43

More information

CS Elementary Graph Algorithms

CS Elementary Graph Algorithms CS483-09 Elementary Graph Algorithms Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 1:30pm - 2:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/ lifei/teaching/cs483_fall07/

More information

LECTURE 17 GRAPH TRAVERSALS

LECTURE 17 GRAPH TRAVERSALS DATA STRUCTURES AND ALGORITHMS LECTURE 17 GRAPH TRAVERSALS IMRAN IHSAN ASSISTANT PROFESSOR AIR UNIVERSITY, ISLAMABAD STRATEGIES Traversals of graphs are also called searches We can use either breadth-first

More information

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS Department of Computer Science University of Babylon LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS By Faculty of Science for Women( SCIW), University of Babylon, Iraq Samaher@uobabylon.edu.iq

More information

DFS & STRONGLY CONNECTED COMPONENTS

DFS & STRONGLY CONNECTED COMPONENTS DFS & STRONGLY CONNECTED COMPONENTS CS 4407 Search Tree Breadth-First Search (BFS) Depth-First Search (DFS) Depth-First Search (DFS) u d[u]: when u is discovered f[u]: when searching adj of u is finished

More information

CSC Design and Analysis of Algorithms. Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms. Brute-Force Approach

CSC Design and Analysis of Algorithms. Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms. Brute-Force Approach CSC 8301- Design and Analysis of Algorithms Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms Brute-Force Approach Brute force is a straightforward approach to solving a problem, usually

More information

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W. : Coping with NP-Completeness Course contents: Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems Reading: Chapter 34 Chapter 35.1, 35.2 Y.-W. Chang 1 Complexity

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures Strongly Connected Components Ulf Leser Content of this Lecture Graph Traversals Strongly Connected Components Ulf Leser: Algorithms and Data Structures, Summer Semester

More information

Graph Data Processing with MapReduce

Graph Data Processing with MapReduce Distributed data processing on the Cloud Lecture 5 Graph Data Processing with MapReduce Satish Srirama Some material adapted from slides by Jimmy Lin, 2015 (licensed under Creation Commons Attribution

More information

1 Digraphs. Definition 1

1 Digraphs. Definition 1 1 Digraphs Definition 1 Adigraphordirected graphgisatriplecomprisedofavertex set V(G), edge set E(G), and a function assigning each edge an ordered pair of vertices (tail, head); these vertices together

More information

Scribes: Romil Verma, Juliana Cook (2015), Virginia Williams, Date: May 1, 2017 and Seth Hildick-Smith (2016), G. Valiant (2017), M.

Scribes: Romil Verma, Juliana Cook (2015), Virginia Williams, Date: May 1, 2017 and Seth Hildick-Smith (2016), G. Valiant (2017), M. Lecture 9 Graphs Scribes: Romil Verma, Juliana Cook (2015), Virginia Williams, Date: May 1, 2017 and Seth Hildick-Smith (2016), G. Valiant (2017), M. Wootters (2017) 1 Graphs A graph is a set of vertices

More information

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value 1 Possible implementations Sorted linear implementations o Appropriate if

More information

Graph Algorithms. A Brief Introduction. 高晓沨 (Xiaofeng Gao) Department of Computer Science Shanghai Jiao Tong Univ.

Graph Algorithms. A Brief Introduction. 高晓沨 (Xiaofeng Gao) Department of Computer Science Shanghai Jiao Tong Univ. Graph Algorithms A Brief Introduction 高晓沨 (Xiaofeng Gao) Department of Computer Science Shanghai Jiao Tong Univ. 目录 2015/5/7 1 Graph and Its Applications 2 Introduction to Graph Algorithms 3 References

More information

Outline. 1 The matching problem. 2 The Chinese Postman Problem

Outline. 1 The matching problem. 2 The Chinese Postman Problem Outline The matching problem Maximum-cardinality matchings in bipartite graphs Maximum-cardinality matchings in bipartite graphs: The augmenting path algorithm 2 Let G = (V, E) be an undirected graph.

More information

Chapter 2 Graphs. 2.1 Definition of Graphs

Chapter 2 Graphs. 2.1 Definition of Graphs Chapter 2 Graphs Abstract Graphs are discrete structures that consist of vertices and edges connecting some of these vertices. Graphs have many applications in Mathematics, Computer Science, Engineering,

More information

Elementary Graph Algorithms. Ref: Chapter 22 of the text by Cormen et al. Representing a graph:

Elementary Graph Algorithms. Ref: Chapter 22 of the text by Cormen et al. Representing a graph: Elementary Graph Algorithms Ref: Chapter 22 of the text by Cormen et al. Representing a graph: Graph G(V, E): V set of nodes (vertices); E set of edges. Notation: n = V and m = E. (Vertices are numbered

More information

Konigsberg Bridge Problem

Konigsberg Bridge Problem Graphs Konigsberg Bridge Problem c C d g A Kneiphof e D a B b f c A C d e g D a b f B Euler s Graph Degree of a vertex: the number of edges incident to it Euler showed that there is a walk starting at

More information

Randomized Graph Algorithms

Randomized Graph Algorithms Randomized Graph Algorithms Vasileios-Orestis Papadigenopoulos School of Electrical and Computer Engineering - NTUA papadigenopoulos orestis@yahoocom July 22, 2014 Vasileios-Orestis Papadigenopoulos (NTUA)

More information

Fundamental Graph Algorithms Part Four

Fundamental Graph Algorithms Part Four Fundamental Graph Algorithms Part Four Announcements Problem Set One due right now. Due Friday at 2:15PM using one late period. Problem Set Two out, due next Friday, July 12 at 2:15PM. Play around with

More information

P -vs- NP. NP Problems. P = polynomial time. NP = non-deterministic polynomial time

P -vs- NP. NP Problems. P = polynomial time. NP = non-deterministic polynomial time P -vs- NP NP Problems P = polynomial time There are many problems that can be solved correctly using algorithms that run in O(n c ) time for some constant c. NOTE: We can say that an nlogn algorithm is

More information

Lecture 6 Basic Graph Algorithms

Lecture 6 Basic Graph Algorithms CS 491 CAP Intro to Competitive Algorithmic Programming Lecture 6 Basic Graph Algorithms Uttam Thakore University of Illinois at Urbana-Champaign September 30, 2015 Updates ICPC Regionals teams will be

More information

Module 6 NP-Complete Problems and Heuristics

Module 6 NP-Complete Problems and Heuristics Module 6 NP-Complete Problems and Heuristics Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 97 E-mail: natarajan.meghanathan@jsums.edu Optimization vs. Decision

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms s of s Computer Science & Engineering 423/823 Design and Analysis of Lecture 03 (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 29 s of s s are abstract data types that are applicable

More information

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths Part VI Graph algorithms Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths 1 Chapter 22 Elementary Graph Algorithms Representations of graphs

More information

Solutions to relevant spring 2000 exam problems

Solutions to relevant spring 2000 exam problems Problem 2, exam Here s Prim s algorithm, modified slightly to use C syntax. MSTPrim (G, w, r): Q = V[G]; for (each u Q) { key[u] = ; key[r] = 0; π[r] = 0; while (Q not empty) { u = ExtractMin (Q); for

More information

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies: UNIT 5 CSE 103 - Unit V- Graph GRAPH Graph is another important non-linear data structure. In tree Structure, there is a hierarchical relationship between, parent and children that is one-to-many relationship.

More information

Formally-Proven Kosaraju s algorithm

Formally-Proven Kosaraju s algorithm Formally-Proven Kosaraju s algorithm Laurent Théry Laurent.Thery@sophia.inria.fr Abstract This notes explains how the Kosaraju s algorithm that computes the strong-connected components of a directed graph

More information

Topic 12: Elementary Graph Algorithms

Topic 12: Elementary Graph Algorithms Topic 12: Elementary Graph Algorithms Pierre Flener Lars-enrik Eriksson (version of 2013-02-10) Different kinds of graphs List Tree A B C A B C Directed Acyclic Graph (DAG) D A B C D E Directed Graph (Digraph)

More information

8 NP-complete problem Hard problems: demo

8 NP-complete problem Hard problems: demo Ch8 NPC Millennium Prize Problems http://en.wikipedia.org/wiki/millennium_prize_problems 8 NP-complete problem Hard problems: demo NP-hard (Non-deterministic Polynomial-time hard), in computational complexity

More information

CSCE 750, Fall 2002 Notes 6 Page Graph Problems ffl explore all nodes (breadth first and depth first) ffl find the shortest path from a given s

CSCE 750, Fall 2002 Notes 6 Page Graph Problems ffl explore all nodes (breadth first and depth first) ffl find the shortest path from a given s CSCE 750, Fall 2002 Notes 6 Page 1 10 Graph Algorithms (These notes follow the development in Cormen, Leiserson, and Rivest.) 10.1 Definitions ffl graph, directed graph (digraph), nodes, edges, subgraph

More information

Graph Theory. Connectivity, Coloring, Matching. Arjun Suresh 1. 1 GATE Overflow

Graph Theory. Connectivity, Coloring, Matching. Arjun Suresh 1. 1 GATE Overflow Graph Theory Connectivity, Coloring, Matching Arjun Suresh 1 1 GATE Overflow GO Classroom, August 2018 Thanks to Subarna/Sukanya Das for wonderful figures Arjun, Suresh (GO) Graph Theory GATE 2019 1 /

More information

Design and Analysis of Algorithms - - Assessment

Design and Analysis of Algorithms - - Assessment X Courses» Design and Analysis of Algorithms Week 1 Quiz 1) In the code fragment below, start and end are integer values and prime(x) is a function that returns true if x is a prime number and false otherwise.

More information

Module 6 NP-Complete Problems and Heuristics

Module 6 NP-Complete Problems and Heuristics Module 6 NP-Complete Problems and Heuristics Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 397 E-mail: natarajan.meghanathan@jsums.edu Optimization vs. Decision

More information

Strongly Connected Components

Strongly Connected Components Strongly Connected Components Let G = (V, E) be a directed graph Write if there is a path from to in G Write if and is an equivalence relation: implies and implies s equivalence classes are called the

More information

Lecture 3: Graphs and flows

Lecture 3: Graphs and flows Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected

More information

Math 443/543 Graph Theory Notes 2: Transportation problems

Math 443/543 Graph Theory Notes 2: Transportation problems Math 443/543 Graph Theory Notes 2: Transportation problems David Glickenstein September 15, 2014 1 Readings This is based on Chartrand Chapter 3 and Bondy-Murty 18.1, 18.3 (part on Closure of a Graph).

More information

Final. Name: TA: Section Time: Course Login: Person on Left: Person on Right: U.C. Berkeley CS170 : Algorithms, Fall 2013

Final. Name: TA: Section Time: Course Login: Person on Left: Person on Right: U.C. Berkeley CS170 : Algorithms, Fall 2013 U.C. Berkeley CS170 : Algorithms, Fall 2013 Final Professor: Satish Rao December 16, 2013 Name: Final TA: Section Time: Course Login: Person on Left: Person on Right: Answer all questions. Read them carefully

More information

An On-Line Satisfiability Algorithm for Conjunctive Normal Form Expressions with Two Literals

An On-Line Satisfiability Algorithm for Conjunctive Normal Form Expressions with Two Literals From: FLAIRS-02 Proceedings. Copyright 2002, AAAI (www.aaai.org). All rights reserved. An On-Line Satisfiability Algorithm for Conjunctive Normal Form Expressions with Two Literals John F. Kolen Institute

More information

A Deterministic Polynomial-time Algorithm for the Clique Problem and the Equality of P and NP Complexity Classes

A Deterministic Polynomial-time Algorithm for the Clique Problem and the Equality of P and NP Complexity Classes Vol:, No:9, 008 A Deterministic Polynomial-time Algorithm for the Clique Problem and the Equality of P and NP Complexity Classes Zohreh O. Akbari Abstract In this paper a deterministic polynomial-time

More information

NP-Complete Reductions 2

NP-Complete Reductions 2 x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 12 22 32 CS 447 11 13 21 23 31 33 Algorithms NP-Complete Reductions 2 Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline NP-Complete

More information

11.2 Eulerian Trails

11.2 Eulerian Trails 11.2 Eulerian Trails K.. onigsberg, 1736 Graph Representation A B C D Do You Remember... Definition A u v trail is a u v walk where no edge is repeated. Do You Remember... Definition A u v trail is a u

More information

Detecting negative cycles with Tarjan s breadth-first scanning algorithm

Detecting negative cycles with Tarjan s breadth-first scanning algorithm Detecting negative cycles with Tarjan s breadth-first scanning algorithm Tibor Ásványi asvanyi@inf.elte.hu ELTE Eötvös Loránd University Faculty of Informatics Budapest, Hungary Abstract The Bellman-Ford

More information

1 The Traveling Salesperson Problem (TSP)

1 The Traveling Salesperson Problem (TSP) CS 598CSC: Approximation Algorithms Lecture date: January 23, 2009 Instructor: Chandra Chekuri Scribe: Sungjin Im In the previous lecture, we had a quick overview of several basic aspects of approximation

More information

Computational Optimization ISE 407. Lecture 19. Dr. Ted Ralphs

Computational Optimization ISE 407. Lecture 19. Dr. Ted Ralphs Computational Optimization ISE 407 Lecture 19 Dr. Ted Ralphs ISE 407 Lecture 19 1 Search Algorithms Search algorithms are fundamental techniques applied to solve a wide range of optimization problems.

More information

CSE 548: Analysis of Algorithms. Lecture 13 ( Approximation Algorithms )

CSE 548: Analysis of Algorithms. Lecture 13 ( Approximation Algorithms ) CSE 548: Analysis of Algorithms Lecture 13 ( Approximation Algorithms ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Fall 2017 Approximation Ratio Consider an optimization problem

More information