Foundations of Discrete Mathematics

Similar documents
Foundations of Discrete Mathematics

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees

March 20/2003 Jayakanth Srinivasan,

Trees Algorhyme by Radia Perlman

Hamilton paths & circuits. Gray codes. Hamilton Circuits. Planar Graphs. Hamilton circuits. 10 Nov 2015

An undirected graph is a tree if and only of there is a unique simple path between any 2 of its vertices.

Graph and Digraph Glossary

Chapter Summary. Introduction to Trees Applications of Trees Tree Traversal Spanning Trees Minimum Spanning Trees

CS 441 Discrete Mathematics for CS Lecture 26. Graphs. CS 441 Discrete mathematics for CS. Final exam

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207.

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

Crossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia)

Konigsberg Bridge Problem

Graph Theory CS/Math231 Discrete Mathematics Spring2015

Chapter 9 Graph Algorithms


Chapter 9 Graph Algorithms

Chapter 10: Trees. A tree is a connected simple undirected graph with no simple circuits.

Introduction to Computers and Programming. Concept Question

Elements of Graph Theory

CS204 Discrete Mathematics. 11 Trees. 11 Trees

CSC Intro to Intelligent Robotics, Spring Graphs

Graph Theory. Probabilistic Graphical Models. L. Enrique Sucar, INAOE. Definitions. Types of Graphs. Trajectories and Circuits.

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Chapter 9 Graph Algorithms

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Chapter 11: Graphs and Trees. March 23, 2008

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Graph Algorithms Using Depth First Search

v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS

Directed Graph and Binary Trees

CSE 21 Mathematics for Algorithm and System Analysis

An Introduction to Graph Theory

Undirected Graphs. Hwansoo Han

BACKGROUND: A BRIEF INTRODUCTION TO GRAPH THEORY

12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees

Discrete mathematics

Lecture 5: Graphs & their Representation

Trees. Arash Rafiey. 20 October, 2015

Reference Sheet for CO142.2 Discrete Mathematics II

Discrete mathematics II. - Graphs

Chapter 2 Graphs. 2.1 Definition of Graphs

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

EECS 1028 M: Discrete Mathematics for Engineers

Info 2950, Lecture 16

1 Digraphs. Definition 1

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Logic: The Big Picture. Axiomatizing Arithmetic. Tautologies and Valid Arguments. Graphs and Trees

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

Graphs Definitions. Gunnar Gotshalks. GraphDefinitions 1

Graphs V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs

Chapter 3 Trees. Theorem A graph T is a tree if, and only if, every two distinct vertices of T are joined by a unique path.

Module 2: NETWORKS AND DECISION MATHEMATICS

Figure 4.1: The evolution of a rooted tree.

Definition of Graphs and Trees. Representation of Trees.

Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

ROOT A node which doesn t have a parent. In the above tree. The Root is A. LEAF A node which doesn t have children is called leaf or Terminal node.

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

GRAPHICAL ALGORITHMS. UNIT _II Lecture-12 Slides No. 3-7 Lecture Slides No Lecture Slides No

UNDIRECTED GRAPH: a set of vertices and a set of undirected edges each of which is associated with a set of one or two of these vertices.

Graph Theory. Part of Texas Counties.

License. Discrete Mathematics. Tree. Topics. Definition tree: connected graph with no cycle. examples. c T. Uyar, A. Yayımlı, E.

7.3 Spanning trees Spanning trees [ ] 61

Graphs: basic concepts and algorithms

Chapter 9. Priority Queue

Trees. Truong Tuan Anh CSE-HCMUT

Chapter 4 Trees. Theorem A graph G has a spanning tree if and only if G is connected.

THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS

Trees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington

4. (a) Draw the Petersen graph. (b) Use Kuratowski s teorem to prove that the Petersen graph is non-planar.

Week 11: Eulerian and Hamiltonian graphs; Trees. 15 and 17 November, 2017

DS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV

Graphs and Genetics. Outline. Computational Biology IST. Ana Teresa Freitas 2015/2016. Slides source: AED (MEEC/IST); Jones and Pevzner (book)

Trees. CSC 1300 Discrete Structures Villanova University

Definition Example Solution

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010

ROOT: A node which doesn't have a parent. In the above tree. The Root is A.

Lecture 22 Tuesday, April 10

Graph Theory and Applications

Binary Trees

EE 368. Weeks 5 (Notes)

Major Themes. Trees. Types of Graphs. Which of the following are trees? G 3 G 1 G 2 G 4. Dr Papalaskari 1

Computer Science 280 Fall 2002 Homework 10 Solutions

Graphs - I CS 2110, Spring 2016

LECTURE 26 PRIM S ALGORITHM

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/

