Programming Abstractions Cynthia Lee CS106X. Graphs Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Minimum Spanning Tree Sarah Brubaker Tuesday 4/22/8.
Chen, Lu Mentor: Zhou, Jian Shanghai University, School of Management Chen213.shu.edu.cn.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
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.
Discussion #36 Spanning Trees
MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 15, Friday, October 3.
T,  e  T c(e) = 50 G = (V, E), c(e) Minimum Spanning Tree.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Tirgul 13 Today we’ll solve two questions from last year’s exams.
Lecture 27 CSE 331 Nov 6, Homework related stuff Solutions to HW 7 and HW 8 at the END of the lecture Turn in HW 7.
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.
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Graphs.
Lecture 17: Spanning Trees Minimum Spanning Trees.
WEIGHTED GRAPHS. Weighted Graphs zGraph G = (V,E) such that there are weights/costs associated with each edge Õw((a,b)): cost of edge (a,b) Õrepresentation:
ADA: 10. MSTs1 Objective o look at two algorithms for finding mimimum spanning trees (MSTs) over graphs Prim's algorithm, Kruskal's algorithm Algorithm.
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Chapter 2 Graph Algorithms.
(CSC 102) Lecture 32 Discrete Structures. Trees Previous Lecture  Matrices and Graphs  Matrices and Directed Graphs  Matrices and undirected Graphs.
COSC 2007 Data Structures II Chapter 14 Graphs III.
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.
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:
Introduction to Graph Theory
1 Minimum Spanning Trees (some material adapted from slides by Peter Lee, Ananda Guna, Bettina Speckmann)
Minimal Spanning Tree Problems in What is a minimal spanning tree An MST is a tree (set of edges) that connects all nodes in a graph, using.
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
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.
SPANNING TREES Lecture 21 CS2110 – Fall Nate Foster is out of town. NO 3-4pm office hours today!
CSC2100B Tutorial 10 Graph Jianye Hao.
CSCI2100 Data Structures Tutorial 12
Minimum- Spanning Trees
Graph Revisited Fei Chen CSCI2100B Data Structures Tutorial 12 1.
Tree Diagrams A tree is a connected graph in which every edge is a bridge. There can NEVER be a circuit in a tree diagram!
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Graphs. Introduction Graphs are a collection of vertices and edges Graphs are a collection of vertices and edges The solid circles are the vertices A,
Graph Search Applications, Minimum Spanning Tree
Minimum Spanning Trees
COMP108 Algorithmic Foundations Greedy methods
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Programming Abstractions
Minimum Spanning Tree Chapter 13.6.
Programming Abstractions
Spanning Trees.
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Minimum Spanning Trees and Shortest Paths
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Programming Abstractions
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Graph Algorithm.
Spanning Trees.
Minimum Spanning Tree.
Minimum Spanning Trees
Connected Components Minimum Spanning Tree
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
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.
CSE332: Data Abstractions Lecture 18: Minimum Spanning Trees
Graphs.
Minimum spanning trees
CSE 417: Algorithms and Computational Complexity
Minimum Spanning Trees (MSTs)
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Prim’s algorithm for minimum spanning trees
CSE 373: Data Structures and Algorithms
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

Programming Abstractions Cynthia Lee CS106X

Graphs Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things we can prove about graphs? 3.Breadth-first search on a graph  Spoiler: just a very, very small change to tree version 4.Dijkstra’s shortest paths algorithm  Spoiler: just a very, very small change to BFS 5.A* shortest paths algorithm  Spoiler: just a very, very small change to Dijkstra’s 6.Minimum Spanning Tree  Kruskal’s algorithm

A* Solving Super Mario (video)

Minimum Spanning Tree

BD ECA F How many distinct minimum spanning trees are in this graph? A.0-1 B.2-3 C.4-5 D.6-7 E.> Edges: (A,B)=1 (A,C)=3 (B,C)=6 (B,D)=3 (C,E)=3 (D,E)=3 (D,F)=7

Prim’s Algorithm

Prim’s algorithm Arbitrarily choose start vertex Add start vertex to MST While vertices in MST < total vertices:  Examine all edges that leave the current MST  Choose the smallest one  Add the end vertex of that edge to the MST

Prim’s algorithm

Kruskal’s Algorithm

Kruskal’s algorithm Remove all edges from graph Place all edges in a PQ based on length/weight While !PQ.isEmpty():  Dequeue edge  If the edge connects previous disconnected nodes or groups of nodes, keep the edge  Otherwise discard the edge

Kruskal’s algorithm

Remove all edges from graph Place all edges in a PQ based on length/weight While !PQ.isEmpty():  Dequeue edge  If the edge connects previous disconnected nodes or groups of nodes, keep the edge  Otherwise discard the edge Efficiency of this step is key

Cluster management questions The assignment handout asks you to consider questions such as:  How will you keep track of which nodes are in each cluster?  How will you determine which cluster a node belongs to?  How will you merge together two clusters?

Cluster management strategies [watch lecture for whiteboard hints]

The Good Will Hunting Problem

Video Clip

“Draw all the homeomorphically irreducible trees with n=10.”

In this case “trees” simply means graphs with no cycles “with n = 10” (i.e., has 10 nodes) “homeomorphically irreducible”  No nodes of degree 2 allowed in your solutions › For this problem, nodes of degree 2 are useless in terms of tree structure—they just act as a blip on an edge—and are therefore banned  Have to be actually different › Ignore superficial changes in rotation or angles of drawing