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
Похожие презентации
BREADTH FIRST TRAVERSAL Lesson Plan -3. Evocation.
Advertisements

Minimum spanning trees. Minimum Connector Algorithms Kruskals algorithm 1.Select the shortest edge in a network 2.Select the next shortest edge which.
Sequences Sequences are patterns. Each pattern or number in a sequence is called a term. The number at the start is called the first term. The term-to-term.
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.
UNIT-III SORTING Lesson Plan-1 Insertion Sort, Selection Sort.
Sec. 3.4: Find and Use Slopes of Lines. Example Find the slope of each line in the graph. If undefined, write undefined.
© 2006 Cisco Systems, Inc. All rights reserved. BSCI v Module Summary BGP is a path-vector routing protocol that allows routing policy decisions.
Searching Lesson Plan - 6. Contents Evocation Objective Introduction Sequential Search Algorithm Variations on sequential search Mind map Summary.
S4-1 PAT328, Section 4, September 2004 Copyright 2004 MSC.Software Corporation SECTION 4 FIELD IMPORT AND EXPORT.
Copyright 2003 CCNA 3 Chapter 4 EIGRP By Your Name.
© 2006 Cisco Systems, Inc. All rights reserved. CVOICE v Configuring Voice Networks Configuring Dial Peers.
While its always a good idea to think outside the box when approaching a creative task, this is not always the case. For example, when working with teams,
© 2007 Cisco Systems, Inc. All rights reserved.DESGN v Designing IP Addressing and Selecting Routing Protocols Designing a Routing Protocol Deployment.
Date: File:GRAPH_02e.1 SIMATIC S7 Siemens AG All rights reserved. SITRAIN Training for Automation and Drives Project Planning and Configuration.
11 BASIC DRESS-UP FEATURES. LESSON II : DRESS UP FEATURES 12.
© 2006 Cisco Systems, Inc. All rights reserved. BSCI v Configuring EIGRP Using EIGRP in an Enterprise Network.
«When you look at your life, the greatest happinesses are family happinesses»
Parachuting, also known as skydiving, is the activity of jumping from enough height to deploy a fabric parachute and land. Parachuting is performed as.
© 2005 Cisco Systems, Inc. All rights reserved. BGP v BGP Overview Understanding BGP Path Attributes.
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.
Транксрипт:

DEPTH FIRST TRAVERSAL Lesson Plan -2

Evocation

Traverse Graph All vertices in graph must to traverse A vertex in graph have multiple parents, traversal of graph have some problems not found in traversal of list and trees Two standard graph traversal Depth first traversal Breadth first traversal

Evocation

Depth First Traversal In depth first traversal, process all of vertex descendent before moving to adjacent vertex Process the first vertex of graph After processing first vertex, select any vertex adjacent to first vertex and process it As processing each vertex, select an adjacent vertex until reach a vertex with no adjacent entries

Depth First Traversal of a Tree A BCD EFGHI Depth First Traversal: A B E F C D G H I

Depth First Traversal of Graph

Push the first vertex A into stack Loop, pop the stack and after process the vertex, push all of adjacent vertices into stack To process X at step2, pop X from stack, process it and push G and H into stack, give the stack contents form step 3 When stack is empty, traversal is complete

DFS Example

Depth first Traversal Algorithm Algorithm depth First (graph) if (empty graph) return set walkptr to graph first loop (through all vertices) set processed to 0 end loop create stack (stack) loop (through vertex list) if (vertex not processed and not in stack) push stack( stack, walkptr ) set walkptr processed to 1 end if loop ( not empty stack(stack)) set vertex to pop stack(stack) process (vertex) set vertex to processed

Depth first Traversal Algorithm loop(through arc list) if(arc destination not in stack) push stack( stack, destination ) set destination to in stack end if get next destination end loop end if get next vertex end loop destroy stack (stack) end depth first

Mind Map Traverse Graph Depth First Traversal Breadth First Traversal DFS Example DFS Algorithm

Summary Graph must traverse all vertices Two standard graph traversal depth first and breadth first In depth first traversal, process all of vertex descendent before moving to adjacent vertex