CS 441 Discrete Mathematics for CS Lecture 26. Graphs. CS 441 Discrete mathematics for CS. Final exam

Similar documents
v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

Graphs. Introduction To Graphs: Exercises. Definitions:

Chapter 10: Trees. A tree is a connected simple undirected graph with no simple circuits.

Hamilton paths & circuits. Gray codes. Hamilton Circuits. Planar Graphs. Hamilton circuits. 10 Nov 2015

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

CSC Intro to Intelligent Robotics, Spring Graphs

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees

Graphs. Pseudograph: multiple edges and loops allowed

March 20/2003 Jayakanth Srinivasan,

Chapter Summary. Introduction to Trees Applications of Trees Tree Traversal Spanning Trees Minimum Spanning Trees

Graph Theory CS/Math231 Discrete Mathematics Spring2015

(5.2) 151 Math Exercises. Graph Terminology and Special Types of Graphs. Malek Zein AL-Abidin

Foundations of Discrete Mathematics

CS 441 Discrete Mathematics for CS Lecture 24. Relations IV. CS 441 Discrete mathematics for CS. Equivalence relation

Graph and Digraph Glossary

An undirected graph is a tree if and only of there is a unique simple path between any 2 of its vertices.

Graph Theory. Probabilistic Graphical Models. L. Enrique Sucar, INAOE. Definitions. Types of Graphs. Trajectories and Circuits.

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.

Graph Algorithms Using Depth First Search

Introduction to Computers and Programming. Concept Question

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

Introduction to Graphs

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory

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

Elements of Graph Theory

Foundations of Discrete Mathematics

Varying Applications (examples)

CPCS Discrete Structures 1

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

Trees Algorhyme by Radia Perlman


12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees

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

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.

Section 8.2 Graph Terminology. Undirected Graphs. Definition: Two vertices u, v in V are adjacent or neighbors if there is an edge e between u and v.

CMSC 380. Graph Terminology and Representation

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

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

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

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

Definition of Graphs and Trees. Representation of Trees.

Introduction III. Graphs. Motivations I. Introduction IV

Basics of Graph Theory

CSE 21 Mathematics for Algorithm and System Analysis

Definition Example Solution

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.

Ma/CS 6b Class 5: Graph Connectivity

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests

Discrete mathematics II. - Graphs

Trees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.

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

Graph Theory. Part of Texas Counties.

Treewidth and graph minors

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

Chapter 2 Graphs. 2.1 Definition of Graphs

Undirected Graphs. Hwansoo Han

Lecture 3: Graphs and flows

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Introduction to Graph Theory

BIL694-Lecture 1: Introduction to Graphs

Discrete Mathematics (2009 Spring) Graphs (Chapter 9, 5 hours)

Proposition 1. The edges of an even graph can be split (partitioned) into cycles, no two of which have an edge in common.

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

Chapter 11: Graphs and Trees. March 23, 2008

A generalization of Mader s theorem

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Graphs. The ultimate data structure. graphs 1

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

Data Structures and Algorithms

Math 776 Graph Theory Lecture Note 1 Basic concepts

2. CONNECTIVITY Connectivity

Solving problems on graph algorithms

An Introduction to Graph Theory

1. Why Study Trees? Trees and Graphs. 2. Binary Trees. CITS2200 Data Structures and Algorithms. Wood... Topic 10. Trees are ubiquitous. Examples...

BACKGROUND: A BRIEF INTRODUCTION TO GRAPH THEORY

Combinatorics Summary Sheet for Exam 1 Material 2019

Mathematics Masters Examination

Graph Theory: Introduction

8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F))

Section 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents

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

Problem Set 2 Solutions

Characterizations of graph classes by forbidden configurations

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

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

Trees. Eric McCreath

Lecture 32. No computer use today. Reminders: Homework 11 is due today. Project 6 is due next Friday. Questions?

Figure 4.1: The evolution of a rooted tree.

Searching in Graphs (cut points)

Discrete Structures CISC 2315 FALL Graphs & Trees

Binary Trees

Trees. CSC 1300 Discrete Structures Villanova University

Definition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.

Trees. Arash Rafiey. 20 October, 2015

