Graphs

advertisement
CHAPTER 2
Graphs
1. Introduction to Graphs and Graph Isomorphism
1.1. The Graph Menagerie.
Definition 1.1.1.
• A simple graph G = (V, E) consists of a set V of vertices and a set E of
edges, represented by unordered pairs of elements of V .
• A multigraph consists of a set V of vertices, a set E of edges, and a function
f : E → {{u, v} : u, v ∈ V and u 6= v}.
If e1 , e2 ∈ E are such that f (e1 ) = f (e2 ), then we say e1 and e2 are multiple
or parallel edges.
• A pseudograph consists of a set V of vertices, a set E of edges, and a
function f : E → {{u, v} : u, v ∈ V }. If e ∈ E is such that f (e) = {u, u} =
{u}, then we say e is a loop.
• A directed graph or digraph G = (V, E) consists of a set V of vertices
and a set E of directed edges, represented by ordered pairs of vertices.
Discussion
In Section 1.1 we recall the definitions of the various types of graphs that were
introduced in MAD 2104. In this section we will revisit some of the ways in which
graphs can be represented and discuss in more detail the concept of a graph isomorphism.
1.2. Representing Graphs and Graph Isomorphism.
Definition 1.2.1. The adjacency matrix, A = [aij ], for a simple graph G =
(V, E), where V = {v1 , v2 , ..., vn }, is defined by
1 if {vi , vj } is an edge of G,
aij =
0 otherwise.
Discussion
58
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
59
We introduce some alternate representations, which are extensions of connection
matrices we have seen before, and learn to use them to help identify isomorphic
graphs.
Remarks 1.2.1. Here are some properties of the adjacency matrix of an undirected
graph.
(1) The adjacency matrix is always symmetric.
(2) The vertices must be ordered: and the adjacency matrix depends on the order
chosen.
(3) An adjacency matrix can be defined for multigraphs by defining aij to be the
number of edges between vertices i and j.
(4) If there is a natural order on the set of vertices we will use that order unless
otherwise indicated.
v1
v2
v3
v5
v4
Example 1.2.1. An adjacency matrix for this graph is

0
1

0

1
1
1
0
1
1
1
0
1
0
1
0
1
1
1
0
1

1
1

0

1
0
Discussion
As with connection matrices, an adjacency matrix can be constructed by using a
table with the columns and rows labeled with the elements of the vertex set.
Here is another example
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
60
Example 1.2.2. The adjacency matrix for the graph
u1
u2
u5
u3
u4

0
0

is the matrix M = 
1
1
1
0
0
1
0
1
1
1
0
1
1
1
0
1
0
1

1
1

1

1
0
1.3. Incidence Matrices.
Definition 1.3.1. The incidence matrix, A = [aij ], for the undirected graph
G = (V, E) is defined by
1 if edge j is incident with vertex i
aij =
0 otherwise.
Discussion
The incidence matrix is another way to use matrices to represent a graph.
Remarks 1.3.1.
(1) This method requires the edges and vertices to be labeled and the matrix depends on the order in which they are written.
(2) Every column will have exactly two 1’s.
(3) As with adjacency matrices, if there is a natural order for the vertices and
edges that order will be used unless otherwise specified.
1.4. Example 1.4.1.
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
v1
e1
v2
e2
e8
e5
e6
e7
v5
61
v3
e3
e4
Example 1.4.1. The incidence matrix

1 0 0 0
1 1 0 0

0 1 1 0

0 0 1 1
0 0 0 1
v4
for this graph is

1 0 0 1
0 1 1 0

0 0 0 0

