10.2 graph terminology and special types of graphs · 10.2 graph terminology and special types of...

80
1 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent (neighbors) in G if u and v are endpoints of an edge e of G. Such an edge is called incident with vertices u and v , and is said to connect u and v . a b c d adjacent vertices incident with vertices a and c connects u and v

Upload: others

Post on 23-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

1

10.2 Graph terminology and special types of graphs

[Def] Two vertices u and v in an undirected graph G are called adjacent (neighbors) in G if u and v are endpoints of an edge e of G.Such an edge is called incident with vertices u and v, and is said to connect u and v.

a

b c

d

adjacent vertices

incident with vertices a and c

connects u and v

Page 2: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

2

10.2 Graph terminology and special types of graphs

[Def] neighborhood of v, N(v), is the set of all neighbors of v.

a

b c

d

adjacent vertices

Page 3: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

3

10.2 Graph terminology and special types of graphs

[Def] neighborhood of v, N(v), is the set of all neighbors of v.

a

b c

d

adjacent vertices

neighborhood of a: N(a) = {b,c} ,neighborhood of b: N(b) = {a,d} ,neighborhood of c: N(c) = {a} ,neighborhood of d: N(d) = {b} ,

Page 4: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

4

10.2 Graph terminology and special types of graphs

[Def] the degree of a vertex in 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.

denotaion: deg(v)

a

b c

d

Page 5: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

5

10.2 Graph terminology and special types of graphs

[Def] the degree of a vertex in 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.

denotaion: deg(v)

a

b c

d

deg(a) = 2 deg(c) = 1deg(b) = 2+2 = 4 deg(d) = 1

Page 6: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

6

10.2 Graph terminology and special types of graphs

[Def] the degree of a vertex in 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.

denotaion: deg(v)

a

b c

d

A vertex of degree 0 is called isolated.A vertex of degree 1 is called pendant.

pendant

pendant

Page 7: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

7

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then 2m=∑v∈V

deg(v)

Page 8: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

8

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

a

b c

d

2m=∑v∈V

deg(v)

m = 4deg(a) = 2, deg(b) = 4, deg(c) = 1, deg(d) = 12 4 = 2 + 4 + 1 + 1 8 = 8

Page 9: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

9

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

Why is it so?

2m=∑v∈V

deg(v)

Page 10: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

10

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

Why is it so?

● each non-loop edge contributes 2 to the sum of the degrees ( 1 for each of adjacent vertices)

● each loop contributes 2 to the sum of the degrees (only for one vertex)

2m=∑v∈V

deg(v)

Page 11: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

11

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

[Theorem] An undirected graph has an even number of vertices of odd degree.

2m=∑v∈V

deg(v)

Page 12: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

12

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

[Theorem] An undirected graph has an even number of vertices of odd degree.

Proof: Let V1 and V

2 be the set of vertices of even

degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m

2m=∑v∈V

deg(v)

Page 13: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

13

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

[Theorem] An undirected graph has an even number of vertices of odd degree.

Proof: Let V1 and V

2 be the set of vertices of even

degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m

2m=∑v∈V

deg(v)

2m=∑v∈V

deg(v)=∑v∈V 1

deg(v)+∑v∈V 2

deg(v)

Page 14: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

14

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

[Theorem] An undirected graph has an even number of vertices of odd degree.

Proof: Let V1 and V

2 be the set of vertices of even

degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m

2m=∑v∈V

deg(v)

2m=∑v∈V

deg(v)=∑v∈V 1

deg(v)+∑v∈V 2

deg(v)even

even

Page 15: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

15

10.2 Graph terminology and special types of graphs

