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

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

Graphs. Introduction To Graphs: Exercises. Definitions:

Chapter 9 Graph Algorithms

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

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list

Konigsberg Bridge Problem

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

Chapter 9 Graph Algorithms

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

Chapter 9 Graph Algorithms

1 Digraphs. Definition 1

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

Graphs. Pseudograph: multiple edges and loops allowed

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1

GRAPHICAL ALGORITHMS. UNIT _II Lecture-12 Slides No. 3-7 Lecture Slides No Lecture Slides No

Varying Applications (examples)

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

CMSC 380. Graph Terminology and Representation

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

Foundations of Discrete Mathematics

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207.

This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science.

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

Logic: The Big Picture. Axiomatizing Arithmetic. Tautologies and Valid Arguments. Graphs and Trees

Graph and Digraph Glossary

CS302 - Data Structures using C++

Graph Theory. Part of Texas Counties.

CS6702 GRAPH THEORY AND APPLICATIONS 2 MARKS QUESTIONS AND ANSWERS

UNIT III TREES. A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items.

Introduction to Graph Theory

Basic Graph Definitions

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.

國立清華大學電機工程學系. Outline

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

Chapter 1 Graph Theory

An Introduction to Graph Theory

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

2. CONNECTIVITY Connectivity

V :non-empty vertex ornode set E V V :edge set G (V, E) :directed graph on V, or digraph on V

Discrete mathematics II. - Graphs

0.0.1 Network Analysis

CS 311 Discrete Math for Computer Science Dr. William C. Bulko. Graphs

CS 4407 Algorithms Lecture 5: Graphs an Introduction

Introduction III. Graphs. Motivations I. Introduction IV

Fundamental Properties of Graphs

CSC Intro to Intelligent Robotics, Spring Graphs

CS 206 Introduction to Computer Science II

Outline. Graphs. Divide and Conquer.

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

Chapter 2 Graphs. 2.1 Definition of Graphs

Ordinary Differential Equation (ODE)

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

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.

PATH FINDING AND GRAPH TRAVERSAL

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

Math 776 Graph Theory Lecture Note 1 Basic concepts

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

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. Graph Theory

Algorithm Design (8) Graph Algorithms 1/2

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

EECS 1028 M: Discrete Mathematics for Engineers

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

Introduction to Mathematical Programming IE406. Lecture 16. Dr. Ted Ralphs

Combinatorics Summary Sheet for Exam 1 Material 2019

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

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

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

Compatible circuits in eulerian digraphs

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

Undirected Graphs. Hwansoo Han

Chapter 6. GRAPHS. Figure 6.1 : The bridges of Koenigsberg

Module 2: NETWORKS AND DECISION MATHEMATICS

Elements of Graph Theory

Graph Theory. Many problems are mapped to graphs. Problems. traffic VLSI circuits social network communication networks web pages relationship

BACKGROUND: A BRIEF INTRODUCTION TO GRAPH THEORY

Graphs. The ultimate data structure. graphs 1

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

Unweighted Graphs & Algorithms

Crossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia)

Graph theory: basic concepts

Graphs Definitions. Gunnar Gotshalks. GraphDefinitions 1

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

CHAPTER 14 GRAPH ALGORITHMS ORD SFO LAX DFW

8.2 Paths and Cycles

Network models and graph theory

Graph. Vertex. edge. Directed Graph. Undirected Graph

Graphs. Data Structures 1 Graphs

Some Graph Theory for Network Analysis. CS 249B: Science of Networks Week 01: Thursday, 01/31/08 Daniel Bilar Wellesley College Spring 2008

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

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

Module 11. Directed Graphs. Contents

Graphs and Trees. An example. Graphs. Example 2

BIL694-Lecture 1: Introduction to Graphs

Introduction to Graphs. common/notes/ppt/

Reference Sheet for CO142.2 Discrete Mathematics II

Various Graphs and Their Applications in Real World

Graph Theory CS/Math231 Discrete Mathematics Spring2015

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

Graph Algorithms Using Depth First Search

Transcription:

Graph Chapter 9

Outline Introduction Definitions and Basic Terminologies Representations of Graphs Graph Traversals Breadth first traversal Depth first traversal Applications Single source shortest path problem Minimum cost spanning trees ADT for graphs

