Graphs 1 Neil Ghani University of Strathclyde. Where are we …. We studied lists: * Searching and sorting a list Then we studied trees: * Efficient search.

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

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.
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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:
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.
Spanning Trees. 2 Spanning trees Suppose you have a connected undirected graph Connected: every node is reachable from every other node Undirected: edges.
Two Discrete Optimization Problems Problem #2: The Minimum Cost Spanning Tree Problem.
The Shortest Path Problem
Minimum Spanning Trees What is a MST (Minimum Spanning Tree) and how to find it with Prim’s algorithm and Kruskal’s algorithm.
Lecture 23. Greedy Algorithms
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
University of Texas at Arlington Srikanth Vadada Kishan Kumar B P Fall CSE 5311 Solving Travelling Salesman Problem for Metric Graphs using MST.
SPANNING TREES Lecture 21 CS2110 – Spring
Minimum Spanning Tree Given a weighted graph G = (V, E), generate a spanning tree T = (V, E’) such that the sum of the weights of all the edges is minimum.
Graph Theory Hamilton Paths and Hamilton Circuits.
Spanning Trees Introduction to Spanning Trees AQR MRS. BANKS Original Source: Prof. Roger Crawfis from Ohio State University.
Spanning Trees Introduction to Spanning Trees AQR MRS. BANKS Original Source: Prof. Roger Crawfis from Ohio State University.
Spring 2015 Mathematics in Management Science Network Problems Networks & Trees Minimum Networks Spanning Trees Minimum Spanning Trees.
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
Minimum spanning trees Aims: To know the terms: tree, spanning tree, minimum spanning tree. To understand that a minimum spanning tree connects a network.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Kruskal’s and Dijkstra’s Algorithm.  Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted.
Michael Walker. From Maps to Graphs  Make Intersections Vertices  Make Roads Edges  Result is Weighted Directed Graph  Weights: Speed Limit Length.
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
Chapter 14 Section 4 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
Graphs and MSTs Sections 1.4 and 9.1. Partial-Order Relations Everybody is not related to everybody. Examples? Direct road connections between locations.
Trees Thm 2.1. (Cayley 1889) There are nn-2 different labeled trees
Prims Algorithm for finding a minimum spanning tree
Lecture 19 Minimal Spanning Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
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.
Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
Unit 2 Hamiltonian Circuits. Hamiltonian Circuit: A tour that starts at a vertex of a graph and visits each vertex once and only once, returning to where.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Shana Norman Dec 11, 2003 Final Project
Hamilton Paths and Hamilton Circuits
Weighted Graphs and traveling Salesperson problem
Minimum Spanning Trees
Shortest Path Problems
CSC 172 DATA STRUCTURES.
Greedy Technique.
Minimum Spanning Tree Chapter 13.6.
Discrete Math 2 Weighted Graph Search Tree
Unweighted Shortest Path Neil Tang 3/11/2010
Topological Sort (topological order)
Short paths and spanning trees
Refresh and Get Ready for More
Spanning Trees Discrete Mathematics.
Minimum-Cost Spanning Tree
CSC 172 DATA STRUCTURES.
CSCE350 Algorithms and Data Structure
Minimum Spanning Trees
Graphs & Graph Algorithms 2
Chapter 2: Business Efficiency Business Efficiency
Spanning Trees.
4-4 Graph Theory Trees.
Chapter 23 Minimum Spanning Tree
Louisiana Travels.
Networks Kruskal’s Algorithm
Lecture 11 CSE 331 Sep 21, 2017.
Lecture 11 CSE 331 Sep 22, 2016.
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Section 13.4 Trees.
Traveling Salesman Problems Nearest Neighbor Method
Minimum-Cost Spanning Tree
Presentation transcript:

Graphs 1 Neil Ghani University of Strathclyde

Where are we …. We studied lists: * Searching and sorting a list Then we studied trees: * Efficient search of trees * BSTs, AVL Trees, Red Black Trees Now we study graphs: * Minimal Spanning Trees * Travelling Salesman

What is a graph A map has cities and roads between them A process has states and actions between them A graph has … * A set V of vertexes * A set E of edges. There are functions start: E -> V finish : E -> V distance : E -> Nat

Two graph algorithms Minimal spanning tree * find a set of edges connecting all vertices * with minimal total distance Travelling salesman problem * find a cycle (route) through the graph * with minimal total distance

Minimal Spanning Tree Kruskal’s algortihm solves constructs a minimal spanning tree Create a set S containing all the edges Create a set F of all vetices Remove an element of S with least weight. If the edge connects two trees in F, replace these two trees by the new connected tree Stop when there is only one tree in F

Complexity of Kurskal What is the complexity of Kruskal’s algorithm. * To choose the shortest edge, we may as well sort which is O(n log n) where n is the number of edges * Next, we have n operations of constant time T(n) = O(n log n) + O(n) = O(n log n)

Travelling salesman problem Very famous problem: * Given a graph (V,E), what is the shortest path starting and ending at the same place that contains all vertices?

Brute Force Method There is no simple solution. Brute force method defines d(v,v’,X) to be the shortest distance from v to v’ using edges in X d (v,v) = 0 d (v,v’,X) = min { distance(e) + d(v’’,v’, X-{e}) | e is an edge in X from v to v’’}

Complexity of Solution Let n be the number of vertices in the graph. Then T(n) = n * T(n-1) So T is O(n!) which is VERY VERY bad!