[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.

Then

[Theorem] An undirected graph has an even number of vertices of odd degree.

Proof: Let V1 and V

2 be the set of vertices of even

degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m

2m=∑v∈V

deg(v)

2m=∑v∈V

deg(v)=∑v∈V 1

deg(v)+∑v∈V 2

deg(v)even

must be even q.e.d.

even

Page 16: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

16

10.2 Graph terminology and special types of graphs

Let's discuss the terminology for directed graphs

Page 17: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

17

10.2 Graph terminology and special types of graphs

[Def] When (u,v) is an edge of the directed graph G, u is said to be adjacent to v, and v is adjacent from u.u is called initial vertex of (u,v), andv is called terminal/end vertex of (u,v).The initial and terminal vertex of the loop is the same.

a

b c

d

edges (a,b), (a,c):initial vertex,a is adjacent to b and to c

for edge (a,b):terminal vertex,b is adjacent from a;

for edge (b,d):initial vertex,b is adjacent to d

Page 18: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

18

10.2 Graph terminology and special types of graphs

[Def] The in-degree of a vertex v is the number of edges with v as their terminal vertex. deg-(v) The out-degree of a vertex v is the number of edges with v as their initial vertex. deg+(v)

Loop contributes to both in-degree and out-degree.

a

b c

d

Page 19: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

19

10.2 Graph terminology and special types of graphs

[Def] The in-degree of a vertex v is the number of edges with v as their terminal vertex. deg-(v) The out-degree of a vertex v is the number of edges with v as their initial vertex. deg+(v)

Loop contributes to both in-degree and out-degree.

a

b c

d

deg-(a) = 1 , deg+(a) = 3deg-(b) = 1 , deg+(b) = 1deg-(c) = 1 , deg+(c) = 0deg-(d) = 1 , deg+(d) = 0

Page 20: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

20

10.2 Graph terminology and special types of graphs

[Theorem] Let G = (V,E) be a directed graph. Then

a

b c

d

deg-(a) = 1 , deg+(a) = 3deg-(b) = 1 , deg+(b) = 1deg-(c) = 1 , deg+(c) = 0deg-(d) = 1 , deg+(d) = 0 4 4|E| = 4

∑v∈V

deg−(v)=∑v∈V

deg+(v)=|E|

Page 21: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

21

10.2 Graph terminology and special types of graphs

[Theorem] Let G = (V,E) be a directed graph. Then

a

b c

d

deg-(a) = 1 , deg+(a) = 3deg-(b) = 1 , deg+(b) = 1deg-(c) = 1 , deg+(c) = 0deg-(d) = 1 , deg+(d) = 0 4 4|E| = 4

∑v∈V

deg−(v)=∑v∈V

deg+(v)=|E|

Why is it so?

Page 22: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

22

10.2 Graph terminology and special types of graphs

[Theorem] Let G = (V,E) be a directed graph. Then

a

b c

d

Because each edge has an initial vertex and a terminal vertex, hence contributes to both out-degree and in-degree.

∑v∈V

deg−(v)=∑v∈V

deg+(v)=|E|

Why is it so?

Page 23: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

23

10.2 Graph terminology and special types of graphs

We can take a directed graph and convert to to undirected graph by ignoring the directions.Such a graph is called underlying undirected graph.

The directed graph and its underlying undirected graph have the same number of edges.

a

b c

d a

b c

d

Page 24: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

24

10.2 Graph terminology and special types of graphs

Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?

b) What does the neighborhood of a vertex represent?

c) What do isolated and pendant vertices represent?

Page 25: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

25

10.2 Graph terminology and special types of graphs

Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?

the degree of a vertex represents the number of times the actor worked together with other actors on a movie or a TV show

b) What does the neighborhood of a vertex represent?

c) What do isolated and pendant vertices represent?

Page 26: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

26

10.2 Graph terminology and special types of graphs

Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?

b) What does the neighborhood of a vertex represent?

N(a) represents the list of all actors actor a worked with on a movie or a TV show.

c) What do isolated and pendant vertices represent?

Page 27: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

27

10.2 Graph terminology and special types of graphs

Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?

b) What does the neighborhood of a vertex represent?

c) What do isolated and pendant vertices represent?

