1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of...

43
1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) Based on slides by Y. Peng University of Maryland University of Maryland

Transcript of 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of...

Page 1: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

1

Representing Graphs and

Graph Isomorphism(Chapter 10.3)

Connectivity (Chapter 10.4)

Based on slides by Y. PengUniversity of MarylandUniversity of Maryland

Page 2: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

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: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

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: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

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: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

5

Representing Directed GraphsRepresenting Directed Graphs

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

Solution:Solution:

aa

bb

cc

dd

0111

0000

0001

0100

GA

Page 6: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

6

Representing PseudographsRepresenting Pseudographs

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

Solution:Solution:

Page 7: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

7

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 8: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

8

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 undirected graphs Incidence matrices of undirected graphs contain two 1s per column for edges contain two 1s per column for edges connecting two vertices and one 1 per column connecting two vertices and one 1 per column for loops.for loops.

aa

bb

cc

dd

1122

445533

66

Page 9: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

9

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 10: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

10

Isomorphism of GraphsIsomorphism of GraphsFrom 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 11: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

11

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 12: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

12

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 are isomorphic, because they can be arranged to look identical. You can they can be arranged to look identical. You can see this if in the right graph you move vertex b see this if in the right graph you move vertex b to the left of the edge {a, c}. Then the to the left of the edge {a, c}. Then the isomorphism f from the left to the right graph isomorphism f from the left to the right graph is: f(a) = e, f(b) = a, 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 13: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

13

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, , they are not isomorphic, because they differ in the degrees of their because they differ in the degrees of their vertices.vertices.

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

Page 14: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

ExampleExample

Are these two graphs isomorphic?Are these two graphs isomorphic?

– They both have 5 verticesThey both have 5 vertices– They both have 8 edgesThey both have 8 edges– They have the same number of vertices with They have the same number of vertices with

the same degrees: 2, 3, 3, 4, 4.the same degrees: 2, 3, 3, 4, 4.

G HG H

uu11 uu22

uu55 uu3 3

uu44

vv11 vv22

vv55

vv3 3

vv44

Page 15: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Example (Cont.)Example (Cont.)

uu11 uu22 uu33 uu44 uu55

uu11 0 1 0 1 1 0 1 0 1 1

uu22 1 0 1 1 1 1 0 1 1 1

uu33 0 1 0 1 0 0 1 0 1 0

uu44 1 1 1 0 1 1 1 1 0 1

uu55 1 1 0 1 0 1 1 0 1 0

vv11 vv2 2 vv33 vv44 vv55

vv11 0 0 1 1 1 0 0 1 1 1

vv22 0 0 1 0 1 0 0 1 0 1

vv33 1 1 0 1 1 1 1 0 1 1

vv44 1 0 1 0 1 1 0 1 0 1

vv55 1 1 1 1 0 1 1 1 1 0– G and H don’t appear to be isomorphic. G and H don’t appear to be isomorphic.

– However, we haven’t tried mapping vertices from However, we haven’t tried mapping vertices from G onto H yet. G onto H yet.

vv11 vv33 vv22 vv55 vv44

vv11

vv33

vv22

vv55

vv44

GG HH H H G? G?

Page 16: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Example (Cont.)Example (Cont.)

Start with the vertices of degree 2 since each Start with the vertices of degree 2 since each graph only has one:graph only has one:

deg(deg(uu33) = deg() = deg(vv22) = 2 therefore ) = 2 therefore ff((uu33) = ) = vv22

Page 17: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Example (Cont.)Example (Cont.)

Now consider vertices of degree 3Now consider vertices of degree 3deg(deg(uu11) = deg() = deg(uu55) = deg() = deg(vv11) = deg() = deg(vv44) = 3) = 3

therefore we must have either one oftherefore we must have either one of

ff((uu11) = ) = vv11 and and ff((uu55) = ) = vv4 4

ff((uu11) = ) = vv44 and and ff((uu55) = ) = vv11

