Discrete Mathematics 6. GRAPHS Lecture 9 Dr.-Ing. Erwin Sitompul .

Post on 31-Mar-2015

238 views 4 download

Tags:

transcript

Discrete Mathematics

6. GRAPHS

Lecture 9

Dr.-Ing. Erwin Sitompulhttp://zitompul.wordpress.com

9/2Erwin Sitompul Discrete Mathematics

Homework 8

A chairperson and a treasurer of PUMA IE should be chosen out of 50 eligible association members. In how many ways can a chairperson and a treasurer can be elected, if:(a) There is no limitation.(b) Amir wants to serve only if elected as a chairperson.(c) Budi and Cora want to be elected together or not at all.(d) Dudi and Encep do not want to work together.

• The position of chairperson and treasurer are different.• The sequence of election must be considered.• The problem in this homework is a permutation problem.

9/3Erwin Sitompul Discrete Mathematics

Solution of Homework 8

(a) There is no limitation.

(50,2)P 50 49 2450 ways

(b) Amir wants to serve only if elected as a chairperson.

(49,1) (49,2) P P 49 2352 2401 ways

Amir is elected as chairperson, with 49 ways to fill the treasurer position

Amir is not elected as chairperson an thus does not want to serve; the 2 positions will now be filled by the remaining 49 members

9/4Erwin Sitompul Discrete Mathematics

Solution of Homework 8

(c) Budi and Cora want to be elected together or not at all.

(2,2) (48,2)P P 2 2256 2258 ways

Budi and Cora are elected together

The wish of Budi and Cora does not come true; and from the remaining 48 members, 2 people will be elected to fill the positions

9/5Erwin Sitompul Discrete Mathematics

Solution of Homework 8

(d) Dudi and Encep do not want to work together.

(48,1) (48,1) (48,1) (48,1) (48,2)P P P P P 2248 ways

Dudi elected as chairperson, Encep not elected as treasurer

Dudi and Encep are not elected, whether as chairperson or treasure

(50,2) 2P 2448 ways

All possible ways to elect

Events where Dudi and Encep work together

Dudi elected as treasurer, Encep not elected as chairperson

Encep elected as chairperson, Dudi not elected as treasurer

Encep elected as treasurer, Dudi not elected as chairperson

9/6Erwin Sitompul Discrete Mathematics

Definition of Graph

A graph is an abstract representation of a set of discrete objects where some pairs of the objects are connected by links.

The figure below shows a graph that represents a map of road network that connects a number of cities in Central Java.

9/7Erwin Sitompul Discrete Mathematics

Bridges of Königsberg (Euler, 1736)

Can someone pass every bridge exactly once and come back the his/her original position?

A graph can be used to represent the Königsberg bridge: Vertex represents a dry land Arc or edge represents a bridge

9/8Erwin Sitompul Discrete Mathematics

Graph Representation

Graph G = (V,E) where:V = Set of vertices, may not be a null set

= {v1,v2,...,vn} E = Set of edges, each connecting a pair of vertices

= {e1,e2,...,en}

9/9Erwin Sitompul Discrete Mathematics

Graph Representation

G1

G1 is a graph withV = {1,2,3,4} E = {(1,2),(1,3),(2,3),(2,4),(3,4)}

Simple graph

9/10Erwin Sitompul Discrete Mathematics

Graph Representation

G2 Multigraph

G2 is a graph withV = {1,2,3,4}E = {(1,2),(2,3),(1,3),(1,3),(2,4),(3,4),(3,4)}

= {e1,e2,e3,e4,e5,e6,e7}

9/11Erwin Sitompul Discrete Mathematics

Graph Representation

G3 Pseudograph

G3 is a graph withV = {1,2,3,4}E = {(1,2),(2,3),(1,3),(1,3),(2,4),(3,4),(3,4),(3,3)}

= {e1,e2,e3,e4,e5,e6,e7,e8}

9/12Erwin Sitompul Discrete Mathematics

Graph Classification

Based on the existence of loop or multiple edges, a graph can be classified into:1. Simple graph, if the graph does not have any loop or double

edge.2. Unsimple graph, if the graph has any loop or double edge.

9/13Erwin Sitompul Discrete Mathematics

Graph Classification

Based on the orientation of the edges, a graph can be classified into 2 types:1. Undirected graph, if the edges are directed.2. Directed graph or digraph, if all the edges are directed.