0 1 0 1
1 0 1 0
Discussion
Again you can use a table to get the matrix. List all the vertices as the labels for
the rows and all the edges for the labels of the columns.
1.5. Degree.
Definition 1.5.1.
(1) Let G = (V, E) be an undirected graph.
• Two vertices u, v ∈ V are adjacent or neighbors if there is an edge e
between u and v.
– The edge e connects u and v.
– The vertices u and v are endpoints of e.
• The degree of a vertex v, denoted deg(v), is the number of edges for
which it is an endpoint. A loop contributes twice in an undirected graph.
– If deg(v) = 0, then v is called isolated.
– If deg(v) = 1, then v is called pendant.
(2) Let G = (V, E) be a directed graph.
• Let (u, v) be an edge in G. Then u is an initial vertex and is adjacent
to v. The vertex v is a terminal vertex and is adjacent from u.
• The in degree of a vertex v, denoted deg − (v) is the number of edges
which terminate at v.
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
62
• Similarly, the out degree of v, denoted deg + (v), is the number of edges
which initiate at v.
Discussion
We now recall from MAD 2104 the terminology we use with undirected and directed graphs. Notice that a loop contributes two to the degree of a vertex.
1.6. The Handshaking Theorem.
Theorem 1.6.1 (The Handshaking Theorem). Let G = (V, E) be an undirected
graph. Then
X
2|E| =
deg(v)
v∈V
Proof. Each edge contributes twice to the sum of the degrees of all vertices. Discussion
The handshaking theorem is one of the most basic and useful combinatorial formulas associated to a graph. It lets us conclude some facts about the numbers of
vertices and the possible degrees of the vertices. Notice the immediate corollary.
Corollary 1.6.1.1. The sum of the degrees of the vertices in any graph must be
an even number.
In other words, it is impossible to create a graph so that the sum of the degrees
of its vertices is odd (try it!).
1.7. Example 1.7.1.
Example 1.7.1. Suppose a graph has 5 vertices. Can each vertex have degree 3?
degree 4?
• The sum of the degrees of the vertices would be 3 · 5 if the graph has 5 vertices
of degree 3. This is an odd number, though, so this is not possible by the
handshaking Theorem.
• The sum of the degrees of the vertices if there are 5 vertices with degree 4 is
20. Since this is even it is possible for this to equal 2|E|.
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
63
Discussion
If the sum of the degrees of the vertices is an even number then the handshaking
theorem is not contradicted. In fact, you can create a graph with any even degree
you want if multiple edges are permitted. However, if you add more restrictions it
may not be possible. Here are two typical questions the handshaking theorem may
help you answer.
Exercise 1.7.1. Is it possible to have a graph S with 5 vertices, each with degree
4, and 8 edges?
Exercise 1.7.2. A graph with 21 edges has 7 vertices of degree 1, three of degree
2, seven of degree 3, and the rest of degree 4. How many vertices does it have?
1.8. Theorem 1.8.1.
Theorem 1.8.1. Every graph has an even number of vertices of odd degree.
Proof. Let Vo be the set of vertices of odd degree, and let Ve be the set of vertices
of even degree. Since V = Vo ∪ Ve and Vo ∩ Ve = ∅, the handshaking theorem gives us
X
X
X
deg(v)
deg(v) +
deg(v) =
2|E| =
v∈V
v∈Ve
v∈Vo
or
X
v∈Vo
deg(v) = 2|E| −
X
deg(v).
v∈Ve
Since the sum of any number of even integers is again an even integer, the righthand-side of this equations is an even integer. So the left-hand-side, which is the sum
of a collection of odd integers, must also be even. The only way this can happen,
however, is for there to be an even number of odd integers in the collection. That is,
the number of vertices in Vo must be even.
Discussion
Theorem 1.8.1 goes a bit further than our initial corollary of the handshaking
theorem. If you have a problem with the last sentence of the proof, consider the
following facts:
• odd + odd = even
• odd + even = odd
• even + even = even
If we add up an odd number of odd numbers the previous
facts will imply we get
P
an odd number. Thus to get an even number out of v∈Vo deg(v) there must be an
even number of vertices in Vo (the set of vertices of odd degree).
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
64
While there must be an even number of vertices of odd degree, there is no restrictions on the parity (even or odd) of the number of vertices of even degree.
This theorem makes it easy to see, for example, that it is not possible to have a
graph with 3 vertices each of degree 1 and no other vertices of odd degree.
1.9. Handshaking Theorem for Directed Graphs.
Theorem 1.9.1. For any directed graph G = (E, V ),
X
X
|E| =
deg − (v) =
deg + (v).
v∈V
v∈V
Discussion
When considering directed graphs we differentiate between the number of edges
going into a vertex verses the number of edges coming out from the vertex. These
numbers are given by the in degree and the out degree.
Notice that each edge contributes one to the in degree of some vertex and one to
the out degree of some vertex. This is essentially the proof of Theorem 1.9.1.
1.10. Graph Invariants. The following are invariants under isomorphism of a
graph G:
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
G
G
G
G
G
G
G
G
G
has r vertices.
has s edges.
has degree sequence (d1 , d2 , ..., dn ).
is a bipartite graph.
contains r complete graphs Kn (as a subgraphs).
contains r complete bipartite graphs Km,n .
contains r n-cycles.
contains r n-wheels.
contains r n-cubes.
Discussion
Recall that two simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if
there is a bijection
f : V1 → V2
such that vertices u and v in V1 are adjacent in G1 if and only if f (u) and f (v) are
adjacent in G2 . If there is such a function, we say f is an isomorphism and we write
G1 ' G2 .
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
65
It is often easier to determine when two graphs are not isomorphic. This is sometimes made possible by comparing invariants of the two graphs to see if they are
different. We say a property of graphs is a graph invariant (or, just invariant) if,
whenever a graph G has the property, any graph isomorphic to G also has the property. The degree sequence a graph G with n vertices is the sequence (d1 , d2 , ..., dn ),
where d1 , d2 , ..., dn are the degrees of the vertices of G and d1 ≥ d2 ≥ · · · ≥ dn .
Note that a graph could conceivably have infinitely many vertices. If the vertices are
countable then the degree sequence would be an infinite sequence. If the vertices are
not countable, then this degree sequence would not be defined.
The invariants in Section 1.10 may help us determine fairly quickly in some examples that two graphs are not isomorphic.
Example 1.10.1. Show that the following two graphs are not isomorphic.
1
2
5
a
e
6
8
7
G1
f
h
g
4
3
b
d
c
G2
The two graphs have the same number of vertices, the same number of edges, and
same degree sequences (3, 3, 3, 3, 2, 2, 2, 2). Perhaps the easiest way to see that they are
not isomorphic is to observe that G1 has three 4-cycles, whereas G2 has two 4-cycles.
In fact, the four vertices of G1 of degree 3 lie in a 4-cycle in G1 , but the four vertices
of G2 of degree 3 do not. Either of these two discrepancies is enough to show that the
graphs are not isomorphic.
Another way we could recognize the graphs above are not isomorphic is to consider
the adjacency relationships. Notice in G1 all the vertices of degree 3 are adjacent to
2 vertices of degree 3 and 1 of degree 2. However, in graph G2 all of the vertices
of degree 3 are adjacent to 1 vertex of degree 3 and 2 vertices of degree 2. This
discrepancy indicates the two graphs cannot be isomorphic.
Example 1.10.2. The following two graphs are not isomorphic. Can you find an
invariant that is different on the graphs.
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
1
2
5
a
b
e
6
8
7
f
h
g
4
3
66
d
c
G2
G1
1.11. Example 1.11.1.
Example 1.11.1. Determine whether the graphs G1 and G2 are isomorphic.
v1
u1
v2
v3
v5
G1
v4
u2
u5
u3
G2
u4
Solution
We go through the following checklist that might tell us immediately if the two
are not isomorphic.
• They have the same number of vertices, 5.
• They have the same number of edges, 8.
• They have the same degree sequence (4, 4, 3, 3, 2).
Since there is no obvious reason to think they are not isomorphic, we try to
construct an isomorphism, f .
Note that the above does not tell us there is an isomorphism, only that there might
be one.
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
67
The only vertex on each that have degree 2 are v3 and u2 , so we must have
f (v3 ) = u2 .
Now, since deg(v1 ) = deg(v5 ) = deg(u1 ) = deg(u4 ), we must have either
• f (v1 ) = u1 and f (v5 ) = u4 , or
• f (v1 ) = u4 and f (v5 ) = u1 .
It is possible only one choice would work or both choices may work (or neither
choice may work, which would tell us there is no isomorphism).
We try f (v1 ) = u1 and f (v5 ) = u4 .
Similarly we have two choices with the remaining vertices and try f (v2 ) = u3 and
f (v4 ) = u5 . This defines a bijection from the vertices of G1 to the vertices of G2 . We
still need to check that adjacent vertices in G1 are mapped to adjacent vertices in G2 .
To check this we will look at the adjacency matrices.
The adjacency matrix for G1 (when we

0 1
1 0

A=
0 1
1 1
1 1
list the vetices of G1 by v1 , v2 , v3 , v4 , v5 ) is

