BREADTH FIRST TRAVERSAL Lesson Plan -3. Evocation.

Презентация:



Advertisements
Похожие презентации
DEPTH FIRST TRAVERSAL Lesson Plan -2. Evocation Traverse Graph All vertices in graph must to traverse A vertex in graph have multiple parents, traversal.
Advertisements

Convolutional Codes Mohammad Hanaysheh Mahdi Barhoush.
Minimum spanning trees. Minimum Connector Algorithms Kruskals algorithm 1.Select the shortest edge in a network 2.Select the next shortest edge which.
© 2005 Cisco Systems, Inc. All rights reserved. BGP v Customer-to-Provider Connectivity with BGP Connecting a Multihomed Customer to Multiple Service.
Searching Lesson Plan - 6. Contents Evocation Objective Introduction Sequential Search Algorithm Variations on sequential search Mind map Summary.
11 BASIC DRESS-UP FEATURES. LESSON II : DRESS UP FEATURES 12.
Multiples Michael Marchenko. Definition In mathematics, a multiple is the product of any quantity and an integer. in other words, for the quantities a.
1/27 Chapter 9: Template Functions And Template Classes.
WS9-1 WORKSHOP 9 ANCHOR GEOMETRY CREATION PAT301, Workshop 9, October 2003.
HPC Pipelining Parallelism is achieved by starting to execute one instruction before the previous one is finished. The simplest kind overlaps the execution.
Loader Design Options Linkage Editors Dynamic Linking Bootstrap Loaders.
CONSTRAINTS 52. You do your CONSTRAINING in Sketcher mode to create your part to exacting dimensions. This is the opposite of free-form creating we have.
Java Collections Framework (JCF) in Java Tutorial for students of universities Author: Oxana Dudnik.
Knot theory. In topology, knot theory is the study of mathematical knots. While inspired by knots which appear in daily life in shoelaces and rope, a.
REFERENCE ELEMENTS 64. If your REFERENCE ELEMENTS toolbar is not in view and not hidden, you can retrieve it from the toolbars menu seen here. 65.
In mathematics, the notion of permutation is used with several slightly different meanings, all related to the act of permuting (rearranging) objects.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Connecting Networks Exploring How Routing Works.
SPLAY TREE The basic idea of the splay tree is that every time a node is accessed, it is pushed to the root by a series of tree rotations. This series.
© 2006 Cisco Systems, Inc. All rights reserved. MPLS v Label Assignment and Distribution Introducing MPLS Label Allocation, Distribution, and Retention.
Ideal Family Were prepared by Iryna Molokova and Ilona Synytsia.
Транксрипт:

BREADTH FIRST TRAVERSAL Lesson Plan -3

Evocation

Breadth First Traversal

Process all adjacent vertices of a vertex before going to next level Pick a vertex A then process all of adjacent vertices (BCD) Process all of first vertex, pick its first adjacent vertex (B) and process all of vertices, then second adjacent vertex C and all of vertices

BFS Example

Breadth First Traversal Algorithm Algorithm breadth First (graph) if (empty graph) return end if create Queue (queue) loop (through all vertices) set vertex to not processed end loop loop (through all vertices) if (vertex not processed) if (vertex not in queue) enqueue (queue, walkptr) set vertex t enqueued end if

Breadth First Traversal Algorithm loop (not emptyQueue (queue)) set vertex to dequeue (queue) process (vertex) set vertex to processed loop (through adjacency list) if (destination not enqueued or processed) enqueue (queue, destination) set destination to enqueued end if get next destination end loop end if get next vertex end loop destroy Queue (queue) end breadth First

Graph Storage Structures To represent graph, need to store two set First set represent vertices of graph Second set represents edges or arcs Adjacency Matrix Use vector (one dimensional array) for vertices and a matrix (two dimensional array) to store edges If two vertices are adjacent If there is an edge between them the matrix intersect has value of 1 If there is no edge between them the matrix intersect has value of 0

Graph Representation

Adjacency matrix for non directed graph

Adjacency matrix for directed graph

Adjacency List Adjacency list uses two dimensional ragged array to store edges

Adjacency list for non directed graph

Adjacency list for directed graph

Adjacency Multilist Lists in which nodes may be shared among several lists (an edge is shared by two different paths) There is exactly one node for each edge Example

Mind Map Breadth First Traversal BFS Example BFS Algorithm Graph Storage Structures Adjacency Matrix Adjacency List Adjacency MultiList Directed Non-directed

Summary In breadth first search all adjacent vertices are processed before processing descendants of vertex To represent graph, we need to store two sets of information first represent vertices, second set represent edges Methods used to store graph are adjacency matrix, adjacency list, adjacency multilist In adjacency matrix, use a vector to store vertices and matrix to store edges In adjacency list, use linked list to store vertices and two dimensional linked list to store edges In adjacency multilist, nodes are shared among several list