CS 280 Problem Set 10 Solutions Due May 3, Part A

Generalized Pebbling Number

Solutions to Exercises 9

Transcription:

CS 441 Discrete Mathematics for CS Lecture 26 Graphs Milos Hauskrecht milos@cs.pitt.edu 5329 Sennott Square Final exam Saturday, April 26, 2014 at 10:00-11:50am The same classroom as lectures The exam is: Closed book cumulative Please bring your own calculators 1

Graphs: basics Basic types of graphs: Directed graphs Undirected graphs a b a b c d c Complete graphs A complete graph on n vertices, denoted by K n, is the simple graph that contains exactly one edge between each pair of distinct vertices. 2

A cycle A cycle C n for n 3 consists of n vertices v 1, v 2,,v n, and edges {v 1, v 2 }, {v 2, v 3 },, {v n-1, v n }, {v n, v 1 }. N-dimensional hypercube An n-dimensional hypercube, or n-cube, Q n, is a graph with 2 n vertices representing all bit strings of length n, where there is an edge between two vertices that differ in exactly one bit position. 3

Bipartite graphs Definition: A simple graph G is bipartite if V can be partitioned into two disjoint subsets V 1 and V 2 such that every edge connects a vertex in V 1 and a vertex in V 2. In other words, there are no edges which connect two vertices in V 1 or in V 2. Note: An equivalent definition of a bipartite graph is a graph where it is possible to color the vertices red or blue so that no two adjacent vertices are the same color. Bipartite graphs Definition: A simple graph G is bipartite if V can be partitioned into two disjoint subsets V 1 and V 2 such that every edge connects a vertex in V 1 and a vertex in V 2. In other words, there are no edges which connect two vertices in V 1 or in V 2. Note: An equivalent definition of a bipartite graph is a graph where it is possible to color the vertices red or blue so that no two adjacent vertices are the same color. 4

Subgraphs Definition: A subgraph of a graph G = (V,E) is a graph (W,F), where W V and F E. A subgraph H of G is a proper subgraph of G if H G. Example: K 5 and one of its subgraphs. Subgraphs Definition: Let G = (V, E) be a simple graph. The subgraph induced by a subset W of the vertex set V is the graph (W,F), where the edge set F contains an edge in E if and only if both endpoints are in W. Example: K 5 and the subgraph induced by W = {a,b,c,e}. 5

Representation of graphs Definition: An adjacency list can be used to represent a graph with no multiple edges by specifying the vertices that are adjacent to each vertex of the graph. Example: Representation of graphs Definition: An adjacency list can be used to represent a graph with no multiple edges by specifying the vertices that are adjacent to each vertex of the graph. Example: 6

Adjacency matrices Definition: Suppose that G = (V, E) is a simple graph where V = n. Arbitrarily list the vertices of G as v 1, v 2,, v n. The adjacency matrix A G of G, with respect to the listing of vertices, is the n n zero-one matrix with 1 as its (i, j)th entry when v i and v j are adjacent, and 0 as its (i, j)th entry when they are not adjacent. In other words, if the graphs adjacency matrix is A G = [a ij ], then Example: The ordering of vertices is a, b, c, d. Adjacency matrices Adjacency matrices can also be used to represent graphs with loops and multiple edges. A loop at the vertex v i is represented by a 1 at the (i, i)th position of the matrix. When multiple edges connect the same pair of vertices v i and v j, (or if multiple loops are present at the same vertex), the (i, j)th entry equals the number of edges connecting the pair of vertices. Example: The adjacency matrix of the pseudograph shown here using the ordering of vertices a, b, c, d. 7

Graph isomorphism Definition: The simple graphs G 1 = (V 1, E 1 ) and G 2 = (V 2, E 2 )are isomorphic if there is a one-to-one and onto function f from V 1 to V 2 with the property that a and b are adjacent in G 1 if and only if f(a) and f(b) are adjacent in G 2, for all a and b in V 1. Such a function f is called an isomorphism. Two simple graphs that are not isomorphic are called nonisomorphic. Example: Are the two graphs isomorphic? Graph isomorphism Definition: The simple graphs G 1 = (V 1, E 1 ) and G 2 = (V 2, E 2 )are isomorphic if there is a one-to-one and onto function f from V 1 to V 2 with the property that a and b are adjacent in G 1 if and only if f(a) and f(b) are adjacent in G 2, for all a and b in V 1. Such a function f is called an isomorphism. Two simple graphs that are not isomorphic are called nonisomorphic. Example: Are the two graphs isomorphic? u1 v1 u2 v4 u3 v2 u4 v3 8

