based on slides by y. peng university of maryland

25
1 Representing Graphs and Graph Isomorphism (Chapter 9.3) Connectivity (Chapter 9.4) Based on slides by Y. Peng University of Maryland University of Maryland

Upload: alphonse-meller

Post on 31-Dec-2015

22 views

Category:

Documents


1 download

DESCRIPTION

Based on slides by Y. Peng University of Maryland. Representing Graphs and Graph Isomorphism (Chapter 9.3) Connectivity (Chapter 9.4). a. a. d. b. b. d. c. c. Initial Vertex. Vertex. Adjacent Vertices. Terminal Vertices. a. a. b, c, d. c. b. b. a. a, d. c. c. a, d. d. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Based on slides by Y. Peng University of Maryland

1

Representing Graphs and

Graph Isomorphism(Chapter 9.3)

Connectivity (Chapter 9.4)

Based on slides by Y. PengUniversity of MarylandUniversity of Maryland

Page 2: Based on slides by Y. Peng University of Maryland

2

Representing GraphsRepresenting Graphsaa

bb

cc

dd

aa

bb

cc

dd

a, da, dbb

a, da, dcc

a, b, ca, b, cdd

b, c, db, c, daa

Adjacent Adjacent VerticesVerticesVertexVertex

aabb

cc

a, b, ca, b, cdd

ccaa

Terminal Terminal VerticesVertices

Initial Initial VertexVertex

Page 3: Based on slides by Y. Peng University of Maryland

3

Representing GraphsRepresenting Graphs

Definition:Definition: Let G = (V, E) be a simple graph with Let G = (V, E) be a simple graph with |V| = n. Suppose that the vertices of G are listed |V| = n. Suppose that the vertices of G are listed in arbitrary order as vin arbitrary order as v11, v, v22, …, v, …, vnn. .

The The adjacency matrixadjacency matrix A (or A A (or AGG) of G, with ) of G, with respect to this listing of the vertices, is the nrespect to this listing of the vertices, is the nn n zero-one matrix with 1 as its (i, j) entry when vzero-one matrix with 1 as its (i, j) entry when vii and vand vjj are adjacent, and 0 otherwise. are adjacent, and 0 otherwise.

In other words, for an adjacency matrix A = [aIn other words, for an adjacency matrix A = [aijij], ],

aaijij = 1 = 1 if {vif {vii, v, vjj} is an edge of G,} is an edge of G,aaijij = 0 = 0 otherwise.otherwise.

Page 4: Based on slides by Y. Peng University of Maryland

4

Representing GraphsRepresenting Graphs

aa

bb

cc

dd

Example:Example: What is the What is the adjacency matrix Aadjacency matrix AGG for the for the following graph G based on following graph G based on the order of vertices a, b, c, the order of vertices a, b, c, d ?d ?

Solution:Solution:

0111

1001

1001

1110

GA

Note:Note: Adjacency matrices of undirected Adjacency matrices of undirected graphs are always symmetric.graphs are always symmetric.

Page 5: Based on slides by Y. Peng University of Maryland

5

Representing GraphsRepresenting Graphs

Definition:Definition: Let G = (V, E) be an undirected Let G = (V, E) be an undirected graph with |V| = n. Suppose that the vertices and graph with |V| = n. Suppose that the vertices and edges of G are listed in arbitrary order as vedges of G are listed in arbitrary order as v11, v, v22, , …, v…, vn n and eand e11, e, e22, …, e, …, emm, respectively. , respectively.

The The incidence matrixincidence matrix of G with respect to this of G with respect to this listing of the vertices and edges is the nlisting of the vertices and edges is the nm zero-m zero-one matrix with 1 as its (i, j) entry when edge eone matrix with 1 as its (i, j) entry when edge e jj is incident with vis incident with vii, and 0 otherwise., and 0 otherwise.

In other words, for an incidence matrix M = [mIn other words, for an incidence matrix M = [m ijij], ],

mmijij = 1 = 1 if edge eif edge ejj is incident with v is incident with vii mmijij = 0 = 0 otherwise.otherwise.

Page 6: Based on slides by Y. Peng University of Maryland

6

Representing GraphsRepresenting GraphsExample:Example: What is the What is the incidence matrix M for the incidence matrix M for the following graph G based on following graph G based on the order of vertices a, b, c, d the order of vertices a, b, c, d and edges 1, 2, 3, 4, 5, 6?and edges 1, 2, 3, 4, 5, 6?

Solution:Solution:

001110

111000

000101

010011

M

Note:Note: Incidence matrices of directed graphs contain two 1s Incidence matrices of directed graphs contain two 1s per column for edges connecting two vertices and one 1 per per column for edges connecting two vertices and one 1 per column for loops.column for loops.

aa

bb

cc

dd

1122

445533

66

Page 7: Based on slides by Y. Peng University of Maryland

7

Isomorphism of GraphsIsomorphism of Graphs