Isolated vertices represent actors who didn't work with any other actor (present in the graph) on a movie or a TV show.Pendant vertices represent only actors with one collaboration only.

Page 28: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

28

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Page 29: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

29

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.

Page 30: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

30

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.

deg(v1) = 0, deg(v

2) = 0

v1 v

2

2 vertices:

Page 31: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

31

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.

deg(v1) = 1, deg(v

2) = 1

v1 v

2

2 vertices:

Page 32: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

32

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.

deg(v1) = 0, deg(v

2) = 0, deg(v

3) = 0,

v1 v

2

3 vertices:

v3

Page 33: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

33

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.

deg(v1) = 1, deg(v

2) = 1, deg(v

3) = 0,

v1 v

2

3 vertices:

v3

Page 34: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

34

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.

deg(v1) = 2, deg(v

2) = 1, deg(v

3) = 1,

v1 v

2

3 vertices:

v3

Page 35: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

35

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.

deg(v1) = 2, deg(v

2) = 2, deg(v

3) = 2,

v1 v

2

3 vertices:

v3

Page 36: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

36

10.2 Graph terminology and special types of graphs

Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.

v1 v

2

v1 v

2

v1 v

2

v3

v1 v

2

v3

v1 v

2

v3

v1 v

2

v3

...

...

...

Page 37: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

37

10.2 Graph terminology and special types of graphs

Special Simple Graphs

- complete graphs ( Kn, for n Z+ )

- cycles ( Cn, for n Z+ and n 3)

- wheels ( Wn, for n Z+ and n 3)

- n-cubes ( Qn, for n Z+ )

Page 38: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

38

10.2 Graph terminology and special types of graphs

Special Simple Graphs: Complete graphs

A complete graph Kn on n vertices is a simple graph

that contains exactly one edge between each pair of distinct vertices.n = 1, 2, 3, 4, ...

K1 K

2 K3 K

4K

5

Page 39: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

39

10.2 Graph terminology and special types of graphs

Special Simple Graphs: Cycles

A cycle Cn on n vertices consists on n vertices v

1, v

2, …,

vn and edges {v

1,v

2}, {v

2,v

3},..., and {v

n-1,v

n}.

n = 3, 4, 5, ...

C3 C

4C

5 C6

Page 40: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

40

10.2 Graph terminology and special types of graphs

Special Simple Graphs: Wheels

A wheel Wn can be obtained from cycle C

n by adding

an additional vertex and connecting this new vertex with each of the n vertices in C

n.

n = 3, 4, 5, ...

W3 W

4W

5W

6

Page 41: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

41

10.2 Graph terminology and special types of graphs

Special Simple Graphs: n-Cubes

Graph of Qn has 2n vertices

Q1 Q

2 Q3

Page 42: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

42

10.2 Graph terminology and special types of graphs

Special Simple Graphs: n-Cubes

Graph of Qn has 2n vertices

n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...

Q1 Q

2 Q3

Page 43: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

43

10.2 Graph terminology and special types of graphs

Special Simple Graphs: n-Cubes

Graph of Qn has 2n vertices

n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...

Q1 Q

2

10Q

1

Q3

Page 44: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

44

10.2 Graph terminology and special types of graphs

Special Simple Graphs: n-Cubes

Graph of Qn has 2n vertices

n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...

Q1 Q

2

Q2

10Q

1 00 01

10 11

2nd place

1st place

Q3

Page 45: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

45

10.2 Graph terminology and special types of graphs

Special Simple Graphs: n-Cubes

Graph of Qn has 2n vertices

n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...

Q1 Q

2

Q2

10Q

1 00 01

10 11

2nd place

1st place

111110

000 001

011100

3rd place

1st place

2nd place

Q3

Q3

Page 46: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

46

10.2 Graph terminology and special types of graphs

Special Simple Graphs: n-Cubes

Graph of Qn has 2n vertices

n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...

Q1 Q