Page 18: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Example (Cont.)Example (Cont.)

Now try vertices of degree 4:Now try vertices of degree 4:deg(deg(uu22) = deg() = deg(uu44) = deg() = deg(vv33) = deg() = deg(vv55) = 4 ) = 4

therefore we must have one of:therefore we must have one of:ff((uu22) = ) = vv33 and and ff((uu44) = ) = vv55 oror

ff((uu22) = ) = vv55 and and ff((uu44) = ) = vv33

Page 19: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Example (Cont.)Example (Cont.)

There are four possibilities (this can get There are four possibilities (this can get messy!)messy!)ff((uu11) = ) = vv11, , ff((uu22) = ) = vv33, , ff((uu33) = ) = vv22, , ff((uu44) = ) = vv55,, ff((uu55) = ) = vv44

ff((uu11) = ) = vv44, , ff((uu22) = ) = vv33, , ff((uu33) = ) = vv22, , ff((uu44) = ) = vv55,, ff((uu55) = ) = vv11

ff((uu11) = ) = vv11, , ff((uu22) = ) = vv55, , ff((uu33) = ) = vv22, , ff((uu44) = ) = vv33,, ff((uu55) = ) = vv44

ff((uu11) = ) = vv44, , ff((uu22) = ) = vv55, , ff((uu33) = ) = vv22, , ff((uu44) = ) = vv33,, ff((uu55) = ) = vv11

Page 20: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Example (Cont.)Example (Cont.)

uu11 uu22 uu33 uu44 uu55

uu11 0 1 0 1 1 0 1 0 1 1

uu22 1 0 1 1 1 1 0 1 1 1

uu33 0 1 0 1 0 0 1 0 1 0

uu44 1 1 1 0 1 1 1 1 0 1

uu55 1 1 0 1 0 1 1 0 1 0

vv11 vv2 2 vv33 vv44 vv55

vv11 0 0 1 1 1 0 0 1 1 1

vv22 0 0 1 0 1 0 0 1 0 1

vv33 1 1 0 1 1 1 1 0 1 1

vv44 1 0 1 0 1 1 0 1 0 1

vv55 1 1 1 1 0 1 1 1 1 0We permute the adjacency matrix of We permute the adjacency matrix of HH (per function choices (per function choices

above) to see if we get the adjacency of above) to see if we get the adjacency of GG.. Let’s try:Let’s try:

ff((uu11) = ) = vv11, , ff((uu22) = ) = vv33, , ff((uu33) = ) = vv22, , ff((uu44) = ) = vv55,, ff((uu55) = ) = vv44

Does G = H’? Yes!Does G = H’? Yes!

vv11 vv33 vv22 vv55 vv44

vv11 0 1 0 1 1 0 1 0 1 1

vv33 1 0 1 1 1 1 0 1 1 1

vv22 0 1 0 1 0 0 1 0 1 0

vv55 1 1 1 0 1 1 1 1 0 1

vv44 1 1 0 1 0 1 1 0 1 0

GG HH H’ H’

Page 21: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Example (Cont.)Example (Cont.)

uu11 uu22 uu33 uu44 uu55

uu11 0 1 0 1 1 0 1 0 1 1

uu22 1 0 1 1 1 1 0 1 1 1

uu33 0 1 0 1 0 0 1 0 1 0

uu44 1 1 1 0 1 1 1 1 0 1

uu55 1 1 0 1 0 1 1 0 1 0

vv11 vv2 2 vv33 vv44 vv55

vv11 0 0 1 1 1 0 0 1 1 1

vv22 0 0 1 0 1 0 0 1 0 1

vv33 1 1 0 1 1 1 1 0 1 1

vv44 1 0 1 0 1 1 0 1 0 1

vv55 1 1 1 1 0 1 1 1 1 0It turns out thatIt turns out that

