Graph A graph G is a set V(G) of vertices (nodes) and a set E(G) of edges which are pairs of vertices. abcd e i fgh jkl V = { a, b, c, d, e, f, g, h, i,

Slides:



Advertisements
Similar presentations
CS 253: Algorithms Chapter 22 Graphs Credit: Dr. George Bebis.
Advertisements

Analysis of Algorithms CS 477/677
Graph-02.
1 Slides based on those of Kenneth H. Rosen Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Graphs.
1 Representing Graphs. 2 Adjacency Matrix Suppose we have a graph G with n nodes. The adjacency matrix is the n x n matrix A=[a ij ] with: a ij = 1 if.
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.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Wednesday, 9/26/01 Graph Basics.
Graphs1 Part-H1 Graphs ORD DFW SFO LAX
CTIS 154 Discrete Mathematics II1 8.2 Paths and Cycles Kadir A. Peker.
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.
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.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE Discrete.
Graphs Rosen 8.1, 8.2. There Are Many Uses for Graphs! Networks Data organizations Scene graphs Geometric simplification Program structure and processes.
Graphs CS /02/05 Graphs Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved Definition.
Intro to Graphs CSIT 402 Data Structures II. CSIT 402 Graph Introduction2 Graphs Graphs are composed of ›Nodes (vertices) Can be labeled ›Edges (arcs)
Lecture 13 Graphs. Introduction to Graphs Examples of Graphs – Airline Route Map What is the fastest way to get from Pittsburgh to St Louis? What is the.
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
Chapter 2 Graph Algorithms.
Lecture17: Graph I Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Graphs – ADTs and Implementations ORD DFW SFO LAX
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Graphs Chapter 12.
1 CS104 : Discrete Structures Chapter V Graph Theory.
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
Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements.
1/24 Introduction to Graphs. 2/24 Graph Definition Graph : consists of vertices and edges. Each edge must start and end at a vertex. Graph G = (V, E)
Lecture 10: Graph-Path-Circuit
Introduction to Graph Theory
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.
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Basic properties Continuation
Chapter 9: Graphs.
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
Graph Theory Graph Theory - History Leonhard Euler's paper on “Seven Bridges of Königsberg”, published in 1736.
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University Graphs Original Slides by Rada Mihalcea.
CHAPTER 13 GRAPH ALGORITHMS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
Graphs ORD SFO LAX DFW Graphs 1 Graphs Graphs
BCA-II Data Structure Using C Submitted By: Veenu Saini
Graphs 10/24/2017 6:47 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Directed Graphs 12/7/2017 7:15 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
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.
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.
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs ORD SFO LAX DFW Graphs Graphs
Directed Graphs 9/20/2018 1:45 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
CMSC 341 Lecture 21 Graphs (Introduction)
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs.
Graphs ORD SFO LAX DFW Graphs Graphs
Graphs CSE 2011 Winter November 2018.
CS100: Discrete structures
What is a Graph? a b c d e V= {a,b,c,d,e} E= {(a,b),(a,c),(a,d),
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,
Directed Graphs Directed Graphs Directed Graphs 2/23/ :12 AM BOS
Graphs By Rajanikanth B.
Graphs ORD SFO LAX DFW /15/ :57 AM
Graphs.
Graphs G = (V, E) V are the vertices; E are the edges.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
GRAPHS.
Presentation transcript:

Graph A graph G is a set V(G) of vertices (nodes) and a set E(G) of edges which are pairs of vertices. abcd e i fgh jkl V = { a, b, c, d, e, f, g, h, i, j, k, l } E = { (a, b), (a, e), (b, e), (b, f), (c, j), (c, g), (c, h), (d, h), (e, j), (g, k), (g, l), (g, h), (i, j) }

A Directed Graph In a directed graph (digraph), edges are ordered pairs. TW 45 UA 120 AA 49 AA 411 AA 523 AA 1387 DL 335 UA 877 AA 903 DL 247 NW 35 From Goodrich and Tamassia (1998) SFO ORD BOS JFK LAX DFW MIA

Applications of Graphs Graphs describe relationships The Internet Streets / Highways (Roadmaps) Molecules Social Networks Geometric Surfaces (CAD) Circuits Parts in an Assembly … John Yoko Ringo George Paul Linda Flow Charts

More General Graphs A multipgraph allows multiple edges between two vertices. a bdf c A pseudograph is a multigraph that allows self-loops (edges from a vertex to itself)

Edges & Degrees u w v e e 1 2 endpoint incident on u and v degree(u) = 2 deg(w) = 1 b a d e c destination source in-degree(b) = 3 out-degree(b) = 4 u and v are adjacent

Handshaking Theorem Let G = (V, E) be an undirected simple graph. ∑ deg(v) = 2 | E | v  Vv  V If G is directed: ∑∑ v  Vv  Vv  Vv  V indeg(v) = outdeg(v) = | E | | E | ≤ | V | · (| V | – 1) / 2 K has ( ) = 6 edges | E | ≤ | V | · (| V | – 1)

Path A path of length k is a sequence v, v, …, v of vertices such that (v, v ) for i = 0, 1, …, k – 1 is an edge of G. 0 1 k i i+1 g a e j n b f k dc o h l p m q Non-simple path: a, b, e, f, g, b, g, l Simple path: a, e, k, p, l, q m, h, d, c, g (no repeated vertices) b, c, d not a path

Cycle a e j n b f k dc o g h l p m q A cycle is a path that starts and ends at the same vertex. A simple cycle has no repeated vertices. k, j, n, k, p, o,k is not simple.

Subgraph a e j n b f k d c o g h l p m q A subgraph H of G is a graph; its edges and vertices are subsets of those of G. V(H) = {b, d, e, f, g, h, l, p, q} E(H) = {(b, e), (b, g), (e, f), (d, h), (l, p), (l, q)}

Connectivity G is connected if there is a path between every pair of vertices. a b d f e c If G is not connected, the maximal connected subgraphs are the connected components of G. efg a c b d C C C 1 3 2

Strong & Weak Connectivity A directed graph is strongly connected if every two vertices are reachable from each other. a f e c d b It is weakly connected if the underlying undirected graph is connected. f e a d c b

Property of Connectivity Let G = (V, E) be an undirected graph. If G is connected, then | E | ≥ | V | – 1. If G is a tree, then | E | = | V | – 1. If G is a forest, then | E | ≤ | V | – 1.

Adjacency Lists If G is directed, the total length of all the adjacency lists is | E | Adj If G is undirected, the total length is 2 | E |. Space requirement:  (|V| + |E|). Preferable representation.

Adjacency Matrix ij A = (a ) a = ij 1 if (i, j)  E(G) 0 otherwise Space:  (|V| ). 2 Preferred when the graph is small or dense.

Operation Time Operation Adjacency List Adjacency Matrix Scan incident edges  (deg(v))  (|V|) Test adjacency of u and v  (min(deg(u), deg(v))  (1) Scan outgoing edges  (outdeg(v))  (|V|) Scan incoming edges  (indeg(v))  (|V|) Lecture notes modified over Dr. Fernandez-Baca’s Space  (|V|+|E|)  (|V| ) 2