2 Q3

Q2

10Q

1 00 01

10 11

2nd place

1st place

111110

000 001

011100

3rd place

1st place

2nd place

010101

Q3

Page 47: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

47

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Def] a simple graph is called bipartite if its vertex set V can be partitioned into two disjoint sets V

1 and V

2 such

that every edge in the graph connects a vertex in V1 and

a vertex in V2 (i.e. no same-set vertices connections).

We call the pair (V1, V

2) a bipartition of V.

Example:

a

b

c d

e

f a

b

c d

e

fbipartite graph not a bipartite graph

Page 48: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

48

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Def] a simple graph is called bipartite if its vertex set V can be partitioned into two disjoint sets V

1 and V

2 such

that every edge in the graph connects a vertex in V1 and

a vertex in V2 (i.e. no same-set vertices connections).

We call the pair (V1, V

2) a bipartition of V.

Example:

a

b

c d

e

f a

b

c d

e

f

V1= {b,c,f}

V2 = {a,d,e}

Page 49: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

49

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Def] a simple graph is called bipartite if its vertex set V can be partitioned into two disjoint sets V

1 and V

2 such

that every edge in the graph connects a vertex in V1 and

a vertex in V2 (i.e. no same-set vertices connections).

We call the pair (V1, V

2) a bipartition of V.

Example:

a

b

c d

e

f a

b

c d

e

fbipartite graph not a bipartite graph

V1= {b,c,f}

V2 = {a,d,e}

Page 50: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

50

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Theorem] a simple graph is bipartite if and only if (iff) it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertics have the same color.

a

b

c d

e

fnot a bipartite graph

a

b

c d

e

fbipartite graph

Page 51: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

51

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Theorem] a simple graph is bipartite if and only if (iff) it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertices have the same color.

Proof: (): Assume that G = (V,E) is a bipartite graph, so there exist V

1 V and V

2 V, such that V

1 V

2 = ,

V = V1 V

2, and every edge in E connects a vertex from

V1 to vertex from V

2.

Page 52: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

52

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Theorem] a simple graph is bipartite if and only if (iff) it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertices have the same color.

Proof: (): Assume that G = (V,E) is a bipartite graph, so there exist V

1 V and V

2 V, such that V

1 V

2 = ,

V = V1 V

2, and every edge in E connects a vertex from

V1 to vertex from V

2.

Let's color all vertices from V1 with one color and all

vertices from V2 with other color. No adjacent vertices

will have the same color.

Page 53: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

53

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Theorem] a simple graph is bipartite if and only if (iff) it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertices have the same color.

Proof: (): Assume that it is possible to assign colors to the vertices of the graph using only two colors so that no two adjacent vertices have the same color.

Page 54: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

54

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Theorem] a simple graph is bipartite if and only if (iff) it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertices have the same color.

Proof: (): Assume that it is possible to assign colors to the vertices of the graph using only two colors so that no two adjacent vertices have the same color.Let V

1 be the set of vertices of color 1, and

V2 be the set of vertices of color 1, then

Page 55: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

55

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Theorem] a simple graph is bipartite if and only if (iff) it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertices have the same color.

Proof: (): Assume that it is possible to assign colors to the vertices of the graph using only two colors so that no two adjacent vertices have the same color.Let V

1 be the set of vertices of color 1, and

V2 be the set of vertices of color 1, then

V1 V

2 = , V = V

1 V

2, and every edge in E connects a

vertex from V1 to vertex from V

2, therefore, G is bipartite.

q.e.d.

Page 56: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

56

10.2 Graph terminology and special types of graphs

Bipartite graphs

[Theorem] a simple graph is bipartite if and only if (iff) it is possible to assign one of two different colors to each vertex of the graph so that no two adjacent vertics have the same color.

Theorem can be used to determine whether the graph is bipartite, and find the partition of bipartite graphs.

Page 57: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

57