9/14Erwin Sitompul Discrete Mathematics

Program Analysis

Graph Applications

t:=0;read(x);while x <> 1945 do begin if x < 0 then writeln(‘Year may not be negative.’); else

t:=t+1; read(x); end;writeln(‘Guessed after’,t,’attempts.’);

1 : t:=02 : read(x)3 : x <> 1945 4 : x < 05 : writeln(‘Year...’)6 : t:=t+17 : read(x)8 : writeln(‘Guessed...)

9/15Erwin Sitompul Discrete Mathematics

Automata Theory in a Vending Machine

Graph Applications

D : Dime (10 cent)Q : Quarter (25 cent)

The price of 1 bottle drink is 45 cent

9/16Erwin Sitompul Discrete Mathematics

Graph Terminology

1. Adjacency Two vertices are said to be adjacent if they are directly

connected through an edge. Observe graph G1:

Vertex 1 is adjacent with vertex 2 and 3. Vertex 1 is not adjacent to vertex 4.

G1

9/17Erwin Sitompul Discrete Mathematics

Graph Terminology

2. Incidence For any edge e = (vj,vk), it is said that e is incident to vertex vj , and

e is incident to vertex vk . Observe graph G1:

Edge (2,3) is incident to vertex 2 and vertex 3. Edge (2,4) is incident to vertex 2 and vertex 4.Edge (1,2) is not incident with vertex 4.

G1

9/18Erwin Sitompul Discrete Mathematics

3. Isolated Vertex A vertex is called isolated vertex if it does not have any

edge incident to it. Observe graph G4:

Vertex 5 is an isolated vertex.

Graph Terminology

G4

9/19Erwin Sitompul Discrete Mathematics

4. Empty Graph (Null Graph) An empty graph is a graph whose set of edges is a null set. Observe graph G5:

It is an empty graph (null graph).

Graph Terminology

G5

9/20Erwin Sitompul Discrete Mathematics

5. Degree of Vertex The degree of a vertex is the number of edges incident to

the vertex itself. Notation: d(v). Observe graph G1:

d(1) = d(4) = 2.d(2) = d(3) = 3.

G1

Graph Terminology

9/21Erwin Sitompul Discrete Mathematics

Observe graph G4:d(5) = 0 isolated vertexd(4) = 1 pendant vertex

Observe graph G6:d(1) = 3 incident to double edgesd(3) = 4 incident to a loop

G4 G6

Graph Terminology

9/22Erwin Sitompul Discrete Mathematics

Graph Terminology In a directed graph:

din(v) = in-degree= number of arcs arriving to a vertex

dout(v) = out-degree= number of arcs departing from a vertex

d(v) = din(v) + dout(v)

9/23Erwin Sitompul Discrete Mathematics

Graph Terminology

G7

Observe graph G7:din(1) = 2 dout(1) = 1din(2) = 2 dout(2) = 3 din(3) = 2 dout(3) = 1din(4) = 1 dout(4) = 2

9/24Erwin Sitompul Discrete Mathematics

Graph Terminology

Handshake Lemma The sum of the degree of all vertices in a graph is an even

number; that is, twice the number of edges in the graph. In other words, if G = (V, E), then

( ) 2v V

d v E

G1

Observe graph G1:d(1) + d(2) + d(3) + d(4)

= 2 + 3 + 3 + 2= 2 number of edges= 2 5

9/25Erwin Sitompul Discrete Mathematics

G4 G6

Observe graph G4:d(1) + d(2) + d(3) + d(4) + d(5)

= 2 + 2 + 3 + 1 + 0= 2 number of edges= 2 4

Graph Terminology

Observe graph G6:d(1) + d(2) + d(3)

= 3 + 3 + 4= 2 number of edges= 2 5

9/26Erwin Sitompul Discrete Mathematics

Example:A graph has five vertices. Can you draw the graph if the degree of the vertices are:(a) 2, 3, 1, 1, and 2?(b) 2, 3, 3, 4, and 4?

Graph Terminology

Solution:(a) No,

because 2 + 3 + 1 + 1 + 2 = 9, is an odd number.

(b) Yes, because 2 + 3 + 3 + 4 + 4 = 16, is an even number.

9/27Erwin Sitompul Discrete Mathematics

G1

Graph Terminology

6. Path A path with length n from vertex of origin v0 to vertex of

