A Unified View of Graph Searching

Slides:



Advertisements
Similar presentations
Graphs - II Algorithms G. Miller V. Adamchik CS Spring 2014 Carnegie Mellon University.
Advertisements

Interval Graph Test.
Bayesian Networks, Winter Yoav Haimovitch & Ariel Raviv 1.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
GRAPHS AND GRAPH TRAVERSALS 9/26/2000 COMP 6/4030 ALGORITHMS.
GOLOMB RULERS AND GRACEFUL GRAPHS
1 Data Structures DFS, Topological Sort Dana Shapira.
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.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
A Unified View of Graph Searching
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
Great Theoretical Ideas in Computer Science for Some.
Interval Graph Test Wen-Lian Hsu.
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.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
Introduction to Algorithms
Breadth-First Search (BFS)
Graphs – Breadth First Search
Directed Graphs 12/7/2017 7:15 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
An Introduction to Graph Theory
CSE 373, Copyright S. Tanimoto, 2002 Graphs 2 -
Chapter 22 Elementary Graph Algorithms
Main algorithm with recursion: We’ll have a function DFS that initializes, and then calls DFS-Visit, which is a recursive function and does the depth first.
Chapter 9 (Part 2): Graphs
Topological Sort In this topic, we will discuss: Motivations
Discrete Mathematicsq
Minimal Spanning Trees
Csc 2720 Instructor: Zhuojun Duan
12. Graphs and Trees 2 Summary
Lectures on Network Flows
Great Theoretical Ideas in Computer Science
Chapter 14 Graph Algorithms
Depth-First Search.
Greedy Algorithms / Interval Scheduling Yin Tat Lee
CS120 Graphs.
Graph Algorithms Using Depth First Search
Spanning Trees Longin Jan Latecki Temple University based on slides by
Planarity Testing.
The Art Gallery Problem
Discrete Mathematics for Computer Science
CSE 421: Introduction to Algorithms
Graph Algorithms – 2 DAGs Topological order
Graph Representation Adjacency list representation of G = (V, E)
Lecture 10 Algorithm Analysis
The Art Gallery Problem
Polygon Triangulation
Graphs Chapter 15 explain graph-based algorithms Graph definitions
Graph Algorithms – 2.
Advanced Algorithms Analysis and Design
Advanced Algorithms Analysis and Design
Applications of DFS Topological sort (for directed acyclic graph)
Lectures on Graph Algorithms: searching, testing and sorting
Elementary Graph Algorithms
Graphs.
Basic Graph Algorithms
Graphs Part 2 Adjacency Matrix
Depth-First Search Graph Traversals Depth-First Search DFS.
Spanning Trees Longin Jan Latecki Temple University based on slides by
Richard Anderson Autumn 2016 Lecture 5
Directed Graphs Directed Graphs Directed Graphs 2/23/ :12 AM BOS
Graph Implementation.
Applied Combinatorics, 4th Ed. Alan Tucker
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Elementary Graph Algorithms
Concepts of Computation
Locality In Distributed Graph Algorithms
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
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 everywhere in computer science. The search is applied through the neighborhoods of the vertices. Each edge is traversed exactly once, and we eventually reach all vertices. The algorithms are varied differing mostly in the selection of the next edge to traverse.

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

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 characterizations can help us reveal the structure or properties of a graph. For example, the characterization of LexBFS helps in proving that the reverse of a LexBFS-ordering of a chordal graph is a perfect elimination ordering.

Definitions and Notations All our 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] 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 neighborhood is a clique in G. Perfect Elimination Order an ordering  = (v1,…, vn) of V(G), where vi is simplicial in G[i].

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

