Graph Theory. ICT Theory Excerpt from various sources by Robert Pergl

Similar documents
Review: Graph Theory and Representation

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

Graphs Definitions. Gunnar Gotshalks. GraphDefinitions 1

Graph and Digraph Glossary

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

Varying Applications (examples)

Lecture 5: Graphs & their Representation

Algorithm Design (8) Graph Algorithms 1/2

CS 4407 Algorithms Lecture 5: Graphs an Introduction

Graph Theory. Part of Texas Counties.

Chapter 9 Graph Algorithms

Introduction III. Graphs. Motivations I. Introduction IV

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

1 Digraphs. Definition 1

Lecture 1: Examples, connectedness, paths and cycles

Introduction to Graph Theory

Graphs, graph algorithms (for image segmentation),... in progress

Graphs: Introduction. Ali Shokoufandeh, Department of Computer Science, Drexel University

Elements of Graph Theory

Graphs. Graph G = (V, E) Types of graphs E = O( V 2 ) V = set of vertices E = set of edges (V V)

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

CS 561, Lecture 9. Jared Saia University of New Mexico

CMSC 380. Graph Terminology and Representation

Algorithms: Graphs. Amotz Bar-Noy. Spring 2012 CUNY. Amotz Bar-Noy (CUNY) Graphs Spring / 95

Algorithms. Graphs. Algorithms

Graph Algorithms Using Depth First Search

Lesson 22: Basic Graph Concepts

Basic Graph Definitions

Chapter 9 Graph Algorithms

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

7.3 Spanning trees Spanning trees [ ] 61

Directed Graph and Binary Trees

Definition of Graphs and Trees. Representation of Trees.

Discrete Mathematics

DS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV

Chapter 9 Graph Algorithms

Number Theory and Graph Theory

Graphs. Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale Room - Faner 3131

An Introduction to Graph Theory

Graph Theory: Introduction

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory

Graphs & Digraphs Tuesday, November 06, 2007

Course Introduction / Review of Fundamentals of Graph Theory

Lecture 22 Tuesday, April 10

Chapter 11: Graphs and Trees. March 23, 2008

Lecture 10. Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS

Graph Theory CS/Math231 Discrete Mathematics Spring2015

Introduction to Graphs

Graphs and Genetics. Outline. Computational Biology IST. Ana Teresa Freitas 2015/2016. Slides source: AED (MEEC/IST); Jones and Pevzner (book)

Graph Algorithms: Chapters Part 1: Introductory graph concepts

Characterizing Graphs (3) Characterizing Graphs (1) Characterizing Graphs (2) Characterizing Graphs (4)

Graphs. Outline. Definitions Graph implementation as data structure Visiting algorithms C implementations

Konigsberg Bridge Problem

Introductory Remarks

CSI 604 Elementary Graph Algorithms

Graphs. Introduction To Graphs: Exercises. Definitions:

CS200: Graphs. Prichard Ch. 14 Rosen Ch. 10. CS200 - Graphs 1

CS 220: Discrete Structures and their Applications. graphs zybooks chapter 10

Review of Graph Theory. Gregory Provan

CHAPTER 14 GRAPH ALGORITHMS ORD SFO LAX DFW

Graph Theory. Connectivity, Coloring, Matching. Arjun Suresh 1. 1 GATE Overflow

4. (a) Draw the Petersen graph. (b) Use Kuratowski s teorem to prove that the Petersen graph is non-planar.

Elementary Graph Algorithms

Lecture 3: Recap. Administrivia. Graph theory: Historical Motivation. COMP9020 Lecture 4 Session 2, 2017 Graphs and Trees

Graphs. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1

Undirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1

Algorithm Design and Analysis

Undirected Graphs. Hwansoo Han

BACKGROUND: A BRIEF INTRODUCTION TO GRAPH THEORY

Discrete Structures CISC 2315 FALL Graphs & Trees

Graphs. Motivations: o Networks o Social networks o Program testing o Job Assignment Examples: o Code graph:

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise.

COT 6405 Introduction to Theory of Algorithms

K 4 C 5. Figure 4.5: Some well known family of graphs

CSE 101, Winter Discussion Section Week 1. January 8 - January 15

Graph Overview (1A) Young Won Lim 5/9/18

Graphs (MTAT , 6 EAP) Lectures: Mon 14-16, hall 404 Exercises: Wed 14-16, hall 402

Let G = (V, E) be a graph. If u, v V, then u is adjacent to v if {u, v} E. We also use the notation u v to denote that u is adjacent to v.

DEFINITION OF GRAPH GRAPH THEORY GRAPHS ACCORDING TO THEIR VERTICES AND EDGES EXAMPLE GRAPHS ACCORDING TO THEIR VERTICES AND EDGES

Assignment 4 Solutions of graph problems

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Parallel Graph Algorithms

Chapter 2 Graphs. 2.1 Definition of Graphs

