Download presentation

Presentation is loading. Please wait.

Published byGabriella Knight Modified over 2 years ago

1
Breadth first search

2
Structures for BFS Implementation (Δ, D) – graph

3
BFS by practice

4
target Breadth first search We start from a source node. We want to see if we can reach a target node. We proceed by waves. source

5
target Breadth first search We start from a source node. We want to see if we can reach a target node. We proceed by waves. source 3 waves total.

6
target Breadth first search source a Queue, in which we add neighbours and from which we select the next one to visit a Dictionary: to each node that we visited we bind as value its predecessor. 2 data structures pred: Robin pred: Pranil pred: Pranil pred: Pranil pred: Shivam pred: Danish pred: Awin

7
Implementation

8
(Δ, D) – graph

9
Distance Breadth first search The number of hops it takes to go from A to B is called the distance from A to B and denoted d(A,B). 1 hop 2 hops 3 hops d(Pranil,Som) = 3

10
Distance Breadth first search The number of hops it takes to go from A to B is called the distance from A to B and denoted d(A,B). 2 d(Danish,Aram) = 2 1 We use the shortest path.

11
Diameter Breadth first search The diameter of a graph is the maximum distance between two vertices, and is denoted D. D = 5

12
(Δ, D) – graph Breadth first search Let Δ be the maximum degree in a graph, i.e. the largest number of neighbours that any node can have. Let D be the diameter. For a given Δ and D, design the graph having as many nodes as possible. Example: we want to create a good network of workstations. Each workstation can be connected to at most 3, and the diameter must be 1. The best (3, 1) – graph has 4 nodes.

13
(Δ, D) – graph Breadth first search Let Δ be the maximum degree in a graph, i.e. the largest number of neighbours that any node can have. Let D be the diameter. For a given Δ and D, design the graph having as many nodes as possible. The best (3, 1) – graph has 4 nodes. Practice: draw the best (3, 2) – graph possible.

14
(Δ, D) – graph Breadth first search Practice: draw the best (3, 2) – graph possible. 5 67 810

15
Breadth first search

16
Pavol Hell, SFU Jean-Claude Bermond, Université de Nice The network teams from Nice and SFU are associated.

Similar presentations

OK

1 Graphs Traversals In many graph problems, we need to traverse the vertices of the graph in some order Analogy: Binary tree traversals –Pre-order Traversal.

1 Graphs Traversals In many graph problems, we need to traverse the vertices of the graph in some order Analogy: Binary tree traversals –Pre-order Traversal.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google