Plan. I Gale-Shapley Running Time. I Graphs. I Motivation and definitions I Graph traversal: BFS and DFS

Similar documents
CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

An undirected graph G = (V, E) V a set of vertices E a set of unordered edges (v,w) where v, w in V

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs.

CS61B Lecture #33. Administrivia: Autograder will run this evening. Today s Readings: Graph Structures: DSIJ, Chapter 12

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

CSC Design and Analysis of Algorithms. Example: Change-Making Problem

CSE 373. Graphs 1: Concepts, Depth/Breadth-First Search reading: Weiss Ch. 9. slides created by Marty Stepp

CS200: Graphs. Graphs. Directed Graphs. Graphs/Networks Around Us. What can this represent? Sometimes we want to represent directionality:

CS 461, Lecture 17. Today s Outline. Example Run

CS 241 Analysis of Algorithms

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs

Exam 1 Solution. CS 542 Advanced Data Structures and Algorithms 2/14/2013

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes.

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1

Algorithmic and NP-Completeness Aspects of a Total Lict Domination Number of a Graph

Why the Junction Tree Algorithm? The Junction Tree Algorithm. Clique Potential Representation. Overview. Chris Williams 1.

Outline. Circuits. Euler paths/circuits 4/25/12. Part 10. Graphs. Euler s bridge problem (Bridges of Konigsberg Problem)

Section 10.4 Connectivity (up to paths and isomorphism, not including)

Module graph.py. 1 Introduction. 2 Graph basics. 3 Module graph.py. 3.1 Objects. CS 231 Naomi Nishimura

5/7/13. Part 10. Graphs. Theorem Theorem Graphs Describing Precedence. Outline. Theorem 10-1: The Handshaking Theorem

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2

Problem solving by search

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

CSE 373: AVL trees. Warmup: Warmup. Interlude: Exploring the balance invariant. AVL Trees: Invariants. AVL tree invariants review

Planar Upward Drawings

Constructive Geometric Constraint Solving

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s?

Announcements. Not graphs. These are Graphs. Applications of Graphs. Graph Definitions. Graphs & Graph Algorithms. A6 released today: Risk

COMP108 Algorithmic Foundations

Outline. 1 Introduction. 2 Min-Cost Spanning Trees. 4 Example

0.1. Exercise 1: the distances between four points in a graph

Weighted graphs -- reminder. Data Structures LECTURE 15. Shortest paths algorithms. Example: weighted graph. Two basic properties of shortest paths

Similarity Search. The Binary Branch Distance. Nikolaus Augsten.

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology!

Solutions for HW11. Exercise 34. (a) Use the recurrence relation t(g) = t(g e) + t(g/e) to count the number of spanning trees of v 1

Outline. Computer Science 331. Computation of Min-Cost Spanning Trees. Costs of Spanning Trees in Weighted Graphs

Garnir Polynomial and their Properties

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths.

N=4 L=4. Our first non-linear data structure! A graph G consists of two sets G = {V, E} A set of V vertices, or nodes f

COMPLEXITY OF COUNTING PLANAR TILINGS BY TWO BARS

More Foundations. Undirected Graphs. Degree. A Theorem. Graphs, Products, & Relations

Numbering Boundary Nodes

(2) If we multiplied a row of B by λ, then the value is also multiplied by λ(here lambda could be 0). namely

Announcements. These are Graphs. This is not a Graph. Graph Definitions. Applications of Graphs. Graphs & Graph Algorithms

12. Traffic engineering

learning objectives learn what graphs are in mathematical terms learn how to represent graphs in computers learn about typical graph algorithms

Scientific Programming. Graphs

1 Introduction to Modulo 7 Arithmetic

The University of Sydney MATH2969/2069. Graph Theory Tutorial 5 (Week 12) Solutions 2008

Seven-Segment Display Driver

Formal Concept Analysis

Present state Next state Q + M N

Minimum Spanning Trees

10/30/12. Today. CS/ENGRD 2110 Object- Oriented Programming and Data Structures Fall 2012 Doug James. DFS algorithm. Reachability Algorithms

Chapter 9. Graphs. 9.1 Graphs

CSI35 Chapter 11 Review

Improving Union. Implementation. Union-by-size Code. Union-by-Size Find Analysis. Path Compression! Improving Find find(e)

Register Allocation. How to assign variables to finitely many registers? What to do when it can t be done? How to do so efficiently?

The Plan. Honey, I Shrunk the Data. Why Compress. Data Compression Concepts. Braille Example. Braille. x y xˆ

Register Allocation. Register Allocation. Principle Phases. Principle Phases. Example: Build. Spills 11/14/2012