0 1 1
1 1 1

0 1 0

1 0 1
0 1 0
We create an adjacency matrix for G2 , using the bijection f as follows: since
f (v1 ) = u1 , f (v2 ) = u3 , f (v3 ) = u2 , f (v4 ) = u5 , and f (v5 ) = u4 , we rearrange the
order of the vertices of G2 to u1 , u3 , u2 , u5 , u4 . With this ordering, the adjacency
matrix for G2 is


0 1 0 1 1
1 0 1 1 1



B=
0 1 0 1 0
1 1 1 0 1
1 1 0 1 0
Since A = B, adjacency is preserved under this bijection. Hence the graphs are
isomorphic.
Discussion
In this example we show that two graphs are isomorphic. Notice that it is not
enough to show they have the same number of vertices, edges, and degree sequence.
In fact, if we knew they were isomorphic and we were asked to prove it, we would
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
68
proceed directly to try and find a bijection that preserves adjacency. That is, the
check list is not necessary if you already know they are isomorphic. On the other
hand, having found a bijection between two graphs that doesn’t preserve adjacency
doesn’t tell us the graphs are not isomorphic, because some other bijection might
work. If we go down this path, we would have to show that every bijection fails to
preserve adjacency.
The advantage of the checklist is that it will give you a quick and easy way to
show two graphs are not isomorphic if some invariant of the graphs turn out to be
different. If you examine the logic, however, you will see that if two graphs have all
of the same invariants we have listed so far, we still wouldn’t have a proof that they
are isomorphic. Indeed, there is no known list of invariants that can be efficiently
checked to determine when two graphs are isomorphic. The best algorithms known to
date for determining graph isomorphism have exponential complexity (in the number
n of vertices).
Exercise 1.11.1. Determine whether the following two graphs are isomorphic.
1
2
5
a
6
G1
f
e
4
3
b
d
c
G2
Exercise 1.11.2. How many different isomorphism (that is, bijections that preserve adjacencies) are possible from G2 to itself in Example 1.10.1.
Exercise 1.11.3. There are 14 nonisomorphic pseudographs with 3 vertices and
3 edges. Draw all of them.
Exercise 1.11.4. Draw all nonisomorphic simple graphs with 6 vertices, 5 edges,
and no cycles.
Exercise 1.11.5. Recall the equivalence relation on a set, S, of graphs given by
G1 is related to G2 if and only if G1 ' G2 . How many equivalence classes are there
if S is the set of all simple graphs with 6 vertices, 5 edges, and no cycles? Explain.
1.12. Proof of Section 1.10 Part 3 for simple graphs.
Proof. Let G1 and G2 be isomorphic simple graphs having degree sequences.
By part 1 of Section 1.10 the degree sequences of G1 and G2 have the same number
1. INTRODUCTION TO GRAPHS AND GRAPH ISOMORPHISM
69
of elements (finite or infinite). Let f : V (G1 ) → V (G2 ) be an isomorphism and let
v ∈ V (G1 ). We claim degG1 (v) = degG2 (f (v)). If we show this, then f defines a
bijection between the vertices of G1 and G2 that maps vertices to vertices of the same
degree. This will imply the degree sequences are the same.
Proof of claim: Suppose degG1 (v) = k. Then there are k vertices adjacent to
v, say u1 , u2 , . . . , uk . The isomorphism maps each of the vertices to k distinct vertices adjacent to f (u) in G2 since the isomorphism is a bijection and preserves adjacency. Moreover, f (u) will not be adjacent to any vertices other than the k vertices
f (u1 ), f (u2 ), . . . f (uk ). Otherwise, u would be adjacent to the preimage of such a
vertex and this preimage would not be one of the vertices u1 , u2 , . . . , uk since f is an
isomorphism. This would contradict that the degree of u is k. This shows the degree
of f (u) in G2 must be k as well, proving our claim.
Exercise 1.12.1. Prove the remaining properties listed in Section 1.10 for simple
graphs using only the properties listed before each and the definition of isomorphism.
Download