Week 11 - Friday.  What did we talk about last time?  Exam 2 post mortem  Cycle detection in undirected graphs  Topological sort and cycle detection.

Slides:



Advertisements
Similar presentations
© 2004 Goodrich, Tamassia Depth-First Search1 DB A C E.
Advertisements

What is a graph ? G=(V,E) V = a set of vertices E = a set of edges edge = unordered pair of vertices
Depth-First Search1 Part-H2 Depth-First Search DB A C E.
Lecture 16: DFS, DAG, and Strongly Connected Components Shang-Hua Teng.
Graphs – Depth First Search ORD DFW SFO LAX
Graph Searching CSE 373 Data Structures Lecture 20.
Breadth-First Search Seminar – Networking Algorithms CS and EE Dept. Lulea University of Technology 27 Jan Mohammad Reza Akhavan.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 8, Part I Graph Algorithms.
Graph Searching (Graph Traversal) Algorithm Design and Analysis Week 8 Bibliography: [CLRS] – chap 22.2 –
16a-Graphs-More (More) Graphs Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
ITEC200 – Week 12 Graphs. 2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study.
Depth-First Search1 DB A C E. 2 Outline and Reading Definitions (§6.1) Subgraph Connectivity Spanning trees and forests Depth-first search (§6.3.1) Algorithm.
Data Structures & Algorithms Graph Search Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Graph Traversals Reading Material: Chapter 9. Graph Traversals Some applications require visiting every vertex in the graph exactly once. The application.
CS 311 Graph Algorithms. Definitions A Graph G = (V, E) where V is a set of vertices and E is a set of edges, An edge is a pair (u,v) where u,v  V. If.
Spanning Trees.
Spanning Trees. 2 Spanning trees Suppose you have a connected undirected graph Connected: every node is reachable from every other node Undirected: edges.
Connected Components, Directed Graphs, Topological Sort COMP171.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
© 2004 Goodrich, Tamassia Depth-First Search1 DB A C E.
CS344: Lecture 16 S. Muthu Muthukrishnan. Graph Navigation BFS: DFS: DFS numbering by start time or finish time. –tree, back, forward and cross edges.
© 2006 Pearson Addison-Wesley. All rights reserved14 B-1 Chapter 14 (continued) Graphs.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Spanning Trees. Spanning trees Suppose you have a connected undirected graph –Connected: every node is reachable from every other node –Undirected: edges.
Social Media Mining Graph Essentials.
Week 11 - Friday.  What did we talk about last time?  Exam 2 post mortem  Cycle detection  Connectivity.
Charles Lin. Graph Representation Graph Representation DFS DFS BFS BFS Dijkstra Dijkstra A* Search A* Search Bellman-Ford Bellman-Ford Floyd-Warshall.
Spring 2015 Lecture 10: Elementary Graph Algorithms
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,
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
COSC 2007 Data Structures II Chapter 14 Graphs III.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
Depth-First Search1 DB A C E. 2 Depth-first search (DFS) is a general technique for traversing a graph A DFS traversal of a graph G – Visits all the vertices.
Week 12 - Monday.  What did we talk about last time?  Topological sort and cycle detection in directed graphs  Connectivity  Strong connectivity.
CS 61B Data Structures and Programming Methodology Aug 5, 2008 David Sun.
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 A graphs is an abstract representation of a set of objects, called vertices or nodes, where some pairs of the objects are connected by links, called.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Depth-First Search Lecture 21: Graph Traversals
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Graphs Upon completion you will be able to:
Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.
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.
Graphs + Shortest Paths David Kauchak cs302 Spring 2013.
Graph Searching CSIT 402 Data Structures II. 2 Graph Searching Methodology Depth-First Search (DFS) Depth-First Search (DFS) ›Searches down one path as.
Main Index Contents 11 Main Index Contents Graph Categories Graph Categories Example of Digraph Example of Digraph Connectedness of Digraph Connectedness.
Week 11 - Wednesday.  What did we talk about last time?  Exam 2  And before that:  Graph representations  Depth first search.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
© 2006 Pearson Addison-Wesley. All rights reserved14 B-1 Chapter 14 (continued) Graphs.
Graph Search Applications, Minimum Spanning Tree
Graphs Chapter 20.
Lecture 11 Graph Algorithms
C.Eng 213 Data Structures Graphs Fall Section 3.
CS120 Graphs.
Comp 245 Data Structures Graphs.
Refresh and Get Ready for More
Graph Search Applications
Connected Components Minimum Spanning Tree
Spanning Trees.
Graph Representation (23.1/22.1)
CSE 373 Data Structures Lecture 16
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

Week 11 - Friday

 What did we talk about last time?  Exam 2 post mortem  Cycle detection in undirected graphs  Topological sort and cycle detection in directed graphs

Spellchecker

 Connected for an undirected graph: There is a path from every node to every other node  How can we determine if a graph is connected?

 Startup 1. Set the number of all nodes to 0 2. Pick an arbitrary node u and run DFS( u, 1 )  DFS( node v, int i ) 1. Set number(v) = i++ 2. For each node u adjacent to v If number(u) is 0 DFS( u, i )  If any node has a number of 0, the graph is not connected

 Connected components are the parts of the graph that are connected to each other  In a connected graph, the whole graph forms a connected component  In a graph that is not entirely connected, how do we find connected components?  DFS again!  We run DFS on every unmarked node and mark all nodes with a number count  Each time DFS completes, we increment count and start DFS on the next unmarked node  All nodes with the same value are in a connected component

 Weakly connected directed graph: If the graph is connected when you make all the edges undirected  Strongly connected directed graph: If for every pair of nodes, there is a path between them in both directions

 Components of a directed graph can be strongly connected  A strongly connected component is a subgraph such that all its nodes are strongly connected  To find strongly connected components, we can use a special DFS  It includes the notion of a predecessor node, which is the lowest numbered node in the DFS that can reach a particular node

 StrongDFS( node v, int i ) 1. Set number(v) = i++ 2. Set predecessor(v) to number(v) 3. Push(v) 4. For each node u adjacent to v If number(u) is 0 StrongDFS( u, i ) predecessor(v) = min(predecessor(v), predecessor(u)) Else if number(u) < number(v) and u is 0n the stack predecessor(v) = min(predecessor(v), number(u)) 5. If predecessor(v) is number(v) w = pop() while w is not v output w w = pop() output w

 StronglyConnected( Vertices V )  Set i = 1  For each node v in V Set number(v) = 0  For each node v in V If number(v) is 0 StrongDFS( v, i ) Remember that i is passed by reference

A B I D F H C E G

 Minimum spanning trees  Shortest paths  Matching  Euler tours

 Finish Project 3  Due tonight before midnight  Keep reading sections 4.3 and 4.4