Definition:Definition: The simple graphs G The simple graphs G11 = (V = (V11, E, E11) and ) and GG22 = (V = (V22, E, E22) are ) are isomorphicisomorphic if there is a if there is a bijection (an one-to-one and onto function) f bijection (an one-to-one and onto function) f from Vfrom V11 to V to V22 with the property that a and b are with the property that a and b are adjacent in Gadjacent in G11 if and only if f(a) and f(b) are if and only if f(a) and f(b) are adjacent in Gadjacent in G22, for all a and b in V, for all a and b in V11..

Such a function f is called an Such a function f is called an isomorphismisomorphism..

In other words, GIn other words, G11 and G and G22 are isomorphic if their are isomorphic if their vertices can be ordered in such a way that the vertices can be ordered in such a way that the adjacency matrices Madjacency matrices MGG11

and M and MGG22 are identical. are identical.

Page 8: Based on slides by Y. Peng University of Maryland

8

Isomorphism of GraphsIsomorphism of Graphs

From a visual standpoint, GFrom a visual standpoint, G11 and G and G22 are are isomorphic if they can be arranged in such a isomorphic if they can be arranged in such a way that their way that their displays are identicaldisplays are identical (of (of course without changing adjacency).course without changing adjacency).

Unfortunately, for two simple graphs, each with Unfortunately, for two simple graphs, each with n vertices, there are n vertices, there are n! possible n! possible isomorphismsisomorphisms that we have to check in order that we have to check in order to show that these graphs are isomorphic.to show that these graphs are isomorphic.

However, showing that two graphs are However, showing that two graphs are notnot isomorphic can be easy.isomorphic can be easy.

Page 9: Based on slides by Y. Peng University of Maryland

9

Isomorphism of GraphsIsomorphism of GraphsFor this purpose we can check For this purpose we can check invariantsinvariants, that , that is, properties that two isomorphic simple graphs is, properties that two isomorphic simple graphs must both have.must both have.

For example, they must haveFor example, they must have

• the same number of vertices,the same number of vertices,

• the same number of edges, andthe same number of edges, and

• the same degrees of vertices.the same degrees of vertices.

Note that two graphs that Note that two graphs that differdiffer in any of these in any of these invariants are not isomorphic, but two graphs invariants are not isomorphic, but two graphs that that matchmatch in all of them are not necessarily in all of them are not necessarily isomorphic.isomorphic.

Page 10: Based on slides by Y. Peng University of Maryland

10

Isomorphism of GraphsIsomorphism of GraphsExample I:Example I: Are the following two graphs isomorphic? Are the following two graphs isomorphic?

dd

aa

bb

cc

ee

dd

aa

bbcc

ee

Solution:Solution: YesYes, they are isomorphic, because they can be , they are isomorphic, because they can be arranged to look identical. You can see this if in the right graph arranged to look identical. You can see this if in the right graph you move vertex b to the left of the edge {a, c}. Then the you move vertex b to the left of the edge {a, c}. Then the isomorphism f from the left to the right graph is: f(a) = e, f(b) = a, isomorphism f from the left to the right graph is: f(a) = e, f(b) = a, f(c) = b, f(d) = c, f(e) = d. f(c) = b, f(d) = c, f(e) = d.

Page 11: Based on slides by Y. Peng University of Maryland

11

Isomorphism of GraphsIsomorphism of GraphsExample II:Example II: How about these two graphs? How about these two graphs?

dd

aabb

cc

ee

dd

aa

bb

cc

ee

Solution:Solution: NoNo, they are not isomorphic, because , they are not isomorphic, because they differ in the degrees of their vertices.they differ in the degrees of their vertices.

Vertex d in right graph is of degree one, but there is Vertex d in right graph is of degree one, but there is no such vertex in the left graph.no such vertex in the left graph.

Page 12: Based on slides by Y. Peng University of Maryland

12

ExamplesExamples

Determine if the following two graphs G1 and G2 are isomorphic:

Question 35, p. 619, and 41, p. 620

Page 13: Based on slides by Y. Peng University of Maryland

13

ConnectivityConnectivity

Definition:Definition: A A pathpath of length n from u to v, of length n from u to v, where n is a positive integer, in an where n is a positive integer, in an undirected undirected graphgraph is a sequence of edges e is a sequence of edges e11, e, e22, …, e, …, enn of of the graph such that ethe graph such that e11 = {x = {x00, x, x11}, e}, e22 = {x = {x11, x, x22}, }, …, e…, enn = {x = {xn-1n-1, x, xnn}, where x}, where x00 = u and x = u and xnn = v. = v.

When the graph is simple, we denote this path When the graph is simple, we denote this path by its by its vertex sequencevertex sequence x x00, x, x11, …, x, …, xnn, since it , since it uniquely determines the path.uniquely determines the path.

The path is a The path is a circuitcircuit if it begins and ends at the if it begins and ends at the same vertex, that is, if u = v. same vertex, that is, if u = v.

Page 14: Based on slides by Y. Peng University of Maryland

14

ConnectivityConnectivity