Introduction The history of graphs dates back to 1736 in what is now referred to as the classical Koenigsberg bridge problem. Euler solved the problem with a theory that laid the foundation for graph theory Definition and Basic terminology A graph G = (V, E) consists of a finite non empty set of vertices V also called points or nodes and a finite set E of unordered pairs of distinct vertices called edges or arcs or links.

Definition cont.. V : Vertices : {a, b, c, d} E : edges : {e1, e2, e3, e4}e e1 a b e3 e3 e2 e2 c d e4 e4

Terminology A graph G = (V, E) where E = Φ, is called as a null or empty graph. A graph with one vertex and no edges is called a trivial graph A multigraph G = (V, E) also consists of a set of vertices and edges except that E may contain multiple edges (i.e.) edges connecting the same pair of vertices, or may contain loops or self edges (i.e.) an edge whose end points are the same vertex A graph whose definition makes reference to unordered pairs of vertices as edges is known as an undirected graph On the other hand, directed graphs or digraphs make reference to edges which are directed (i.e.) edges which are ordered pairs of vertices.

A complete graphs & a sub-graph The number of distinct unordered pairs (vi, vj), vi vj in a graph with n vertices is C n.(n 1) n 2 2 An n vertex undirected graph with exactly n.( n 1) edges is 2 said to be complete In the case of a digraph with n vertices, the maximum n number of edges is given by P2=n.(n 1) Such a graph with exactly n.(n-1) edges is said to be a complete digraph

A subgraph G = (V,E ) of a graph G = (V, E) is such that V V and E E.

Path A path from a vertex v to vertex vi in an undirected graph G is a sequence of vertices vi,vl1,vl2,vl3,,vlk, vj. such that (vi,vl1) (vl1,vl2),.(vlk,vj ) are edges in G. If G is directed then the path from vi to vj more specially known as a directed path consists of edges <vi,vl1 > <vl1,vl2>... <vlk,vj > in G. The length of a path is the number of edges on it. A simple path is a path in which all the vertices except possibly the first and last vertices are distinct. A cycle is a simple path in which the first and last vertices are the same. A cycle is also known as a circuit, elementary cycle, circular path or polygon.

The graph path

Connected graph Two vertices vi, vj in a graph G are said to be connected only if there is a path in G between vi and vj An undirected graph is said to be a connected graph if every pair of distinct vertices vi, vj are connected. In the case of an undirected graph which is not connected, the maximal connected subgraph is called as a connected component or simply a component. A directed graph is said to be strongly connected if every pair of distinct vertices vi, vj are connected (by means of a directed path). A strongly connected component is a maximal subgraph that is strongly connected.

Tree and Degree A tree is defined to be a connected acyclic graph. The following properties are satisfied by a tree: (i) There exists a path between any two vertices of the tree, and (ii) No cycles must be present in the tree. In other words, trees are acyclic

The degree of a vertex in an undirected graph is the number of edges incident to that vertex. A vertex with degree one is called as a pendant vertex or end vertex. A vertex with degree zero and hence has no incident edges is called an isolated vertex. In the case of digraphs, we define the indegree of a vertex v to be the number of edges with v as the head and the outdegree of a vertex to be number of edges with v as the tail.

Isomorphic & cut set Two graphs are said to be isomorphic if, they have the same number of vertices they have the same number of edges they have an equal number of vertices with a given degree.

A cut set in a connected graph G is the set of edges whose removal from G leaves G disconnected, provided the removal of no proper subset of these edges disconnects the graph G.

A graph G is called a labeled graph if its edges and / or vertices are assigned some data. In particular if the edge e is assigned a non negative number l(e) then it is called the weight or length of the edge e. A walk starting at any vertex going through each edge exactly once and terminating at the start vertex is called an Eulerian walk or Euler line

Hamiltonian Circuit A Hamiltonian circuit in a connected graph is defined as a closed walk that traverses every vertex of G exactly once, except of course the starting vertex at which the walk terminates A circuit in a connected graph G is said to be Hamiltonian if it includes every vertex of G. If any edge is removed from a Hamiltonian circuit then what remains is referred to as a Hamiltonian path. Hamiltonian path traverses every vertex of G.