Generic Search Characterization d b c Property (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. Note: d may occur either before or after a

Generic Search Characterization 1 4 3 5 6 2 Example  = (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 S 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 have 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 a contradiction that there exists an order  which respects Property (S), but is not a search order. Let vi be the first vertex in  that can’t be chosen next by the algorithm. That is, vi is not yet in S. Let u be the next vertex the algorithm chooses. So, u is in S at iteration i. Let w be neighbor of u which caused him to be added to S. So, wuE, but wviE. By applying Property (S) on the triple (w,vi, u), there exists d < vi with dviE. Hence viS, so it could have been 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 typically uses an queue as its data structure to obtain the restriction. However, it does not determine in which order to push the neighbors of the chosen vertex.

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

A view of S during BFS et cetera [ x | all unnumbered neighbors of x ] [ x < y | all unnumbered neighbors of x | all remaining unnumbered neighbors of y ] [ x < y < z | all unnumbered neighbors of x | all remaining unnumbered neighbors of y | all remaining unnumbered neighbors of z ] et cetera

BFS Characterization d a b c Note: Here d must occur before a Property (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. Note: Here d must occur before a

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 in a given order  vi is the first vertex in  that can’t be chosen next by the BFS algorithm. So vi is not yet in S. Let u be the next vertex the algorithm chooses. So there is a w < vi adjacent to u but not adjacent to vi. Choose w to be the leftmost such vertex in . By applying Property (B) on the triple (w,vi, u): there exists d < vi with dvi  E. Since w was chosen leftmost, any vertex left of 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 have choosen vi before u. A Contradiction.

LexBFS – Lexicographic BFS LexBFS is a very important special case of BFS. When adding new vertices to S, it also refines its preference between otherwise equivalent vertices already in S. It creates an order between the neighbors of a selected vertex using lexicographic labeling of the vertices through the search.

LexBFS Algorithm (vertex label version) Input : a graph G = (V, E) and start vertex s Output : 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 For each 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 Algorithm (refinement version) Input : a graph G = (V, E) and start vertex s Output : an ordering  of V The data structure S is a partitioned queue. [ x < y < z | all unnumbered neighbors of x | all remaining unnumbered neighbors of y | all remaining unnumbered neighbors of z ] BFS LexBFS [ x < y < z | all remaining common neighbors of x, y, z | all remaining common neighbors of x, y | all remaining common neighbors of x, z | all remaining neighbors of x | all remaining common neighbors of y, z | all remaining neighbors of y | all remaining neighbors of z | all remaining unnumbered vertices ]

LexBFS Algorithm (refinement version) Place all vertices in S with s at the beginning For i  1 to n do Pop v from S (i)  v For each “slice” L (equivalence class) of the partitioned queue S, split L into two parts L1 = L  neighbors of v L2 = L  non-neighbors of v placing L1 in front of L2

LexBFS Example 6 1 4 3 5 6 2 5 5 5 4 4 2 4 4 3 4 3 3 2  = { }  = { 1 2 3 5 4 }  = { 1 2 3 5 4 6 }  = { 1 2 3 5 }  = { 1 2 3 }  = { 1 }  = { 1 2 } [ 1 4 2 6 3 5 ] ordered arbitrarily but with s = 1 [ 1 | 2 3 | 4 6 5 ] refined ordered as neighbors of 1 [ 1 2 | 3 | 4 5 | 6 ] refined ordered as neighbors of 2 [ 1 2 3 | 5 | 4 | 6 ] refined ordered as neighbors of 3

LexBFS Characterization d a b c Property (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. Note: d must occur before a and extra non-edge

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 BFS and LexBFS is the requirement of dcE. A LexBFS-ordering is a BFS-ordering, since Property (B) subsumes Property (LB).

DFS – Depth First Search DFS explores the graph differently than BFS. DFS 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. DFS uses a stack as its data structure to obtain this restriction.

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

DFS Characterization d a b c Note: Here d must occur after a Property (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. Note: Here d must occur after a

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). Proof: Exercise.

LexDFS – lexicographic DFS Looking at the relation between BFS and LexBFS, one naturally asks: Is there 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 to be adjacent to those vertices which have “most recently” been numbered. But is it “useful” for something?

LexDFS Characterization b c Property (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 For each unnumbered vertex w adjacent to v do Prepend i to Label(w)

LexDFS Example  1 4 3 5 6 2 1  1 2 1  2 4 2  2 3 2  4 3  3  = { 1 2 3 }  = { 1 2 3 5 6 4 }  = { 1 }  = { 1 2 3 5 6 }  = {}  = { 1 2 3 5 }  = { 1 2 } [ 1 4 2 6 3 5 ] ordered arbitrarily but with s = 1 [ 1 | 2 3 | 4 6 5 ] refined ordered as neighbors of 1 [ 1 2 | 3 | 4 5 | 6 ] refined ordered as neighbors of 2 [ 1 2 3 | 5 | 6 | 4 ] refined ordered as neighbors of 3 (6 goes ahead of 4 )

LexDFS Example d a b c 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 Property (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. Note: d may occur either before or after a

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 For each unnumbered vertex w adjacent to v do Append 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 search characterizations can be extended to more general environments. These characterizations 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. For example: Recognition of cographs Recognition of unit interval graphs