Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Structures Graphs 1 (Ch. 10) Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore.

Similar presentations


Presentation on theme: "Discrete Structures Graphs 1 (Ch. 10) Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore."— Presentation transcript:

1 Discrete Structures Graphs 1 (Ch. 10) Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore. mhumayoun@ciitlahore.edu.pk https://sites.google.com/a/ciitlahore.edu.pk/dstruct/ Modified slides of Dr. M. Atif 1

2 Graphs What are Graphs? – A class of discrete structures useful for representing relations among objects. – Vertices (nodes) connected by edges. – Theory about graphs can be used to solve a lot of important problems 2

3 Perhaps the first graph you saw Can we sent all the utilities to the three houses without crossing wires? Not possible! 3

4 The first graph theory The first graph theory paper by Leonhard Euler In 1736: Seven bridges of Königsberg A town with 7 bridges and 4 pieces of land… 4

5 The Origin of Graph Theory Can we travel each bridge exactly once and return to the starting point? Not possible! 5

6 Definition - Graphs A graph G = (V, E) is defined by a set of vertices V, and a set of edges E consisting of ordered or unordered pairs of vertices from V. Thus a graph G = (V, E) – V = set of vertices – E = set of edges = subset of V  V – Thus |E| = O(|V| 2 ) 6

7 Simple Graphs A graph in which each edge connects two different vertices and where no two edges connect the same pair of vertices. 7

8 Example of a Simple Graph Let V be the set of states in the far southeastern U.S.: – i.e., V={FL, GA, AL, MS, LA, SC, TN, NC} Let E={{u,v}| u,v ∈ V and u adjoins v} = {{FL,GA},{FL,AL},{FL,MS}, {FL,LA}, {GA,AL}, {AL,MS}, {MS,LA}, {GA,SC}, {GA,TN}, {SC,NC}, {NC,TN}, {MS,TN}, {MS,AL}} 8

9 Multigraphs A multigraph: multiple edges connecting the same nodes  E.g., nodes are cities, edges are segments of major highways. 9

10 Pseudographs Pseudograph: Like a multigraph, but edges connecting a node to itself are allowed. 10

11 Directed Graphs A directed graph (V,E) consists of a set of vertices V and a set of directed edges E on V : ordered pairs of elements (u,v), u,v ∈ V. Road networks between cities are typically undirected. Street networks within cities are almost always directed because of one- way streets. Most graphs of graph- theoretic interest are undirected. 11

12 Directed Multigraphs A directed multigraph has directed parallel edges.  E.g., V=web pages,  E=hyperlinks. The WWW is a directed multigraph... 12

13 Types of Graphs: Summary Summary of the book’s definitions. Keep in mind this terminology is not fully standardized across different authors... 13

14 Graph Models Graphs are used in a wide variety of models We now describe some diverse graph models for some interesting applications 14

15 SOCIAL NETWORKS Acquaintanceship Graphs Represent whether two people know each other, that is, whether they are acquainted. Each person in a particular group of people is represented by a vertex. Undirected edge is used to connect two people when these people know each other. No multiple edges are used. Usually no loops are used. (If we want to include the notion of self- knowledge, we would include loops.) 15

16 Example 16

17 17

18 An influence graph A directed edge (a, b) means a can influence b. E.g. (Fred, Brian) means Fred can influence Brian. 18

19 Collaboration Graphs Academic Non-Academic 19

20 COMMUNICATIONNETWORKS Call Graphs 20

21 Call Graphs (2) Call graphs that model actual calling activities can be huge. For example, one call graph studied at AT&T, modeling calls during 20 days, has about 290 million vertices and 4 billion edges 21

22 SOFTWARE DESIGN APPLICATIONS A Precedence Graph 22

23 TOURNAMENTS Round Robin Tournaments A tournament where every team plays every other team exactly once. Such tournaments can be modeled using directed graphs where each team is represented by a vertex. Note that (a, b) is an edge if team ‘a’ beats team ‘b’. This graph is a simple directed graph, containing no loops or multiple directed edges. 23

