1 Discrete Math Graphs, representation, isomorphism, connectivity

Preview:

Citation preview

1

Discrete Math

Graphs,

representation,

isomorphism,

connectivity

Adjacent The vertices u and v in a undirected graph

are adjacent when there are endpoints of an edge of G represented by the un ordered pair (u,v)

When the initial vertex u and final vertex v in a directed graph are endpoints of the edge represented by the ordered pair (u,v), then u is adjacent to v and v is adjacent from u

2

Representation Consider a graph with no multiple edges.

(NOTE: For directed graphs the pairs (u,v) and (v,u) are not multiple edges)

The graph can be represented by a list of all the edges that are part of the graph

The graph can be represented by an adjacency list

The graph can be represented by an adjacency matrix.

3

Adjacency List: undirected

vertex Adjacent vertices

a c

b c

c a, b, d

d c, e, f

e d, e, f

f d, e

4

e

f

c

d

a

f

e

d

c

b

Adjacency Matrix The Adjacency matrix A of a graph G=(V,E), with

respect to the set of edges V, where V does not include multiple edges is

The graph has at most one edge If the graph is not directed is an unordered pair If the graph is directed is a ordered pair

5

otherwise

Gofedgeanisvvifa mkkm 0

),(1

),( mk vv

),( mk vv

),( mk vv

Adjacency Matrix

6

e

f

c

d

a

f

e

d

c

b

011000

111000

110100

001011

000100

000100

Adjacency matrix element amk is 1 if there is an edge between node number m and number k, and 0 otherwise

Adjacency List: directed

Initial vertex Terminal vertices

a b, c, g

b a

c d, e

d e, g

e c, e, g, f

f -

g d, f

7

e

f

c

d

a

f

e

d

c

b

dg

Adjacency Matrix

8

0101000

0000000

1110100

1010000

0011000

0000001

1000110

Adjacency matrix element amk is 1 if there is an edge from node number m to node number k, and 0 otherwise

e

f

c

d

a

f

e

d

c

b

dg

Observations The adjacency matrix of an undirected

graph is symmetric The adjacency list will be more useful in a

sparse graph with few edges The adjacency matrix will be most useful

in a dense graph with many edges

9

What about multiple edges? How do we generalize these representations to

include graphs with multiple edges between the same vertices Multiple edges for an undirected graph means two or

more edges between the same pair of nodes Multiple edges for a directed graph means two or

more edges between the same ordered pair of nodes. That is multiple edges in the same direction between the same pair of nodes

10

Adjacency Matrix The Adjacency matrix A of a graph G=(V,E), with

respect to the set of edges V, where V does include multiple edges is

11

otherwise

Ginmv

kvedgesnarethereifn

kma

0

),(

Adjacency Matrix

12

e

f

c

d

a

f

e

d

c

b

014000

113000

430100

001012

000100

000200

Adjacency matrix element amk is 1 if there is an edge between node number m and number k, and 0 otherwise

Adjacency Matrix

13

0201000

0000000

1410100

1010000

0011000

0000002

1000310

Adjacency matrix element amk is 1 if there is an edge from node number m to node number k, and 0 otherwise

e

f

c

d

a

f

e

d

c

b

dg

Incidence matrices Let G=(V,E) be an undirected graph, an

incidence matrix representing G has one row for each vertex v1, v2, … , vn in V and one column for each edge e1, e2, …, em in E.

14

otherwise

vwithincidentiseedgewhenkpm kp

0

1

Incidence Matrix

15

e

f

c

d

a

f

e

d

c

b

00000000000

00111110000

11100000000

10011111000

00000001111

00000000100

00000000011

Incidence matrix element amk is 1 if there is an edge ek is incident with node number m and node number k, and 0 otherwise

e9

e1, e2

e5,e6 e7, e8

e4

e3

e10

e11

Incidence matrices Let G=(V,E) be an directed graph, an

incidence matrix representing G has one row for each vertex v1, v2, … , vn in V and one column for each edge e1, e2, …, em in E.

16

otherwise

vtoinincidentiseedgewhenvfromoutincidentiseedgewhen

kpm kp

kp

0

11

Incidence Matrix

17

11100000110

11101001000

00011110000

00010000000

00000111111

00000000001

Adjacency matrix element amk is 1 if there is an edge from node number m to node number k, and 0 otherwise

e

c

d

a

f

e

d

c

db

e8

e9,

e10 e11

e7

e5, e6

e4

e2, e3

e1

Isomorphism Two simple graphs G1=(V,E) and

G2=(W,F) are isomorphic if there is a oneto one and onto function f from V to W with the property that if a and b are adjacent in G1 iff f(a) and f(b) are adjacent in G2, for all a and b in V.

Such a function f is called an isomorphism

18

Isomorphic graphs When two graphs are isomorphic then they have

the same number of vertices the same number of edges the same number of vertices or any degree n

These properties are called graph invariants and are identical for two graphs that are isomorphic. If any of these invariants changes between the two graphs, the two graphs are not isomorphic.

However, if these graph invariants are all identical it does not imply the graphs are isomorphic

19

Graphs A and B

20

a1

a5a4

a3a2

b5b4

b3b2b1

Are A and B isomorphic? They both have the same number of vertices They both have the same number of edges They both have 3 vertices of degree 2, and 2 vertices

of degree 3 The graphs may be isomorphic, to prove they are we

need to find an isomorphism However, in graph a there are no two nodes of degree

2 that are adjacent to each other, in graph b there are two nodes of degree 2 that are adjacent. Therefore, the two graphs are not isomorphic

21

Graphs A and B

22

a1

a5a4

a3a2

b5b4

b3b2b1

Are A and B isomorphic? They both have the same number of

vertices They both have the same number of edges They both have two vertices of degree 2,

two vertices of degree 3 and 1 vertex of degree 4

The graphs may be isomorphic, to prove they are we need to find an isomorphism

23

Isomorphism Since an isomorphism preserves

adjacency, If n vertices are adjacent to a given vertex in a graph, then the images of those n vertices must be adjacent to the image of the vertex in the isomorphic graph.

Therefore, the order of the nodes should be preserved by the isomorphism.

24

Graphs A and B

25

a1

a5a4

a3a2

b5b4

b3b2b1

Isomorphism (2) There is only one node that is adjacent to 4

other nodes ( degree 4) so the image of that node must be the node in graph B which has degree 4. So F(a1) = b2

a1 is adjacent to 2 nodes of degree 3 (a2 and a3). The images of these nodes must be the nodes in B which have degree 3 (b4 and b5). Both are adjacent to b2

26

Isomorphism (3) We have two possible ways to choose to assign

the isomorphism between these points. Since both ways preserve adjacency a2 and a3 are adjacent, b4 and b5 are adjacent a2 and a3 are both adjacent to a1, b4 and b5 are

both adjacent to b2 a2 and a3 are both adjacent to a node of degree 2,

that is adjacent to a1, b4 and b5 are both adjacent to a node of degree 2 that is adjacent to b2

27

Isomorphism (4) we will randomly choose one, if it does

not work we will return and try the other. F(a2) = b5 F(a3) = b4

28

Graphs A and B

29

a1

a5a4

a3a2

b5b4

b3b2b1

Isomorphism (5) F(a1)= b2 F(a2) = b5 F(a3) = b4 A4 is adjacent to both a3 and a1, so its

image must be adjacent to b4 and b2. A5 is adjacent to both a2 and a1 so its

image must be adjacent to b5 and b4 F(a4) = b1, F(a5) = b3

30

Isomorphic Graphs A and B

31

a1

a5a4

a3a2

b5b4

b3b2b1

Paths: undirected graphs Let n be a nonnegative integer and G an undirected graph. A

path of length n from u to v in G is a sequence of n edges e1, e2, … , en of G such that e1 is (u, x1), e2 is (x1,x2), and en is (xn-1, v). When the graph is simple we denote the path by the vertex

sequence u, x1, x2, … , xn-1, v.

A circuit is a path with n>0 which starts and ends at the same vertex

The path or circuit passes through these vertices and traverses the edges

A path or circuit is simple if it does not traverse the same edge more than once

32

Paths: directed graphs Let n be a nonnegative integer and G a directed graph. A path

of length n from u to v in G is a sequence of n edges e1, e2, … , en of G such that e1 is (u, x1), e2 is (x1,x2), and en is (xn-1, v).

When there are no multiple edges we denote the path by the vertex sequence u, x1, x2, … , xn-1, v.

A circuit is a path with n>0 which starts and ends at the same vertex

The path or circuit passes through these vertices and traverses the edges

A path or circuit is simple if it does not traverse the same edge more than once

33

Alternate terms A walk is an alternating sequence of

vertices and edges starting at vertex u and ending at vertex v

A circuit may be called a closed walk S simple circuit may be called a trail If a reference is using walk, closed walk

and trail, it may use path do describe a trail with no repeated vertices

34

Connected An undirected graph is called connected

if there is a path between every pair of distinct vertices of the graph.

35

Connectedness: directed graphs A directed graph is strongly connected if

there is a path from a to b and from b to a whenever a and b are nodes in the directed graph

A directed graph is weakly connected if there is a path between each of the vertices in the underlying undirected graph

36

Connected? Is this undirected graph connected?

37NO

Connected? Is this undirected graph connected?

The green vertex is an isolated vertex. There is no path connecting it to any other vertex. The graph cannot be connected.

The red vertex is a pendant vertex. It is connected to the graph by only a single edge

38

Connected? Is this undirected graph connected?

39

YES

Strongly Connected? Is this undirected graph strongly connected?

40

NO

Weakly Connected? Is this undirected graph strongly connected?

41

Underlying undirected graph

Is this underlying undirected graph connected?

YES: so the digraph is weakly connected42

Strongly Connected? Is this undirected graph connected?

43

YES

Subgraph Recall

A subgraph of a graph G=(V,E) is a graph H=(W,F) when W⊆V and F⊆E.

A subgraph H of G is a proper subgraph of G if H=G

44

Connected component A maximal connected subgraph is a subgraph

such that there are no nodes and edges in the original graph that could be added to the subgraph and still leave it connected.

A connected component of a graph G is a connected subgraph of G that is not a proper subgraph of another connected subgraph of G. That is, it is a maximal connected subgraph of G

45

Connected components?

46

Cut Edges When removing a vertex, increases the number

of connected components in the graph then the vertex (that was removed) is called a cut vertex or articulation point

Let v be a vertex in a graph G=(V,E). The subgraph of G denoted G-v has the vertex set V1=V-v and the edges E1⊆E where E1 contains all edges in E except for those that are incident with (out from, in to) the vertex v

47

Find a cut vertex

48

With cut vertex removed

49

Cut Edges When removing a edge, increases the number

of connected components in the graph then the edge (that was removed) is called a cut edge or bridge

Let e be an edge in a graph G=(V,E). The subgraph of G denoted G-e has the same vertex set V and the edges E1=E-e

50

Find a cut edge

51

With a cut edge removed

52

Paths and Isomorphism The existance of a circuit of a particular

length within a graph is an isomorphic invariant.

If a graph G has a circuit of length n from node v to node v then any graph that is isomorphic to G must also have a circuit of length n from F(v) to F(v)

53

Recommended