LOGO. Relations: In these slides: Introductions to graphs Graph terminology Representing graphs...

133
LOGO LOGO Discrete Structures Instructor: Dr. Ali Movaghar Sharif University of Technology Fall 1389 In The Name of Allah

description

LOGO 3

Transcript of LOGO. Relations: In these slides: Introductions to graphs Graph terminology Representing graphs...

Page 1: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

LOGO

D i s c r e t e S t r u c t u r e sInstructor: Dr. Ali Movaghar

Sharif University of Technology Fall 1389

In The Name of Allah

Page 2: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

2

Relations: In these slides:

• Introductions to graphs• Graph terminology• Representing graphs and graph isomorphism• Connectivity• Euler and Hamilton paths

Dis

cret

e S

truct

ures

Fall

1389

Page 3: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

3

Introductions to

graphs

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 4: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGOWhat are Graphs?General meaning in everyday math:

A plot or chart of numerical data using a coordinate system.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 5: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGOWhat are Graphs?General meaning in everyday math:

A plot or chart of numerical data using a coordinate system.Technical meaning in discrete mathematics:

A particular class of discrete structures (to be defined) that is useful for representing relations and has a convenient graphical representation.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 6: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

6

What are Graphs?General meaning in everyday math:

A plot or chart of numerical data using a coordinate system.Technical meaning in discrete mathematics:

A particular class of discrete structures (to be defined) that is useful for representing relations and has a convenient graphical representation.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Not

Page 7: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

7

Applications of Graphs(At least) anything that can be modelled

using 1- or 2-place relations.Apps in networking, scheduling, flow

optimization, circuit design, path planning, search; genealogy, any kind of taxonomy, …

Challenge: name a topic that graphs cannot model

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 8: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

8

We shall introduce a number of different types of graphs, starting with undirected graphs: “simple” graphs multigraphs pseudographs

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 9: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

9

Simple GraphsCorrespond to symmetric,

irreflexive binary relations R.A simple graph G=(V,E)

consists of: a set V of vertices or nodes (V corresponds to the

universe of the relation R), a set E of edges: unordered pairs of distinct

elements u,v V, such that uRv.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 10: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

10

Simple GraphsCorrespond to symmetric,

irreflexive binary relations R.A simple graph G=(V,E)

consists of: a set V of vertices or nodes (V corresponds to the

universe of the relation R), a set E of edges: unordered pairs of distinct

elements u,v V, such that uRv.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Visual Representationof a Simple Graph

Page 11: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

11

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 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}}

Example of a Simple Graph

TN

ALMS

LA

SC

GA

FL

NC

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 12: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

12

ExtensionsAll the main types of graphs can be extended

to make them more expressive

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 13: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

13

ExtensionsAll the main types of graphs can be extended

to make them more expressiveFor example, edges may be labelled:

Labelled graphs

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 14: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

14

ExtensionsAll the main types of graphs can be extended

to make them more expressiveFor example, edges may be labelled:

Labelled graphsE.g., the edges in the previous example may

be labelled with the type of border (e.g., patrolled/non-patrolled)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 15: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

15

MultigraphsLike simple graphs, but there may be more

than one edge connecting two given nodes.A multigraph G=(V, E, f ) consists of a set

V of vertices, a set E of edges (as primitive objects), and a functionf:E{{u,v}|u,vV uv}.

E.g., nodes are cities, edgesare segments of major highways.

Paralleledges

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 16: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

16

Multigraphs extended

Extension: edges may be labelled with numbers of miles. How about this example?

110

8020 90

BA

C

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 17: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

17

Multigraphs extended

Can go from A to B via C in less than 110.The distances in the graph are not minimal,

or something is wrong. 110

8020 90

BA

C

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 18: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

18

PseudographsLike a multigraph, but edges connecting a node to

itself are allowed. (R may even be reflexive.)A pseudograph G=(V, E, f ) where

f:E{{u,v}|u,vV}. Edge eE is a loop if f(e)={u,u}={u}.

E.g., nodes are campsitesin a state park, edges arehiking trails through the woods.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 19: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

19

