Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 13 (Part 1): Graphs

Similar presentations


Presentation on theme: "Chapter 13 (Part 1): Graphs"— Presentation transcript:

1 Chapter 13 (Part 1): Graphs
11/19/2018 Chapter 13 (Part 1): Graphs Introduction to Graphs Graph Terminology

2 History Basic ideas were introduced in the eighteenth century by Leonard Euler (Swiss mathematician) Euler was interested in solving the Königsberg bridge problem (Town of Königsberg is in Kaliningrad, Republic of Russia) Graphs have several applications in many areas: Study of the structure of the World Wide Web Shortest path between 2 cities in a transportation network Molecular chemistry

3 Introduction to Graphs (9.1)
There are 5 main categories of graphs: Simple graph Multigraph Pseudograph Directed graph Directed multigraph

4 Introduction to Graphs (cont.)
Definition 1 A simple graph G = (V,E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements of V called edges. Example: Telephone lines connecting computers in different cities.

5 Introduction to Graphs (cont.)
Definition 2: A multigraph G = (V,E) consists of a set E of edges, and a function f from E to {{u,v} | u, v  V, u  v}. The edges e1 and e2 are called multiple or parallel edges if f(e1) = f(e2). Example: Multiple telephone lines connecting computers in different cities.

6 Introduction to Graphs (cont.)
San Fransisco Los Angeles Denver Chicago Detroit Washington New York A Computer network with multiple lines

7 Introduction to Graphs (cont.)
Definition 3: A pseudograph G = (V,E) consists of a set V of vertices, a set E of edges, and a function f from E to {{u,v} | u, v  V}. An edge is a loop if f(e) = {u,u} = {u} for some u  V.

8 Introduction to Graphs (cont.)
San Fransisco Los Angeles Denver Chicago Detroit Washington New York A Computer network with diagnostic lines

9 Introduction to Graphs (cont.)
Definition 4: A directed graph (V,E) consists of a set of vertices V and a set of edges E that are ordered pairs of elements of V.

10 Introduction to Graphs (cont.)
San Fransisco Los Angeles Denver Chicago Detroit Washington New York Host A Communication network with one-way telephone lines This example shows that the host computer can only receive data from other computer, it cannot emit

11 Introduction to Graphs (cont.)
Definition 5: A directed multigraph G = (V,E) consists of a set V of vertices, a set E of edges, and a function f from E to {{u,v} | u, v  V}. The edges e1 and e2 are multiple edges if f(e1) = f(e2).

12 Introduction to Graphs (cont.)
San Fransisco Los Angeles Denver Chicago Detroit Washington New York A Computer network with multiple one-way telephone lines

13 Introduction to Graphs (cont.)
Modeling graphs Example: Competition between species in an ecological system can be modeled using a niche overlap graph. An undirected edge connect two vertices if the two species represented by these vertices compete for food.

14 Introduction to Graphs (cont.)
Racoon Hawk Owl Opossum Shrew Mouse Woodpecker Crow Squirrel A niche overlap graph

15 Introduction to Graphs (cont.)
Example: Influence of one person in society A directed graph called an influence graph is used to model this behavior There is a directed edge from vertex a to vertex b if the person represented by a vertex a influences the person represented by vertex b.

16 Introduction to Graphs (cont.)
Linda Deborah Fred Yvonne Brian An influence graph

17 Introduction to Graphs (cont.)
Example: The World Wide Web can be modeled as a directed graph where each web page is represented by a vertex and where an edge connects 2 web pages if there is a link between the 2 pages

18 Graph Terminology Basic Terminology
Goal: Introduce graph terminology in order to further classify graphs Definition 1: Two vertices u and v in an undirected graph G are called adjacent (or neighbors) in G if {u,v} is an edge of G. If e = {u,v}, the edge e is called incident with the vertices u and v. The edge e is also said to connect u and v. The vertices u and v are called endpoints of the edge {u,v}.

19 Graph Terminology (cont.)
Definition 2: The degree of a vertex in an undirected graph is the number of edges incident with it, except that a loop at a vertex contributes twice to the degree of that vertex. The degree of the vertex v is denoted by deg(v).

20 Example: What are the degrees of the vertices in the graphs G and H?
Solution: a f e g d c b G H a e d c b

21 Graph Terminology (cont.)
Theorem 1: The handshaking theorem Let G = (V,E) be an undirected graph with e edges. Then (Note that this applies even if multiple edges & loops are present.)

22 Graph Terminology (cont.)
Example: How many edges are there in a graph with ten vertices each of degree 6 ? Solution: Since the sum of the degrees of the vertices is 6*10 = 60  2e = 60. Therefore, e = 30

23 Graph Terminology (cont.)
Theorem 2: An undirected graph has an even number of vertices of odd degree. Proof: Let V1 and V2 be the set of vertices of even degree and the set of vertices of odd degree, respectively, in an undirected graph G = (V,E). Then Since deg(v) is even for v  V1, the first term in the right-hand side of the last equality is even. Furthermore, the sum of the two terms on the right-hand side of the last equality is even, since this sum is 2e. Hence, the second term in the sum is also even. Since all the terms in this sum are odd, there must be an even number of such terms. Thus, there are an even number of vertices of odd degree.

24 Graph Terminology (cont.)
Definition 3: When (u,v) is an edge of the graph G with directed edges, u is said to be adjacent to v and v is said to be adjacent from u. The vertex u is called the initial vertex of (u,v), and v is called the terminal or end vertex of (u,v). The initial vertex and terminal vertex of a loop are the same.

25 Graph Terminology (cont.)
Definition 4: In a graph with directed edges the in-degree of a vertex v, denoted deg-(v), is the number of edges with v as their terminal vertex. The out-degree of v, denoted by deg+(v), is the number of edges with v as their initial vertex. (Note that a loop at a vertex contributes 1 to both the in-degree and the out-degree of this vertex)

26 Graph Terminology (cont.)
Example: Find the in-degree and the out-degree of each vertex in the graph G Solution: The in-degree of G are: deg-(a) = 2, deg-(b) = 2, deg-(c) = 3, deg-(d) = 2, deg-(e) = 3, and deg-(f) = 0. The out-degree of G are: deg+(a) = 4, deg+(b) = 1, deg+(c) = 2, deg+(d) = 2, deg+(e) = 3, and deg+(f) = 0 a b c d f e

27 Graph Terminology (cont.)
Theorem 3: Let G = (V,E) be a graph with directed edges. Then

28 Chapter 13 (Part 2): Graphs
11/19/2018 Chapter 13 (Part 2): Graphs Graph Terminology (cont.) Representing Graphs & Graph Isomorphism Connectivity

29 Graph Terminology (cont.)
Some special simple graphs Complete graph They are denoted by Kn, they contain exactly one edge between each pair of distinct vertices Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

30 Graph Terminology (cont.)
K3 K4 K1 K2 K6 K5 The graphs Kn for 1  n  6 Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

31 Graph Terminology (cont.)
Cycles They are denoted by Cn(n  3): they consist of n vertices v1, v2, …, vn and edges {v1, v2}, {v2, v3}, …, {vn, vn-1} and {vn, v1} Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

32 Graph Terminology (cont.)
The cycles C3, C4, C5 & C6 Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

33 Graph Terminology (cont.)
Wheels They are denoted by Wn; they are obtained by adding a vertex to the graphs Cn and connect this vertex to all vertices Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

34 Graph Terminology (cont.)
W3 W4 W6 W5 The Wheels W3, W4, W5 & W6 Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

35 Graph Terminology (cont.)
n-cubes They are denoted by Qn, they are graphs that have vertices representing the 2n bit strings of length n. Two vertices are adjacent if and only if the bits strings that they represent differ in exactly one bit position Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

36 Graph Terminology (cont.)
Q3 000 001 011 111 110 100 101 010 Q2 00 01 10 11 Q1 1 The n-cube Qn for n = 1, 2, and 3. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

37 Graph Terminology (cont.)
Bipartite graph Definition 5: A simple graph is called bipartite if its vertex set V can be partitioned into 2 disjoint sets V1 and V2 such that every edge in the graph connects a vertex in V1 and a vertex in V2 (so that no edge in G connects either 2 vertices in V1 or 2 vertices in V2). Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

38 Graph Terminology (cont.)
Example: C6 is bipartite, since its vertex set can be partitioned into the 2 sets V1 = {v1, v3, v5} and V2 = {v2, v4, v6}, and every edge of C6 connects a vertex in V1 and a vertex in V2. Example: K3 is not bipartite. Why? v1 v3 v5 v2 v4 v6 V1 V2 Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

39 Graph Terminology (cont.)
Characterization of bipartite graph A graph is bipartite if and only if it is possible to color the vertices of the graph with at most 2 colors so that no 2 adjacent vertices have the same color Example: Complete bipartite graphs: they are denoted by Km,n. Their vertices set is partitioned into 2 subsets of m and n vertices, respectively. There is an edge between 2 vertices if and only if one vertex is in the first subset and the other vertex is in the second subset. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

40 Graph Terminology (cont.)
K3,3 K2,3 K3,5 K2,6 Some complete bipartite graphs Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

41 Graph Terminology (cont.)
Some applications of special types of graphs Local area network Goal: connecting computers as well as peripheral devices in a building using a local area network topology Some of these networks are based on a star topology, where all devices are connected to a central control device The star topology is equivalent to a K1,n complete bipartite graph Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

42 Graph Terminology (cont.)
Other local area networks use a ring topology  Cn graphs Finally, the hybrid topology which is equivalent to a Wn graph is also used Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

43 Graph Terminology (cont.)
(b) (c) Star, ring, and hybrid topologies for local area networks Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

44 Graph Terminology (cont.)
Interconnection networks for parallel processing Linear arrays for processor connection Mesh network (Markovian neighborhood) Hypercube interconnection (generalization of n-cubes) Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

45 Representing Graphs & Graph Isomorphism
Introduction Goal: Consists of choosing the most convenient representation of a graph We need to determine whether 2 graphs are isomorphic, this problem is important in graph theory Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

46 Representing Graphs & Graph Isomorphism (cont.)
List all the edges of the graph (no multiple edges) Use adjacency list, which specifies the vertices that are adjacent to each vertex of the graph Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

47 Representing Graphs & Graph Isomorphism (cont.)
Example: Use adjacency lists to describe this simple graph. b c a e d Vertex Adjacent vertices a b c d e b, c, e a, d, e c, e a, c, d Solution: Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

48 Representing Graphs & Graph Isomorphism (cont.)
Adjacency matrices To simplify computation, graphs can be represented using matrices Adjacency matrix Incident matrix The adjacency matrix is defined as A = [aij] such that Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

49 Representing Graphs & Graph Isomorphism (cont.)
Example: Use a adjacency matrix to represent this graph: a b c d Solution: We order the vertices a, b, c, d. The matrix representing this graph is Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

50 Representing Graphs & Graph Isomorphism (cont.)
In case of pseudographs , the adjacency matrix is not a binary matrix but is formed of elements that represent the number of edges between 2 vertices Example: Use an adjacency matrix to represent this pseudograph: a b d c Solution: The adjacency matrix using The ordering of vertices a, b, c, d is: Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

51 Representing Graphs & Graph Isomorphism (cont.)
Incidence matrices Let G = (V,E) be an undirected graph. Incidence matrices are defined by the matrix M = [mij] such that Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

52 Representing Graphs & Graph Isomorphism (cont.)
Example: Using an incidence matrix, represent the following undirected graph: v1 v2 v3 v4 v5 e1 e2 e3 e6 e5 e4 e1 e2 e3 e4 e5 e6 v1 v2 v3 v4 v5 Solution: Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

53 Representing Graphs & Graph Isomorphism (cont.)
Isomorphism of graphs Goal: is it possible to draw 2 graphs in the same way? In chemistry, different graph compounds can have the same molecular formula but can differ in structure The graphs of these compounds cannot be drawn in the same way Graphs having the same structure share common properties Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

54 Representing Graphs & Graph Isomorphism (cont.)
Definition 1: The simple graphs G1 = (V1,E1) and G2 = (V2,E2) are isomorphic if there is a one-to-one and onto function f from V1 to V2 with the property that a and b are adjacent in G1 if and only if f(a) and f(b) are adjacent in G2, for all a and b in V1. Such a function f is called an isomorphism. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

55 Representing Graphs & Graph Isomorphism (cont.)
Example: Show that the graphs G = (V,E) and H = (W,F) are isomorphic G u1 u2 u3 u4 v1 v2 v3 v4 H Solution: The function f with f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2 is a one-to-one correspondence between V and W. To see that this correspondence preserves adjacency, note that adjacent vertices in G are u1 and u2, u1 and u3, u2 and u4, and u3 and u4, and each of the pairs f(u1) = v1 and f(u2) = v4, f(u1) = v1 and f(u3) = v3, f(u2) = v4 and f(u3) = v3, and f(u1) = v1 and f(u4) = v2 are adjacent in H. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

56 Connectivity Goal: determination of paths within graphs
Many problems can be modeled with paths formed by traveling along the edges of graphs Some examples of problems are: Study the link between remote computers Efficient planning of routes for mail delivery Garbage pickup Diagnostic in computer networks Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

57 Connectivity (cont.) Path Definition 1:
Let n be a nonnegative integer and G an undirected graph. A path of length n from u to v in G is a sequence of n edges e1, e2, …, en of G such that f(e1) = {x0, x1}, f(e2) = {x1, x2}, …, f(en) = {xn-1, xn}, where x0 = u and xn = v. When the graph is simple, we denote this path by its vertex sequence x0, x1, …, xn (since listing these vertices uniquely determines the path). The path is a circuit if it begins and ends at the same vertex, that is, if u = v, and has length greater than zero. The path or circuit is said to pass through the vertices x1, x2, …, xn-1 or traverse the edges e1, e2, …, en. A path or circuit is simple if it does not contain the same edge more than once. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

58 Connectivity (cont.) a b c Example:
In this simple graph a, d, c, f, e is a simple path of length 4, since {a,d}, {d,c}, {c,f}, and {f,e} are all edges. However, d, e, c, a is not a path, since {e,c} is not an edge. Note that b, c, f, e, b is a circuit of length 4 since {b,c}, {c,f}, {f,e}, and {e,b} are edges, and this path begins and ends at b. The path a, b, e,d,a,b, which is of length 5, is not simple since it contains the edge {a,b} twice. d e f Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

59 Connectivity (cont.) Definition 2:
Let n be a nonnegative integer and G a directed multigraph. A path of length n from u to v in G is a sequence of edges e1, e2, …, en of G such that f(e1) = (x0, x1), f(e2) = (x1, x2), …, f(en) = (xn-1, xn), where x0 = u and xn = v. When there are no multiple edges in the directed graph, this path is denoted by its vertex sequence x0, x1, …, xn. A path of length greater than zero that begins and ends at the same vertex is called a circuit or cycle. A path or circuit is called simple it it does not contain the same edge more than once. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

60 Connectedness in undirected graphs
Connectivity (cont.) Connectedness in undirected graphs Question asked: When does a computer network have the property that every pair of computers can share information, if message can be sent through one or more intermediate computers? This question is equivalent to: When is there always a path between 2 vertices in the graph? Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

61 Connectivity (cont.) Definition 3:
An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph Theorem 1: There is a simple path between every pair of distinct vertices of a connected undirected graph Proof: Exercise! Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

62 Connectivity (cont.) A graph that is not connected is the union of two or more connected subgraphs, each pair of which has no vertex in common. These disjoint connected subgraphs are called the connected components of the graph Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

63 Connectivity (cont.) Connected in directed graphs Definition 4:
A directed graph is strongly connected if there is a path from a to b and from b to a whenever a and b are vertices in the graph Definition 5: A directed graph is weakly connected if there is a path between every 2 vertices in the underlying undirected graph Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

64 Connectivity (cont.) A directed graph is weakly connected  there is always a path between 2 vertices when the directions of the edges are ignored Strongly connected  weakly connected directed graph Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

65 Connectivity (cont.) Example: Are the directed graphs G and H strongly connected? a b c d e G H a b c d e Solution: G is strongly connected because there is a path between any 2 vertices in this directed graph. Hence, G is also weakly connected. The graph H is not strongly connected. There is no directed path from a to b in this graph. However, H is weakly connected, since there is a path between any 2 vertices in their underlying undirected graph of H. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

66 Connectivity (cont.) Paths & isomorphism
Paths and circuits can help determine whether 2 graphs are isometric The existence of a simple circuit (or cycle) of a particular length is a useful invariant to show that 2 graphs are not isomorphic Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

67 Connectivity (cont.) Example: Determine whether the graph G and H are isomorphic. G u6 u1 u2 u3 u4 u5 H v6 v1 v2 v3 v4 v5 Solution: Both G and H have 6 vertices and 8 edges. Each has 4 vertices of degree 3, and two vertices of degree 2. However, H has a simple circuit of length 3, namely, v1, v2, v6, v1 whereas G has no simple circuit of length 3, as can be determined by inspection (all simple circuits in G have length at least four). Since the existence of a simple circuit of length 3 is an isomorphic invariant, G and H are not isomorphic. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

68 Counting paths between vertices
Connectivity (cont.) Counting paths between vertices Theorem 2: Let G be a graph with adjacency matrix A with respect to the ordering v1, v2, …, vn (with directed or undirected edges, with multiple edges and loops allowed). The number of different paths of length r from vi to vj, where r is a positive integer is equals to the (i, j)th entry of Ar. Proof: Exercise! Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

69 Connectivity (cont.) Example: How many paths of length 4 are there from a to d in the simple graph G? a b d c G Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs

70 Connectivity (cont.) a b d c G
Solution: The adjacency matrix of G (ordering the vertices as a, b, c, d) is Hence, the number of paths of length 4 from a to d is the (1,4)th entry of A4. Since there are exactly 8 paths of length 4 from a to d. By inspection of the graph, we see that a, b, a, b, d; a, b, a, c, d; a, b, d, b, d; a, b, d, c, d; a, c, a, b, d; a, c, a, c, d; a, c, d, b, d; and a, c, d, c, d are the 8 paths from a to d. Dr. Djamel Bouchaffra CSE 504 Discrete Structures & Foundations of Computer Science, Ch. 8 (part 2): Graphs


Download ppt "Chapter 13 (Part 1): Graphs"

Similar presentations


Ads by Google