Minimum spanning trees

UNIT III TREES. A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items.

CS 151. Binary Trees. Friday, October 5, 12

DOMINATION IN SOME CLASSES OF DITREES

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

r=1 The Binomial Theorem. 4 MA095/98G Revision

DEFINITION OF GRAPH GRAPH THEORY GRAPHS ACCORDING TO THEIR VERTICES AND EDGES EXAMPLE GRAPHS ACCORDING TO THEIR VERTICES AND EDGES

Trees and Intro to Counting

Binary Trees, Binary Search Trees

Transcription:

Foundations of Discrete Mathematics Chapter 12 By Dr. Dalia M. Gil, Ph.D.

Trees Tree are useful in computer science, where they are employed in a wide range of algorithms. They are used to construct efficient algorithms for locating items in a list.

Trees Trees can be used to construct efficient code saving cost in data transmission and storage. Trees can be used to study games such as checkers and chess an can help determine winning strategies for playing these games.

Trees Trees can be used to model procedures carried out using a sequence of decisions. Constructing these models can help determine the computational complexity of algorithms based on a sequence of decisions, such a sorting algorithms.

Trees Procedures for building trees including Depth-first search, Breadth-first search, can be used to systematically explore the vertices of a graph.

Trees A tree is a connected undirected graph with no simple circuits. A tree cannot have a simple circuit, so a tree cannot contain multiple edges or loops. Any tree must be a simple graph.

An Example of a Tree The Bernoulli Family of Mathematicians Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 632

Example: Trees G 1 and G 2 are trees. Both are connected graph with no simple circuits. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 632

Example: Not Trees G 3 is not a tree. e, b, a, d, e is a simple circuit. G 4 is not a tree. It is not connected. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 632

Forest A Forest is a graph containing no simple circuits that are not necessarily connected. Forests have the property that each of their connected components is a tree.

Example: Forest A one graph with three connected components Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 633

Theorem An undirected graph is a tree if and only if there is a unique simple path between any two vertices.

A Rooted Tree A rooted tree is a tree in which one vertex has been designated as the root and every edge is directed away from the root. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 634

Rooted Trees We can change an unrooted tree into a rooted tree by choosing any vertex as the root. Different choices of the root produce different trees. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 578

Example: Rooted Trees The rooted trees formed by designating a to be the root and c to be the root, respectively, in the tree T. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 634

The Terminology for Trees Suppose that T is a rooted tree. If v is a vertex in T other than the root. The parent of v is the unique vertex u such that there is a directed edge from u to v.

The Terminology for Trees When u is the parent of v, v is called a child of u. Vertices with the same parent are called siblings.

The Terminology for Trees The ancestors of a vertex other than the root are the vertices in the path from the root to this vertex, excluding the vertex itself and including the root. The descendants of a vertex v are those that have v as an ancestor.

The Terminology for Trees A vertex of a tree is called a leaf if it has no children. Vertices that have children are called internal vertices. The root is an internal vertex unless it is the only vertex in the graph, in which case it is a leaf.

The Terminology for Trees If a is a vertex in a tree, the subtree with a as its root is the subgraph of the tree consisting of a and its descendants and all edges incident to these descendant. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 582

Example: Using Terminology T is a rooted tree with root a. The parent of vertex c is b. The children of g are h, i, and j. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

Example: Using Terminology The siblings of h are i and j. The ancestors of e are c, b, and a. The descendant of b are c, d, and e. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

Example: Using Terminology The internal vertices are a, b, c, g, h, and j. The leaves are d, e, f, i, k, l, and m. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

Example: Using Terminology The subtree rooted at g is Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

m-ary Tree A rooted tree is called m-ary tree if every internal vertex has no more than m children. The tree is called a full m-ary tree if every internal vertex has exactly m children. An m-ary tree with m=2 is called a binary tree.

Example of m-ary tree T 1 is a full binary tree. Each of its internal vertices has two children Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

Example of m-ary tree T 2 is a full 3-ary tree. Each of its internal vertices has three children Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

Example of m-ary tree T 3 is a full 5-ary tree. Each of its internal vertices has five children Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

Example of m-ary tree T 4 is not a full m-ary tree for any m. Some of its internal vertices has 2 children and others have 3. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 635

Ordered Rooted Tree An ordered rooted tree is rooted tree where the children of each internal vertex are ordered. Ordered rooted trees are drawn so that the children of each internal vertex are shown in order from left to right.

Ordered Binary Tree In ordered binary tree (a binary tree), if an internal vertex has two children. The first child is called the left child and the second child is called the right child.

Ordered Binary Tree The tree rooted at the left child of a vertex is called the left subtree of this vertex, and the tree rooted at the right child of a vertex is called the right subtree of the vertex.