Graphs Introduction and Depth first algorithm

Graphs V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

Elementary Graph Algorithms. Ref: Chapter 22 of the text by Cormen et al. Representing a graph:

Module 11. Directed Graphs. Contents

UNDIRECTED GRAPH: a set of vertices and a set of undirected edges each of which is associated with a set of one or two of these vertices.

Paths. Path is a sequence of edges that begins at a vertex of a graph and travels from vertex to vertex along edges of the graph.

GRAPHS Lecture 19 CS2110 Spring 2013

0.0.1 Network Analysis

Data Structure. IBPS SO (IT- Officer) Exam 2017

IS 709/809: Computational Methods in IS Research. Graph Algorithms: Introduction

Chapter 9: Elementary Graph Algorithms Basic Graph Concepts

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8

Minimum Spanning Trees My T. UF


Transcription:

Graph Theory ICT Theory Excerpt from various sources by Robert Pergl

What can graphs model? Cost of wiring electronic components together. Shortest route between two cities. Finding the shortest distance between all pairs of cities in a road atlas. Flow of material (liquid flowing through pipes, current through electrical networks, information through communication networks, parts through an assembly line, etc). State of a machine (FSM). Used in Operating systems to model resource handling (deadlock problems). Used in compilers for parsing and optimizing the code. 2 Czech University of Life Sciences

What is a Graph? Informally a graph is a set of nodes joined by a set of lines or arrows. 2 3 2 3 4 5 6 4 5 6 3 Czech University of Life Sciences

A directed graph, also called a digraph G is a pair ( V, E ), where the set V is a finite set and E is a binary relation on V. The set V is called the vertex set of G and the elements are called vertices. The set E is called the edge set of G and the elements are edges (also called arcs ). A edge from node a to node b is denoted by the ordered pair ( a, b ). Self loop 2 3 7 Isolated node 4 5 6 V = {, 2, 3, 4, 5, 6, 7 } V = 7 E = { (,2), (2,2), (2,4), (4,5), (4,), (5,4),(6,3) } E = 7 4 Czech University of Life Sciences

An undirected graph G = ( V, E ), but unlike a digraph the edge set E consist of unordered pairs. We use the notation (a, b ) to refer to a directed edge, and { a, b } for an undirected edge. A B C V = { A, B, C, D, E, F } V = 6 D E F E = { {A, B}, {A,E}, {B,E}, {C,F} } E = 4 Some texts use (a, b) also for undirected edges. So ( a, b ) and ( b, a ) refers to the same edge. 5 Czech University of Life Sciences

Degree of a Vertex in an undirected graph is the number of edges incident on it. In a directed graph, the out degree of a vertex is the number of edges leaving it and the in degree is the number of edges entering it. A B C The degree of B is 2. D E F Self-loop 2 The in degree of 2 is 2 and the out degree of 2 is 3. 4 5 6 Czech University of Life Sciences

Simple Graphs Simple graphs are graphs without multiple edges or self-loops. We will consider only simple graphs. Proposition: If G is an undirected graph then Σ deg(v) = 2 E v G Proposition: If G is a digraph then Σ indeg(v) = Σ outdeg(v) = E v G v G 7 Czech University of Life Sciences

A weighted graph is a graph for which each edge has an associated weight, usually given by a weight function w: E R..2 2 3.2.5.5.3 4 5 6 2 2 3 5 4 5 6 3.5 8 Czech University of Life Sciences

A path is a sequence of vertices such that there is an edge from each vertex to its successor. A path from a vertex to itself is called a cycle. A graph is called cyclic if it contains a cycle; otherwise it is called acyclic A path is simple if each vertex is distinct. 2 3 A B C Cycle 4 5 6 D E F Cycle Simple path from to 5 = (, 2, 4, 5 ) or as in our text ((, 2), (2, 4), (4,5)) Unreachable If there is path p from u to v then we say v is reachable from u via p. 9 Czech University of Life Sciences

Walks and Paths V 2 3 V 3 2 V 3 V 6 4 4 V 4 A walk is an sequence of nodes (v, v 2,..., v L ) such that {(v, v 2 ), (v, v 2 ),..., (v, v 2 )} E, e.g. (V 2, V 3,V 6, V 5,V 3 ) A simplepath is a walk with no repeated nodes, e.g. (V, V 4,V 5, V 2,V 3 ) A cycle is an walk (v, v 2,..., v L ) where v =v L with no other nodes repeated and L>3, e.g. (V, V 2,V 5, V 4,V ) A graph is called cyclic if it contains a cycle; otherwise it is called acyclic 0 Czech University of Life Sciences V 5

A Complete graph is an undirected/directed graph in which every pair of vertices is adjacent. If (u, v ) is an edge in a graph G, we say that vertex v is adjacent to vertex u. A B A B E D 4 nodes and (4*3)/2 edges V nodes and V*(V-)/2 edges Note: if self loops are allowed V(V- )/2 +Vedges D 3 nodes and 3*2 edges V nodes and V*(V-) edges Note: if self loops are allowed V 2 edges Czech University of Life Sciences