Multipoint Alternate Marking method for passive and hybrid performance monitoring

A Simple Code Generator. Code generation Algorithm. Register and Address Descriptors. Example 3/31/2008. Code Generation

Outline. Binary Tree

Integration Continued. Integration by Parts Solving Definite Integrals: Area Under a Curve Improper Integrals

IEEE TRANSACTIONS ON COMPUTATIONAL BIOLOGY AND BIOINFORMATICS, VOL. TK, NO. TK, MONTHTK YEARTK 1. Hamiltonian Walks of Phylogenetic Treespaces

(a) v 1. v a. v i. v s. (b)

DUET WITH DIAMONDS COLOR SHIFTING BRACELET By Leslie Rogalski

What do you know? Listen and find. Listen and circle. Listen and chant. Listen and say. Lesson 1. sheep. horse

Greedy Algorithms, Activity Selection, Minimum Spanning Trees Scribes: Logan Short (2015), Virginia Date: May 18, 2016

QUESTIONS BEGIN HERE!

Nefertiti. Echoes of. Regal components evoke visions of the past MULTIPLE STITCHES. designed by Helena Tang-Lim

CS September 2018

Using the Printable Sticker Function. Using the Edit Screen. Computer. Tablet. ScanNCutCanvas

Graph Contraction and Connectivity

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued...

XML and Databases. Outline. Recall: Top-Down Evaluation of Simple Paths. Recall: Top-Down Evaluation of Simple Paths. Sebastian Maneth NICTA and UNSW

Page 1. Question 19.1b Electric Charge II Question 19.2a Conductors I. ConcepTest Clicker Questions Chapter 19. Physics, 4 th Edition James S.

MAT3707. Tutorial letter 201/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/201/1/2017

ECE 407 Computer Aided Design for Electronic Systems. Circuit Modeling and Basic Graph Concepts/Algorithms. Instructor: Maria K. Michael.

Trees as operads. Lecture A formalism of trees

Section 3: Antiderivatives of Formulas

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA.

Graph Theory. Vertices. Vertices are also known as nodes, points and (in social networks) as actors, agents or players.

CS553 Lecture Register Allocation 1

Module 2 Motion Instructions

CMPS 2200 Fall Graphs. Carola Wenk. Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk

1. Determine whether or not the following binary relations are equivalence relations. Be sure to justify your answers.

Round 7: Graphs (part I)

16.unified Introduction to Computers and Programming. SOLUTIONS to Examination 4/30/04 9:05am - 10:00am

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata

Chapter 18. Minimum Spanning Trees Minimum Spanning Trees. a d. a d. a d. f c

QUESTIONS BEGIN HERE!

Aquauno Video 6 Plus Page 1

NP-Completeness. CS3230 (Algorithm) Traveling Salesperson Problem. What s the Big Deal? Given a Problem. What s the Big Deal? What s the Big Deal?

Spanning Trees. BFS, DFS spanning tree Minimum spanning tree. March 28, 2018 Cinda Heeren / Geoffrey Tien 1

GREEDY TECHNIQUE. Greedy method vs. Dynamic programming method:

Transcription:

Pln CS : Grphs: BFS n DFS Dn Shlon Gl-Shply Running Tim Grphs Motivtion n finitions Grph trvrsl: BFS n DFS Frury, 0 Running Tim of Gl-Shply? nitilly ll ollgs n stunts r fr whil som ollg is fr n hsn t m o rs to vry stunt o Choos suh ollg Lt s th highst rnk stunt to whom hs not m n o r if s is fr thn n s om ngg ls if s is ngg to 0 ut prfrs to 0 thn 0 oms fr n s om ngg ls rmins fr n if n whil Dt Struturs Running-tim pns on implmnttion tils n t struturs (.g. how to hoos suh ollg ). Q: How shoul w think out t struturs whn signing lgorithms? A: Most of th tim, s lk oxs with running-tim gurnts (.g., fin n lmnt in O(log n) tim ). Goo nws: on t n to rmmr tils of t struturs B nws: thy my sm opqu O(n ) itrtions. Ar ll sttmnts insi th loop onstnt tim? Rviw: Lists n Arrys Wht Dt Struturs to Us For G-S? Arry List Gt ith ntry O() O(i) Fin lmnt O(n) O(log n) if sort O(n) nsrt/lt O(n) O() N to o th following in O() tim Fin fr ollg Fin nxt stunt s in prfrn list of Fin urrnt ollg 0 of s Chk if s liks 0 ttr thn Not: O() = onstnt numr of stps