Representation of graph The sequential or the matrix representation of graphs have the following methods: Adjacency matrix representation Incidence matrix representation Circuit matrix representation Cut set matrix representation Path matrix representation Linked representation of graphs

Adjacency Matrix

Incidence matrix

Circuit matrix representation

Cut set matrix representation

Path matrix representation

Linked list graph representation Adjacency list representation of a graph

Graph traversal-breadth first Traversal Algorithm 9.1 Breadth first traversal Procedure BFT(s) /* s is the start vertex of the traversal in an undirected graph G, Q is a queue which keeps track of the vertices whose adjacent nodes are to be visited Vertices which have been visited have their visited flags set to 1 (i.e.) visited (vertex) = 1. Initially, visited (vertex) = 0 for all vertices of graph G */ Initialize queue Q; visited(s) = 1; call ENQUEUE (Q,s); /* insert s into Q */ while not EMPTY_QUEUE(Q) do /* process until Q is empty */ call DEQUEUE (Q,s) /* delete s from Q*/ print (s); /* output vertex visited */ for all vertices v adjacent to s do if (visited (v) = 0) then { call ENQUEUE (Q,v); visited (v) =1; } end endwhile end BFT.

Breadth First traversal

Graph traversal-depth first traverse Procedure DFT(s) /* s is the start vertex */ visited(s) = 1; print (s); /* Output visited vertex for each vertex v adjacent to s do if visited(v) = 0 then call DFT(v); end end DFT */

Depth first traversal

Application of graph Determination of shortest path (Single Source Shortest path problem) Dijkstra SSSP Algorithm, and Extraction of minimum cost spanning trees.

Dijkstra SSSP Algorithm Algorithm 9.3 : Dijkstra s algorithm for the single source shortest path problem. Procedure DIJKSTRA_SSSP(N, COST) /*N is the number of vertices labeled { 1, 2, 3, N} of the weighted digraph. COST[1:N,1:N] is the cost matrix of the graph. If there is no edge then COST [i,j] = **//* The procedure computes the cost of the shortest path from vertex 1 the source, to every other vertex of the weighted digraph */ T = {1}; /* Initialize T to source vertex */ for i = 2 to N do DISTANCE[i] = COST[1,i]; /*Initialize DISTANCE vector to the cost of the edges connecting vertex i with the source vertex 1 If there is no edge then COST [1, i] = end for i = 1 to N 1 do Choose a vertex u in V T such that DISTANCE[u] is a minimum; Add u to T; for each vertex w in V-T do DISTANCE[w] = minimum(distance[w],distance[u] + COST[u,w] ); end end end procedure **/

Example Dijikstra Algorithm

Minimum Cost Spanning tree Let G = (V, E) be an undirected connected graph. A subgraph T = (V, E ) of G is a spanning tree of G iff T is a tree. Given G = (V, E) to be a connected, weighted undirected graph where each edge involves a cost, the extraction of a spanning tree extends itself to the extraction of a minimum cost spanning tree. A minimum cost spanning tree is a spanning tree which has a minimum total cost.

ADTs for Graph Data objects: A graph G of vertices and edges. Vertices represent data. Operations: Check if graph G is empty CHECK_GRAPH_EMPTY (G) (Boolean function) Insert an isolated vertex V into a graph G. Ensure that V does not exist in G before insertion. :INSERT_VERTEX (G, V) Insert an edge connecting vertices U, V into a graph G. Ensure that such an edge does not exist in G before insertion. :INSERT_EDGE(G, U, V) Delete vertex V and all the edges incident on it from the graph G. Ensure that such a vertex exists in the graph before deletion. :DELETE_VERTEX (G, V) Delete an edge from the graph G connecting the vertices U, V. Ensure that such an edge exists before deletion. : DELETE_EDGE (G, U, V)

Cont.. Store ITEM into a vertex V of graph G Retrieve data of a vertex V in the graph G and return it in ITEM RETRIEVE_DATA (G, V, ITEM) Perform Breadth first traversal of a graph G. STORE_DATA(G, V, ITEM) BFT (G) Perform Depth first traversal of a graph G. DFT(G)