PseudographsLike a multigraph, but edges connecting a node to

itself are allowed. (R may even be reflexive.)A pseudograph G=(V, E, f ) where

f:E{{u,v}|u,vV}. Edge eE is a loop if f(e)={u,u}={u}.

E.g., nodes are campsitesin a state park, edges arehiking trails through the woods.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 20: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

20

Directed GraphsCorrespond to arbitrary binary relations R,

which need not be symmetric.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 21: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

21

Directed GraphsCorrespond to arbitrary binary relations R,

which need not be symmetric.A di(rected) graph (V,E) consists of a set of

vertices V and a binary relation E on V.E.g.: V = set of People,

E={(x,y) | x loves y}

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 22: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

22

Directed GraphsCorrespond to arbitrary binary relations R,

which need not be symmetric.A di(rected) graph (V,E) consists of a set of

vertices V and a binary relation E on V.E.g.: V = set of People,

E={(x,y) | x loves y}

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 23: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

23

Directed MultigraphsLike directed graphs, but there may be

more than one edge from a node to another.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 24: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

24

Directed MultigraphsLike directed graphs, but there may be

more than one edge from a node to another.A directed multigraph G=(V, E, f ) consists

of a set V of vertices, a set E of edges, and a function f:EVV.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 25: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

25

Directed MultigraphsLike directed graphs, but there may be

more than one edge from a node to another.A directed multigraph G=(V, E, f ) consists

of a set V of vertices, a set E of edges, and a function f:EVV.

E.g., V=web pages,E=hyperlinks. The WWW asa directed multigraph...

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 26: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

26

Directed MultigraphsLike directed graphs, but there may be

more than one edge from a node to another.A directed multigraph G=(V, E, f ) consists

of a set V of vertices, a set E of edges, and a function f:EVV.

E.g., V=web pages,E=hyperlinks. The WWW asa directed multigraph...

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 27: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

27

Types of Graphs: SummarySummary of the book’s definitions.This terminology is not fully standardized

across different authors

TermEdgetype

Multipleedges ok?

Self-loops ok?

Simple graph Undir. No NoMultigraph Undir. Yes NoPseudograph Undir. Yes YesDirected graph Directed No YesDirected multigraph Directed Yes Yes

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 28: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

28

Graph Terminology

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 29: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

29

Graph Terminology

Introducing the following terms:Adjacent, connects, endpoints, degree, initial,

terminal, in-degree, out-degree, complete, cycles, wheels, n-cubes, bipartite, subgraph, union.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 30: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

30

Adjacency

Let G be an undirected graph with edge set E. Let eE be (or map to) the pair {u,v}. Then we say:

u, v are adjacent / 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.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 31: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

31

Degree of a VertexLet G be an undirected graph, vV a vertex.The degree of v, deg(v), is its number of

incident edges. (Except that any self-loops are counted twice.)

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

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 32: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

32

Degree of a VertexThe degree of v, deg(v), is its number of

incident edges. (Except that any self-loops are counted twice.)

Exercise: construct a pseudograph with three vertices, all of which have different degrees.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 33: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

33

Handshaking TheoremLet G be an undirected (simple, multi-, or

pseudo-) graph with vertex set V and edge set E. Then

Proof: every edge causes degree:= degree +2

EvVv

