Graphs - PowerPoint PPT Presentation

About This Presentation
Title:

Graphs

Description:

Graphs Types of Records One link For stack and queue. Two links For double ended queue. Many links: Searching in a Graph A Generic algorithm: Let G=(V,E) be ... – PowerPoint PPT presentation

Number of Views:91
Avg rating:3.0/5.0
Slides: 28
Provided by: amir84
Category:
Tags: graphs | types

less

Transcript and Presenter's Notes

Title: Graphs


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

3
(No Transcript)
4
Order is important
5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
(No Transcript)
13
(No Transcript)
14
(No Transcript)
15
Searching in a Graph
  • A Generic algorithm
  • Let G(V,E) be the graph.
  • Let D be a data structure (well later see which
    one).

For unmarked vertex v VISIT(v) end
16
VISIT(v)
  • D INSERT(v)
  • While D?Ø do
  • x REMOVE(D)
  • visit and mark x
  • for all unmarked w adjacent to x do
  • D INSERT(w)
  • end
  • end

17
Depth-First Search
  • D is LIFO
  • D PUSH(v)
  • While D?Ø do
  • x POP(D)
  • visit and mark x
  • for all unmarked w adjacent to x do
  • D PUSH(w)
  • end
  • end

A
B
C
E
F
D
18
Breadth-First Search
  • D is FIFO
  • D ENQUEUE(v)
  • While D?Ø do
  • x DEQUEUE(D)
  • visit and mark x
  • for all unmarked w adjacent to x do
  • D ENQUEUE(w)
  • end
  • end

A
B
C
E
F
D
19
(No Transcript)
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
24
???? ????????
  • ????? ?? ??????????? ??? ???? ?????? ???
  • ???? ???? ??????? ???? ???? ??? ??????
  • ?? ???????? ????? ???? ???? ???? ????? ?????.

????? 1
??????? 1
????? 2
??????? 2
???? ??????
???? ??????
25
Algorithm
Topological-Sort() Call DFS to
compute finish time for each vertex Insert vertex
finished into the beginning of linked list Return
the linked list of vertices ???? ???
?????? ????? ???? O(VE).
26
Example
27
Example
Write a Comment
User Comments (0)
About PowerShow.com