Graphs CS 2606.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Instructor Neelima Gupta Table of Contents Approximation Algorithms.
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Chapter 8, Part I Graph Algorithms.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
Combinatorial Algorithms
CS 206 Introduction to Computer Science II 11 / 11 / Veterans Day Instructor: Michael Eckmann.
Graphs. Overview What is a graph? Some terminology Types of graph Implementing graphs (briefly) Some graph algorithms Graphs 2/18.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
22C:19 Discrete Math Graphs Spring 2014 Sukumar Ghosh.
GRAPH Learning Outcomes Students should be able to:
Graphs CS /02/05 Graphs Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved Definition.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graphs Rosen, Chapter 8. Isomorphism (Rosen 560 to 563) Are two graphs G1 and G2 of equal form? That is, could I rename the vertices of G1 such that the.
CS 200 Algorithms and Data Structures
Data Structures & Algorithms Graphs
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
Graphs Upon completion you will be able to:
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
Programming Abstractions Cynthia Lee CS106B. Upcoming Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Limitation of Computation Power – P, NP, and NP-complete
Graphs Chapter 20.
CSC 172 DATA STRUCTURES.
Redraw these graphs so that none of the line intersect except at the vertices B C D E F G H.
Minimum Spanning Tree Chapter 13.6.
Graph theory Definitions Trees, cycles, directed graphs.
Agenda Lecture Content: Introduction to Graph Path and Cycle
Discrete Structures – CNS2300
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
EECS 203 Lecture 20 More Graphs.
Graphs: As a mathematics branch
Topological Sort (topological order)
CS120 Graphs.
Discrete Maths 9. Graphs Objective
Comp 245 Data Structures Graphs.
Spanning Trees Discrete Mathematics.
Graph Algorithm.
Approximation Algorithms for TSP
CSC 172 DATA STRUCTURES.
Can you draw this picture without lifting up your pen/pencil?
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Graph Theory.
Graphs Chapter 13.
Genome Assembly.
Richard Anderson Lecture 28 NP-Completeness
A path that uses every vertex of the graph exactly once.
Computation Basics & NP-Completeness
Euler and Hamilton Paths
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
Euler circuit Theorem 1 If a graph G has an Eulerian path, then it must have exactly two odd vertices. Theorem 2 If a graph G has an Eulerian circuit,
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Lecture 24 Vertex Cover and Hamiltonian Cycle
Presentation transcript:

Graphs CS 2606

Topics Graph notation revisited More graph problems Undirected graph Weighted/labeled graph More graph problems Euler Tour Hamiltonian cycle Max Clique Traveling salesman Graphs Slide 2

Undirected Graph Graph G=(V,E): V={a,b,c,d}, E={(a,b),(b,c),(b,d),(a,d)} a b c d Graphs Slide 3

Directed Graph Edge set is a set of ordered pairs Graph G=(V,E): V={a,b,c,d}, E={(a,b),(b,c),(b,d),(d,b),(d,a)} a b c d Graphs Slide 4

Weighted Graph Graph G=(V,E,w): V={a,b,c,d,e}, E={(a,b),(a,d),(b,c),(b,d),(b,e)}, w: function that maps vertex-pairs to values (can be stored in adjacency matrix) w(a,b) = w(b,a) = 20 w(a,d) = w(d,a) = 65 w(b,c) = w(c,b) = 32 w(b,d) = w(d,b) = 12 w(b,e) = w(e,b) = 35 for all other vertex pairs: w(x,y) = 0 if x = y else, w(x,y) = infinity a 20 35 e b 12 32 c 65 d Graphs Slide 5

Graph problems Euler tour Hamiltonian cycle Max Clique Find a sequence of vertices that traverse all edges in the graph exactly once Hamiltonian cycle Find a simple cycle that connects all vertices in the graph Max Clique Find the largest subset of vertices that are all pair-wise adjacent (connected by an edge) Graphs Slide 6

Graph problems 2 Shortest Paths Minimum Cost Spanning Tree Section 11.4 of textbook Minimum Cost Spanning Tree Section 11.5 of textbook Traveling Salesman Given a weighted graph G, find the shortest (minimum-length) cycle that contains all vertices in G Graphs Slide 7

Euler Tour Euler Tour/Cycle: sequence of vertices that traverse all edges exactly once c d a b f e Euler tour: c,d,f,e,a,b,e,c Graphs Slide 8

f,c,d and e have odd degree Euler Tour (2) Some graphs do not have euler tours specifically those with vertices whose degree (# of neighbors) is odd c a b d e g f f,c,d and e have odd degree Graphs Slide 9

Euler Tour (3) There is a straightforward algorithm that obtains an euler tour of a graph, if one such tour exists Algorithm sketch Start with any vertex; traverse edges by repeatedly visiting neighbors without repeating an edge Repeat process, combining the partial tours as you go, until all edges are exhausted Graphs Slide 10

hamiltonian cycle: a,b,c,d,f,e,(then back to a) Hamiltonian cycle: simple cycle containing all vertices w c a b z d x y f e no hamiltonian cycle hamiltonian cycle: a,b,c,d,f,e,(then back to a) Graphs Slide 11

Hamiltonian Cycle (2) Exhaustive (inefficient) algorithm that finds a hamiltonian cycle if one such cycle exists: Consider all permutations of the vertices Return the permutation that forms a cycle An O( n! n ) algorithm Hamiltonian cycle is an example of an NP-complete (intractable) problem No algorithm that performs better (than the exhaustive algorithm) is known Graphs Slide 12

Max Clique Clique: subset of vertices that are all connected by an edge Clique examples: {a,b,e} {e,g} {b,c,d,f} Max-clique: {b,c,d,f} c a b d e f g h Graphs Slide 13

Max Clique (2) Exhaustive algorithm for Max Clique: Consider all subsets of vertices Determine if the subset is a clique Return the clique with the largest size An O( 2n n2 ) algorithm Max Clique is also NP-Complete Graphs Slide 14

w,x,y,z,w – length: 34 y,w,x,z,y – length: 36 z,w,y,x,z – length: 28 Traveling Salesman Find shortest tour of all vertices (may impose that the salesman end where he started) w Sample tours w,x,y,z,w – length: 34 y,w,x,z,y – length: 36 z,w,y,x,z – length: 28 4 10 14 y 3 7 z x 11 Graphs Slide 15

Traveling Salesman (2) O( n! n ) algorithm: Consider all permutations Compute resulting length for each permutation Return the permutation that yields the shortest length Traveling salesman is also NP-complete Graphs Slide 16

More on NP-Completeness See chapter 15 of the textbook Graphs Slide 17