ff((uu11) = ) = vv44, , ff((uu22) = ) = vv33, , ff((uu33) = ) = vv22, , ff((uu44) = ) = vv55,, ff((uu55) = ) = vv11

also works.also works.

vv44 vv33 vv22 vv55 vv11

vv44 0 1 0 1 1 0 1 0 1 1

vv33 1 0 1 1 1 1 0 1 1 1

vv22 0 1 0 1 0 0 1 0 1 0

vv55 1 1 1 0 1 1 1 1 0 1

vv11 1 1 0 1 0 1 1 0 1 0

GG HH H’ H’

Page 22: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

22

ExamplesExamples

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

Question 41, p. 677Question 35, p. 676

Page 23: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

23

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 24: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

24

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 25: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

25

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 26: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

26

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 27: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

27

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 28: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

28

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 The connected components are the graphs with vertices {a, b, c, d}, {e}, {f}, {i, g, graphs with vertices {a, b, c, d}, {e}, {f}, {i, g, h, j}.h, j}.

Page 29: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

29

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 30: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

30

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 31: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

The Connected Components of the Web The Connected Components of the Web GraphGraph

Recall that at any particular instant the web graph provides a Recall that at any particular instant the web graph provides a snapshot of the web, where vertices represent web pages and snapshot of the web, where vertices represent web pages and edges represent links. According to a edges represent links. According to a 19991999 study, the Web study, the Web graph at that time had over graph at that time had over 200200 million vertices and over million vertices and over 1.51.5 billion edges. (The numbers today are several orders of billion edges. (The numbers today are several orders of magnitude larger.)magnitude larger.)

The underlying undirected graph of this Web graph has a The underlying undirected graph of this Web graph has a connected component that includes approximately connected component that includes approximately 9090% of the % of the vertices.vertices.

There is a There is a giant strongly connected component (GSCC) giant strongly connected component (GSCC) consisting consisting of more than of more than 5353 million vertices. A Web page in this million vertices. A Web page in this component can be reached by following links starting in any component can be reached by following links starting in any other page of the component. There are three other categories other page of the component. There are three other categories of pages with each having about 44 million vertices: of pages with each having about 44 million vertices: – pages that can be reached from a page in the GSCC, but do not link back.pages that can be reached from a page in the GSCC, but do not link back.– pages that link back to the GSCC, but can not be reached by following links from pages that link back to the GSCC, but can not be reached by following links from

pages in the GSCC.pages in the GSCC.– pages that cannot reach pages in the GSCC and can not be reached from pages pages that cannot reach pages in the GSCC and can not be reached from pages

in the GSCC.in the GSCC.

Page 32: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

32

How connected is a graph?How connected is a graph?

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 33: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

33

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 34: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

34

EXAMPLE: Find the cut vertices and cut EXAMPLE: Find the cut vertices and cut edges in the graph edges in the graph GG11..

Solution: The cut vertices of GSolution: The cut vertices of G11 are b, c, and are b, c, and e. The removal of one of these vertices (and e. The removal of one of these vertices (and itsits

adjacent edges) disconnects the graph. adjacent edges) disconnects the graph.

The cut edges are {The cut edges are {a, b} and {c, e}. a, b} and {c, e}. Removing either one Removing either one of these edges of these edges disconnects disconnects GG11..

Page 35: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

35

Not all graphs have cut vertices. For example, Not all graphs have cut vertices. For example, the complete graph the complete graph KKnn, where n ≥ 3, has no , where n ≥ 3, has no cut vertices. When you remove a vertex from cut vertices. When you remove a vertex from KKnn and all edges and all edges incident to it, the resulting incident to it, the resulting subgraph is the complete graph subgraph is the complete graph KKn−1n−1, a , a connected graph.connected graph.

KK44KK55

Page 36: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

36

Connected Connected graphs without cut vertices are graphs without cut vertices are called called nonseparable graphs, and can be nonseparable graphs, and can be thought of as more thought of as more connected than those connected than those with a cut vertex.with a cut vertex.