Wht Dt Struturs to Us For G-S? Anothr Exmpl: Hpsort nput: prfn lists = D rrys,.g. CollgPrf[, i] = stunt in position i on s list Oprtion Dt strutur Fn fr ollg link list: frcollgs Fin nxt stunt s in prfrn list of rry i = Nxt[] s = CollgPrf[, i] Fin urrnt ollg 0 of s -D rry: Currnt[s] Chk if s liks 0 ttr thn nput unsort rry A[] of lngth n Lt Q hp-s priority quu for i = to n o nsrt(q, A[i]) n for for i = to n o A[i] = ExtrtMin(Q) n for Running tim: (n nsrt) + (n ExtrtMin) -D rry: Rnking[s,] O(n log n) if oth oprtions r O(log n) xmpl on or Grphs Unirt Grph Motivtion n Dfinitions Brth-First Srh (BFS) n Dpth-First Srh (DFS) Unirt grph. G = (V, E)! V = nos (vrtis)! E = gs twn pirs of nos.! Cpturs pirwis rltionship twn ojts.! Grph siz prmtrs: n = V, m = E. V = {,,,, }! E = {(,), (,), (,), (,), (,),! (,)}! n=! m=6 Grphs Four Dgrs of Sprtion Four Dgrs of Sprtion Lrs Bkstrom Boli Mro Ros John Ugnr Lrs Bkstrom Polo Boli Mro RosPolo John Ugnr Sstino Vign Jnury 6, 0 Fook: how mny grs of sprtion twn m n Brk Om? An mny mor... stuying th istn istriution of vry lrg grphs: istriution HyAstrt stuying th istn of v pranf []. Builing on prviouspranf grph omprssion [] work []. Builing on prvious grph Frigys Krinthy, in his 99 shortkrinthy, story Lánszmk on th i Lánszmk of iffusiv omputtion pionr [], omputti Frigys in his 99n short story n on th i of in iffusiv ( Chins ) suggst tht ny( Chins ) two prsons r istn y two th prsons nw toolr m it possil urtly suggst tht ny istn y toth nw toolstuy mth it ispossil to u t most six frinship links. t Stnly in his links. fmous tn istriution orrs of mgnitu lrgr thn orrs of m most Milgrm six frinship Stnly Milgrm inofhisgrphs fmous tn istriution of grphs xprimnt [0, ] hllngxprimnt popl to rout postrs to it ws prviously possil. [0, ] hllng popl to rout postrs to it ws prviously possil. fix ripint y pssing thm onlyripint through y irt quinonthrough of th gols in stuying istriution th fix pssing thm only irt quin-th istn On of th gols in is stuying th ist tns. Th vrg numr tns. of intrmiris on th pth ofintifition of intrsting sttistil prmtrs tht n sttistil Th vrg numr intrmiris on th pth intifition of intrsting of th postrs ly twn of.th npostrs.7, pning on th. n us.7, to pning tll propr on soil from othr omplx ly twn thntworks us to tll propr soil ntworks smpl of popl hosn. ntworks, suh s w grphs. Mor gnrlly, th istn smpl of popl hosn. ntworks, suh s w grphs. Mor g W rport th rsults of th first worl-sl soil-ntwork istriution is on intrsting glol ftur tht mks it W rport th rsults of th first worl-sl soil-ntwork istriution is on intrsting glol f grph-istn omputtions, using th ntir Fook nt- possil to rjt proilisti mols vn whn thy mth grph-istn omputtions, using th ntir Fook ntpossil to rjt proilisti mols work of tiv usrs ( 7 million usrs, 69 illion frin- lol fturs suh s th in-gr istriution. work of tiv usrs ( 7 million usrs, 69 illion frinlol fturs suh s th in-gr ist ship links). Th vrg istn w osrv is.7, orn prtiulr, rlir work h shown tht th spi, ship or links). Th vrg istn w osrv is.7, orn istn prtiulr, rlir work h sh rsponing to.7 intrmiris grs of sprtion, whih msurs th isprsion of th istriution, rsponing to.7 intrmiris or grs of sprtion, whih msurs thfor isprsion of th showing tht th worl is vn smllr thn w xpt, n ppr to smllr thn (unrisprsion) soshowing tht th worl vn smllr thn w xpt, n ppr to smllr prompting th titl of this ppr. Mor gnrlly, w isstuy il ntworks, ut lrgr thn on (ovrisprsion) for wthn (un prompting th titl of this ppr. Mor gnrlly, w stuy th istn istriution of Fook n of som intrst- grphs []. Hn, uring th tlk, il ntworks, lrgr on of thut min opnthn on (ov th istn istriution of Fook n som is intrsting gogrphi sugrphs, looking lso t thir volution ovr grphs []. Hn, uring th tlk, o qustions wsof Wht th spi of Fook?. ing gogrphi sugrphs, looking Lrs lso t thir volution ovrto listn tim. qustions wstlk, Wht th spi of F Bkstrom hppn to th n issugth ntworks w r l totim. xplor r lmost two orrs gst ollortion stuying thlrs Bkstrom to listn Fook grph.hppn This of mgnitu lrgr thn thos nlys in th prvious litr-to xplor Th ntworks w r l r lmost two orrs ws of ours n xtrmly intriguing possiility: si tstgst ollortion stuying th F tur. W rport til sttistil mtt showing tht nlys of mgnitu lrgr thn thos in th prvious omputing litr- wsth ing th spi hypothsis, istnnistriution of ours xtrmly intriguing po our msurmnts (whih rly on proilisti lgorithms) tur. W rport til sttistil showing ththving of th mtt Fook grph woul n lrgst Milgrm-omputing th thth spi hypothsis, r vry urt. our msurmnts (whih rly lik on proilisti lgorithms) [0] xprimnt vr prform, of mgnitus of thorrs Fook grph woul hv n lrgr thn prvious ttmpts (uring our xprimnts r vry urt. lik [0] xprimnt Fvr prform, o ook hs 7 million tiv usrs nthn 69prvious illion frinlrgr ttmpts (uring o ntroution ship links). ook hs 7 million tiv usrs n Astrt v:.70v [s.s] Jn 0 Googl Mps: wht is th shortst riving rout from South Hly to Flori? Xiv:.70v [s.s] Jn 0 Sstin Jnury 6, 0

Trminology Dfinitions f = (u, v) is n g, thn: () u is nighor of v () u is jnt to v () is inint on u n v () u n v r th npoints of is jnt to! (,) is inint on n Pth Distn A pth is squn P of nos v, v,, v k-, v k with th proprty tht h onsutiv pir v i, v i+ is join y n g in E. Th istn from u to v is th minimum numr of gs in ny pth from u to v -- is pth.! -- is NOT pth. istn(,) =! istn(,) = Cyl A yl is pth v, v,, v k-, v k in whih v = v k, k >, n th first k- nos r ll istint. Conntivity An unirt grph is onnt if for vry pir of nos u n v, thr is pth twn u n v. --- is yl.! -- is NOT yl.! ---- is NOT yl.! ------- is NOT yl. is onnt grph. is NOT onnt grph.

Prnts, snnts, nstors? (Upsi-own) Trs Trs A tr is n unirt grph tht is onnt n os not ontin yl. is tr is NOT tr http://www.offttrvl.om/moca.html Rviw Dfinitions Grph Trvrsl s grph onnt? Wht to know: n, m, nighor, inint, pth, istn, yl, onnt, tr! Exmpl on or sy Grph Trvrsl hmmm... s Grph Connt? Algorithm : Brth-first srh (BFS) Explor outwr y istn s grph onnt?! Approh: xplor outwr from ritrry strting no s to fin ll nos rhl from s (onnt omponnt) Strt t : Visit ll nos t istn from : Visit ll nos t istn from :

Brth-First Srh BFS Tr Lyrs L0 = {s} L = ll nighors of L0 L = ll nos with n g to L tht on t long to L0 or L... Li+ = nos with n g to Li tht on t long to n rlir lyr: f w kp only th gs trvrs whil oing rth-first srh, w will hv tr Exmpl on or Li+ = {v : 9(u, v) E, u Li, v / (L0 [... [ Li )} Osrvtion: Li onsists of ll nos t istn xtly i from s. Thr is pth from s to t if n only if t pprs in som lyr. A Mor Gnrl Strtgy BFS Tr Proprty. Lt T BFS tr of G = (V, E), n lt (x, y) n g of G. Thn th lyr of x n y iffr y t most. Lyr 0: {}! Lyr : {,, }! Lyr : {} To xplor th onnt omponnt, ny no v for whih (u, v) is n g u is xplor, ut v is not Pitur on or Proof on or DFS Algorithm s Grph Connt? Algorithm : Dpth-first srh (DFS) - Kp xploring from most rntly no until you hv to ktrk DFS(u) Mrk u s Explor for h g (u, v) inint to u o if v is not mrk Explor thn Rursivly invok DFS(v) n if n for

Dpth First Srh Thorm: Lt T pth-first srh tr. Lt x n y nos in th tr. Lt (x, y) n g tht is in G ut not in T. Thn ithr x is n nstor of y or y is n nstor of x in T. Summry Dfinitions G =(V,E),n= V,m= E nighor, inint, yl, pth, onnt BFS n DFS Two wys to trvrs grph, h prous tr BFS tr: shllow n wi ( ushy ) DFS tr: p n nrrow ( srggly ) Proof?