+ All Categories
Home > Documents > Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many...

Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many...

Date post: 18-Jan-2018
Category:
Upload: sibyl-powell
View: 216 times
Download: 0 times
Share this document with a friend
27
Graphs
Transcript
Page 1: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Graphs

Page 2: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Types of RecordsOne link – For stack and queue.

Two links – For double ended queue.

Many links:

Page 3: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 4: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Order is important

Page 5: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 6: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 7: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 8: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 9: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 10: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 11: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 12: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 13: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 14: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 15: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Searching in a GraphA Generic algorithm:Let G=(V,E) be the graph.Let D be a data structure (we’ll later

see which one).

For unmarked vertex v:VISIT(v)

end

Page 16: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

VISIT(v)D INSERT(v)While D≠Ø do

x REMOVE(D)visit and mark xfor all unmarked w adjacent to x do

D INSERT(w)end

end

Page 17: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Depth-First SearchD is LIFO:D PUSH(v)While D≠Ø do

x POP(D)visit and mark xfor all unmarked w adjacent to x do

D PUSH(w)end

end

A

B C

D E F

Page 18: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Breadth-First SearchD is FIFO:D ENQUEUE(v)While D≠Ø do

x DEQUEUE(D)visit and mark xfor all unmarked w adjacent to x do

D ENQUEUE(w)end

end

A

B C

D E F

Page 19: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 20: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 21: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 22: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 23: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:
Page 24: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

מיון טופולוגיכידוע יש באוניברסיטה לכל •

קדםקורס דרישות

נניח שאני מעוניין לקחת • לסמסטר אחדקורס

שיגיד איזה אלגוריתםתן •קורס לקחת באיזה סמסטר.

אינפי 1

אינפי 2

לינארית 2

לינארית 1

מבני נתונים

מבוא לחישוב

אינפי 1

לינארית 1

לינארית 2

מבוא לחישוב

מבני נתונים

אינפי 2

Page 25: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Topological-Sort )( {

Call DFS to compute finish time for each vertexInsert vertex finished into the beginning of linked listReturn the linked list of vertices

{

.)O)V+Eהזמן זהה לחיפוש לעומק והוא

Algorithm

Page 26: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

Example

Undershorts

Watch

Socks

Jacket

Tie

Shirt

Belt

ShoesPants

Page 27: Graphs. Types of Records One link  For stack and queue. Two links  For double ended queue. Many links:

ExampleUndershorts

WatchSocks

Jacket

Tie

ShirtBelt

ShoesPants

Socks JacketUndershorts Pants Shoes watch Shirt Belt Tie


Recommended