We can extend this notion by defining a more We can extend this notion by defining a more granulated measure of graph connectivity granulated measure of graph connectivity based on the minimum number of vertices based on the minimum number of vertices that can be removed to disconnect a graph.that can be removed to disconnect a graph.

Page 37: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

37

A subset A subset S S of the vertex set of the vertex set V of G = (V ,E) is a V of G = (V ,E) is a vertex cut, or separating set, if V − S vertex cut, or separating set, if V − S is is disconnected. We define the disconnected. We define the vertex vertex connectivityconnectivity

of a noncomplete graph of a noncomplete graph G, denoted by κ(G), G, denoted by κ(G), as the minimum number of vertices in a as the minimum number of vertices in a separating setseparating set..

When When G is a complete graph, we set κ(KG is a complete graph, we set κ(Knn) = n ) = n − 1− 1..

Hence, for every graph Hence, for every graph G, κ(G) is minimum G, κ(G) is minimum number of vertices that can be removed number of vertices that can be removed from from G to either disconnect G or produce a graph G to either disconnect G or produce a graph with a single vertex. with a single vertex.

We have We have 0 ≤ 0 ≤ κ(G) ≤ n − 1 if G has n vertices, κ(G) ≤ n − 1 if G has n vertices,

κ(G) = 0 if and only if G is disconnected or G κ(G) = 0 if and only if G is disconnected or G = K= K11, , and and κ(G) = n − 1 if and only if G is κ(G) = n − 1 if and only if G is complete .complete .

Page 38: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

38

EXAMPLE: Find the vertex connectivity for EXAMPLE: Find the vertex connectivity for each of the graphs:each of the graphs:

Solution: Solution: Because Because G1 is a connected graph with a cut G1 is a connected graph with a cut vertex, vertex, κ(G1) = 1. Similarly, κ(G2) = 1, because c is a κ(G1) = 1. Similarly, κ(G2) = 1, because c is a cut vertex of cut vertex of G2.G2.

G3 has no cut vertices. but {b, g} is a separating set. Hence, G3 has no cut vertices. but {b, g} is a separating set. Hence, κ(G3) = 2. Similarly, G4 has a separating set of size two, {c, f }, κ(G3) = 2. Similarly, G4 has a separating set of size two, {c, f }, but no cut vertices. It but no cut vertices. It follows that follows that κ(G4) = 2. κ(G4) = 2.

Page 39: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

39

The larger The larger κ(G) is, the more connected we κ(G) is, the more connected we consider G to be. Disconnected graphs and Kconsider G to be. Disconnected graphs and K11

have have κ(G) = 0, connected graphs with cut κ(G) = 0, connected graphs with cut vertices and Kvertices and K22 have κ(G) = 1, graphs without have κ(G) = 1, graphs without cutcut

vertices that can be disconnected by vertices that can be disconnected by removing two vertices and removing two vertices and KK33 have κ(G) = 2, have κ(G) = 2, and soand so

on. We say that a graph is on. We say that a graph is kk-connected (or -connected (or k-vertex-connected), if κ(G) ≥ k. A graph k-vertex-connected), if κ(G) ≥ k. A graph G is 1-G is 1-connected if it is connected and not a connected if it is connected and not a graph containing a single vertex; a graph is 2-graph containing a single vertex; a graph is 2-connected, or connected, or biconnected, if it is biconnected, if it is nonseparable and has at least three nonseparable and has at least three vertices. Note that if vertices. Note that if G is a k-connected G is a k-connected graph, then graph, then G is a j -connected graph for all j G is a j -connected graph for all j with 0 ≤ j ≤ k.with 0 ≤ j ≤ k.

Page 40: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

Counting Paths between Counting Paths between VerticesVertices

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.

We can use the adjacency matrix of a graph to find the We can use the adjacency matrix of a graph to find the number of paths between two vertices in the graph.number of paths between two vertices in the graph.

