Concepts of Computation

Slides:



Advertisements
Similar presentations
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
Advertisements

Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Introduction to Graphs
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.
SE561 Math Foundations Week 11 Graphs I
Graph Theory in CS Route Search in Online Map Services
CTIS 154 Discrete Mathematics II1 8.2 Paths and Cycles Kadir A. Peker.
Selected Topics in Data Networking Graph Representation.
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.
Social Media Mining Graph Essentials.
9.2 Graph Terminology and Special Types Graphs
Graphs Chapter 10.
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,
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.
1 CS104 : Discrete Structures Chapter V Graph Theory.
GRAPHS THEROY. 2 –Graphs Graph basics and definitions Vertices/nodes, edges, adjacency, incidence Degree, in-degree, out-degree Subgraphs, unions, isomorphism.
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.
Graphs What are Graphs? General meaning in everyday math: A plot or chart of numerical data using a coordinate system. Technical meaning in discrete.
Basic Notions on Graphs. The House-and-Utilities Problem.
1 12/2/2015 MATH 224 – Discrete Mathematics Formally a graph is just a collection of unordered or ordered pairs, where for example, if {a,b} G if a, b.
COSC 2007 Data Structures II Chapter 14 Graphs I.
Chapter 5 Graphs  the puzzle of the seven bridge in the Königsberg,  on the Pregel.
Graph Theory and Applications
Lecture 10: Graph-Path-Circuit
Graphs 9.1 Graphs and Graph Models أ. زينب آل كاظم 1.
Basic properties Continuation
Discrete Structures CISC 2315 FALL 2010 Graphs & Trees.
Graphs Basic properties.
1 Graphs Terminology By: Sandeep Tuli Astt. Prof. CSE.
Chapter 9: Graphs.
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
Chapter 05 Introduction to Graph And Search Algorithms.
Chap 7 Graph Def 1: Simple graph G=(V,E) V : nonempty set of vertices E : set of unordered pairs of distinct elements of V called edges Def 2: Multigraph.
GRAPH THEORY Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
Fundamental Graph Theory (Lecture 1) Lectured by Hung-Lin Fu 傅 恆 霖 Department of Applied Mathematics National Chiao Tung University.
Chapter Chapter Summary Graphs and Graph Models Graph Terminology and Special Types of Graphs Representing Graphs and Graph Isomorphism Connectivity.
BCA-II Data Structure Using C Submitted By: Veenu Saini
An Introduction to Graph Theory
Applied Discrete Mathematics Week 13: Graphs
Copyright © Zeph Grunschlag,
COT 3100, Spring 2001 Applications of Discrete Structures
Chapter 5 Fundamental Concept
Graph theory Definitions Trees, cycles, directed graphs.
Agenda Lecture Content: Introduction to Graph Path and Cycle
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Graphs Slides are adopted from “Discrete.
CSE373: Data Structures & Algorithms Lecture 16: Introduction to Graphs Linda Shapiro Winter 2015.
Advanced Algorithms Analysis and Design
Graphs Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
CSE373: Data Structures & Algorithms Lecture 16: Introduction to Graphs Linda Shapiro Spring 2016.
Foundations of Discrete Mathematics
Rosen 5th ed., chs. 8-9 ~44 slides (more later), ~3 lectures
Graphs All tree structures are hierarchical. This means that each node can only have one parent node. Trees can be used to store data which has a definite.
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),
Representing Graphs Wade Trappe.
Let us switch to a new topic:
Lecture 5.3: Graph Isomorphism and Paths
GRAPHS Lecture 17 CS2110 Spring 2018.
5/9/2019 Discrete Math II Howon Kim
Paths and Connectivity
Paths and Connectivity
Applied Discrete Mathematics Week 13: Graphs
Concepts of Computation
Agenda Review Lecture Content: Shortest Path Algorithm
GRAPHS.
Concepts of Computation
Presentation transcript:

Concepts of Computation Session 8a Graphs Dr Oded Lachish Email: oded@dcs.bbk.ac.uk (Slides prepared with the support of Dr Paul Newman and Eva Szatmari)

Graphs Graphs What is a graph? Representation of graphs Vertex degrees etc. Connectivity of graphs

Before we had Smart Phones and Navigation apps We used a map. The map was usually very detailed and in big cities it took an effort to just find where you. Now we have smart phones. So instead of navigating with a map, we let the smart phone give us the instructions. Does the smart phone look at the map? Sort of

Computers and maps For a computer to take a look at a map requires a lot of effort. They don’t just see the whole picture, they have to look pixel by pixel. So just looking at a map like we used to, is too much. In reality, to navigate we don’t really need an exact map and it doesn’t need to have so much information. Have you tried walking from king cross St Pancras to Caledonian road just because they are close on the map (I did)

Underground map The underground map contains just the information required for navigating the underground. It is not good for navigating in London. The same idea is used in computers. What the computer stores as a “map” is only the information that is required for its purposes. Lets suppose that the purpose of the computer is to tell you how to go from one junction to another junction