24 24 Team 1 is undefeated in this tournament, and Team 3 is winless.

25 A Single-Elimination Tournament 25

26 Question Can you find a subject to which graph theory has not been applied? 26

27 10.2 Graph Terminology 27

28 Graph Terminology Adjacency: Let G be an undirected graph with edge set E. Let e ∈ E be (or map to) the pair {u,v}. Then we say: u, v are adjacent / neighbors / connected. Edge e is incident with vertices u and v. Edge e connects u and v. Vertices u and v are endpoints of edge e. 28

29 Neighborhood of a Vertex Let G be an undirected graph, v ∈ V a vertex. The neighborhood of v, N(v), is the set of all neighbors. N(a) = {b, c} N(b) = {a, c} N(c) = {a, b, d} N(d) = {d} N(e) = {} 29

30 Degree of a Vertex Let G be an undirected graph, v ∈ V a vertex. The degree of v, deg(v), is its number of incident edges. (Note: self-loops are counted twice.) deg(a) = 3 deg(b) = 3 + 2 = 5 deg(c) = 5 deg(d) = 3 + 2 = 5 deg(e) = 0 (isolated vertex) Pendent vertex = with deg. 1 30

31 EXAMPLE What are the degrees and what are the neighborhoods of the vertices in the graph: 31

32 EXAMPLE The degrees: – deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, and deg(d ) = 5. The neighborhoods – N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b}, N(d) = {a, b, e}, and N(e) = {a, b, d}. 32

33 The Handshaking Theorem Let G be an undirected graph * with vertex set V and edge set E. Then The sum of all the vertex degrees is an even number. 33 * (simple, multi, or pseudo)

34 Example deg(a)=3, deg(b)=5, deg(c)=5, deg(d)=5, deg(e)=0 34

35 Example How many edges are there in a graph with 10 vertices each of degree six? deg(a) = deg(b) = deg(c) = … = deg(j) = 6 35 deg(a) + deg(b) + deg(c) + … + deg(j) = 2|E| 10*6 = 2|E| |E| = 60/2 = 30

36 The handshaking lemma It is called the handshaking lemma because: – It tells us that if several people shake hands, then the total number of hands shaken must be even – It is precisely because just two hands are involved in each handshake. Examples on board. – 2 vertices (deg(a)+deg(b)=2|E|) 1+1 = 2*|E| – 3 vertices (deg(a)+deg(b)+deg(c)=2|E|) 2+2+2=2*|E| 1+1+0 = 2*|E| – 4 vertices (deg(a)+deg(b)+deg(c)+deg(d)=2|E|) 2+3+2+3 / 3+3+3+3 / 0+2+2+2 36

37 Handshaking Theorem (Corollary) Corollary: Any undirected graph has an even number of vertices of odd degree. In any undirected graph the number of vertices of odd degree is even. Examples on board. 1+1 = 2 3+3 =6 3+1+1+1+5+3 = 14 3+3+3+3 = 12 2+(3+1+1+1) = 6 37

38 Directed Graphs 38

39 Directed Degree Let G be a directed graph, v a vertex of G. The in-degree of v, deg - (v), is the number of edges going to v. The out-degree of v, deg + (v), is the number of edges coming from v. The degree of v, deg(v):≡deg - (v)+deg + (v), is the sum of v’s in-degree and out-degree. 39

40 Directed Degree Determine in/out-degree of each node deg + (a)= 4 deg - (a)= 2 deg + (b)= 1deg - (b)= 2 deg + (c)= 2deg - (c)= 3 deg + (d)= 2deg - (d)= 2 deg + (e)= 3deg - (e)= 3 deg + (f)= 0deg - (f)= 0 40

41 Directed Handshaking Theorem Let G be a directed (possibly multi-) graph with vertex set V and edge set E. Then: Note that the degree of a node is unchanged by whether we consider its edges to be directed or undirected. 41

42 END 42


Download ppt "Discrete Structures Graphs 1 (Ch. 10) Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore."

Similar presentations


Ads by Google