TheoremTheorem: Let G be a graph with adjacency matrix : Let G be a graph with adjacency matrix AA with with respect to the ordering respect to the ordering vv11, … , v, … , vnn of vertices (with of vertices (with directed or undirected edges, multiple edges and loops directed or undirected edges, multiple edges and loops allowed). The number of different paths of length allowed). The number of different paths of length rr from from vvii to to vvjj, where , where r >r >0 0 is a positive integer, equals the (is a positive integer, equals the (ii,,jj)th )th entry of entry of AArr..

Note: This is the standard power of matrix Note: This is the standard power of matrix AA, , not a Boolean product.not a Boolean product.

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

Page 41: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

ExampleExample: How many paths of length four : How many paths of length four are there from are there from aa to to dd in the graph G. in the graph G.

SolutionSolution: The adjacency matrix of : The adjacency matrix of GG is is given above. Hence the number of paths of given above. Hence the number of paths of length four from length four from aa to to dd is the ( is the (11, , 44)th entry )th entry of of AA44 . The eight paths are as: . The eight paths are as:

GGadjacency adjacency matrix A of matrix A of GG

AA44 ==

aa, , bb, , aa, , bb, , d ad a, , bb, , aa, , cc, , dd

aa, , bb, , dd, , bb, , d ad a, , bb, , dd, , cc, , dd

aa, , cc, , aa, , bb, , d ad a, , cc, , aa, , cc, , dd

aa, , cc, , dd, , bb, , d ad a, , cc, , dd, , cc, , dd

Page 42: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

42

Example 2Example 2

Page 43: 1 Representing Graphs and Graph Isomorphism (Chapter 10.3) Connectivity (Chapter 10.4) University of Maryland Based on slides by Y. Peng University of.

TheoremTheorem: Let G be a graph with adjacency matrix : Let G be a graph with adjacency matrix AA with respect to the orderingwith respect to the orderingvv11, … , v, … , vnn of vertices. The of vertices. The number of different paths of length number of different paths of length rr from from vvii to to vvjj, , where where r >r >0 0 is a positive integer, equals the (is a positive integer, equals the (ii,,jj)th )th entry of entry of AArr..

ProofProof by mathematical inductionby mathematical induction: : Basis StepBasis Step: By definition of the adjacency matrix, the number of : By definition of the adjacency matrix, the number of paths from paths from vvii to to vvjj of length of length 11 is the ( is the (ii,,jj)th entry of )th entry of AA. . Inductive StepInductive Step: For the inductive hypothesis, we assume that that : For the inductive hypothesis, we assume that that the (the (ii,,jj)th entry of )th entry of AArr is the number of different paths of length is the number of different paths of length rr from from vvii to to vvjj. . –Because Because AAr+r+11 = = AArr A A, the (, the (ii,,jj)th entry of )th entry of AAr+r+11 equals equals bbii11aa11jj + + bbii22aa22jj + + ⋯⋯ + + bbininaanjnj, where , where bbik ik is the (is the (ii,,kk))thth entry of entry of AArr. By the . By the inductive hypothesis, inductive hypothesis, bbik ik is the number of paths of length is the number of paths of length rr from from vvii to to vvkk. .

–A path of length A path of length rr + + 1 from 1 from vvii to to vvjj is made up of a path of length is made up of a path of length rr from from vvii to some to some vvkk , , and an edge from and an edge from vvkk to to vvjj. By the product . By the product rule for counting, the number of such paths is the product of the rule for counting, the number of such paths is the product of the number of paths of length number of paths of length rr from from vvii to to vvkk (i.e., (i.e., bbik ik ) and the ) and the number of edges from from number of edges from from vvkk to to vvjj (i.e, (i.e, aakjkj). The sum over all ). The sum over all possible intermediate vertices possible intermediate vertices vvkk is b is bii11aa11jj + + bbii22aa22jj + + ⋯⋯ + + bbininaanj nj ..