Lecture 19 CSE 331 Oct 13, 2010.

Slides:



Advertisements
Similar presentations
What is a graph ? G=(V,E) V = a set of vertices E = a set of edges edge = unordered pair of vertices
Advertisements

Graphs CSE 331 Section 2 James Daly. Reminders Homework 4 is out Due Thursday in class Project 3 is out Covers graphs (discussed today and Thursday) Due.
Lecture 16 CSE 331 Oct 9, Announcements Hand in your HW4 Solutions to HW4 next week Remember next week I will not be here so.
Lecture 15 CSE 331 Oct 7, Mid-term stuff Chapters 1-3 in [KT] Sample mid-term (and graded HW3) at the END of class The web version has the correct.
Lecture 14 CSE 331 Oct 5, Extra lectures on proofs Tuesday 5-6pm (Jeff) Wednesday 4:30-6pm (Atri) Commons 9 Prefer my name to Professor/Dr. Rudra.
Lecture 17 CSE 331 Oct 8, HW 4 due today Q1 and Q2 in one pile Q3 in another pile I will not take any HW after 1:15pm.
Lecture 33 CSE 331 Nov 17, Online office hours Alex will host the office hours.
Lecture 18 CSE 331 Oct 11, Mid term Next Monday in class.
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
GRAPH ALGORITHM. Graph A pair G = (V,E) – V = set of vertices (node) – E = set of edges (pairs of vertices) V = (1,2,3,4,5,6,7) E = ( (1,2),(2,3),(3,5),(1,4),(4,5),(6,7)
Nattee Niparnan. Graph  A pair G = (V,E)  V = set of vertices (node)  E = set of edges (pairs of vertices)  V = (1,2,3,4,5,6,7)  E = ((1,2),(2,3),(3,5),(1,4),(4,
1 CSE 332: Graphs Richard Anderson Spring Announcements This week and next week – Graph Algorithms Reading, Monday and Wednesday, Weiss
Topological Sort. Sorting technique over DAGs (Directed Acyclic Graphs) It creates a linear sequence (ordering) for the nodes such that: –If u has an.
Breadth-First Search (BFS)
Lecture 16 CSE 331 Oct 5, 2011.
Topological Sorting.
Graphs Chapter 20.
CSE 373 Topological Sort Graph Traversals
Lecture 11 Graph Algorithms
CSE 2331/5331 Topic 9: Basic Graph Alg.
Csc 2720 Instructor: Zhuojun Duan
Graph Searching.
Lecture 12 Graph Algorithms
CISC 235: Topic 10 Graph Algorithms.
Lecture 20 CSE 331 Oct 15, 2010.
Lecture 15 CSE 331 Oct 3, 2016.
Lecture 16 CSE 331 Oct 5, 2016.
Lecture 17 CSE 331 Oct 3, 2014.
CS120 Graphs.
More Graph Algorithms.
Graph.
Topological Sort.
Graph Algorithm.
Lecture 15 CSE 331 Oct 5, 2012.
Lecture 15 CSE 331 Sep 29, 2014.
Lecture 15 CSE 331 Oct 3, 2016.
Topological Sort.
Lecture 10 Algorithm Analysis
Graphs Chapter 15 explain graph-based algorithms Graph definitions
Paul Beame in lieu of Richard Anderson
Lecture 14 CSE 331 Sep 30, 2016.
Lecture 12 CSE 331 Sep 26, 2016.
"Learning how to learn is life's most important skill. " - Tony Buzan
Lecture 14 CSE 331 Sep 30, 2011.
Lecture 17 CSE 331 Oct 10, 2012.
Search Related Algorithms
Topological Sort CSE 373 Data Structures Lecture 19.
Chapter 22: Elementary Graph Algorithms I
Graph Representation (23.1/22.1)
What is a Graph? a b c d e V= {a,b,c,d,e} E= {(a,b),(a,c),(a,d),
Lecture 13 CSE 331 Sep 27, 2017.
Lecture 16 CSE 331 Oct 4, 2017.
CSE 373 Data Structures Lecture 16
Lecture 14 CSE 331 Oct 3, 2012.
Lecture 14 CSE 331 Sep 29, 2017.
Lecture 16 CSE 331 Oct 8, 2012.
Lecture 16 CSE 331 Oct 2, 2013.
Graph Algorithms "A charlatan makes obscure what is clear; a thinker makes clear what is obscure. " - Hugh Kingsmill CLRS, Sections 22.2 – 22.4.
Richard Anderson Winter 2009 Lecture 6
Lecture 15 CSE 331 Oct 3, 2011.
Graph Traversal Lecture 18 CS 2110 — Spring 2019.
Lecture 17 CSE 331 Oct 7, 2011.
CSE 417: Algorithms and Computational Complexity
Lecture 25 CSE 331 Oct 28, 2011.
Richard Anderson Winter 2019 Lecture 6
Lecture 11 Graph Algorithms
Lecture 13 CSE 331 Sep 28, 2016.
Richard Anderson Autumn 2015 Lecture 6
Presentation transcript:

Lecture 19 CSE 331 Oct 13, 2010

Online Office hours Tonight 9:30-10:30pm

On Friday, Oct 15 hours-a-thon Atri: 2:00-3:30 (Bell 123) Jeff: 3:30-5:00 (Commons 9) Alex: 5:00-6:30 (Bell 224)

Polls on the blog In my blog post for Lect 18

O(m+n) BFS Implementation Input graph as Adjacency list BFS(s) Array CC[s] = T and CC[v] = F for every v≠ u Set i = 0 Set L0= {s} While Li is not empty Linked List Li+1 = Ø For every u in Li Consider every edge (u,v) If CC[v] = F then CC[v] = T Add v to Li+1 i++

All layers are considered in first-in-first-out order All the layers as one BFS(s) All layers are considered in first-in-first-out order CC[s] = T and CC[v] = F for every v≠ u Set i = 0 Set L0= {s} While Li is not empty Li+1 = Ø For every u in Li Can combine all layers into one queue: all the children of a node are added to the end of the queue For every edge (u,v) If CC[v] = F then CC[v] = T Add v to Li+1 i++

An illustration 1 2 3 4 5 7 8 6 1 7 2 3 8 4 5 6

Implementing DFS in O(m+n) time Same as BFS except stack instead of a queue

Reading Assignment Sec 3.3, 3.4 and 3.5 of [KT]

Directed graphs Model asymmetric relationships Precedence relationships u needs to be done before v means (u,v) edge

Directed graphs Adjacency matrix is not symmetric Each vertex has two lists in Adj. list rep.

Directed Acyclic Graph (DAG) No directed cycles Precedence relationships are consistent

Topological Sorting of a DAG Order the vertices so that all edges go “forward”