Introduction (with applications) ADT & terminology

Slides:



Advertisements
Similar presentations
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Advertisements

CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Graphs Chapter 30 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 excerpts Graphs (breadth-first-search)
Data Structures Using C++
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
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.
CS 206 Introduction to Computer Science II 11 / 11 / Veterans Day Instructor: Michael Eckmann.
Graphs Chapter 30 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
CSE 326: Data Structures Lecture #19 Graphs I Alon Halevy Spring Quarter 2001.
Graphs CS-240/341. Uses for Graphs computer networks and routing airline flights geographic maps course prerequisite structures tasks for completing a.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
CSE 326: Data Structures Lecture #17 Trees and DAGs and Graphs, Oh MY! Bart Niswonger Summer Quarter 2001.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Graphs Chapter 28 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
CSC 2300 Data Structures & Algorithms March 30, 2007 Chapter 9. Graph Algorithms.
GRAPH Learning Outcomes Students should be able to:
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 Graphs.
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
 What is a graph? What is a graph?  Directed vs. undirected graphs Directed vs. undirected graphs  Trees vs graphs Trees vs graphs  Terminology: Degree.
CSE 326: Data Structures First Post-Schism Lecture Lecture #22 SteganoGRAPHy Steve Wolfman Winter Quarter 2000.
CPSC 320: Intermediate Algorithm Design & Analysis Greedy Algorithms and Graphs Steve Wolfman 1.
Graphs, Puzzles, & Map Coloring
COSC 2007 Data Structures II Chapter 14 Graphs I.
Graph Theory. A branch of math in which graphs are used to solve a problem. It is unlike a Cartesian graph that we used throughout our younger years of.
Graphs Chapter Chapter Contents Some Examples and Terminology Road Maps Airline Routes Mazes Course Prerequisites Trees Traversals Breadth-First.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Graphs Upon completion you will be able to:
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
Graphs. Contents Terminology Graphs as ADTs Applications of Graphs.
Graphs Chapter 28 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank Carrano.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
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.
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Topological Sorting.
ADT description Implementations
Graphs Chapter 20.
Graphs Lecture 19 CS2110 – Spring 2013.
Graphs Representation, BFS, DFS
Introduction to Graphs
Csc 2720 Instructor: Zhuojun Duan
Introduction to Graphs
C.Eng 213 Data Structures Graphs Fall Section 3.
Minimum Spanning Trees and Shortest Paths
Cinda Heeren / Geoffrey Tien
CS120 Graphs.
Can you draw this picture without lifting up your pen/pencil?
Graphs Chapter 13.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Chapter 14 Graphs © 2006 Pearson Addison-Wesley. All rights reserved.
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS Lecture 17 CS2110 Spring 2018.
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Chapter 9 Graph algorithms
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Introduction to Graphs
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Introduction (with applications) ADT & terminology Graphs Introduction (with applications) ADT & terminology March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Total order 1 2 5 4 7 6 3 A B means A must go before B March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Partial order Getting dressed pants shirt socks coat undies belt watch boots pocket knife March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Topological sort Given a graph, 𝐺= 𝑉,𝐸 , output all vertices in V such that no vertex is output before any other vertex with an edge to it Classic application: course prerequisites CPSC 110 CPSC 121 MATH 100 MATH 101 CPSC 210 CPSC 221 STAT 241 MATH 200 MATH 221 CPSC 213 CPSC 310 CPSC 320 CPSC 313 March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Topological sort Label each vertex's in-degree (# of inbound edges) Initialize a queue to contain all vertices with in-degree zero While there are vertices remaining in the queue Pick a vertex 𝑣 from the queue and output it Reduce the in-degree of all vertices adjacent to 𝑣 Put any of these with updated zero in-degree on the queue Remove 𝑣 from the queue March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Topological sort Queue: 1 6 Vertex In-degree 1 2 3 4 5 6 2 4 5 1 6 3 March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Topological sort Queue: 1 6 2 Vertex In-degree 1 2 3 4 5 6 2 4 5 1 6 3 1 1 6 March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Topological sort Queue: 2 3 Vertex In-degree 1 2 3 4 5 6 2 4 5 1 6 3 1 6 2 March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Topological sort Queue: 3 4 Vertex In-degree 1 2 3 4 5 6 2 4 5 1 6 3 1 1 6 2 3 March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Topological sort Queue: 4 5 Vertex In-degree 1 2 3 4 5 6 2 4 5 1 6 3 1 6 2 3 4 5 March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Graph applications Graphs are used as representations of many types of problems Computer network configuration Airline flight booking Pathfinding algorithms Database dependencies Task scheduling Road traffic modeling … March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Exam scheduling CPSC 221 CPSC 210 BIOL 201 ECON 211 MATH 200 MATH 223 Vertices represent courses Edges represent conflicts (at least one student is enrolled in both courses) Colours represent time slots Can we colour the graph (ideally using a limited number of colours) such that vertices joined by an edge do not have the same colour? March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Finite state automata Begin in the start vertex at the top for each digit d in the given number, follow d blue (solid) edges in succession after processing one digit, follow 1 red (dashed) edge If you end up back at the start node, the number is divisible by 7 e.g. 3703 YES March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Navigation Find a driving route(s) from location A to B March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Pathfinding Movement/position of video game elements, around terrain/obstacles etc. March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Medical imaging Automatic segmentation of anatomy in medical images March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Graphics Stanford bunny March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Game theory Game states and searching for winning sequence of moves March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Graph ADT Graphs are a formalism useful for representing relationships between things A graph 𝐺 is represented as 𝐺= 𝑉,𝐸 𝑉 is a set of vertices: 𝑣 1 , 𝑣 2 ,…, 𝑣 𝑛 E is a set of edges: 𝑒 1 , 𝑒 2 ,…, 𝑒 𝑚 where each 𝑒 𝑖 connects two vertices 𝑣 𝑖1 , 𝑣 𝑖2 𝑉= 𝑇𝑜𝑚, 𝑆ℎ𝑒𝑙𝑙𝑦, ℎ𝑎𝑚𝑠𝑡𝑒𝑟, 𝑝𝑜𝑝𝑐𝑜𝑟𝑛 𝐸= 𝑇𝑜𝑚, 𝑆ℎ𝑒𝑙𝑙𝑦 , 𝑆ℎ𝑒𝑙𝑙𝑦, 𝑇𝑜𝑚 , 𝑆ℎ𝑒𝑙𝑙𝑦,ℎ𝑎𝑚𝑠𝑡𝑒𝑟 , ℎ𝑎𝑚𝑠𝑡𝑒𝑟,𝑝𝑜𝑝𝑐𝑜𝑟𝑛 Tom Shelly hamster popcorn March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Graph ADT Operations Operations might include: Creation (with a certain number of vertices) Iterate through all vertices in the graph (traversal) Iterating over vertices adjacent to a specific vertex Asking whether an edge exists connecting two vertices Ask about the weight/cost of an edge between two vertices Inserting/removing edges (other operations/algorithms that may be useful) March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Graph terminology Paths, vertices, edges A graph consists of two sets, 𝑉 and 𝐸 Two vertices may be connected by a path A sequence of edges that begins at one vertex and ends at the other A simple path does not pass through the same vertex more than once A cycle is a path that starts and ends at the same vertex If a graph has v vertices, how many edges does it have? If every vertex is connected to every other vertex, and we count each direction as two edges v2 – v If the graph is a tree v – 1 Minimum number of edges March 21, 2018 Cinda Heeren / Geoffrey Tien

Connected / unconnected graphs A connected graph is one where every pair of distinct vertices has a path between them A complete graph is one where every pair of vertices has an edge between them A graph (usually) cannot have multiple edges between the same pair of vertices A graph (usually) cannot have self edges i.e. an edge from and to the same vertex connected graph complete graph unconnected graph March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Directed graphs In a directed graph (or digraph) each edge has a direction and is called a directed edge A directed edge can only be traveled in one direction A pair of vertices in a digraph may have two edges between them, one in each direction March 21, 2018 Cinda Heeren / Geoffrey Tien

Cinda Heeren / Geoffrey Tien Weighted graphs In a weighted graph each edge is assigned a weight Edges are labeled with their weights Each edge’s weight represents the cost to travel along that edge The cost could be distance, time, money or some other measure The cost depends on the underlying problem 1 2 4 3 5 March 21, 2018 Cinda Heeren / Geoffrey Tien

Readings for this lesson Carrano & Henry Chapter 20.1 – 20.2 (Graph terminology, ADT) Next class: Carrano & Henry, Chapter 20.2 – 20.3 (implementation, traversals) March 21, 2018 Cinda Heeren / Geoffrey Tien