An undirected graph is connected if you can get from any node to any other by following a sequence of edges OR any two nodes are connected by a path. In an undirected graph, a connected component is a maximal connected subgraph. Adirected graph is strongly connected if there is a directed path from any node to any other node. In a directed graph, a strongly connected component is a maximal strongly connected subgraph. An undirected graph with 3 components 2 Czech University of Life Sciences

Planar Graphs cut-set: a subset of edges whose removal increase the number of components a Ex..2 b d e f h cut-sets: {(a,b),(a,c)}, {(b,d),(c,d)},{(d,f)},... c a bridge g For planar graphs, cycles in one graph correspond to cut-sets in a dual graphs and vice versa. 3 Czech University of Life Sciences

A bipartite graph is an undirected graph G = (V,E) in which V can be partitioned into 2 sets V and V 2 such that ( u,v) E implies either u V and v V 2 OR v V and u V 2. 4 Czech University of Life Sciences

Graphs: Subgraphs A graph G (V,E ) is a subgraph of the graph G(V,E) if V V and E E. Note that this does require G (V,E ) to be a graph, so one cannot form a subgraph of arbitrary subsets of V and E. The second graph below is a subset of the first. a b a b c d c 5 Czech University of Life Sciences

A free tree is an acyclic, connected, undirected graph. A forest is an acyclic undirected graph. A rooted tree is a tree with one distinguished node, root. Let G = (V, E ) be an undirected graph. The following statements are equivalent.. G is a tree 2. Any two vertices in G are connected by unique simple path. 3. G is connected, but if any edge is removed from E, the resulting graph is disconnected. 4. G is connected, and E = V - 5. G is acyclic, and E = V - 6. G is acyclic, but if any edge is added to E, the resulting graph contains a cycle. 6 Czech University of Life Sciences

Spanning Tree Spanning tree T of a connected, undirected graph G is a tree composed of all the vertices and some (or perhaps all) of the edges of G. Informally, a spanning tree of G is a selection of edges of G that form a tree spanning every vertex. That is, every vertex lies in the tree, but no cycles (or loops) are formed. On the other hand, every bridge of G must belong to T. A spanning tree of a connected graph G can also be defined as a maximal set of edges of G that contains no cycle, or as a minimal set of edges that connect all vertices. 7 Czech University of Life Sciences

Implementation of a Graph. Adjacency-list representation of a graph G = ( V, E ) consists of an array ADJ of V lists, one for each vertex in V. For each u V, ADJ [ u ] points to all its adjacent vertices. 2 2 2 5 5 3 4 5 3 3 4 4 2 4 2 5 3 5 4 2 8 Czech University of Life Sciences

Adjacency-list representation for a directed graph. 2 2 2 5 5 3 4 5 3 3 4 4 5 4 5 5 Variation: Can keep a second list of edges coming into a vertex. 9 Czech University of Life Sciences

Adjacency lists Advantage: Saves space for sparse graphs. Most graphs are sparse. Visit edges that start at v Must traverse linked list of v Size of linked list of v is degree(v) θ(degree(v)) Disadvantage: Check for existence of an edge (v, u) Must traverse linked list of v Size of linked list of v is degree(v) θ(degree(v)) 20 Czech University of Life Sciences

Adjacency List Storage We need V pointers to linked lists For a directed graph the number of nodes (or edges) contained (referenced) in all the linked lists is Σ(out-degree (v)) = E. So we need Θ( V + E) v V For an undirected graph the number of nodes is Σ(degree (v)) = 2 E Also Θ( V + E) v V 2 Czech University of Life Sciences

Adjacency-matrix-representation of a graph G = ( V, E) is a V x V matrix A = ( a ij ) such that a ij = (or some Object) if (i, j ) E and 0 (or null) otherwise. 0 0 2 3 4 4 3 2 0 2 3 4 0 0 0 0 0 0 0 0 0 0 0 22 Czech University of Life Sciences

Adjacency Matrix Representation for a Directed Graph 0 2 3 4 0 4 3 2 0 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23 Czech University of Life Sciences

Adjacency Matrix Representation Advantage: Saves space on pointers for dense graphs, and on small unweighted graphs using bit per edge. Check for existence of an edge (v, u) (adjacency [i] [j]) == true?) So θ() Disadvantage: visit all the edges that start at v Row v of the matrix must be traversed. So θ( V ). 24 Czech University of Life Sciences

Adjacency Matrix Representation Storage Θ( V 2 ) ( We usually just write, Θ( V 2 ) ) For undirected graphs you can save storage (only /2(V 2 )) by noticing the adjacency matrix of an undirected graph is symmetric. Need to update code to work with new representation. Gain in space is offset by increase in the time required by the methods. 25 Czech University of Life Sciences