2)deg(

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 34: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

34

Handshaking TheoremLet G be an undirected (simple, multi-, or

pseudo-) graph with vertex set V and edge set E. Then

Corollary: Any undirected graph has an even number of vertices of odd degree.

Dis

cret

e S

truct

ures

Fa

ll 13

89

EvVv

2)deg(

Page 35: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

35

`Sociological’ example(Like previous exercise, this is from Jonathan

L.Gross’ coursenotes to Rosen) Suppose the students in this class are represented

as vertices. An edge between a and b means that a and b were acquainted before the course began. [This is a simple graph.]

How many students knew an odd number of other students? Could there be 3?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 36: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

36

`Sociological’ example(Like previous exercise, this is from Jonathan

L.Gross’ coursenotes to Rosen) Suppose the students in this class are represented

as vertices. An edge between a and b means that a and b were acquainted before the course began. [This is a simple graph.]

[By corollary to handshaking theorem:] The number of students who knew an odd number of other students is even.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 37: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

37

Directed AdjacencyLet G be a directed (possibly multi-) graph,

and let e be an edge of G that is (or maps to) (u,v). Then we say: u is adjacent to v, v is adjacent from u e comes from u, e goes to v. e connects u to v, e goes from u to v the initial vertex of e is u the terminal vertex of e is v

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 38: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

38

Directed DegreeLet 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.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 39: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

39

Directed Handshaking TheoremLet G be a directed (possibly multi-) graph

with vertex set V and edge set E. Then:

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 40: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

40

Directed Handshaking TheoremLet G be a directed (possibly multi-) graph

with vertex set V and edge set E. Then:

EvvvVvVvVv

)deg(21)(deg)(deg

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 41: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

41

Directed Handshaking TheoremLet 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.

EvvvVvVvVv

)deg(21)(deg)(deg

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 42: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

42

Special Graph Structures

Special cases of undirected graph structures:Complete graphs Kn

Cycles Cn

Wheels Wn

n-Cubes Qn

Bipartite graphsComplete bipartite graphs Km,n

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 43: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

43

Complete GraphsFor any nN, a complete graph on n vertices,

Kn, is a simple graph with n nodes in which every node is adjacent to every other node: u,vV: uv{u,v}E.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 44: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

44

Complete GraphsFor any nN, a complete graph on n vertices,

Kn, is a simple graph with n nodes in which every node is adjacent to every other node: u,vV: uv{u,v}E.

K1 K2 K3K4 K5 K6

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 45: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

45

Complete GraphsFor any nN, a complete graph on n vertices,

Kn, is a simple graph with n nodes in which every node is adjacent to every other node: u,vV: uv{u,v}E.

K1 K2 K3K4 K5 K6

Dis

cret

e S

truct

ures

Fa

ll 13

89

Note that Kn has edges.2

)1(1

1

nnin

i

Page 46: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

46

Consider a complete graph G=(V,E).

Can E contain any edges connecting a node in V to itself?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 47: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

47

Consider a complete graph G=(V,E).

Can E contain any edges connecting a node in V to itself?

No: this would mean {u,v}E, where u=v hence u,vV: uv{u,v}E.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 48: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

48

Can you think of a natural example where complete graphs might model the facts?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 49: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

49

Can you think of a natural example where complete graphs might model the facts? E.g., Graphs that model, for groups of n people,

which people are seen by each member of the group

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 50: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

50

CyclesFor any n3, a cycle on n vertices, Cn, is a

simple graph where V={v1,v2,… ,vn} and E={{v1,v2},{v2,v3},…,{vn1,vn},{vn,v1}}.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 51: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

51

CyclesFor any n3, a cycle on n vertices, Cn, is a

simple graph where V={v1,v2,… ,vn} and E={{v1,v2},{v2,v3},…,{vn1,vn},{vn,v1}}.

C3 C4 C5 C6 C7C8

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 52: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

52

CyclesFor any n3, a cycle on n vertices, Cn, is a

simple graph where V={v1,v2,… ,vn} and E={{v1,v2},{v2,v3},…,{vn1,vn},{vn,v1}}.

C3 C4 C5 C6 C7C8

How many edges are there in Cn?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 53: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

53

CyclesFor any n3, a cycle on n vertices, Cn, is a

simple graph where V={v1,v2,… ,vn} and E={{v1,v2},{v2,v3},…,{vn1,vn},{vn,v1}}.

C3 C4 C5 C6 C7C8

How many edges are there in Cn? n

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 54: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

54

Can you think of a natural example where cycles might model the facts? E.g., Graphs that model, for groups of n people,

which people are sitting next to each other (on a round table)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 55: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

55

Can a cycle be a complete graph?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 56: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

56

Can a cycle be a complete graph?Yes: every cycle with exactly 3 elements

is a complete graph.No other cycle can be a complete graph.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 57: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

57

Can a cycle be a complete graph?Yes: every cycle with exactly 3 elements

is a complete graph.No other cycle can be a complete graph.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Can be proven by proving with induction that: |Edges(C_n)|<|Edges(K_n)| for n>2.

Page 58: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

58

WheelsFor any n3, a wheel Wn, is a simple graph

obtained by taking the cycle Cn and adding one extra vertex vhub and n extra edges {{vhub,v1}, {vhub,v2},…,{vhub,vn}}.

W3 W4 W5 W6 W7W8

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 59: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

59

WheelsFor any n3, a wheel Wn, is a simple graph

obtained by taking the cycle Cn and adding one extra vertex vhub and n extra edges {{vhub,v1}, {vhub,v2},…,{vhub,vn}}.

W3 W4 W5 W6 W7W8

How many edges are there in Wn?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 60: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

60

WheelsFor any n3, a wheel Wn, is a simple graph

obtained by taking the cycle Cn and adding one extra vertex vhub and n extra edges {{vhub,v1}, {vhub,v2},…,{vhub,vn}}.

W3 W4 W5 W6 W7W8

How many edges are there in Wn? 2n

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 61: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

61

Definition: A graph is regular iff every vertex has the same degree.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 62: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

62

Which of these are regular? (What degree?) Complete graphs? Cycle graphs? Wheel graphs?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 63: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

63

Which of these are regular? (What degree?) Complete graphs? Yes: degree n-1 (for n nodes) Cycle graphs? Yes: degree 2 Wheel graphs? No, except when they have 3 nodes

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 64: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

64

n-cubes (hypercubes)For any nN, the hypercube Qn is a simple

graph consisting of two copies of Qn-1 connected together at corresponding nodes. Q0 has 1 node.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 65: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

65

n-cubes (hypercubes)For any nN, the hypercube Qn is a simple

graph consisting of two copies of Qn-1 connected together at corresponding nodes. Q0 has 1 node.

Q0

Q1 Q2 Q3

Dis

cret

e S

truct

ures

Fa

ll 13

89

?What do you think about

Q4?

Page 66: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

66

n-cubes (hypercubes)For any nN, the hypercube Qn is a simple

graph consisting of two copies of Qn-1 connected together at corresponding nodes. Q0 has 1 node.

Q0

Q1 Q2 Q3

Dis

cret

e S

truct

ures

Fa

ll 13

89

Q4

Page 67: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

67

n-cubes (hypercubes)For any nN, the hypercube Qn is a simple

graph consisting of two copies of Qn-1 connected together at corresponding nodes. Q0 has 1 node.

Number of vertices: 2n. Number of edges:Exercise to try!

Dis

cret

e S

truct

ures

Fa

ll 13

89

Q0

Q1 Q2 Q3

Q4

Page 68: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

68

n-cubes (hypercubes) For any nN, the hypercube Qn can be defined

recursively as follows: Q0={{v0},} (one node and no edges) For any nN, if Qn=(V,E), where V={v1,…,va} and

E={e1,…,eb}, then Qn+1 = …

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 69: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

69

n-cubes (hypercubes)For any nN, the hypercube Qn can be defined

recursively as follows: Q0={{v0},} (one node and no edges) For any nN, if Qn=(V,E), where V={v1,…,va} and

E={e1,…,eb}, then Qn+1= (V{v1´,…,va´}, E{e1´,…,eb´}{{v1,v1´},{v2,v2´},…,{va,va´}}) where v1´,…,va´ are new vertices, and where if ei={vj,vk} then ei´={vj´,vk´}.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 70: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

70

Def’n.: A graph G=(V,E) is bipartite (two-part) iff V = V1 V2 where V1∩V2= and eE: v1V1,v2V2: e={v1,v2}.

Bipartite GraphsD

iscr

ete

Stru

ctur

es

Fall

1389

Page 71: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

71

Def’n.: A graph G=(V,E) is bipartite (two-part) iff V = V1 V2 where V1∩V2= and eE: v1V1,v2V2: e={v1,v2}.

In Human Mode(!): The graph canbe divided into two partsin such a way that all edges go between the two parts.

Bipartite Graphs

V1 V2

Can represent withzero-one matrices.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 72: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

72

Def’n.: A graph G=(V,E) is bipartite (two-part) iff V = V1 V2 where V1∩V2= and eE: v1V1,v2V2: e={v1,v2}.

In Human Mode(!): The graph canbe divided into two partsin such a way that all edges go between the two parts.

Bipartite Graphs

V1 V2

This definition can easily be adapted for the case of multigraphs and directed graphs as well.

Can represent withzero-one matrices.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 73: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

73

Bipartite graphs… are extremely common, for example when

you’re modelling a domain that consists of two different kinds of entities Animals in a zoo, linked with their keepers Words, linked with numbers of letters in them Logical formulas, linked with English sentences

that express their meaning

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 74: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

74

Some questionsCan you think of a graph with two vertices

that is not bipartite?Can you think of a simple graph with two

vertices that is not bipartite?Can you think of a simple graph with three

vertices and a nonempty set of edges that is bipartite?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 75: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

75

Some questionsCan you think of a graph with two vertices that is not

bipartite? Yes: if there are self-loopsCan you think of a simple graph with two vertices

that is not bipartite? No: must be bipartiteCan you think of a simple graph with three vertices

and a nonempty set of edges that is bipartite? Yes: as long as it’s not complete

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 76: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

76

Given a (bipartite) graph, can there be more than 1 way of partitioning V into V1 and V2 ?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 77: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

77

Given a (bipartite) graph, can there be more than 1 way of partitioning V into V1 and V2 ?

Yes: isolated verticescan be put in either part:

Bipartite Graphs

V1 V2

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 78: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

78

Complete Bipartite GraphsFor m,nN, the complete bipartite graph Km,n

is a bipartite graph where |V1| = m, |V2| = n, and E = {{v1,v2}|v1V1 v2V2}. That is, there are m nodes

in the left part, n nodes in the right part, and every node in the left part is connected to every node in the right part.

K4,3

Km,n has _____ nodesand _____ edges.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 79: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

79

Complete Bipartite GraphsFor m,nN, the complete bipartite graph Km,n

is a bipartite graph where |V1| = m, |V2| = n, and E = {{v1,v2}|v1V1 v2V2}. That is, there are m nodes

in the left part, n nodes in the right part, and every node in the left part is connected to every node in the right part.

K4,3

Km,n has m+n nodesand n*m edges.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 80: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

80

Complete Bipartite GraphsFor m,nN, the complete bipartite graph Km,n

is a bipartite graph where |V1| = m, |V2| = n, and E = {{v1,v2}|v1V1 v2V2}. That is, there are m nodes

in the left part, n nodes in the right part, and every node in the left part is connected to every node in the right part.

K4,3

Km,n has m+n nodesand n*m edges.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Note: not every CBG is complete! (So “CBG” is a strange name)

Page 81: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

81

SubgraphsA subgraph of a graph G=(V,E) is a graph

H=(W,F) where WV and FE.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 82: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

82

SubgraphsA subgraph of a graph G=(V,E) is a graph

H=(W,F) where WV and FE.

G

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 83: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

83

SubgraphsA subgraph of a graph G=(V,E) is a graph

H=(W,F) where WV and FE.

G H

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 84: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

84

A subgraph of a graph G=(V,E) is a graph H=(W,F) where WV and FE.

Note: since H is a graph, F can only involve nodes that are elements of W.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 85: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

85

Graph Representations

& Isomorphism

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 86: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

86

Graph Representations & Isomorphism

Graph representations: Adjacency lists. Adjacency matrices. [Not covered this course] Incidence matrices. [Not covered this course]

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 87: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

87

Adjacency ListsA table with 1 row per vertex, listing its

adjacent vertices.

a b

dc

fe

VertexAdjacentVertices

ab

b, ca, c, e, f

c a, b, fde bf c, b

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 88: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

88

An equivalence relation between graphs

Unlike ordinary pictures, we can say precisely when two graphs are similar

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 89: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

89

An equivalence relation between graphs

Unlike ordinary pictures, we can say precisely when two graphs are similar

Obviously, a given graph (V,E) may be drawn in different ways.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 90: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

90

An equivalence relation between graphs

Unlike ordinary pictures, we can say precisely when two graphs are similar

Obviously, a given graph (V,E) may be drawn in different ways.

But even (V,E) and (V’,E’) (where V<>V’ and E<>E’) may in some sense be equivalent:

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 91: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

91

An equivalence relation between graphs

Unlike ordinary pictures, we can say precisely when two graphs are similar

Obviously, a given graph (V,E) may be drawn in different ways.

But even (V,E) and (V’,E’) (where V<>V’ and E<>E’) may in some sense be equivalent:

Graph isomorphism (informal): Two graphs are isomorphic iff they are identical except for

their node names.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 92: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

92

Graphs that are isomorphic share all their `important’ properties, e.g., The number of nodes and edges The degrees of all their nodes Whether they are bipartite or not, etc.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 93: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

93

Graphs that are isomorphic share all their `important’ properties, e.g., The number of nodes and edges The degrees of all their nodes Whether they are bipartite or not, etc.

How would you define graph isomorphism formally? For simplicity: focus on simple graphs Hint: use the notion of a bijection

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 94: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

94

Graph IsomorphismFormal definition:

Simple graphs G1=(V1, E1) and G2=(V2, E2) are isomorphic iff a bijection f:V1V2 such that a,bV1, a and b are adjacent in G1 iff f(a) and f(b) are adjacent in G2.

f is the “renaming” function between the two node sets that makes the two graphs identical.

This definition can be extended to other types of graphs.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 95: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

95

Graph IsomorphismHow can we tell whether two graphs are

isomorphic?The best algorithms that are known to solve

this problem have exponential worst-case time complexity. (Faster solutions may be possible.)

In practice, a few tests go a long way …

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 96: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

96

Graph Invariants under Isomorphism

Necessary but not sufficient conditions for G1=(V1, E1) to be isomorphic to G2=(V2, E2):

|V1|=|V2| and |E1|=|E2|. The number of vertices with degree n is the same

in both graphs. For every proper subgraph g of one graph, there is

a proper subgraph of the other graph that is isomorphic to g.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 97: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

97

Isomorphism Example

If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.

a

b

cd

ef

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 98: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

98

Isomorphism Example

If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.

a

b

cd

ef

d

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 99: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

99

Isomorphism Example

If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.

a

b

cd

ef

d

f

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 100: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

100

Isomorphism Example

If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.

a

b

cd

ef

b

d

f

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 101: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

101

Isomorphism Example

If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.

a

b

cd

ef

b

d

a

f

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 102: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

102

Isomorphism Example

If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.

a

b

cd

ef

b

d

a

ef

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 103: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

103

Isomorphism Example

If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.

a

b

cd

ef

b

d

a

efc

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 104: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

104

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 105: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

105

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

• Same # of vertices

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 106: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

106

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

• Same # of vertices

• Same # of edges

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 107: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

107

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

• Same # of vertices

• Same # of edges

• Different # of verts of degree 2! (1 vs 3)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 108: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

108

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

• Same # of vertices

• Same # of edges

• Different # of verts of degree 2! (1 vs 3)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 109: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

109

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

• Same # of vertices

• Same # of edges

• Different # of verts of degree 2! (1 vs 3)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 110: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

110

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

• Same # of vertices

• Same # of edges

• Different # of verts of degree 2! (1 vs 3)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 111: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

111

Are These Isomorphic?If isomorphic, label the 2nd graph to show the

isomorphism, else identify difference.

ab

c

d

e

• Same # of vertices

• Same # of edges

• Different # of verts of degree 2! (1 vs 3)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 112: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

112

We now jump to the area that gave raise to the invention of (a formal theory of) graphs

Questions like “Can I travel from a to b?” “Can I go travel a to b

without going anywhere twice?” “What’s the quickest route from a to b?”

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 113: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

113

Connectivity

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 114: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

114

ConnectivityIn an undirected graph, a path of length n from

u to v is a sequence of adjacent edges going from vertex u to vertex v.

A path is a circuit if u=v.A path traverses the vertices along it.A path is simple if it contains no edge more

than once.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 115: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

115

Connectedness

An undirected graph is connected iff there is a path between every pair of distinct vertices in the graph.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 116: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

116

Connectedness

An undirected graph is connected iff there is a path between every pair of distinct vertices in the graph.

Theorem: There is a simple path between any pair of vertices in a connected undirected graph.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 117: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

117

Directed Connectedness

A directed graph is strongly connected iff there is a directed path from a to b for any two verts a and b.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 118: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

118

Directed Connectedness

A directed graph is strongly connected iff there is a directed path from a to b for any two verts a and b.

It is weakly connected iff the underlying undirected graph (i.e., with edge directions removed) is connected.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 119: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

119

Paths & IsomorphismNote that connectedness, and the existence of

a circuit or simple circuit of length k are graph invariants with respect to isomorphism.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 120: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

120

Euler & Hamilton

Paths

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 121: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

121

Euler & Hamilton Paths

We’ll show you the problem that prompted Euler to invent the theory of graphs: the bridges of Koenigsberg (town later called Kaliningrad)

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 122: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

122

Bridges of Königsberg ProblemCan we walk through town, crossing each

bridge exactly once, and return to start?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 123: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

123

Bridges of Königsberg ProblemCan we walk through town, crossing each

bridge exactly once, and return to start?

Dis

cret

e S

truct

ures

Fa

ll 13

89

Can you model the situation using a

graph?

A

B

C

D

The original problem

Page 124: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

124

Bridges of Königsberg ProblemCan we walk through town, crossing each

bridge exactly once, and return to start?

Dis

cret

e S

truct

ures

Fa

ll 13

89

A

B

C

D

The original problemEquivalent multigraph

Page 125: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

125

Euler & Hamilton Paths

Terminology:

An Euler circuit in a graph G is a simple circuit containing every edge of G.

An Euler path in G is a simple path containing every edge of G.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 126: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

126

Bridges of KoenigsbergBridges are edges.

So the answer to the problem is YES iff its graph contains an Euler circuit.

In fact, it does not …

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 127: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

127

Euler Path Theorems

Theorem: A finite connected multigraph has an Euler circuit iff each vertex has even degree. Proof:

• (→) The circuit contributes 2 to degree of each node.• (←) By construction using algorithm on p. 580-581

Theorem: A connected multigraph has an Euler path iff it has exactly 2 vertices of odd degree. One is the start, the other is the end.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 128: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

128

Not all edges have even degree

… so there is no Euler circuit.

A

B

C

D

The original problemEquivalent multigraph

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 129: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

129

Euler Circuit theorem Sketch of proof that even degree implies existence of Euler

circuit: Start with any arbitrary node. Construct simple path from it

till you get back to start. (Graph is connected; every node has even degree, so you can leave any node that you have entered)

Repeat for each remaining subgraph, splicing results back into original cycle. Finiteness of graph implies that this process must end.

Note that the complete version of this proof provides an algorithm: it’s a constructive proof of an existential proposition

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 130: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

130

Hamilton Paths

An Euler circuit in a graph G is a simple circuit containing every edge of G.

An Euler path in G is a simple path containing every edge of G.

A Hamilton circuit is a circuit that traverses each vertex in G exactly once.

A Hamilton path is a path that traverses each vertex in G exactly once.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 131: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

131

Hamiltonian Path TheoremsDirac’s theorem: If (but not only if) G is

connected, simple, has n3 vertices, and v deg(v)n/2, then G has a Hamilton circuit. Ore’s corollary: If G is connected, simple, has

n≥3 nodes, and deg(u)+deg(v)≥n for every pair u,v of non-adjacent nodes, then G has a Hamilton circuit.

Dis

cret

e S

truct

ures

Fa

ll 13

89

Page 132: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

132

You will learn about the following topics in graphs later in other courses: shortest-path problem Graph coloring

Page 133: LOGO.  Relations:  In these slides: Introductions to graphs Graph terminology Representing graphs and graph isomorphism Connectivity Euler and Hamilton.

LOGO

LOGO

Any Question?Good Luck