Computer “maps” Lets suppose that the purpose of the computer is to tell you how to go from one junction to another junction What does the computer need to know: All the junctions All the roads between pairs of junctions and the junctions they are between (we assume that a road does not have junctions in the middle. This enables a cleaner mathematical definition later on) The length of the road Opening hours (The road through Hyde park is locked at night) And other stuff

Computer “maps” Lets suppose that the purpose of the computer is to tell you how to go from one junction to another junction Lets assume that at the beginning all the roads are always open and we only want the computer to find us a route, we don’t care if it the shortest route Now what does the computer need to know: All the junctions All the roads between pairs of junctions and the junctions they are between How do we do this mathematically. Sets

Computer “maps” and Sets Now what does the computer need to know: All the junctions All the roads between pairs of junctions and the junctions they are between Lets have a set of all the junctions, call it V We also need a set for the roads. Lets call that set E. We don’t need the names of the roads, we just need the two junctions they are between (we assume no two roads are between the same two junctions). So, lets represent every road by a set of size 2, containing the two junctions it connects. Conclusion all the sets in E are subsets of V, each of size 2. We almost fully defined a graph. Graphs are very useful and studied. That’s why we formally define them in the next slide.

Graph Ordered, pair because the set on the left is A graph (G) consists of two things: A set V, whose elements are called vertices A set E of unordered pairs (size two sets) of vertices, called edges The graph is denoted G=(V,E) Two vertices u and v in V are adjacent in G if and only if {u,v} ∈𝐸 Ordered, pair because the set on the left is the set of vertices and the set on the right is the set of edges.

Diagrammatic Representation One dot for each vertex, v in V Each edge e = {v1,v2} represented by a line connecting v1 and v2 e4 v1 v4 V = {v1,v2 ,v3,v4} Edges: e1 = {v1,v2}, e2 = {v2,v3} e3 = {v3,v4}, e4 = {v1,v4} e5 = {v1,v3} e1 e3 e5 v2 v3 e2

Multigraphs etc. For every two vertices in a graph, there are one or zero edges connecting two vertices If we need more that one edge between the same two vertices v1 and v2 (parallel edges) we use a generalization of a graph called a multigraph. In a multigraph, we can also have loops, where a loop is an edge between a vertex and itself. A multigraph is finite if we have a finite number of edges and vertices. Remark: In a multigraph, V is a multi set. A multi-set is a generalization of a set in the sense that it allows elements to repeat and you can know how many time each element appears.

Multigraph example e6 e1 v1 v4 e2 e3 e4 v2 v3 e5

Subgraph G(V,E) is a graph. If V’ is a subset of V and E’ is a subset of E whose endpoints belong to V’ Then G(V’,E’) is a subgraph of G(V,E) If E’ contains all the edges from E whose endpoints are in V’, then G(V’,E’) is the subgraph generated by V’

Subgraph example G1 = (V1, E1) v1 G = (V,E) v1 v4 v5 v2 v5 v3 v2 v1 G1=(V1, E1) is a subgraph of G but not an induced subgraph of G (missing {v1,v2} ) G2=(V2, E2) is a an induced subgraph of G G2 = (V2, E1) v1 v5 v2

Degree If v is an endpoint of edge e, then e is incident on v The degree of vertex v, written deg(v), is the number of edges which are incident on v If deg(v) = 0, then the vertex is called isolated Each edge connects two vertices, so the sum of deg(v) is twice the number of edges A vertex is odd if and only if deg(v) is odd A vertex is even if and only if deg(v) is even

Example e4 v1 v2 e1 e3 v5 e5 v3 v4 e2 deg (v1) = 3, deg (v2) = 2, deg (v4) = 3, deg (v3) = 2, deg (v5) = 0 v2, v3 and v5 are even; v1 and v4 are odd v5 is isolated

Directed graphs A directed graph (or digraph) with direction assigned to each edge These directed edges are called arcs and denoted a = <u,v> for an arc connecting initial point u to terminal point v The outdegree, of a vertex v, is the number of arcs beginning at v, the indegree is the number of arcs ending a v A source has zero indegree; a sink has zero outdegree

Walk, Trail, Path A walk in a graph is a series of vertices linked with the edges connecting them. e.g. v0,e1,v1,e2,v2, …, en-1, vn-1, en, vn , where edge ei is incident on vi-1 and vi The number of edges, n, is the length of the walk A trail is a walk where all edges are unique (vertices can repeat, but edges cannot) A path is a walk where all vertices are unique with the exception that the first and last may be the same (a path is therefore also a trail)

Notation, Walk, Trail, Path Formally describing a walk, trail and path is done using a tuple of only vertices. On the graph on the right The following is a walk (v1, v2, v3, v4, v2, v3) Which actually means: (v1,{v1, v2}, v2,{v2, v3}, v3, {v3, v4}, v4, {v4, v2}, v2, {v2, v3}, v3) If one of the edges was missing this is not a walk! v1 v2 v3 v4 v6

