Graph Terminology CSE 373 Data Structures.

Slides:



Advertisements
Similar presentations
Graphs COL 106 Slide Courtesy : Douglas W. Harder, U Waterloo.
Advertisements

 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
1 Section 8.2 Graph Terminology. 2 Terms related to undirected graphs Adjacent: 2 vertices u & v in an undirected graph G are adjacent (neighbors) in.
CSE 321 Discrete Structures Winter 2008 Lecture 25 Graph Theory.
Applied Discrete Mathematics Week 12: Trees
Chapter 9: Graphs Basic Concepts
Graphs Rosen 8.1, 8.2. There Are Many Uses for Graphs! Networks Data organizations Scene graphs Geometric simplification Program structure and processes.
9.2 Graph Terminology and Special Types Graphs
Intro to Graphs CSIT 402 Data Structures II. CSIT 402 Graph Introduction2 Graphs Graphs are composed of ›Nodes (vertices) Can be labeled ›Edges (arcs)
Graphs Chapter 10.
1 Graphs Chapters 9.1 and 9.2 University of Maryland Chapters 9.1 and 9.2 Based on slides by Y. Peng University of Maryland.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Module #19: Graph Theory: part I Rosen 5 th ed., chs. 8-9 내년 3 월 ? 교환 학생 프로그램 영어 점수 미리미리 준비하세요.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
9.2: Graph Terminology. Special Simple Graphs Complete GraphsK 1,… CyclesC 3,… WheelsW 3,… N-cubesQ 1,… Complete bipartiteK 2,2,…
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
1 CS104 : Discrete Structures Chapter V Graph Theory.
9 Graphs. A graph G = (V, E) consists of V, a nonempty set of vertices (or nodes) and E, a set of edges. Each edge has either one or two vertices associated.
COSC 2007 Data Structures II Chapter 14 Graphs I.
Graphs 9.1 Graphs and Graph Models أ. زينب آل كاظم 1.
Graphs A graphs is an abstract representation of a set of objects, called vertices or nodes, where some pairs of the objects are connected by links, called.
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.
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
Graphs Basic properties.
1 Graphs Terminology By: Sandeep Tuli Astt. Prof. CSE.
Chapter 9: Graphs.
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
1 Graphs Chapters 10.1 and 10.2 University of Maryland Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
Chapter Chapter Summary Graphs and Graph Models Graph Terminology and Special Types of Graphs Representing Graphs and Graph Isomorphism Connectivity.
Graphs.
Chapter 9 (Part 1): Graphs
Applied Discrete Mathematics Week 13: Graphs
Graphs: Definitions and Basic Properties
Graph Representations
Lecture 19: CONNECTIVITY Sections
Basic Concepts Graphs For more notes and topics visit:
Copyright © Zeph Grunschlag,
Graph Graphs and graph theory can be used to model:
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.
COT 3100, Spring 2001 Applications of Discrete Structures
Chapters 8.1 and 8.2 Based on slides by Y. Peng University of Maryland
Graphs and Graph Models
Graphs Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
Graphs CSE 2011 Winter November 2018.
Chapters 8.1 and 8.2 Based on slides by Y. Peng University of Maryland
CS100: Discrete structures
Chapter 9: Graphs Basic Concepts
Graphs.
Graph Terminology CSE 373 Data Structures.
CC 215 Data Structures Graph Terminology
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
Let us switch to a new topic:
Graphs By Rajanikanth B.
Lecture 10: Graphs Graph Terminology Special Types of Graphs
Graphs.
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
Chapter 5 Graphs the puzzle of the seven bridge in the Königsberg,
Graph Algorithms DS.GR.1 Chapter 9 Overview Representation
Chapter 10 Graphs and Trees
Graphs: Definitions How would you represent the following?
Chapter 9: Graphs Basic Concepts
CSE 373 Data Structures Lecture 13
Graphs G = (V,E) V is the vertex set.
GRAPHS.
Heaps Chapter 6 Section 6.9.
Presentation transcript:

Graph Terminology CSE 373 Data Structures

