Preview. Graph. Graph. Graph. Graph Representation. Graph Representation 12/3/2018. Graph Graph Representation Graph Search Algorithms

Similar documents
Spanning Tree. Preview. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree 10/17/2017.

Minimum Spanning Trees

Minimum Spanning Trees

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

Lecture 20: Minimum Spanning Trees (CLRS 23)

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

COMP108 Algorithmic Foundations

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

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

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

Shortest Paths in Graphs. Paths in graphs. Shortest paths CS 445. Alon Efrat Slides courtesy of Erik Demaine and Carola Wenk

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

Fundamentals of Continuum Mechanics. Seoul National University Graphics & Media Lab

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

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

A general N-dimensional vector consists of N values. They can be arranged as a column or a row and can be real or complex.

Analysis of Algorithms - Elementary graphs algorithms -

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

(A) the function is an eigenfunction with eigenvalue Physical Chemistry (I) First Quiz

CSI35 Chapter 11 Review

Analysis of Algorithms - Elementary graphs algorithms -

Last time: introduced our first computational model the DFA.

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

b.) v d =? Example 2 l = 50 m, D = 1.0 mm, E = 6 V, " = 1.72 #10 $8 % & m, and r = 0.5 % a.) R =? c.) V ab =? a.) R eq =?

minimize c'x subject to subject to subject to

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

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

Week 3: Connected Subgraphs

CS 241 Analysis of Algorithms

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

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

Chapter 6 Continuous Random Variables and Distributions

ERDOS-SMARANDACHE NUMBERS. Sabin Tabirca* Tatiana Tabirca**

4.1 Interval Scheduling. Chapter 4. Greedy Algorithms. Interval Scheduling: Greedy Algorithms. Interval Scheduling. Interval scheduling.

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

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

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

Fractions. Mathletics Instant Workbooks. Simplify. Copyright

Practice Final Exam. 3.) What is the 61st term of the sequence 7, 11, 15, 19,...?

ELEG 413 Lecture #6. Mark Mirotznik, Ph.D. Professor The University of Delaware

glo beau bid point full man branch last ior s all for ap Sav tree tree God length per down ev the fect your er Cm7 a a our

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

Walk Like a Mathematician Learning Task:

DCDM BUSINESS SCHOOL NUMERICAL METHODS (COS 233-8) Solutions to Assignment 3. x f(x)

Multi-Section Coupled Line Couplers

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

Section 3: Antiderivatives of Formulas

Copyright 2000, Kevin Wayne 1

Errata for Second Edition, First Printing

FSA. CmSc 365 Theory of Computation. Finite State Automata and Regular Expressions (Chapter 2, Section 2.3) ALPHABET operations: U, concatenation, *

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

ON THE COMPLEXITY OF K-STEP AND K-HOP DOMINATING SETS IN GRAPHS

Section 5.1/5.2: Areas and Distances the Definite Integral

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

Examples and applications on SSSP and MST

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

Lucas Test is based on Euler s theorem which states that if n is any integer and a is coprime to n, then a φ(n) 1modn.

5/1/2018. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees

Searching Linked Lists. Perfect Skip List. Building a Skip List. Skip List Analysis (1) Assume the list is sorted, but is stored in a linked list.

Riemann Sums and Riemann Integrals

cycle that does not cross any edges (including its own), then it has at least

Errata for Second Edition, First Printing

Riemann Sums and Riemann Integrals

INF5820/INF9820 LANGUAGE TECHNOLOGICAL APPLICATIONS. Jan Tore Lønning, Lecture 4, 14 Sep

UNIVERSITY OF IOANNINA DEPARTMENT OF ECONOMICS. M.Sc. in Economics MICROECONOMIC THEORY I. Problem Set II

Partially Observable Systems. 1 Partially Observable Markov Decision Process (POMDP) Formalism

8. Linear Contracts under Risk Neutrality

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

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

Chapter Newton-Raphson Method of Solving a Nonlinear Equation

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

(Minimum) Spanning Trees

Instructions for Section 1