Definition (continued):Definition (continued): The path or circuit is The path or circuit is said to said to pass throughpass through or traverse x or traverse x11, x, x22, …, x, …, xn-1n-1. .

A path or circuit is A path or circuit is simplesimple if it does not contain if it does not contain the same edge more than once.the same edge more than once.

Page 15: Based on slides by Y. Peng University of Maryland

15

ConnectivityConnectivity

Let us now look at something new:Let us now look at something new:

Definition:Definition: An undirected graph is called An undirected graph is called connectedconnected if there is a path between every if there is a path between every pair of pair of distinctdistinct vertices in the graph. vertices in the graph.

For example, any two computers in a network For example, any two computers in a network can communicate if and only if the graph of this can communicate if and only if the graph of this network is connected.network is connected.

Note:Note: A graph consisting of only one vertex is A graph consisting of only one vertex is always connected, because it does not contain always connected, because it does not contain any pair of distinct vertices.any pair of distinct vertices.

Page 16: Based on slides by Y. Peng University of Maryland

16

ConnectivityConnectivityExample:Example: Are the following graphs connected? Are the following graphs connected?

dd

aabb

cc

ee

Yes.Yes.

dd

aabb

ccee

No.No.

dd

aabb

cc

ee

Yes.Yes.

dd

aabb

ccee

ffNo.No.

Page 17: Based on slides by Y. Peng University of Maryland

17

ConnectivityConnectivity

Definition:Definition: A graph that is not connected is A graph that is not connected is the union of two or more connected subgraphs, the union of two or more connected subgraphs, each pair of which has no vertex in common. each pair of which has no vertex in common. These disjoint connected subgraphs are called These disjoint connected subgraphs are called the the connected componentsconnected components of the graph. of the graph.

Definition:Definition: A A connected componentconnected component of a of a graph G is a maximal connected subgraph of G.graph G is a maximal connected subgraph of G.

E.g., if vertex v in G belongs to a connected E.g., if vertex v in G belongs to a connected component, then all other vertices in G that is component, then all other vertices in G that is connected to v must also belong to that connected to v must also belong to that component.component.

Page 18: Based on slides by Y. Peng University of Maryland

18

ConnectivityConnectivity

Example:Example: What are the connected components What are the connected components in the following graph?in the following graph?

aa

bb cc

ddii hh

ggjjff

ee

Solution:Solution: The connected components are the graphs The connected components are the graphs with vertices {a, b, c, d}, {e}, {f}, {i, g, h, j}.with vertices {a, b, c, d}, {e}, {f}, {i, g, h, j}.

Page 19: Based on slides by Y. Peng University of Maryland

19

ConnectivityConnectivity

Definition:Definition: An directed graph is An directed graph is strongly strongly connectedconnected if there is a path from a to b and if there is a path from a to b and from b to a whenever a and b are vertices in from b to a whenever a and b are vertices in the graph. the graph.

Definition:Definition: An directed graph is An directed graph is weakly weakly connectedconnected if there is a path between any two if there is a path between any two vertices in the underlying undirected graph. vertices in the underlying undirected graph.

Page 20: Based on slides by Y. Peng University of Maryland

20

ConnectivityConnectivityExample:Example: Are the following directed graphs Are the following directed graphs strongly or weakly connected?strongly or weakly connected?

aa

bb

cc

dd

Weakly connectedWeakly connected, , because, for example, there because, for example, there is no path from b to d.is no path from b to d.

aa

bb

cc

dd

Strongly connectedStrongly connected, , because there are paths because there are paths between all possible pairs of between all possible pairs of vertices.vertices.

Page 21: Based on slides by Y. Peng University of Maryland

21

Cut vertices and edgesCut vertices and edges

If one can remove a vertex (and all incident edges) and produce a graph with more components, the vertex is called a cut vertex or articulation point.

Similarly if removal of an edge creates more components the edge is called a cut edge or bridge.

Page 22: Based on slides by Y. Peng University of Maryland

22

In the graphs G1 and G2 every edge is a cut edge. In the union, no edge is a cut edge.Vertex e is a cut vertex in all graphs.

In the star network the center vertex is a cut vertex. All edges are cut edges.

Page 23: Based on slides by Y. Peng University of Maryland

23

Isomorphic graphs must have ‘the same’ paths.Isomorphic graphs must have ‘the same’ paths.If one is a simple circuit of length If one is a simple circuit of length kk, ,

then so must be the other.then so must be the other.

Theorem.Theorem. Let Let MM be the adjacency matrix for graph be the adjacency matrix for graph GG..

Then each (Then each (i, ji, j) entry in ) entry in MMrr is the number of paths of is the number of paths of

length length rr from vertex from vertex ii to vertex to vertex jj..

Note:Note: This is the standard power of m, This is the standard power of m,

not a Boolean product.not a Boolean product.

Proof is given below. First an example.Proof is given below. First an example.

Page 24: Based on slides by Y. Peng University of Maryland

24

Page 25: Based on slides by Y. Peng University of Maryland

25