CSE 373 AU 04 -- Graph Terminology Reading Reading Goodrich and Tamassia, Chapter 12 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology What are graphs? Yes, this is a graph…. But we are interested in a different kind of “graph” 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Graphs Graphs are composed of Nodes (vertices) Edges (arcs) node edge 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Varieties Nodes Labeled or unlabeled Edges Directed or undirected 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Motivation for Graphs node node Consider the data structures we have looked at so far… Linked list: nodes with 1 incoming edge + 1 outgoing edge Binary trees/heaps: nodes with 1 incoming edge + 2 outgoing edges B-trees: nodes with 1 incoming edge + multiple outgoing edges Value Next Value Next 94 10 97 3 5 96 99 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Motivation for Graphs How can you generalize these data structures? Consider data structures for representing the following problems… 4/29/2019 CSE 373 AU 04 -- Graph Terminology

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 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Representing a Maze S S B E E Nodes = rooms Edge = door or passage 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Representing Electrical Circuits Battery Switch Nodes = battery, switch, resistor, etc. Edges = connections Resistor 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Program statements x1 x2 x1=q+y*z + - x2=y*z-q Naive: q * * q y*z calculated twice y z x1 x2 common subexpression + - eliminated: q * q Nodes = symbols/operators Edges = relationships y z 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Precedence S1 a=0; S2 b=1; S3 c=a+1 S4 d=b+a; S5 e=d+1; S6 e=c+d; 6 5 Which statements must execute before S6? S1, S2, S3, S4 4 3 Nodes = statements Edges = precedence requirements 2 1 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Information Transmission in a Computer Network Sydney 56 Tokyo Seattle Seoul 128 New York 16 181 30 140 L.A. Nodes = computers Edges = transmission rates 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Traffic Flow on Highways UW Nodes = cities Edges = # vehicles on connecting highway 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Graph Definition A graph is simply a collection of nodes plus edges Linked lists, trees, and heaps are all special cases of graphs The nodes are known as vertices (node = “vertex”) Formal Definition: A graph G is a pair (V, E) where V is a set of vertices or nodes E is a set of edges that connect vertices 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Graph Example Here is a directed graph G = (V, E) Each edge is a pair (v1, v2), where v1, v2 are vertices in V V = {A, B, C, D, E, F} E = {(A,B), (A,D), (B,C), (C,D), (C,E), (D,E)} B C A F D E 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Directed vs Undirected Graphs If the order of edge pairs (v1, v2) matters, the graph is directed (also called a digraph): (v1, v2)  (v2, v1) If the order of edge pairs (v1, v2) does not matter, the graph is called an undirected graph: in this case, (v1, v2) = (v2, v1) v2 v1 v1 v2 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Undirected Terminology Two vertices u and v are adjacent in an undirected graph G if {u,v} is an edge in G edge e = {u,v} is incident with vertex u and vertex v Some undirected graphs allow “self loops”. These will need slightly different notation, because {u,u} = {u}. Therefore, use [u,v] and [u,u] to represent the edges of such graphs. The degree of a vertex in an undirected graph is the number of edges incident with it a self-loop counts twice (both ends count) denoted with deg(v) 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Undirected Graph Terminology Edge [A,B] is incident to A and to B B is adjacent to C and C is adjacent to B B C Self-loop A F D E Degree = 0 Degree = 3 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Directed Graph Terminology Vertex u is adjacent to vertex v in a directed graph G if (u,v) is an edge in G vertex u is the initial vertex of (u,v) Vertex v is adjacent from vertex u vertex v is the terminal (or end) vertex of (u,v) Degree in-degree is the number of edges with the vertex as the terminal vertex out-degree is the number of edges with the vertex as the initial vertex 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Directed Terminology B adjacent to C and C adjacent from B B C A F D E In-degree = 0 Out-degree = 0 In-degree = 2 Out-degree = 1 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Handshaking Theorem Let G=(V,E) be an undirected graph with |E|=e edges. Then Every edge contributes +1 to the degree of each of the two vertices it is incident with number of edges is exactly half the sum of deg(v) the sum of the deg(v) values must be even Add up the degrees of all vertices. 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Graph Representations Space and time are analyzed in terms of: Number of vertices = |V| and Number of edges = |E| There are at least two ways of representing graphs: The adjacency matrix representation The adjacency list representation 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Adjacency Matrix A B C D E F B A B C D E F 0 1 0 1 0 0 C A 1 0 1 0 0 0 F 0 1 0 1 1 0 D E 1 0 1 0 1 0 0 0 1 1 0 0 1 if [v, w] is in E M(v, w) = 0 0 0 0 0 0 0 otherwise Space = |V|2 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Adjacency Matrix for a Digraph A B C D E F B A B C D E F 0 1 0 1 0 0 C A 0 0 1 0 0 0 F 0 0 0 1 1 0 D E 0 0 0 0 1 0 0 0 0 0 0 0 1 if (v, w) is in E M(v, w) = 0 0 0 0 0 0 0 otherwise Space = |V|2 4/29/2019 CSE 373 AU 04 -- Graph Terminology

CSE 373 AU 04 -- Graph Terminology Adjacency List For each v in V, L(v) = list of w such that [v, w] is in E a b A B C D E F list of neighbors B B D C A A C B D E F D E A C E C D Space = a |V| + 2 b |E| 4/29/2019 CSE 373 AU 04 -- Graph Terminology

Adjacency List for a Digraph For each v in V, L(v) = list of w such that (v, w) is in E a b A B C D E F B B D C A C F D E D E E Space = a |V| + b |E| 4/29/2019 CSE 373 AU 04 -- Graph Terminology