CSE 373: Data Structures and Algorithms

Slides:



Advertisements
Similar presentations
CS16: Introduction to Data Structures & Algorithms
Advertisements

CSC401 – Analysis of Algorithms Lecture Notes 14 Graph Biconnectivity
CSE 373 Graphs 1: Concepts, Depth/Breadth-First Search
Graphs Chapter 30 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
CS 206 Introduction to Computer Science II 11 / 11 / Veterans Day Instructor: Michael Eckmann.
CSC 213 – Large Scale Programming Lecture 27: Graph ADT.
CSC 213 Lecture 23: Shortest Path Algorithms. Weighted Graphs Each edge in weighted graph has numerical weight Weights can be distances, building costs,
CSC 213 ORD DFW SFO LAX Lecture 20: Graphs.
© 2004 Goodrich, Tamassia Graphs1 ORD DFW SFO LAX
B.Ramamurthy1 Graphs Chapter 12 B.Ramamurthy. 2 Introduction A structure that represents connectivity information. A tree is kind of graph. Applications.
Introduction to Graphs
Graph & BFS Lecture 22 COMP171 Fall Graph & BFS / Slide 2 Graphs * Extremely useful tool in modeling problems * Consist of: n Vertices n Edges D.
1 Graphs ORD DFW SFO LAX Many slides taken from Goodrich, Tamassia 2004.
Introduction to Graphs What is a Graph? Some Example applications of Graphs. Graph Terminologies. Representation of Graphs. –Adjacency Matrix. –Adjacency.
CSE 373: Data Structures and Algorithms Lecture 18: Graphs II 1.
Graphs1 Part-H1 Graphs ORD DFW SFO LAX
Graphs1 ORD DFW SFO LAX Graphs2 Outline and Reading Graphs (§6.1) Definition Applications Terminology Properties ADT Data structures.
Graphs1 ORD DFW SFO LAX Graphs2 Outline and Reading Graphs (§6.1) Definition Applications Terminology Properties ADT Data structures.
Graphs Chapter 28 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
ECE669 L10: Graph Applications March 2, 2004 ECE 669 Parallel Computer Architecture Lecture 10 Graph Applications.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Lecture17: Graph I Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Graphs – ADTs and Implementations ORD DFW SFO LAX
Graphs Chapter 12.
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.
Graphs CSE 2011 Winter June Graphs A graph is a pair (V, E), where  V is a set of nodes, called vertices  E is a collection of pairs.
Spring 2007Graphs1 ORD DFW SFO LAX
1 Dijkstra’s Algorithm Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Programming Abstractions Cynthia Lee CS106X. Upcoming Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.
Graph Terminologies Department of CE/IT M.S.P.V.L.Polytechnic College,
Contest Algorithms January 2016 Introduce the main kinds of graphs, discuss two implementation approaches, and remind you about trees 6. Intro. to Graphs.
Graphs Chapter 28 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank Carrano.
Discrete Maths 11. Graph Theory Objective
CHAPTER 13 GRAPH ALGORITHMS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
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 Illustrated Using The Leda Library Amanuel Lemma CS252 Algorithms.
CHAPTER 13 GRAPH ALGORITHMS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
Programming Abstractions Cynthia Lee CS106B. Upcoming Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Graphs ORD SFO LAX DFW Graphs 1 Graphs Graphs
Minimum-cost spanning tree
Minimum-Cost Spanning Tree and Kruskal’s Algorithm
Graphs.
Graphs 5/14/ :46 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Introduction to Graphs
Shortest Path 6/18/2018 4:22 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Graphs 7/18/2018 7:39 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs ORD SFO LAX DFW Graphs Graphs
Introduction to Graphs
CMSC 341 Lecture 21 Graphs (Introduction)
Discrete Maths 9. Graphs Objective
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs CSE 2011 Winter November 2018.
Graphs.
CSE 373: Data Structures and Algorithms
Graphs.
CSE 373 Data Structures Lecture 17
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs 4/29/15 01:28:20 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
CSE 373 Data Structures and Algorithms
Graphs ORD SFO LAX DFW /15/ :57 AM
Shortest Paths.
Graphs G = (V, E) V are the vertices; E are the edges.
Graphs.
CSE 373 Data Structures Lecture 13
Introduction to Graphs
Introduction to Graphs
Presentation transcript:

CSE 373: Data Structures and Algorithms Lecture 17: Graphs

What are graphs? Yes, this is a graph…. But we are interested in a different kind of “graph”

Airline Routes Nodes = cities Edges = direct flights

Computer Networks 56 Tokyo Seattle Seoul 128 16 181 New York 30 140 L.A. Tokyo Sydney Seoul 128 140 181 30 16 56 Nodes = computers Edges = transmission rates

CSE Course Prerequisites at UW 461 322 373 143 321 326 415 142 410 370 341 413 417 378 Nodes = courses Directed edge = prerequisite 421 401

Graphs graph: a data structure containing a set of vertices V a set of edges E, where an edge represents a connection between 2 vertices G = (V, E) edge is a pair (v, w) where v, w in V the graph at right: V = {a, b, c} and E = {(a, b), (b, c), (c, a)} Assuming that a graph can only have one edge between a pair of vertices and cannot have an edge to itself, what is the maximum number of edges a graph can contain, relative to the size of the vertex set V?

Paths path: a path from vertex A to B is a sequence of edges that can be followed starting from A to reach B can be represented as vertices visited or edges taken example: path from V to Z: {b, h} or {V, X, Z} reachability: v1 is reachable from v2 if a path exists from V1 to V2 connected graph: one in which it's possible to reach any node from any other is this graph connected? P1 X U V W Z Y a c b e d f g h P2

Cycles cycle: path from one node back to itself example: {b, g, f, c, a} or {V, X, Y, W, U, V} loop: edge directly from node to itself many graphs don't allow loops C1 X U V W Z Y a c b e d f g h C2

Weighted graphs weight: (optional) cost associated with a given edge example: graph of airline flights if we were programming this graph, what information would we have to store for each vertex / edge? ORD PVD MIA DFW SFO LAX LGA HNL 849 802 1387 1743 1843 1099 1120 1233 337 2555 142

Directed graphs directed graph (digraph): edges are one-way connections between vertices if graph is directed, a vertex has a separate in/out degree

Trees as Graphs Every tree is a graph with some restrictions: the tree is directed there is exactly one directed path from the root to every node A B C D E F G H

More terminology degree: number of edges touching a vertex example: W has degree 4 what is the degree of X? of Z? adjacent vertices: connected directly by an edge X U V W Z Y a c b e d f g h i j

Graph questions Are the following graphs directed or not directed? Buddy graphs of instant messaging programs? (vertices = users, edges = user being on another's buddy list) bus line graph depicting all of Seattle's bus stations and routes graph of movies in which actors have appeared together Are these graphs potentially cyclic? Why or why not?

Graph exercise Consider a graph of instant messenger buddies. What do the vertices represent? What does an edge represent? Is this graph directed or undirected? Weighted or unweighted? What does a vertex's degree mean? In degree? Out degree? Can the graph contain loops? cycles? Consider this graph data: Jessica's buddy list: Meghan, Alan, Martin. Meghan's buddy list: Alan, Lori. Toni's buddy list: Lori, Meghan. Martin's buddy list: Lori, Meghan. Alan's buddy list: Martin, Jessica. Lori's buddy list: Meghan. Compute the in/out degree of each vertex. Is the graph connected? Who is the most popular? Least? Who is the most antisocial? If we're having a party and want to distribute the message the most quickly, who should we tell first?