James Tam Graphs You will learn basic principles of graphs as well as how they can be applied to problem solving.

Slides:



Advertisements
Similar presentations
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
Advertisements

Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
Data Structure and Algorithms (BCS 1223) GRAPH. Introduction of Graph A graph G consists of two things: 1.A set V of elements called nodes(or points or.
Management Science 461 Lecture 2b – Shortest Paths September 16, 2008.
James Tam Introduction To Graphs In this section of notes you will learn about a new ADT: graphs.
CSC 213 – Large Scale Programming Lecture 27: Graph ADT.
CS 410 Applied Algorithms Applied Algorithms Lecture #3 Data Structures.
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Introduction to Graphs
Lecture 14: Graph Algorithms Shang-Hua Teng. Undirected Graphs A graph G = (V, E) –V: vertices –E : edges, unordered pairs of vertices from V  V –(u,v)
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
16-Graphs Graphs Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
Review of Graphs A graph is composed of edges E and vertices V that link the nodes together. A graph G is often denoted G=(V,E) where V is the set of vertices.
22C:19 Discrete Math Graphs Spring 2014 Sukumar Ghosh.
Coloring 3/16/121. Flight Gates flights need gates, but times overlap. how many gates needed? 3/16/122.
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is NOT meant by term “Graph”  Why no bar charts, scatter plots, & pie charts mentioned.
Representing and Using Graphs
Graphs. What is a graph? A data structure that consists of a set of nodes (vertices) and a set of edges that relate the nodes to each other The set of.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
It's a world-wide webby wonderland.. Graphs are often used to represent real-world information and real-world structures. Graph Theory was even invented.
Incidentor coloring: methods and results A.V. Pyatkin "Graph Theory and Interactions" Durham, 2013.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
© Jalal Kawash 2010 Graphs Peeking into Computer Science.
© Jalal Kawash 2010 Graphs Peeking into Computer Science.
Fundamental Data Structures and Algorithms (Spring ’05) Recitation Notes: Graphs Slides prepared by Uri Dekel, Based on recitation.
September1999 CMSC 203 / 0201 Fall 2002 Week #13 – 18/20/22 November 2002 Prof. Marie desJardins.
1.5 Graph Theory. Graph Theory The Branch of mathematics in which graphs and networks are used to solve problems.
© Jalal Kawash 2010 Graphs Peeking into Computer Science.
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.
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.
Lecture 10: Graph-Path-Circuit
CSE 373: Data Structures and Algorithms
Mudasser Naseer 1 1/9/2016 CS 201: Design and Analysis of Algorithms Lecture # 17 Elementary Graph Algorithms (CH # 22)
1 Directed Graphs Chapter 8. 2 Objectives You will be able to: Say what a directed graph is. Describe two ways to represent a directed graph: Adjacency.
Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms.
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
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.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Graphs Upon completion you will be able to:
Graph. Graph Usage I want to visit all the known famous places starting from Seoul ending in Seoul Knowledge: distances, costs Find the optimal(distance.
Copyright © Curt Hill Graphs Definitions and Implementations.
Great Theoretical Ideas in Computer Science for Some.
Graph Concepts and Algorithms Using LEDA By Caroline Moore and Carmen Frerichs (252a-at and 252a-ao) each graph in the presentation was created using gw_basic_graph_algorithms.
Graph Concepts Elif Tosun 252a-aa (All graphics created by using demo/graphwin/gw*)
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.
Graph Concepts Illustrated Using The Leda Library Amanuel Lemma CS252 Algorithms.
CSC 252: Algorithms October 28, 2000 Homework #5: Graphs Victoria Manfredi (252a-ad) notes: -Definitions for each of the graph concepts are those presented.
Welcome! Cinda Heeren Lecturer Department of CS UIUC The Beauty of Computer Science.
Graph Terms By Susan Ott. Vertices Here are 7 vertices without any edges Each Vertex is labeled a different color and number.
Graph Coloring: Background and Assignment Networked Life NETS 112 Fall 2014 Prof. Michael Kearns.
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
CSC 252 Pallavi Moorthy Homework 5. 1.) Vertices, edges From cd../../handout/demo/graph_alg/gw_shortest_path.
Introduction to Graph & Network Theory Thinking About Networks: From Metabolism to the Genome to Social Conflict Summer Workshop for Teachers June 27 th.
© Jalal Kawash 2010 Graphs And Algorithms Peeking into Computer Science.
Graphs Lecture 19 CS2110 – Spring 2013.
Lecture 11 Graph Algorithms
GRAPHS Lecture 16 CS2110 Fall 2017.
CS120 Graphs.
Graph.
Maximum Flows of Minimum Cost
Graphs Chapter 11 Objectives Upon completion you will be able to:
Graphs.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
GRAPHS Lecture 17 CS2110 Spring 2018.
Presentation transcript:

James Tam Graphs You will learn basic principles of graphs as well as how they can be applied to problem solving.

James Tam A collection of vertices and edges (sets and relations) As shown in the last section, visualizing the set of relations can be easier when shown in graphical rather than textual form. Types of graphs -Directed -Undirected What Is A Graph Vertex Edge

James Tam Directed Graphs Edges are one-way -Direction of travel on streets -Relationships (“likes”) V = {Charlie Brown, Peppermint Patty, Little Red, Linus, Sally} E = {(Charlie Brown, Little Red), (Peppermint Patty, Charlie Brown), (Sally, Linus)} A B Charlie Brown Little Red Peppermint Patty Linus Sally

James Tam Directed Graphs (2) -Organizational structure (“reports to”) CEO VP Finance Payroll VP Information Technology Accounting Database Administrator Webmaster

James Tam Undirected Graphs Edges are two-way -Alberta towns, cities and the highways that connect them. V = {Edmonton, Red Deer, Calgary, Canmore, Banff} E = {(Banff, Canmore), (Calgary, Canmore), (Calgary, Red Deer), (Edmonton, Red Deer)} Edmonton Red Deer Calgary Banff Canmore

James Tam Graphs Can Be Labeled The annotations can provide additional information. -Speed limits -Debts owed Red DeerCalgary 110 km Mary Bill $100 $25

James Tam Adjacent Vertices In a directed graph vertices are adjacent if they are connected by an edge. In an undirected graph: v1 is adjacent to v2 if there is a direct edge from v1 to v2 -Adjacent: Banff-Canmore, Canmore-Calgary etc. -Not adjacent: Red Deer and Canmore etc. Edmonton Red Deer Calgary Banff Canmore

James Tam Paths There is a path between vertices if they are directly connected by an edge or indirectly connected. -Red Deer and Lethbridge are not adjacent but there is at least one path from Red Deer to Lethbridge. Edmonton Red Deer Calgary Banff Canmore Medicine Hat Lethbridge

James Tam Paths (Directed Graphs) There is a path from v 1 to v n (v 1, v 2, v 3..v n-1, v n ) if v 1 is adjacent to v 2, v 2 is adjacent to v 3...v n-1 is adjacent to v n. -The “Love” graph You Her Somebody else Him

James Tam Cyclical Paths A path that starts and ends at the same vertex. One cycle = (Calgary, Medicine Hat, Lethbridge, Calgary) Calgary Medicine Hat Lethbridge

James Tam Degree Of A Vertex It’s the number of edges that are connected to it. Degree of Calgary = 4 Degree of Medicine Hat, Lethbridge = 2 Degree of Canmore and Red Deer = 1 Red Deer Calgary Canmore Medicine Hat Lethbridge

James Tam Degree Of A Vertex (Directed Graphs) There are two measures of degree for directed graphs. -In-degree of a vertex: The number of edges that are adjacent to the vertex (arrows in). -Out-degree of a vertex: The number of edges that are adjacent from the vertex (arrows out). Sol Vega Wolf 359 Rigel Breen Qo’nos Romulas/Remus Sol system Degree in: 4 Degree out: 6

James Tam Multigraphs Most graphs don’t allow for multiple edges between a pair of vertices. Multigraphs allow multiple edges to connect a pair of vertices. Example: path finding when alternatives are possible. A B

James Tam Applications Of Graphs Logistics and supply (multigraph) A B Truck: 2days, $200 Air: 4 hours, $700

James Tam Application Of Graphs (2) Visualizing social networking connections e.g., “6 degrees of separation” A B

James Tam Application Of Graphs (3) Disease transmission: examining which people had intimate contact in order to determine who may have become infected. Original

James Tam Application Of Graphs (4) The World Wide Web itself can be visualized as a directed graph. -Vertex = web page, Edge = link between pages. Visualizing the layout of a page as a graph can be useful in web design. -Are there sufficient connections between pages? -Do the connections (links) make sense to visitor? -Although it should be possible to reach any page without too much clicking (rule of thumb is 3), there are some pages that should always be accessible e.g., home page, contact page etc.

James Tam Application Of Graphs (5)

James Tam Application Of Graphs (6)  

James Tam Graph Coloring Used for scheduling problems e.g., setting up interview schedules for a group of job applicants among a group of interviewers, setting exam schedules to avoid conflicts. Events are drawn as vertices. When events occur at the same time, the vertices are made adjacent. The idea is to color the vertices of the graph so that adjacent nodes aren’t the same color. (Color’s represent time slots or some other resource that may be needed simultaneously). Applying the algorithm correctly will result in the minimum number of colors being used (minimizes the use of resources).

James Tam Graph Coloring Algorithm Input: Undirected graph Output: Colored graph Steps: 1.Select an uncolored vertex v and color it with a new color c. 2.For each uncolored vertex: a.If the vertex is adjacent to a vertex that is already colored with color c skip v with color c. b.If the vertex is not adjacent to a vertex that is already colored with color c, color vertex v with color c. c.Repeat step 2 until all uncolored vertices have been checked. 3.Check if there are any uncolored vertices: a.If there are any uncolored vertices then go to step #1 b.If there aren’t any uncolored vertices then the algorithm is finished (stop coloring).

James Tam Graph Coloring Example 1: Final Exams You are to schedule final exams so that a student will not have two final exams scheduled at the same time. Although you could schedule each exam in it’s own individual time slot (i.e., no two exams run simultaneously) this would be highly inefficient. -Another constraint is to schedule exams with the minimum number of time slots. Examinations for a lecture will be represented with vertices. A pair of vertices will be connected if there is at least one student who is registered in both.

James Tam Graph Coloring Example 1: Final Exams (2) Lecture A: -Student 1, student 2 Lecture B: -Student 2, student 4, student 6 Lecture C: -Student 1, student 3, student 5 Lecture D: -Student 4, student 5 Lecture ALecture B Lecture CLecture D Student 5 Student 4 Student 1 Student 2

James Tam Graph Coloring Example 2: Final Exams Lecture A: -Student 1, student 2, student 4 Lecture B: -Student 2, student 4, student 6 Lecture C: -Student 1, student 3, student 5 Lecture D: -Student 4, student 5 Lecture ALecture B Lecture CLecture D Student 5 Student 4 Student 1 Student 2, 4 Student 4

James Tam Graph Coloring Example 3 Apply the graph coloring algorithm to the following Petersen graph 1 so that the minimum number of colors is used. 1 Developed by Julius Peterson 1898

James Tam You Should Now Know What is a graph, vertex and edge The difference between a directed and an undirected graph What does it mean for vertices to be adjacent What is a path (directed and undirected graphs) What is a cycle The degree of a vertex (directed and undirected graphs) What is a multi-graph (how it differs from a regular graph) How can graphs can be applied to some everyday situations How to apply the graph coloring algorithm to solve scheduling problems