Example The left child of d is f and the right child is g. The left and right subtrees of c are Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 636

Properties of Trees A tree with n vertices has n 1 edges. A full m-ary tree with i internal vertices contains n = m*i + 1 vertices. There are at most m h leaves in an m-ary tree of hight h. Where n: vertices, l: leaves, i: internal vertices.

Properties of Trees A full m-ary tree with 1. n vertices has i=(n 1)/m internal vertices and l = [(m 1) n + 1]/m leaves. 2. i internal vertices has n = m*i + 1 vertices and l = (m 1)i + 1 leaves. 3. l leaves has n = (m*l 1)/(m 1) vertices and i = (l 1)/(m 1) internal vertices.

Properties of Trees A rooted m-ary tree of height is balanced if all leaves are at levels h or h 1. T 1 is balanced. All its leaves are at levels 3 and 4. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 640

Properties of Trees T 2 is not balanced. It has leaves at levels 2, 3, and 4. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 640

Properties of Trees T 3 is balanced. All its leaves are at level 3. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 640

Example: Properties of Trees The root a is at level 0. Vertices b, j, and k are at level 1. Vertices c, e, f, and l are at level 2. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 640

Example: Properties of Trees Vertices g, g, i, m, and n are at level 3. Vertex h is at level 4. This tree has height 4. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 640

Spanning Trees A spanning tree of a connected graph G is a subgraph that is a tree and that includes every vertex of G. A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible sum of weights of its edges.

Prim s Algorithm Prim s algorithm constructs a minimum spanning tree. Successively add to the tree edges of minimum weight that are incident to a vertex already in the tree and not forming a simple circuit with those edges already in the tree. Stop when n 1 edges have been adding.

Prim s Algorithm Step 1: Choose any vertex v and let e1 be and edge of least weight incident with v. Set k = 1. Step 2: While k < n If there exists a vertex that is not in the subgraph T whose edges are e 1, e 2,, e k, Let ek+1 be an edge of least weight among all edges of the form ux, where u is a vertex of T and x is a vertex not in T;

Prim s Algorithm (cont.) Let ek+1 be an edge of least weight among all edges of the form ux, where u is a vertex of T and x is a vertex not in T; Replace k by k + 1; else output e 1, e2,, e k and stop. end while.

Example Using Prim s Algorithm Use Prim s algorithm to design a minimum-cost communication network connecting all the computers represented by the following graph Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 689

Example Using Prim s Algorithm Choosing and initial edge of minimum weight. Successively adding edges of minimum weight that are incident to a vertex in a tree and do not form a simple circuit.

Example Using Prim s Algorithm Choice Edge Cost 1 {Chicago, Atlanta} $700 2 {Atlanta, New York} $800 3 {Chicago, San Francisco} $1200 4 San Francisco, Denver} $900 Total: $3600 Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 691

Example Using Prim s Algorithm Choice Edge Cost 1 {Chicago, Atlanta} $700 2 {Atlanta, New York} $800 3 {Chicago, San Francisco} $1200 4 San Francisco, Denver} $900 Total: $3600 Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 691

Example Using Prim s Algorithm Use Prim s algorithm to find a minimum spanning tree in the following graph. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 691

Example Using Prim s Algorithm Use Prim s algorithm to find a minimum spanning tree in the following graph. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 691

Example Using Prim s Algorithm Use Prim s algorithm to find a minimum spanning tree in the following graph. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 691

Kruskal s Algorithm This algorithm finds a minimum spanning tree in a connected weighted graph with n > 1 vertices.

Kruskal s Algorithm Step 1: Find an edge of least weight and call this e 1. Set k = 1. Step 2: While k < n if there exits an edge e such that {e} {e 1,. e 2,, e k } does not contain a circuit * let e k+1 be such an edge of least weight; replace k by k + 1; else output e 1, e 2,, e k and stop end while

Example Using Kruskal Algorithm Use Kruskal s algorithm to find a minimum spanning tree in the following weighted graph. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 691

Example Using Kruskal Algorithm Use Kruskal s algorithm to find a minimum spanning tree in the following weighted graph. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 692

Digraphs A digraph is a pair (V, E) of sets, V nonempty and each element of E an ordered pair of distinct elements of V. The elements of V are called vertices and the elements of E are called arcs.

Digraphs The same terms can be used for graphs and digraphs. The exception: In a digraph we use term arc instead of edge. An arc is an ordered pair (u, v) or (v, u). An edge is an unordered pair of vertices {u, v}.

Digraphs The vertices of a graph have degrees, a vertex of a digraph has an indegree and outdigree. Indegree is the number of arcs directed into a vertex. Outdegree is the number of arcs directed away from the vertex.