10.2 Graph terminology and special types of graphs

Bipartite graphs

Start with any vertex (with edge). Assign one color to it, say red.

a

b

c d

f

e

Page 58: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

58

10.2 Graph terminology and special types of graphs

Bipartite graphs

Assign other color, say blue, to all vertices that are adjacent to it.

a

b

c d

f

e

Page 59: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

59

10.2 Graph terminology and special types of graphs

Bipartite graphs

Then assign the red color to all vertices that are adjacent to vertices of blue color.

a

b

c d

f

e

Page 60: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

60

10.2 Graph terminology and special types of graphs

Bipartite graphs

Done!V

1 = {a,d,e}, V

2 = {b,c,f}

a

b

c d

f

e

Page 61: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

61

10.2 Graph terminology and special types of graphs

Bipartite graphs

Let's try the other one:

a

b

c d

e

f

Page 62: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

62

10.2 Graph terminology and special types of graphs

Bipartite graphs

Let's try the other one: start with marking a red

a

b

c d

e

f

Page 63: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

63

10.2 Graph terminology and special types of graphs

Bipartite graphs

Let's try the other one: continue by with marking vertices adjacent to a blue

a

b

c d

e

f

Problem: d and f are adjacent!!!

Page 64: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

64

10.2 Graph terminology and special types of graphs

Bipartite graphs

Let's try the other one: continue by with marking vertices adjacent to a blue

a

b

c d

e

f

Problem: d and f are adjacent!!!

not a bipartite graph

Page 65: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

65

10.2 Graph terminology and special types of graphs

Complete bipartite graphs

A complete graph Kn on n vertices is a simple graph that

contains exactly one edge between each pair of distinct vertices. n = 1, 2, 3, 4, …

A complete bipartite graph Km,n

is a graph that has its vertex set partitioned into two subsets of m and n vertices, respectively with an edge between two vertices iff one vertex is in the first subset, and the other is in the second.

K1 K

2 K3 K

4K

5

Page 66: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

66

10.2 Graph terminology and special types of graphs

Complete bipartite graphs

A complete bipartite graph Km,n

is a graph that has its vertex set partitioned into two subsets of m and n vertices, respectively with an edge between two vertices iff one vertex is in the first subset, and the other is in the second.

K2,3

K3,3

Page 67: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

67

10.2 Graph terminology and special types of graphs

Bipartite graphs

Bipartite graphs can be used to model many types of applications that involve matching the elements of one set to elements of another.

Example: Suppose there are m employees in a group and n different jobs than need to be done, where m n.Each employee is trained to do one or more of these jobs. We want to assign one employee to each job.

Use bipartite graphs to model the situation!

Page 68: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

68

10.2 Graph terminology and special types of graphs

Bipartite graphs

m employees n different jobs, where m n

Vertices: employees and jobsEdges: connect employees with jobs he/she can do

Smith Chen Yamagata Rodriguez Collins

requirements design implementationtesting

Page 69: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

69

10.2 Graph terminology and special types of graphs

Bipartite graphs

m employees n different jobs, where m n

Vertices: employees and jobsEdges: connect employees with jobs he/she can do

Smith Chen Yamagata Rodriguez Collins

requirements design implementationtesting

A matching M is a set of edges from simple graph G, such that for any {s,t} and {u,v} M, s,t,u, and v are different vertices.

Page 70: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

70

10.2 Graph terminology and special types of graphs

Bipartite graphs

m employees n different jobs, where m n

Vertices: employees and jobsEdges: connect employees with jobs he/she can do

Smith Chen Yamagata Rodriguez Collins

requirements design implementationtesting

A matching M is a set of edges from simple graph G, such that for any {s,t} and {u,v} M, s,t,u, and v are different vertices.

Page 71: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

71

10.2 Graph terminology and special types of graphs

Bipartite graphs

m employees n different jobs, where m n

Vertices: employees and jobsEdges: connect employees with jobs he/she can do