A circuit is a closed trail, except v0 = vn A walk (v1, v2, …, vn) is closed if v1 = vn, otherwise the walk is from (or between or connects) v1 to vn A circuit is a closed trail, except v0 = vn A simple cycle is a path with the same first and last vertices A cycle of length k is called a k-cycle. The minimum value of k is 3. (v1, v2, …, vn )- this notation is used in order to indicate that we describing a general walk. What the first line means is that a walk is closed if and only if the first and the last vertices in the walk are the same.

Example v1 v2 v3 v4 v5 v6 (v4, v1, v2, v5, v1, v2, v3, v6) Is a walk from, because all pairs of consecutive vertices correspond to an edge in the graph (you need to check this) It is not a trail, because {v1, v2} appears twice, It is not a path because it is not a trail (edges repeating means vertices repeating – in this case v1 and v2) It is not a closed walk, cycle or circuit, because the first and last vertices are different Length 7 The shortest path from P4 to P6 is (P4,P5,P6) which has length 2 This shows that by eliminated unnecessary edges, any walk from a vertex u to a vertex v can be replaced by a path from u to v

Example v1 v2 v3 v4 v5 v6 (v4, v1, v5, v2, v6) Is not a walk, because {v2, v6} is not an edge in the graph Is not anything else on the list, because it is not a walk Doesn’t have a length, because it is not a walk The shortest path from P4 to P6 is (P4,P5,P6) which has length 2 This shows that by eliminated unnecessary edges, any walk from a vertex u to a vertex v can be replaced by a path from u to v

Example v1 v2 v3 v4 v5 v6 (v4, v1, v5, v2, v3, v5, v6) Is a trail, because all pairs of consecutive vertices correspond to an edge in the graph and no edge repeats itself Is a walk, because every walk is also a trail Is not a path because v5 repeats itself It is not a closed walk, cycle or circuit, because the first and last vertices are different Length 6 The shortest path from P4 to P6 is (P4,P5,P6) which has length 2 This shows that by eliminated unnecessary edges, any walk from a vertex u to a vertex v can be replaced by a path from u to v

Example v1 v2 v3 v4 v5 v6 (v4, v1, v5, v3, v6) Is a path, because all pairs of consecutive vertices correspond to an edge in the graph and no vertex repeats itself Is a walk and trail, because every path is also a trail and a walk It is not a closed walk, cycle or circuit, because the first and last vertices are different Length 4 The shortest path from P4 to P6 is (P4,P5,P6) which has length 2 This shows that by eliminated unnecessary edges, any walk from a vertex u to a vertex v can be replaced by a path from u to v

Example v1 v2 v3 v4 v5 v6 (v1, v2, v3, v5, v2, v1) Is a closed walk, because the first and last vertices are the same and all pairs of consecutive vertices correspond to an edge in the graph It is not a trail, because {v1, v2} repeats itself (remember, the order in the edge does not matter {v1, v2} = {v2, v1} ) Is not a path because it is not a trail Is not a circuit, because it is not a trail Is not a simple path because it is not a circuit Length 5 The shortest path from P4 to P6 is (P4,P5,P6) which has length 2 This shows that by eliminated unnecessary edges, any walk from a vertex u to a vertex v can be replaced by a path from u to v

Example v1 v2 v3 v4 v5 v6 (v4, v1, v2, v5, v4) is a simple cycle, because the first and last vertices are the same and all pairs of consecutive vertices correspond to an edge in the graph and only the first and last vertices are the same Is everything on the list, because it is a simple cycle Length 4 The shortest path from P4 to P6 is (P4,P5,P6) which has length 2 This shows that by eliminated unnecessary edges, any walk from a vertex u to a vertex v can be replaced by a path from u to v

Remember Every trail is a walk, but not every walk is a trail Every path is a trail, but not every trail is a path Every circuit is a closed walk, but not every closed walk is a circuit Every simple cycle is a circuit. But not every circuit is a cycle A simple cycle is a path, but not every path is a simple cycle A circuit is a trail, but not every trail is a circuit A closed walk is a walk, but not every walk is closed

Connected graph There is a walk between vertices u and v if and only if there is a path from u to v A graph is connected if there is a path between any two of its vertices. The distance d(u,v), between two vertices u and v in a connected graph G, is the length of the shortest path between u and v The diameter of graph G is the maximum distance (the largest distance) between any two of its vertices

Examples d(v1, v6) = 2, d(v1, v4) = 1 Maximum distance possible is 2, so diameter = 2 The shortest path from P4 to P6 is (P4,P5,P6) which has length 2 This shows that by eliminated unnecessary edges, any walk from a vertex u to a vertex v can be replaced by a path from u to v