Examples: Digraphs G 1 has outdegree 1. G 2 has outdegree 2. G 1 and G 2 are not isomorphic because of the previous reasons. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 344

Examples: Digraphs G 1 is Eulerian because uvwu is an Eulerian circuit and a Hamiltonian cycle. G 2 has neither an Eulerian nor a Hamiltonian cycle, but it has a Hamiltonian path uvw. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 344

Examples: Digraphs G 3 has vertices u and x with indegree 2 and outdegree 1. Vertex v has indegree 0 and outdegree 2 and vertex w has indegree 1 and outdegree 1. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 344

Examples: Digraphs The indegree sequence is 2, 2, 1, 0, and the outdegree sequence is 2, 1, 1, 1. The sum of the indegrees of the vertices equals the sum of the outdegrees of the vertices is the number of arcs. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 344

Examples: Digraphs G 3 is not Hamiltonian because vertex v has indegree 0. There is no way of reaching v on a walk respecting orientation edges, no Hamiltonian cycle can exist. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 344

Examples: Digraphs G 4 is not Hamiltonian because vertex x has outdegree 0, so no walk respecting orientations can leave x. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 344

Digraphs A digraph is called strongly connected if and only if there is a walk from any vertex to any other vertex that respects the orientation of each arc. A digraph is Eulerian if and only if it is strongly connected and, for every vertex, the indegree equals the outdegree.

Examples: Digraphs G 3 is not Eulerian. It is not strongly connected (there is no way to reach v). The indegrees and outdegrees of three vertices (u, v, and x) are not the same. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 346

Examples: Digraphs This digraph is Eulerian. It is strongly connected (there is a circuit uvwu that permits travel in the direction of arrows between two vertices The indegree and outdegree of every vertex are 2.(an Euler circuit uwvuvwu). Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 346

Acyclic Digraphs A directed graph is a acyclic if it contains no directed cycles. This digraph is acyclic. There are no cycles. There is never an arc on which to return to the first vertex. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 393

Acyclic Digraphs A directed graph is a acyclic if it contains no directed cycles. This digraph is not acyclic. There are cycles. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 393

A Canonical Ordering A labeling v 0, v 1,, v n-1 of the vertices of a digraph is called canonical if the only arcs have the form v i v j with i < j. A canonical labeling of vertices is also called a canonical ordering. A digraph has a canonical ordering of vertices if and only if it is acyclic.

A Canonical Ordering A digraph has a canonical ordering of vertices if and only if it is acyclic. A digraph is acyclic if and only if it has a canonical labeling of vertices Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 393

Strongly connected Orientation To orient or to assign an orientation to an edge in a graph is to assign a direction to that edge. To orient or assign an orientation to a graph is to orient every edge in the graph. A graph has a strongly connected orientation if it is possible to orient it in such a way that the resulting digraph is strongly connected.

Depth-First Search Depth-first search is a simple and efficient procedure used as the for a number of important computer algorithms in graphs. We can build a spanning trees for a connected simple graph using a depthfirst search.

Depth-First Search Algorithm Let G be a graph with n vertices. Step 1. Choose any vertex and label it 1. Set k = 1. Step 2. While there are unlabeled vertices if there exists an unlabeld vertex adjacent to k, assign to it the smallest unused label l from the set {1, 2,, n} and set k = l else if k = 1 stop; else backtrack to the vertex l from which k was labeled and set k = l. Step 3. end while.

Example: Depth-First Search Use a depth-first search to find a spanning tree for the graph G. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 678

Example: Depth-First Search Arbitrary start with vertex f. A path is built by successively adding edges incident with vertices not already in the path, as long as possible Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 678

Example: Depth-First Search From f create a path f, g, h, j (other path could have been built). Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 678

Example: Depth-First Search Next, backtrack to k. There is no path beginning at k containing vertices not already visited. So, backtrack to h. Form the path h, i. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 678

Example: Depth-First Search Then, backtrack to h, and then to f. From f build the path f, d, e, c, a. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 678

Example: Depth-First Search Then, backtrack to c, and form the path c, b. The result is the spanning graph. Discrete Mathematics and its Applications. Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 678

Example: Depth-First Search Use a depth-first search to find a spanning tree for the graph G. Discrete Mathematics with Graph Theory. Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 401

Topics covered Trees and their properties. Spanning trees and minimum spanning trees algorithms. Depth-First Search.

Reference Discrete Mathematics with Graph Theory, Third Edition, E. Goodaire and Michael Parmenter, Pearson Prentice Hall, 2006. pp 370-410.

Reference Discrete Mathematics and Its Applications, Fifth Edition, Kenneth H. Rosen, McGraw- Hill, 2003. pp 631-694.