Smith Chen Yamagata Rodriguez Collins

requirements design implementationtesting

A matching M is a set of edges from simple graph G, such that for any {s,t} and {u,v} M, s,t,u, and v are different vertices.

Page 72: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

72

10.2 Graph terminology and special types of graphs

Bipartite graphs

A matching M is a set of edges from simple graph G, such that for any {s,t} and {u,v} M, s,t,u, and v are different vertices.

A vertex that is an endpoint of an edge in matching M is said to be matched in M; otherwise it is said to be unmatched.

A maximum matching is a matching with the largest number of edges.

A complete matching M from V1 to V

2 is the one where

|M| = |V1|.

Page 73: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

73

10.2 Graph terminology and special types of graphs

Bipartite graphs

Goal: one employee to each jobV

1 = jobs

V2 = employees

Smith Chen Yamagata Rodriguez Collins

requirements design implementationtesting

This is a complete matching, because|V

1| = 4 and we see 4 blue edges.

Page 74: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

74

10.2 Graph terminology and special types of graphs

Bipartite graphs

Goal: one employee to each job, and all employees should get a jobV

1 = employees V

2 = jobs

Smith Chen Yamagata Rodriguez Collins

requirements design implementationtesting

This is not a complete matching, because|V

1| = 5 and we see only 4 blue edges.

Page 75: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

75

10.2 Graph terminology and special types of graphs

Bipartite graphs

Example: marriages on an IslandSuppose that there are m men and n women on an island. Each person has a list of members of the opposite gender acceptable as a spouse.

Page 76: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

76

10.2 Graph terminology and special types of graphs

Bipartite graphs

Example: marriages on an IslandSuppose that there are m men and n women on an island. Each person has a list of members of the opposite gender acceptable as a spouse.

We construct a bipartite graph G = (V,E), where V1 is the set of

men, and V2 is the set of women. Edges are between people

that find each other acceptable as a spouse.

Page 77: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

77

10.2 Graph terminology and special types of graphs

Bipartite graphs

Example: marriages on an IslandSuppose that there are m men and n women on an island. Each person has a list of members of the opposite gender acceptable as a spouse.

We construct a bipartite graph G = (V,E), where V1 is the set of

men, and V2 is the set of women. Edges are between people

that find each other acceptable as a spouse.

A maximum matching is the largest possible set of couples to merry.

Page 78: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

78

10.2 Graph terminology and special types of graphs

Bipartite graphs

Example: marriages on an IslandSuppose that there are m men and n women on an island. Each person has a list of members of the opposite gender acceptable as a spouse.

We construct a bipartite graph G = (V,E), where V1 is the set of

men, and V2 is the set of women. Edges are between people

that find each other acceptable as a spouse.

A maximum matching is the largest possible set of couples to merry.A complete matching of set V

1 is a set of all couples where

every man is can merry, but possible not all women.

Page 79: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

79

10.2 Graph terminology and special types of graphs

Bipartite graphs

Necessary and sufficient conditions for complete matchings:

[Theorem] Hall's marriage theoremThe bipartite graph G = (V,E) with bipartition (V

1,V

2) has a

complete matching from V1 to V

2 if and only if (iff)

|N(A)| |A| for all subsets A of V1.

No proof.

Page 80: 10.2 Graph terminology and special types of graphs · 10.2 Graph terminology and special types of graphs [Def] Two vertices u and v in an undirected graph G are called adjacent

80

10.2 Graph terminology and special types of graphs

Bipartite graphs

Example: marriages on an IslandSuppose that there are m men and n women on an island. Each person has a list of members of the opposite gender acceptable as a spouse.

We construct a bipartite graph G = (V,E), where V1 is the set of

men, and V2 is the set of women. Edges are between people

that find each other acceptable as a spouse.

A maximum matching is the largest possible set of couples to merry.A complete matching of set V

1 is a set of all couples where

every man is can merry, but possible not all women.