Graphs and MSTs Sections 1.4 and 9.1. Partial-Order Relations Everybody is not related to everybody. Examples? Direct road connections between locations.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Great Theoretical Ideas in Computer Science
O(N 1.5 ) divide-and-conquer technique for Minimum Spanning Tree problem Step 1: Divide the graph into  N sub-graph by clustering. Step 2: Solve each.
Design and Analysis of Algorithms Approximation algorithms for NP-complete problems Haidong Xue Summer 2012, at GSU.
Greedy Algorithms Greed is good. (Some of the time)
Great Theoretical Ideas in Computer Science for Some.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Great Theoretical Ideas in Computer Science.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Network Optimization Problems: Models and Algorithms This handout: Minimum Spanning Tree Problem.
Chapter 9: Greedy Algorithms The Design and Analysis of Algorithms.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
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.
Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects two different vertices. Edges are.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
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.
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
1 Minimum Spanning Tree Problem Topic 10 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing.
Lecture 13 Graphs. Introduction to Graphs Examples of Graphs – Airline Route Map What is the fastest way to get from Pittsburgh to St Louis? What is the.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
© 2015 JW Ryder CSCI 203 Data Structures1. © 2015 JW Ryder CSCI 203 Data Structures2.
7.1 and 7.2: Spanning Trees. A network is a graph that is connected –The network must be a sub-graph of the original graph (its edges must come from the.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
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
Data Structures & Algorithms Graphs
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
WK15. Vertex Cover and Approximation Algorithm By Lin, Jr-Shiun Choi, Jae Sung.
EMIS 8373: Integer Programming Combinatorial Relaxations and Duals Updated 8 February 2005.
Finding Minimum Spanning Trees Algorithm Design and Analysis Week 4 Bibliography: [CLRS]- Chap 23 – Minimum.
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Graphs 황승원 Fall 2010 CSE, POSTECH. 2 2 Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Design and Analysis of Algorithms - Chapter 91 Greedy algorithms Optimization problems solved through a sequence of choices that are: b feasible b locally.
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.
Graphs. Graph Definitions A graph G is denoted by G = (V, E) where  V is the set of vertices or nodes of the graph  E is the set of edges or arcs connecting.
Graph Concepts Illustrated Using The Leda Library Amanuel Lemma CS252 Algorithms.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
Graphs 1 Neil Ghani University of Strathclyde. Where are we …. We studied lists: * Searching and sorting a list Then we studied trees: * Efficient search.
Kruskal’s Algorithm for Computing MSTs Section 9.2.
Minimum Spanning Trees
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Greedy Technique.
Minimum Spanning Tree Chapter 13.6.
Great Theoretical Ideas in Computer Science
Refresh and Get Ready for More
Discrete Mathematics for Computer Science
Minimum Spanning Trees
Connected Components Minimum Spanning Tree
Minimum Spanning Trees
Graph Operations And Representation
CS 583 Analysis of Algorithms
Graph Searching.
Lecture 11 CSE 331 Sep 21, 2017.
Lecture 11 CSE 331 Sep 22, 2016.
CSC 380: Design and Analysis of Algorithms
Graphs G = (V,E) V is the vertex set.
Presentation transcript:

Graphs and MSTs Sections 1.4 and 9.1

Partial-Order Relations Everybody is not related to everybody. Examples? Direct road connections between locations How about using a tree to represent the connections?

Graphs: Definition G = (V, E) Vertices (nodes) Edges (arcs) Edges are a subset of V  V {(v,v’) : v and v’ are in V} We also write v  v’ instead of (v.v’)

Directed Graphs Our PA map is undirected because if (v,v’)  E then it is assumed that (v’,v)  E (but not included in E) Can you think of a situation were the graph is directed? That is, we may have (v,v’)  E but not (v’,v)  E City streets. Some are one way A directed graph or digraph is one were the order matters vv’

Complete Graphs A complete graph is one where there is an edge between every two nodes If the graph has N nodes and the graph is complete and undirected, how many edges are there? (N-1)N/2 If the digraph has N nodes and the digraph is complete, how many edges are there? (N-1)N

Subgraphs Given a graph G = (V, E) and a graph G’ = (V’, E’), G is a subgraph of G’ if: V  V’ E  E’ Every element in the left set is an element in the right set

Paths Given a graph G = (V, E), a path between two elements v, v’ in V is a sequence of elements: v Quiz: Obtain all the paths in the following digraph: 23 7 v1v1 … vNvN such that v v 1, v 1 v 2,…, v2v2 v’ vNvN are all edges in E The length of the path is the number of edges on it

Weighted Graphs Given a weighted graph G = (V, E), a path between two elements v, v’ in V : v  v1  …  v’, the weight or cost of the path is the summation of the weight of the edges in the path A weighted graph G = (V, E), is a graph such that each edge v  v’ has an associated number (called the weight)

Connected Graphs A graph G = (V, E) is connected if there is at least one path between any two elements Connected? Yes

Acyclic Graphs Given a graph G = (V, E), a cycle is a path of at least length 1 starting with a node and ending in the same node A graph G = (V, E) is acyclic if it has no cycles Acyclic? No

Trees A tree is a connected acyclic graph G = (V, E) Number of arcs in a tree with |V| nodes: |E|-1

Techniques for Design of Algorithms Brute Force: follows directly from the definition  Exhaustive search: particular form of Brute Force Greedy Algorithm: Obtain solution by expanding partial solution constructed so far. On each step a decision is made that is:  Feasible  Locally optimal  Irrevocable

Consider the following undirected graph: B C A H E D G F Example: Greedy algorithm for TSP Use a Greedy technique to obtain a solution of the TSP Does using a Greedy technique always solves TSPs? Complexity (n = # arcs)?O(n) No

The Minimum Spanning Tree Give a graph G = (V, E), the minimum spanning tree (MST) is a weighted graph G’ = (V, E’) such that: E’  E G’ is connected G’ has the minimum cost

V V’ If there is an edge e between the 2 groups with minimum cost, then there is an MST containing e Why does it works? Property: Suppose that we divide the nodes of a graph G = (V, E) in two groups V, V’:

Visited Non visited Example of a non greedy algorithm? Example of a “Greedy” Algorithm Dijkstra-Prim is an example of a greedy algorithm since it looks at a subset of the larger problem Our naïve algorithm for MST Unfortunately, not all problems can be solved with greedy algorithms

Complexity Actual complexity is O((|E|+|V|)log 2 |E|) It is easy to see that it is at most |E||V| … e1 e2 … e1 + (e1 + e2) +…+ (e1 + e2 + … +e2)  |E||V|