destination vn in a graph G is the alternating sequence of vertices and edges in the form of v0, e1, v1, e2, v2, ..., vn –1, en, vn such that e1 = (v0, v1), e2 = (v1, v2), ..., en = (vn–1, vn) are the edges of graph G.

The length of a path is determined by the number of edges in that path.

Observe graph G1: Path 1, 2, 4, 3 is a path with edge sequence of (1,2), (2,4), and (4,3).The length of path 1, 2, 4, 3 is 3.

9/28Erwin Sitompul Discrete Mathematics

G1

Graph Terminology

7. Circuit A path that starts and finishes at the same vertex is called a

circuit. Observe graph G1:

Path 1, 2, 3, 1 is a circuit.The length of the circuit 1, 2, 3, 1 is 3.

9/29Erwin Sitompul Discrete Mathematics

8. Connectivity Two vertices v1 and v2 is said to be connected if there exists

at least one path from v1 to v2. A graph G is said to be a connected graph if for every pair of

vertices vi and vj of set V there exists at least one path from vi to vj.

If not, then G is said to be disconnected graph. Example of a disconnected graph:

Graph Terminology

9/30Erwin Sitompul Discrete Mathematics

Graph Terminology A directed graph G is said to be connected if its non-directed

graph is connected (Note: the non-directed graph of a directed graph G is obtained by omitting all arrow heads).

Two vertices, u and v, in a directed graph G are said as strongly connected vertices if there exists a directed path from u to v and also from v to u.

If u and v are not strongly connected vertices but the non-directed graph of G is a connected one, then u and v are said as weakly connected vertices.

9/31Erwin Sitompul Discrete Mathematics

Graph Terminology Directed graph G is said as strongly connected graph if

every possible pair of vertices u and v in G is strongly connected.

If not, then G is said to be a weakly connected graph.

Weakly connected graph Strongly connected graph

9/32Erwin Sitompul Discrete Mathematics

Graph Terminology

9. Subgraph and Subgraph Complement Suppose G = (V,E) is a graph,

then G1 = (V1,E1) is a subgraph of G if V1 V and E1 E. Complement of subgraph G1 in regard to graph G is the

graph G2 = (V2,E2) such that E2 = E – E1 and V2 is the set of all vertices incident to members of E2.

G8 A subgraph of G8

Complement of the subgraph

9/33Erwin Sitompul Discrete Mathematics

Graph Terminology

10. Spanning Subgraph Subgraph G1 = (V1,E1) of G = (V,E) is said to be a spanning

subgraph if V1 = V; that is if G1 contains all vertices of G.

G9 A spanning

subgraph of G9

Not a spanning subgraph of G9

9/34Erwin Sitompul Discrete Mathematics

Graph Terminology

11. Cut Set Cut set of a connected graph G is a set of edges of G that

can decides whether G is connected or not. If these edges are omitted, then G will be disconnected.

For the graph G10 below, {(1,2),(1,5),(3,5),(3,4)} belong to the cut set.

G10 G10 without the cut set, becomes a disconnected graph

9/35Erwin Sitompul Discrete Mathematics

Graph Terminology

The number of cut sets of a connected graph can be more than one.

For instance, the sets {(1,2),(2,5)}, {(1,3),(1,5),(1,2)} and {(2,6)} are also the cut set of G10.

{(1,2),(2,5),(4,5)} is not a cut set because its subset, {(1,2),(2,5)} is already a cut set.

G10 G10 without the cut set, becomes a disconnected graph

9/36Erwin Sitompul Discrete Mathematics

Graph Terminology

12. Weighted Graph A weighted graph is a graph whose edges are given

weighting numbers.

9/37Erwin Sitompul Discrete Mathematics

Homework 9

Graph G is given by the figure below.(a) List all possible paths from A to C.(b) List all possible circuits.(c) Write down at least 4 cut sets of the graph.(d) Draw the subgraph G1 = {B,C,X,Y}.(e) Draw the complement of subgraph G1.

Graph G

9/38Erwin Sitompul Discrete Mathematics

Homework 9

Observe graph H below.(a) List all possible paths from b to c.(b) List all possible circuits.(c) Write down at least 4 cut sets of the graph.(d) Draw the complement of subgraph H1 with regard to H.(e) Draw a spanning subgraph of H.

Graph H

New

Graph H1