Marina Kogan Sadetsky –

Slides:



Advertisements
Similar presentations
Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each.
Advertisements

Networks Prim’s Algorithm
Minimum Spanning Tree Sarah Brubaker Tuesday 4/22/8.
Discrete Maths Chapter 3: Minimum Connector Problems Lesson 1: Prim’s and Kruskal.
MINIMAL CONNECTOR PROBLEMS Problem: A cable TV company is installing a system of cables to connect all the towns in a region. The numbers in the network.
Aims: To know the terms: tree, spanning tree, minimum spanning tree. To understand that a minimum spanning tree connects a network using the lowest possible.
7.3 Kruskal’s Algorithm. Kruskal’s Algorithm was developed by JOSEPH KRUSKAL.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
גרפים ממשקלים גרף ממשקל הוא גרף עם משקל לכל קשת עץ פורש הוא עץ שצמתיו הם כל הצמתים של הגרף וקשתותיו הן קשתות הגרף.
Minimum Spanning Trees CIS 606 Spring Problem A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting.
3/29/05Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 4.2 Minimal Spanning Trees Prepared by Amanda Dargie and Michele Fretta.
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.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
Lecture 17: Spanning Trees Minimum Spanning Trees.
Minimum Spanning Tree Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Greedy methods Prudence Wong
ADA: 10. MSTs1 Objective o look at two algorithms for finding mimimum spanning trees (MSTs) over graphs Prim's algorithm, Kruskal's algorithm Algorithm.
Minimum spanning trees Aims: To know the terms: tree, spanning tree, minimum spanning tree. To understand that a minimum spanning tree connects a network.
Chapter 4 sections 1 and 2.  Fig. 1  Not connected  All vertices are even.  Fig. 2  Connected  All vertices are even.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Dear teacher, We wanted to apologize for the technical issues that EDpuzzle has experienced today. We have teachers in our team and understand how frustrating.
Minimum spanning trees Aims: To know the terms: tree, spanning tree, minimum spanning tree. To understand that a minimum spanning tree connects a network.
Minimum Spanning Trees Easy. Terms Node Node Edge Edge Cut Cut Cut respects a set of edges Cut respects a set of edges Light Edge Light Edge Minimum Spanning.
Fundamental Data Structures and Algorithms (Spring ’05) Recitation Notes: Graphs Slides prepared by Uri Dekel, Based on recitation.
Spanning Trees. A spanning tree for a connected, undirected graph G is a graph S consisting of the nodes of G together with enough edges of G such that:
MCA 202: Discrete Structures Instructor Neelima Gupta
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
Lecture19: Graph III Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Minimum Spanning tree Prim’s algorithm 1.Select any vertex 2.Select the shortest edge connected to that vertex 3.Select the shortest edge which connects.
Prims Algorithm for finding a minimum spanning tree
Minimum Spanning Trees Text Read Weiss, §9.5 Prim’s Algorithm Weiss §9.5.1 Similar to Dijkstra’s Algorithm Kruskal’s Algorithm Weiss §9.5.2 Focuses on.
MATRIX FORM OF PRIM’S ALGORITHM. This network may be described using a Distance Matrix.
Minimum Spanning Trees
COMP108 Algorithmic Foundations Greedy methods
May 12th – Minimum Spanning Trees
Minimum Spanning Tree Chapter 13.6.
Spanning Trees.
Kruskal’s Algorithm Elaicca Ronna Ordoña. A cable company want to connect five villages to their network which currently extends to the market town of.
Minimum-Cost Spanning Tree
CSCE350 Algorithms and Data Structure
Minimum Spanning Tree.
Minimum Spanning Trees
Connected Components Minimum Spanning Tree
Minimum Spanning Tree.
CSE373: Data Structures & Algorithms Lecture 12: Minimum Spanning Trees Catie Baker Spring 2015.
CSE373: Data Structures & Algorithms Lecture 20: Minimum Spanning Trees Linda Shapiro Spring 2016.
Minimum Spanning Trees
Shortest Path.
4-4 Graph Theory Trees.
Kruskal’s Algorithm for finding a minimum spanning tree
Chapter 23 Minimum Spanning Tree
Example A cable company want to connect five villages to their network which currently extends to the market town of Avonford. What is the minimum.
Minimum spanning trees
AB AC AD AE AF 5 ways If you used AB, then, there would be 4 remaining ODD vertices (C, D, E and F) CD CE CF 3 ways If you used CD, then, there.
Minimum spanning trees
Minimum spanning trees
Networks Kruskal’s Algorithm
Minimum Spanning tree Select any vertex
Weighted Graphs & Shortest Paths
Networks Prim’s Algorithm
Minimum spanning trees
Minimum Spanning Trees (MSTs)
Kruskal’s Algorithm AQR.
Prim’s algorithm for minimum spanning trees
Lecture 14 Minimum Spanning Tree (cont’d)
Single-Source Shortest Path & Minimum Spanning Trees
Spanning Tree.
7 The Mathematics of Networks
Minimum-Cost Spanning Tree
Presentation transcript:

Marina Kogan Sadetsky – 1.2016 יסודות מבני נתונים תרגול 13: עץ פורש מינימלי - Minimum Spanning Tree (MST) Marina Kogan Sadetsky – 1.2016

Minimum Spanning Tree (MST) Kruskal’s algorithm Select the shortest edge in a network Select the next shortest edge which does not create a cycle Repeat step 2 until all vertices have been connected Prim’s algorithm Select any vertex Select the shortest edge connected to that vertex Select the shortest edge connected to any vertex already connected Repeat step 3 until all vertices have been connected

Example Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E List the edges in order of size: ED 2 AB 3 AE 4 CD 4 BC 5 EF 5 CF 6 AF 7 BF 8 CF 8 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm Select the shortest edge in the network B C 3 6 8 F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 (or AE 4) A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 BC 5 – forms a cycle EF 5 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E All vertices have been connected. The solution is ED 2 AB 3 CD 4 AE 4 EF 5 Total weight of tree: 18 A F B C D E 2 7 4 5 8 6 3

Example Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select any vertex A Select the shortest edge connected to that vertex AB 3 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. AE 4 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. ED 2 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. DC 4 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. EF 5 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E All vertices have been connected. The solution is AB 3 AE 4 ED 2 DC 4 EF 5 Total weight of tree: 18 A F B C D E 2 7 4 5 8 6 3

Some points to note Both algorithms will always give solutions with the same length. They will usually select edges in a different order – you must show this in your workings. Occasionally they will use different edges – this may happen when you have to choose between edges with the same length. In this case there is more than one minimum connector for the network.

Kruskal Prim מתחילים בכך שכל קדקוד גרף הוא עץ כל פעם נוסיף קשת בעלת משקל מינימלי המחברת בין שני עצים שונים מסיימים כאשר הוספנו |V|1 צלעות זמן ריצה O(E logV) Prim מתחילים מקדקוד רנדומלי R שהוא יהיה שורש של MST כל פעם מוסיפים קדקוד חדש v לעץ פורש כך שהקשת המחברת את v עם MST היא בעלת משקל מינימלי מסיימים כאשר הוספנו |V|1 צלעות זמן ריצה O(E logV) שאלה: האם נכון להגיד שאם בגרף יש שתי צלעות לפחות עם משקל זהה שמשתתפות באותו מעגל, אז יש לגרף הזה יותר מעץ פורש מינימלי אחד? שאלה: האם נכון להגיד שאם בגרף יש שתי צלעות לפחות עם משקל זהה, אז יש לגרף הזה יותר מעץ פורש מינימלי אחד? תשובה: לא. לדוגמא נקח גרף שהוא מעגל עם שלוש צלעות עם משקלות 1,1,ו 2. ברור שלגרף הזה יש MST יחיד, שבמקרה הזה גם מכיל את שתי הצלעות עם משקל זהה. תשובה: לא. אם גרף הוא עץ כאשר לכל הצלעות אותו משקל (דוגמא קיצונית), הרי ברור שיש לגרף הזה עץ פורש יחיד

שאלה 1