, between the vertical lines x a and x b. Given a demand curve, having price as a function of quantity, p f (x) at height k is the curve f ( x,

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

CSE 417, Winter Greedy Algorithms 1/27/2012. Chapter 4. Ben Birnbaum Widad Machmouchi. 4.1 Interval Scheduling.

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

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

The graphs of Rational Functions

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...

TOPIC 5: INTEGRATION

Linear Algebra Existence of the determinant. Expansion according to a row.

Weighted Graphs. Weighted graphs may be either directed or undirected.

Abstract Interpretation: concrete and abstract semantics

Constructive Geometric Constraint Solving

Problem solving by search

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

Lecture 14. Relic neutrinos Temperature at neutrino decoupling and today Effective degeneracy factor Neutrino mass limits Saha equation

Lecture 11 Waves in Periodic Potentials Today: Questions you should be able to address after today s lecture:

Rank One Update And the Google Matrix by Al Bernstein Signal Science, LLC

1 Introduction to Modulo 7 Arithmetic

10/7/14. Mixture Models. Comp 135 Introduction to Machine Learning and Data Mining. Maximum likelihood estimation. Mixture of Normals in 1D

ITERATIVE METHODS FOR SOLVING SYSTEMS OF LINEAR ALGEBRAIC EQUATIONS

Variable time amplitude amplification and quantum algorithms for linear algebra. Andris Ambainis University of Latvia

Chapter Newton-Raphson Method of Solving a Nonlinear Equation

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

Strongly Connected Components

13. Binary tree, height 4, eight terminal vertices 14. Full binary tree, seven vertices v 7 v13. v 19

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

Transcription:

/3/0 Prvw Grph Grph Rprsntton Grph Srch Algorthms Brdth Frst Srch Corrctnss of BFS Dpth Frst Srch Mnmum Spnnng Tr Kruskl s lgorthm Grph Drctd grph (or dgrph) G = (V, E) V: St of vrt (nod) E: St of dgs (ordrd vrt pr) Undrctd grph G = (V, E) V: St of vrt E: St of dgs (unordrd vrt pr) Grph Grph A B E A B E C D F C D F Dgrph G = (V, E) Undrctd Grph G = (V, E) V = A, B, C, D, E, F V = A, B, C, D, E, F E = (A, B), (C, A), (B, D), (B, C), (C, D), (D, C), (B, B) (F, E) E = (A, B), (A, C), (B, D), (B, C), (E, F) 3 Grph Rprsntton Grph Rprsntton Two stndrd wy to rprsnt grph. Adjcnt Lst Sprs grph. Adjcnt Mtr Dns Grph 3 3 3 Adjcnt Lst 3 3 0 0 0 0 0 0 0 0 0 0 0 Adjcnt Mtr Adjcncy lst If G s drctd grph, th sum of lngths of djcncy lst s E. If G s undrctd grph, th sum of lngths of ll th djcncy lst s E. Wghtd grph s grph for whch ch dg hs n ssoctd wght. Adjcnt lsts cn rdly b dptd to rprsnt wghtd grphs by sv mor nformton for ch nod. A dsdvntg Thr s no quckr wy to dtrmn f gvn dg (u, v) s prsnt n th grph thn srch for v n th djcncy lst A[u].

/3/0 Grph Rprsntton Grph Rprsntton Adjcncy Mtr Th djcncy-mtr rprsntton of grph G conssts of V V mtr A = (, j ) such tht, j f (, j) E 0 othrws Th djcncy mtr rprsntton cn b usd for wghtd grphs. If grph s unwghtd, th djcncy mtr uss only on bt pr ntry. 3 3 3 3 3 Adjcnt Lst 3 0 0 0 0 0 0 0 0 0 0 0 Adjcnt Mtr Grph Rprsntton 3 Grph Rprsntton Wghtd dgrph or grph cn b rprsntd wth djcnt mtr 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 0 3 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 Brdth-Frst Srch Brdth-Frst Srch From sourc nod s n grph G = (V, E), BFS plors th dgs of G vry vrt tht s rchbl from s. It clcult shortst dstnc from s to ny vrt u. BFS d s usd n Djkstr s sngl sourc shortst pth lgorthm nd Prm s mnmum spnnng tr lgorthm. Brdth-Frst srch Th lgorthm dscovrs ll vrtcs t dstnc k from s bfor dscovrng ny vrtcs t dstnc k +. Ech nod hs thr lmnts: color, dstnc nd prnt.. Color s usd for plorng grph,. Dstnc s usd for dnotng th hght from s n brdth-frst srch tr nd 3. Prnt s usd for kp th brdth-frst tr.

/3/0 Brdth-Frst Srch Brdth-Frst Srch (G, s) for ch vrt u V(G) s u.color = wht u.dstnc = u.prnt = Nl s.color = gry s.dstnc = 0 s.prnt = Nl EnQuu (Q, s) whl not mpty(q) u = Top(Q) for ch v djcnt to u f v.color = wht thn v.color = gry v.prnt = u v.dstnc = u.dstnc + ; EnQuu(Q, v) DQuu(Q) u.color = blck Th runnng tm of BFS Intlzton O(V) Ech dgs must plor on tm for BFS O(E) Totl: O(V+ E) 3 Brdth-Frst Srch 0 s Quu Brdth-Frst Srch Brdth-Frst Srch 0 0 s w s w r Quu Quu Brdth-Frst Srch Brdth-Frst Srch 0 0 w r w r t Quu Quu 3

/3/0 Brdth-Frst Srch Brdth-Frst Srch 0 0 w r t r t Quu Quu 0 Brdth-Frst Srch Brdth-Frst Srch 0 0 r t v t v Quu Quu Brdth-Frst Srch Brdth-Frst Srch 0 3 0 3 t v u v u Quu Quu 3

/3/0 Brdth-Frst Srch Brdth-Frst Srch 0 3 0 3 3 3 v u y v u y Quu Quu Brdth-Frst Srch Brdth-Frst Srch 0 3 0 3 3 3 u y y Quu Quu Brdth-Frst Srch Corrctnss of Brdth-Frst Srch Lts s, v V n G = (V, E) 0 3 (s, v): shortst pth from s to v s th mnmum numbr of dgs n ny possbl pth from s to v. 3 BFS crt shortst pth from vrt s to ny vrt v f thr s pth btwn s nd v Quu 30

/3/0 Dpth Frst Srch In dpth-frst srch strtgy s to srch dpr n th grph whnvr possbl. In dpth-frst srch, dgs r plord out of th most rcntly dscovrd vrt v tht stll hs unplord dgs lvng t. Whn ll of v s dgs hv bn plord, th srch bcktrcks to plor dgs lvng th vrt from whch v ws dscovrd Dpth Frst Srch Ech vrt hs four lmnts: color, prnt nd tmstmps (vst_tm nd fnsh_tm).. Color s usd for plorng th grph.. v.vst_tm rcords whn nod v s dscovrd(nd gry). 3. v.fnsh_tm rcords whn th srch fnshs mnng v s djcncy lst.. Prnt s usd for kp th brdth-frst tr or forst. Ths tmstmps r usd n mny grph lgorthms nd r hlpful n rsonng bout th bhvor of dpth-frst srch. Runnng tm : (V + E) 3 3 Dpth Frst Srch Dpth Frst Srch Dpth_Frst_Srch(G) for ch vrt u V(G) u.color = wht u.prnt = nl tm = 0 for ch vrt u V(G) f u.color = wht Dpth_Frst_Vst(u) Dpth_Frst_Vst(u) u.color = gry u.vst_tm = tm + for ch v djcnt u f v.color == wht v.prnt = u Dpth_Frst_Vst(v) u.color = blck u.fnsh_tm = tm + / 33 3 Dpth Frst Srch Dpth Frst Srch / / / / 3/ 3 3

/3/0 Dpth Frst Srch Dpth Frst Srch / / / / / 3/ / 3/ 3 3 Dpth Frst Srch Dpth Frst Srch / / / / / 3/ / 3/ 3 0 Dpth Frst Srch Dpth Frst Srch / / / / / 3/ / 3/

/3/0 Dpth Frst Srch Dpth Frst Srch / / / / / / / 3/ / 3/ 3 Dpth Frst Srch Dpth Frst Srch / / / / / / / 3/ 0/ / 3/ 0/ Dpth Frst Srch / / / / 3/ 0/ Input: connctd undrctd grph G = (V, E) whr for ch dg (u, v) E, w hv wght w(u, v) Output: Fnd n cyclc subst T E tht conncts ll of th vrtcs nd whos totl wght s mnmzd.

/3/0 Mnmum Spnnng Tr us grdy lgorthm Grdy lgorthm lwys mks th choc tht looks bst t th momnt. It mks loclly optml choc n th hop tht ths choc wll ld to globlly optml soluton. Grdy lgorthms do not lwys ylds optml solutons. Kruskl s lgorthm Kruskl s lgorthm s grdy lgorthm, bcus t ch stp t dds to th forst n dgs of lst possbl wght. 0 Kruskl (G, w) A = Strt wth forst whr thr r V trs Sort th dgs of E by non-dcrsng wght w. for ch dg (u, v) E, n ordr by ncrsng wght f u nd v r not blongs to sm tr A = A (u, v) Mk two tr to connct wth dg (u, v). 0 0 0 3

/3/0 0 0 0 0 0 0 0 0

/3/0 0 0 0 0 3 0 0

/3/0 0 0 0 0 0 0 0

/3/0 0 0 3 0 0 0 0 3