Prim’s Algorithm A Proof. Suppose we have a tree T that is the minimal spanning tree for a graph. Let P be the spanning tree from Prim’s alg. and Then.

Slides:



Advertisements
Similar presentations
CSE115/ENGR160 Discrete Mathematics 04/26/12 Ming-Hsuan Yang UC Merced 1.
Advertisements

Greedy Algorithms Greed is good. (Some of the time)
10.4 Spanning Trees. Def Def: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every vertex of G See handout.
Minimum Spanning Tree CSE 331 Section 2 James Daly.
Lecture 17 Path Algebra Matrix multiplication of adjacency matrices of directed graphs give important information about the graphs. Manipulating these.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
1 Section 9.4 Spanning Trees. 2 Let G be a simple graph. A spanning subtree of G is a subgraph of G containing every vertex of G –must be connected; contains.
Graph Search Methods A vertex u is reachable from vertex v iff there is a path from v to u
Graph Search Methods A vertex u is reachable from vertex v iff there is a path from v to u
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Graph Algorithms Mathematical Structures for Computer Science Chapter 6 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraph Algorithms.
Data Structure and Algorithms (BCS 1223) GRAPH. Introduction of Graph A graph G consists of two things: 1.A set V of elements called nodes(or points or.
Discrete Structures Lecture 13: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
ITEC200 – Week 12 Graphs. 2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study.
Discussion #36 Spanning Trees
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Chapter 5 Trees PROPERTIES OF TREES 3 4.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Minimal Spanning Trees. Spanning Tree Assume you have an undirected graph G = (V,E) Spanning tree of graph G is tree T = (V,E T E, R) –Tree has same set.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
CISC220 Fall 2009 James Atlas Nov 13: Graphs, Line Intersections.
Tirgul 13 Today we’ll solve two questions from last year’s exams.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Applied Discrete Mathematics Week 13: Boolean Algebra
Chapter 2 Graph Algorithms.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
Foundations of Discrete Mathematics
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Introduction to Graph Theory
Chap 8 Trees Def 1: A tree is a connected,undirected, graph with no simple circuits. Ex1. Theorem1: An undirected graph is a tree if and only if there.
15-853Page :Algorithms in the Real World Planar Separators I & II – Definitions – Separators of Trees – Planar Separator Theorem.
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesBoolean Algebra.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Trees Thm 2.1. (Cayley 1889) There are nn-2 different labeled trees
Hello Everyone!!! 1. Tree And Graphs 2 Features of Trees  Tree Nodes Each node have 0 or more children A node have must one parent  Binary tree Tree.
Prims Algorithm for finding a minimum spanning tree
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
1 3/21/2016 MATH 224 – Discrete Mathematics First we determine if a graph is connected.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
English for Economic Informatics I Tomáš Foltýnek Theoretical Foundations of Informatics.
Discrete Structures Li Tak Sing( 李德成 ) Lectures
Trees.
Graph Search Applications, Minimum Spanning Tree
Chapter 5 : Trees.
Minimum Spanning Tree Chapter 13.6.
12. Graphs and Trees 2 Summary
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Short paths and spanning trees
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Spanning Trees.
Minimum Spanning Tree.
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
Graphs Chapter 11 Objectives Upon completion you will be able to:
Chapter 23 Minimum Spanning Tree
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Weighted Graphs & Shortest Paths
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

Prim’s Algorithm A Proof

Suppose we have a tree T that is the minimal spanning tree for a graph. Let P be the spanning tree from Prim’s alg. and Then there is an arc, a, in P that is not in T. If arc a connects node x to node y, then there is a path within the tree of T that also connects x to y: x y P T

Case 1: The weight of P is smaller than one of the edges on the path from the tree T Then we remove the edge with highest weight from T and replace it with the edge from P. This gives a smaller spanning tree than T – and contradicts the fact that T is the minimal spanning tree. x y P T

Case 2: The weight of P is greater than the weight of all the edges in the path from T. Then consider the step – in Prim’s algorithm- when we add edge P. P is the shortest edge remaining which can be added to the graph. But we would add xs before P (or st or tu or uy – whichever is still available to add. So we never add P – a contradiction! x P T y s t u

Depth-first search Algorithm DF(G,n) –Start with a given node, n. For all arcs a connected to n Do –DF(G\{n}, a) End - Do

Depth-first example A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K Continue: ABEDCHIJK (BACKTRACK to D) GF

Depth-first example-from K A B C D E F G H I J K

Breadth-First Algorithm BF(G,n) –Start with a given node, n. For all arcs a connected to n Do –Add nodes at end of each vertex. For all arcs a connected to n Do - BF(G\{arcs}, a)

Breadth-first example A B C D E F G H I J K

Add arcs connected to a A B C D E F G H I J K ABCDE

Add arcs connected to b A B C D E F G H I J K ABCDEF

Prim’s Algorithm A Proof

Suppose we have a tree T that is the minimal spanning tree for a graph. Let P be the spanning tree from Prim’s alg. and Then there is an arc, a, in P that is not in T. If arc a connects node x to node y, then there is a path within the tree of T that also connects x to y: x y P T

Case 1: The weight of P is smaller than one of the edges on the path from the tree T Then we remove the edge with highest weight from T and replace it with the edge from P. This gives a smaller spanning tree than T – and contradicts the fact that T is the minimal spanning tree. x y P T

Case 2: The weight of P is greater than the weight of all the edges in the path from T. Then consider the step – in Prim’s algorithm- when we add edge P. P is the shortest edge remaining which can be added to the graph. But we would add xs before P (or st or tu or uy – whichever is still available to add. So we never add P – a contradiction! x P T y s t u

Depth-first search Algorithm DF(G,n) –Start with a given node, n. For all arcs a connected to n Do –DF(G\{n}, a) End - Do

Depth-first example A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K

A B C D E F G H I J K Continue: ABEDCHIJK (BACKTRACK to D) GF

Depth-first example-from K A B C D E F G H I J K

Breadth-First Algorithm BF(G,n) –Start with a given node, n. For all arcs a connected to n Do –Add nodes at end of each vertex. For all arcs a connected to n Do - BF(G\{arcs}, a)

Breadth-first example A B C D E F G H I J K

Add arcs connected to a A B C D E F G H I J K ABCDE

Add arcs connected to b A B C D E F G H I J K ABCDEF

Continue: A B C D E F G H I J K ABCDEFHGJIK

Do breadth-first from D A B C D E F G H I J K

Be able to: Do depth first search and list nodes Do breadth-first search and list nodes Do either search and give the search tree.

Boolean Algebras Named after mathematician George Boole Created Boolean-algebras around 1850 He saw a connection between logic and certain algebraic properties He turned logic into algebra. Used in computers about 100 years after its invention – pure mathematics becomes applied mathematics.

Definition – Boolean Algebra A Boolean algebra is a set B, with two binary operations, + and x, a unary operator ‘ and in which there are special elements 0 and 1 such that x+y=y+xx y = y x (x+y)+z=x+(y+z) (x y) z = x (y z) x+(y z) = (x+y) x (x + z)x (y+z)=xy+xz x+0 = xx 1 = 1 x + x’= 1x x’ = 0

Examples 1. Sets with union (+), intersection (x) and set complement. What are 0 and 1? 2. Logic statements with or(+) and (x) and not(‘). Again, what are zero and one? 3. B={0,1} with usual multiplication and addition, except with 1+1 = 0. What is complement?

Check that every Boolean algebra has the idempotent property Show x+x=x. Proof (x+x)=(x+x) x 1 = (x+x) (x+x’) = x + x x’ (dist prop) X + 0 = x. Look at each example in terms of the idempotent property.