Blobs and Graphs Prof. Noah Snavely CS1114

Slides:



Advertisements
Similar presentations
Great Theoretical Ideas in Computer Science
Advertisements

Great Theoretical Ideas in Computer Science for Some.
Graph algorithms Prof. Noah Snavely CS1114
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
CISC1400: Discrete Structure Introduction 1 Dr. Zhang, Fall 2011, Fordham Univ.
CompSci 102 Discrete Math for Computer Science April 19, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Sorting and Selection, Part 1 Prof. Noah Snavely CS1114
Polygons and the convex hull Prof. Noah Snavely CS1114
Sorting and selection – Part 2 Prof. Noah Snavely CS1114
Great Theoretical Ideas in Computer Science.
Last time: terminology reminder w Simple graph Vertex = node Edge Degree Weight Neighbours Complete Dual Bipartite Planar Cycle Tree Path Circuit Components.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
CS 1114: Data Structures – memory allocation Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Clustering and greedy algorithms — Part 2 Prof. Noah Snavely CS1114
CS 410 Applied Algorithms Applied Algorithms Lecture #3 Data Structures.
CS 1114: Sorting and selection (part one) Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
 Consider the cities Atlanta, Boston, Chicago, Detroit, Fargo, and Los Angeles.  We want to see what connections there are between cities on a particular.
CS 1114: Graphs and Blobs Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Robustness and speed Prof. Noah Snavely CS1114
Polygons and the convex hull Prof. Noah Snavely CS1114
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Clustering and greedy algorithms Prof. Noah Snavely CS1114
Connected components and graph traversal Prof. Noah Snavely CS1114
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
22C:19 Discrete Math Graphs Spring 2014 Sukumar Ghosh.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Coloring 3/16/121. Flight Gates flights need gates, but times overlap. how many gates needed? 3/16/122.
Social Media Mining Graph Essentials.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Image segmentation Prof. Noah Snavely CS1114
Connected Components Fun with graphs, searching, and queues.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
Medians and blobs Prof. Ramin Zabih
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
Robustness and speed Prof. Noah Snavely CS1114
COSC 2007 Data Structures II Chapter 14 Graphs I.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
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.
Finding Red Pixels – Part 2 Prof. Noah Snavely CS1114
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,
Sorting and selection – Part 2 Prof. Noah Snavely CS1114
Breadth-first and depth-first traversal Prof. Noah Snavely CS1114
Great Theoretical Ideas in Computer Science for Some.
Breadth-first and depth-first traversal CS1114
Graph problems Prof. Ramin Zabih
COMPSCI 102 Introduction to Discrete Mathematics.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
Lecture 5.3: Graph Isomorphism and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag.
Blobs and Graphs Prof. Noah Snavely CS1114
Graphs.
Graphs Lecture 19 CS2110 – Spring 2013.
Copyright © Zeph Grunschlag,
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
CS 1114: Sorting and selection (part three)
Discrete Mathematics for Computer Science
Data Structures – Stacks and Queus
Walks, Paths, and Circuits
Quickselect Prof. Noah Snavely CS1114
Sorting, selecting and complexity
GRAPHS Lecture 17 CS2110 Spring 2018.
Discrete Mathematics for Computer Science
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Prof. Ramin Zabih Graph Traversal Prof. Ramin Zabih
Sorting and selection Prof. Noah Snavely CS1114
Presentation transcript:

Blobs and Graphs Prof. Noah Snavely CS1114

2 Administrivia  Assignment 2 is out –First part due on Friday by 5pm –Second part due next Friday by 5pm  Quiz 2 on Thursday –Coverage through today (topics include running time, sorting, graphs) –Closed book / closed note

Administrivia  Webcams in lab not yet working, please load in static images for now 3

4  What is the running time of:  Finding the median using repeating “find biggest”? –Answer: O(n 2 )  Finding the median using quickselect (on average) –Answer: O(n) (expected)  Finding the 2 nd biggest element (>all but 1) using repeated “find biggest”? The 3 rd biggest (> all but 2)? The 50,000 th biggest element? –Answer: All are O(n)  Finding the element bigger than all but 5%? –Suppose we use repeated “find biggest”; Answer: O(n 2 ) –What if we use quickselect? Answer: O(n)  Finding the biggest element in the first 50,000 entries of an array? –O(1) !

Big-O notation  “Constant of proportionality” doesn’t matter  We only care about how the function grows for “large” values of n 5 O(1) O(n 2 ) O(n)

6 Problems, algorithms, programs  A central distinction in CS  Problem: what you want to compute –“Find the median” –Sometimes called a specification  Algorithm: how to do it, in general –“Repeated find biggest” –“Quickselect”  Program: how to do it, in a particular programming language function [med] = find_median[A]...

