A Unified View of Graph Searching

Slides:



Advertisements
Similar presentations
Graph Algorithms Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 11Feb 07, 2014Carnegie Mellon University.
Advertisements

Graphs - II Algorithms G. Miller V. Adamchik CS Spring 2014 Carnegie Mellon University.
Introduction to Algorithms Lecture 12 Prof. Constantinos Daskalakis CLRS
Interval Graph Test.
Graphs COP Graphs  Train Lines Gainesville OcalaDeltona Daytona Melbourne Lakeland Tampa Orlando.
CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.
Bayesian Networks, Winter Yoav Haimovitch & Ariel Raviv 1.
Depth-First Search1 Part-H2 Depth-First Search DB A C E.
Comp 122, Fall 2004 Elementary Graph Algorithms. graphs Lin / Devi Comp 122, Fall 2004 Graphs  Graph G = (V, E) »V = set of vertices »E = set of.
Theory of Computing Lecture 6 MAS 714 Hartmut Klauck.
Graphs – Depth First Search ORD DFW SFO LAX
Graph Traversals Visit vertices of a graph G to determine some property: Is G connected? Is there a path from vertex a to vertex b? Does G have a cycle?
Breadth-First and Depth-First Search
GRAPHS AND GRAPH TRAVERSALS 9/26/2000 COMP 6/4030 ALGORITHMS.
Graph Searching (Graph Traversal) Algorithm Design and Analysis Week 8 Bibliography: [CLRS] – chap 22.2 –
Graph Traversals Visit vertices of a graph G to determine some property: Is G connected? Is there a path from vertex a to vertex b? Does G have a cycle?
GOLOMB RULERS AND GRACEFUL GRAPHS
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Applied Discrete Mathematics Week 12: Trees
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
1 Data Structures DFS, Topological Sort Dana Shapira.
Definition Hamiltonian graph: A graph with a spanning cycle (also called a Hamiltonian cycle). Hamiltonian graph Hamiltonian cycle.
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
CS344: Lecture 16 S. Muthu Muthukrishnan. Graph Navigation BFS: DFS: DFS numbering by start time or finish time. –tree, back, forward and cross edges.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
Graph Theory Ch.5. Coloring of Graphs 1 Chapter 5 Coloring of Graphs.
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
The Art Gallery Problem
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Copyright © Cengage Learning. All rights reserved.
COSC 3101A - Design and Analysis of Algorithms 10
Sept Elementary Graph Algorithms Graph representation Graph traversal -Breadth-first search -Depth-first search Parenthesis theorem.
Discussion #32 1/13 Discussion #32 Properties and Applications of Depth-First Search Trees.
Elementary Graph Algorithms CLRS Chapter 22. Graph A graph is a structure that consists of a set of vertices and a set of edges between pairs of vertices.
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
Chapter 10 Graph Theory Eulerian Cycle and the property of graph theory 10.3 The important property of graph theory and its representation 10.4.
1 Chapter 22 Elementary Graph Algorithms. 2 Introduction G=(V, E) –V = vertex set –E = edge set Graph representation –Adjacency list –Adjacency matrix.
Graph Theory and Applications
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 20.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Trees Thm 2.1. (Cayley 1889) There are nn-2 different labeled trees
Properties and Applications of Depth-First Search Trees and Forests
Shahed University Dr. Shahriar Bijani May  A path is a sequence of vertices P = (v 0, v 1, …, v k ) such that, for 1 ≤ i ≤ k, edge (v i – 1, v.
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture nine Dr. Hamdy M. Mousa.
Interval Graph Test Wen-Lian Hsu.
Graphs + Shortest Paths David Kauchak cs302 Spring 2013.
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
Graph Theory Def: A graph is a set of vertices and edges G={V,E} Ex. V = {a,b,c,d,e} E = {ab,bd,ad,ed,ce,cd} Note: above is a purely mathematical definition.
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.
Graph Algorithms – 2. graphs Parenthesis Theorem Theorem 22.7 For all u, v, exactly one of the following holds: 1. d[u] < f [u] < d[v] < f [v] or.
Introduction to Algorithms
Breadth-First Search (BFS)
An introduction to chordal graphs and clique trees
Graph Algorithms Using Depth First Search
CSE 421: Introduction to Algorithms
Graph Algorithms – 2 DAGs Topological order
Graph Representation Adjacency list representation of G = (V, E)
A Unified View of Graph Searching
Lecture 10 Algorithm Analysis
Advanced Algorithms Analysis and Design
Graphs.
Basic Graph Algorithms
Graphs Part 2 Adjacency Matrix
Depth-First Search Graph Traversals Depth-First Search DFS.
Locality In Distributed Graph Algorithms
Presentation transcript:

A Unified View of Graph Searching Derek G. Corneil Richard Krueger

Outline Goal and Motivation Definitions and Notations Graph Searching Characterization – Basic line Generic Searching BFS LexBFS DFS LexDFS MNS Conclusions

Goal and Motivation Graph Search algorithms are commonly used. The search is being applied through the neighborhood of the vertices. Each edge is traversed exactly once, and we eventually reach all vertices. The algorithms are varied in selection of the next edge to traverse.

Goal and Motivation Searching the graph creates an order of the vertices. We can characterize the search algorithm by exploring the nature of the order it creates. Such characterization can help us reveal the structure of a graph. For example, the characterization of LexBFS helps in proving that the reverse of LexBFS-ordering of a chordal graph is a perfect elimination ordering.

Definitions and Notations All related graphs are connected and undirected.  = (v1,…, vn) – linear ordering of V. (i) = vi and -1(vi( = I – refer to a specific vertex in . G[i] = G[v1,…,vi] – be the subgraph of G induced on a prefix of  Chordal graph – every cycle of length at least 4 has at least one chord. Simplicial vertex – its neighborhood is a clique in G. Perfect Elimination Order – ordering (v1,…,vn) of V of G, where vi is simplicial in gi.

Graph Searching Characterization - Basic Line If a < b < c and acE and abE, then how could vertex b have been chosen before vertex c by our search ?

Generic Search Algorithm The data structure S is generic “set” to store the candidate vertices. Input : a graph G = (V, E) and start vertex s Ouput : an ordering  of V S  {s} For i  1 to n do Pick and remove an unnumbered vertex v from S (i)  v Foreach unnumbered vertex w adjacent to v do Add w to S

Generic Search Characterization d b c (S): given an ordering  of V, if a < b < c and acE and abE, then there exists a vertex d < b such that dbE.

Generic Search Characterization 1 4 3 5 6 2  = (1,2,4,3,5,6) is a valid search-ordering of the 3-sun, but this ordering is neither DFS nor BFS. By using more restrictive data structure we may obtain other properties for our search.

Generic Search Characterization Theorem – For an arbitrary graph G, an ordering  of V is a search-ordering of G if and only if  has property (S). Proof :  At the point when b is chosen, both b and c must be in S. Therefore some neighbor of b must already been chosen, call it d. Thus d < b and dbE. This holds for all triples in , so property (S) holds on .

Generic Search Characterization  suppose for contradiction that given , an order which respect property (S), vi is the first vertex in  that can’t be chosen next by the algorithm. So, vi is not in S yet. Let u be the next vertex the algorithm choose. So, u is in S. Let w be neighbor of u which caused him to be added to S. So, wuE, but wviE. By applying (S) on the triple (w,vi,u), there exists d < vi with dviE. Hence viS, so it could be chosen next. A Contradiction.

BFS – Breadth First Search BFS is a restriction of generic search in that it explores all neighbors of a selected vertex before it goes deeper in the graph. It uses queue as its data structure to obtain the restriction. However, it does not determine which order to push the neighbors of a chosen vertex.

BFS Algorithm The data structure S is a queue. Input : a graph G = (V, E) and start vertex s Ouput : an ordering  of V S  {s} For i  1 to n do pop v from S (i)  v Foreach unnumbered vertex w adjacent to v do If w is not already in S then push w to S

BFS Characterization d a b c (B): given an ordering  of V, if a < b < c and acE and abE, then there exists a vertex d < a such that dbE.

BFS Characterization Theorem – For an arbitrary graph G, an ordering  of V is a BFS-ordering of G if and only if  has property (B). Proof :  At the point when b is chosen, both b and c must be in S. Therefore some neighbor of b was pulled from S as least as early as a, call it d. since b does not have a as a neighbor d must be earlier than a.

BFS Characterization  suppose for contradiction that given  vi is the first vertex in  that can’t be chosen next by the algorithm. So vi is not in S yet. Let u be the next vertex the algorithm choose, So there is a w < vi adjacent to u but not to vi. Choose w to be the leftmost such vertex in . By applying (B) on the triple (w,vi,u), there exists d < vi with dviE. Since w was chosen leftmost, any vertex left to w which is adjacent to u must also be adjacent to vi. But d is left of w and adjacent to vi, therefore a BFS could choose vi before u. A Contradiction.

LexBFS – Lexicographic BFS LexBFS is a BFS with another restriction. It creates an order between the neighbors of a selected vertex using lexicographic labeling of the vertices through the search.

LexBFS Algorithm Input : a graph G = (V, E) and start vertex s Ouput : an ordering  of V Assign the label 0 to all vertices Label(s)  {n+1} For i  1 to n do Pick an unnumbered vertex v with lexicographically largest label (i)  v Foreach unnumbered vertex w adjacent to v do Append (n-i) to label(w)

LexBFS Example 6 1 4 3 5 6 2 5 5 4 5 4 2 4 4 4 3 3 2 3  = { 1 2 3 5 4 }  = { 1 2 3 5 4 6 }  = { 1 }  = { }  = { 1 2 }  = { 1 2 3 }  = { 1 2 3 5 }

LexBFS Characterization d a b c (LB): given an ordering  of V, if a < b < c and acE and abE, then there exists a vertex d < a such that dbE and dcE.

LexBFS Characterization Theorem – For an arbitrary graph G, an ordering  of V is a LexBFS-ordering of G if and only if  has property (LB). The only difference between the algorithms is the requirement of dcE. A LexBFS-ordering is a BFS-ordering, since (B) subsumes (LB).

DFS – Depth First Search DFS explores the graph differently than BFS. It progresses forward through the graph as much as possible, backtracking only when necessary, whereas BFS first explores close vertices before going deeper to the far more vertices. It uses stack as its data structure to obtain this restriction.

DFS Algorithm The data structure S is a stack. Input : a graph G = (V, E) and start vertex s Ouput : an ordering  of V S  {s} For i  1 to n do pop v from S (i)  v Foreach unnumbered vertex w adjacent to v do If w is already in S then remove w to S Push w to S

DFS Characterization d a b c (D): given an ordering  of V, if a < b < c and acE and abE, then there exists a vertex a < d < b such that dbE.

DFS Characterization Theorem – For an arbitrary graph G, an ordering  of V is a DFS-ordering of G if and only if  has property (D).

LexDFS – lexicographic DFS Looking at the relation between BFS and LexBFS, one naturally asks whether there is a “lexicographic analogue” of DFS. Forcing the restriction that dcE on the DFS characterization, immediately creates a new algorithm and a characterization for it.

LexDFS This algorithm must act as DFS and progress forward through the graph as much as possible, but also choose its next vertex that is adjacent to as many vertices we have most recently numbered as possible.

LexDFS Characterization b c (LD): given an ordering  of V, if a < b < c and acE and abE, then there exists a vertex a < d < b such that dbE and dcE.

LexDFS Algorithm Input : a graph G = (V, E) and start vertex s Ouput : an ordering  of V Assign the label  to all vertices Label(s)  {0} For i  1 to n do Pick an unnumbered vertex v with lexicographically largest label (i)  v Foreach unnumbered vertex w adjacent to v do Prepend i to label(w)

LexDFS Example  1 4 3 5 6 2  1 2 1 1   4 2 2 3 2 2  3 4 3   = { 1 2 3 5 6 }  = { 1 2 3 5 6 4 }  = { 1 }  = {}  = { 1 2 3 }  = { 1 2 }  = { 1 2 3 5 }

LexDFS Example a d c b 1 4 3 5 6 2 1 2 1 4 2 3 2 4 3 a d b c 1 4 3 5 6 2 a d 1 2 1 c b 4 2 3 2 4 3 a d b c  = { 1 2 3 5 6 4 } Property (LD) is satisfied on the chosen triple (a,b,c)

LexDFS Characterization Theorem – For an arbitrary graph G, an ordering  of V is a LexDFS-ordering of G if and only if  has property (LD).

Difference between LexBFS and LexDFS LexBFS – we choose a vertex adjacent to as many earliest chosen vertices as possible. LexDFS – we choose a vertex adjacent to as many most recently chosen vertices as possible. The two algorithms have a common restriction - dcE.

MNS – Maximal Neighborhood Search MNS is a generalization of LexBFS and LexDFS. Its characterization is built from the Generic Search property (S) and the restriction dcE. Pick a vertex whose neighborhood in the part of the graph already explored is maximal.

MNS Characterization a d b c (M): given an ordering  of V, if a < b < c and acE and abE, then there exists a vertex d < b such that dbE and dcE.

MNS Characterization Theorem – For an arbitrary graph G, an ordering  of V is a MNS-ordering of G if and only if  has property (M).

MNS Algorithm Input : a graph G = (V, E) and start vertex s Ouput : an ordering  of V Assign the label  Label(s)  {n+1} For i  1 to n do Pick an unnumbered vertex v with maximal label (i)  v Foreach unnumbered vertex w adjacent to v do Add i to label(w)

Summary of search characterization d b c Generic Search d < a a < d dcE BFS DFS dcE dcE MNS d < a a < d LexDFS LexBFS

Conclusions The idea of characterization can be extended to more general environments. These characterization can be applicable on multigraphs. They give us better understanding of how a search reveals the structure of a graph They allow us to employ multiple sweeps of a search to gather additional information about a graph.