Connectivity in the graphs, paths Informal Definition: A 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. As the path travels along its edges, it visits the vertices along this path, that is, the endpoints of these. Applications: Numerous problems can be modeled with paths formed by traveling along edges of graphs such as: determining whether a message can be sent between two computers. efficiently planning routes for mail/message delivery. Connectivity in the graphs We can use the adjacency matrix of a graph to find the number of the different paths between two vertices in the graph. Theorem: Let G be a graph with adjacency matrix A with respect to the ordering v 1,, v n of vertices (with directed or undirected edges, multiple edges and loops allowed). The number of different paths of length r from v i to v j, where r >0 is a positive integer, equals the (i,j)th entry of A r. 9

Connectivity in the graphs Theorem: Let G be a graph with adjacency matrix A with respect to the ordering v 1,, v n of vertices (with directed or undirected edges, multiple edges and loops allowed). The number of different paths of length r from v i to v j, where r >0 is a positive integer, equals the (i,j)th entry of A r. Example: A = Paths of length 4. Connectivity in the graphs Theorem: Let G be a graph with adjacency matrix A with respect to the ordering v 1,, v n of vertices (with directed or undirected edges, multiple edges and loops allowed). The number of different paths of length r from v i to v j, where r >0 is a positive integer, equals the (i,j)th entry of A r. Example: A = Paths of length 4: The adjacency matrix of G (ordering the vertices as a, b, c, d) is given above. Hence the number of paths of length four from a to d is the (1, 4)th entry of A 4 A 4 = 10

Trees Definition: A tree is a connected undirected graph with no simple circuits. Examples: Tree: yes Tree: yes Tree: no Tree: no Connectivity in the graphs Definition: A forest is a graph that has no simple circuit, but is not connected. Each of the connected components in a forest is a tree. Example: 11

Trees Theorem: An undirected graph is a tree if and only if there is a unique simple path between any two of its vertices. B A C D E G F Application of trees Examples: The organization of a computer file system into directories, subdirectories, and files is naturally represented as a tree. structure of organizations. 12

Rooted trees Definition: A rooted tree is a tree in which one vertex has been designated as the root and every edge is directed away from the root. Note: An unrooted tree can be converted into different rooted trees when one of the vertices is chosen as the root. Rooted trees - terminology If v is a vertex of a rooted tree other than the root, the parent of v is the unique vertex u such that there is a directed edge from u to v. When u is a parent of v, v is called a child of u. Vertices with the same parent are called siblings. Parent of g: a Children of g: h,j,k Siblings of g: b,f 13

Rooted trees - terminology The ancestors of a vertex are the vertices on the path from the root to this vertex, excluding the vertex itself and including the root. The descendants of a vertex v are those vertices that have v as an ancestor. Ancestors of j: g,a Descendants of j: l,m Rooted trees - terminology A vertex of a rooted tree with no children is called a leaf. Vertices that have children are called internal vertices. Leafs: d,e,k, l,m Examples of internal nodes: b,g,h 14

Rooted trees - terminology If a is a vertex in a tree, the subtree with a as its root is the subgraph of the tree consisting of a and its descendants and all edges incident to these descendants. M-ary tree Definition: A rooted tree is called an m-ary tree if every internal vertex has no more than m children. The tree is called a full m-ary tree if every internal vertex has exactly m children. An m-ary tree with m = 2 is called a binary tree. Example: Are the following rooted trees full m-ary trees for some positive integer m? 15

Binary trees Definition: A binary tree is an ordered rooted where each internal vertex has at most two children. If an internal vertex of a binary tree has two children, the first is called the left child and the second the right child. The tree rooted at the left child of a vertex is called the left subtree of this vertex, and the tree rooted at the right child of a vertex is called the right subtree of this vertex. 16