Back to the lightstick 7 The lightstick forms a large “blob” in the thresholded image (among other blobs)

8 What is a blob?

9 Finding blobs 1.Pick a 1 to start with, where you don’t know which blob it is in –When there aren’t any, you’re done 2.Give it a new blob color 3.Assign the same blob color to each pixel that is part of the same blob

10 Finding blobs

11 Finding blobs

12 Finding blobs

13 Finding blobs

14 Finding blobs

15 Finding blobs

16 Finding blobs 1.Pick a 1 to start with, where you don’t know which blob it is in –When there aren’t any, you’re done 2.Give it a new blob color 3.Assign the same blob color to each pixel that is part of the same blob –How do we figure this out? –You are part of the blob if you are next to someone who is part of the blob –But what does “next to” mean?

17 What is a neighbor?  We need a notion of neighborhood –Sometimes called a neighborhood system  Standard system: use vertical and horizontal neighbors –Called “NEWS”: north, east, west, south –4-connected, since you have 4 neighbors  Another possibility includes diagonals –8-connected neighborhood system

18 The long winding road to blobs  We actually need to cover a surprising amount of material to get to blob finding –Some of which is not obviously relevant –But (trust me) it will all hang together!

19 A single idea can be used to think about: –Assigning frequencies to radio stations –Scheduling your classes so they don’t conflict –Figuring out if a chemical is already known –Finding groups in Facebook –Ranking web search results

20 Graphs: always the answer  We are going to look at an incredibly important concept called a graph –Note: not the same as a plot  Most problems can be thought of in terms of graphs –But it may not be obvious, as with blobs

21 What is a graph?  Loosely speaking, a set of things that are paired up in some way  Precisely, a set of vertices V and edges E –Vertices sometimes called nodes –An edge (or link) connects a pair of vertices V1 V2 V3 V4 V5 V = { V1, V2, V3, V4, V5 } E = { (V1,V3), (V2,V5), (V3,V4) }

22 Notes on graphs  What can a graph represent? –Cities and direct flights –People and friendships –Web pages and hyperlinks –Rooms and doorways –IMAGES!!! LAX ITH PHL LGA

Notes on graphs  A graph isn’t changed by: –Drawing the edges differently While preserving endpoints –Renaming the vertices 23 V1 V2 V3 V4 LAX ITH PHL LGA

24 Some major graph problems  Graph coloring –Ensuring that radio stations don’t clash  Graph connectivity –How fragile is the internet?  Graph cycles –Helping FedEx/UPS/DHL plan a route  Planarity testing –Connecting computer chips on a motherboard  Graph isomorphism –Is a chemical structure already known?

25 Some major graph problems  Graph coloring –Ensuring that radio stations don’t clash  Graph connectivity –How fragile is the internet?  Graph cycles –Helping FedEx/UPS/DHL plan a route  Planarity testing –Connecting computer chips on a motherboard  Graph isomorphism –Is a chemical structure already known?

26  Given a graph and a set of colors {1,…,k}, assign each vertex a color  Adjacent vertices have different colors Graph coloring problem V1 V2 V3 V4 V5 V1 V3 V4 V5 V2

27 Radio frequencies via coloring  How can we assign frequencies to a set of radio stations so that there are no clashes?  Make a graph where each station is a vertex –Put an edge between two stations that clash I.e., if their signal areas overlap –Any coloring is a non-clashing assignment of frequencies Can you prove this? What about vice-versa? C1 C2 C3 C4 C5

Images as graphs 28

Images as graphs 29

Images as graphs 30

31 Graphs and paths  Can you get from vertex V to vertex W? –Is there a route from one city to another?  More precisely, is there a sequence of vertices V,V 1,V 2,…,V k,W such that every adjacent pair has an edge between them? –This is called a path –A cycle is a path from V to V –A path is simple if no vertex appears twice

European rail links (simplified) 32 Paris Berlin London Rome Frankfurt Vienna Prague Can we get from London to Prague on the train? How about London to Stockholm? Oslo Stockholm

33 Graph connectivity  For any pair of nodes, is there a path between them? –Basic idea of the Internet: you can get from any computer to any other computer –This pair of nodes is called connected –A graph is connected if all nodes are connected  Related question: if I remove an arbitrary node, is the graph still connected? –Is the Internet intact if any 1 computer fails? –Or any 1 edge between computers?

Next time: graphs 34

35 “Eastern Telegraph Co. and its General Connections” (1901)

36

37

Next time:  Quiz 2  How can we find connected components? 38