Introduction
(Undirected) Graphs
e3 e4 e5 e6 v 1 e 1 v 4
e7 v3 e8
v2
e2
is an ordered pair
, where
together with a function (called the incidence function, assigning to each edge the unordered pair of its endpoints). Example 1.2 In the example above, V = E= f (e1 ) = f (e4 ) = f (e7 ) = f (e2 ) = f (e5 ) = f (e8 ) = f (e3 ) = f (e6 ) =
(i.e. if they have the same pair of endpoints). Denition 1.4 A pseudograph is called a if it has no
if it has no
Note: In a graph, the incidence function may be omitted; that is, an can be thought of as
1.2
v2
e4 e5 e6
e2 v 1 e 1
is an ordered pair
together with a function (assigning to each edge an ordered pair of its endpoints). Edges e1 and e2 are called or if
(i.e. if they have the same initial and the same endpoint). An edge e = is called .
Example 1.6 In the example above, V = E= f (e1 ) = f (e4 ) = f (e7 ) = Denition 1.7 A f (e2 ) = f (e5 ) = f (e8 ) = f (e3 ) = f (e6 ) = f (e9 ) = is a directed multigraph without
Note: In a directed graph, the incidence function may be omitted; that is, an can be thought of as
1.3
Graphs as Models
1. Niche Overlap Graphs in Ecology V = {u, v } E if and only if 2. Predator Prey Graphs V = (u, v ) E if and only if 3. Friendship Graphs V = {u, v } E if and only if 4. Tournament Graphs V = (u, v ) E if and only if 5. The Web Graph V = (u, v ) E if and only if 6. Transportation Networks, e.g. airline connection networks V = {u, v } E if and only if 7. Call Graphs V = (u, v ) E if and only if 8. And many more: computer networks, electrical networks, road maps, inuence graphs, precedence graphs,....
2
2.1
Graph Terminology
Basic Terminology for Undirected Graphs
Let G = (V, E ) be an undirected graph. Denition 2.1 Vertices u, v V are called if We write An edge e = {u, v } is said to be u and v . Example 2.2 to say that with its or
v2
v3
v 1
v 4
v 6
Denition 2.3 The is
v 5
of a vertex u V , denoted by ,
Note that a loop contributes A vertex of degree 0 is called A vertex of degree 1 is called
Theorem 2.4 [The Handshaking Theorem] If G = (V, E ) is a graph (possibly multigraph or pseudograph) with e edges, then
Example 2.5 How many edges in a graph with 5 vertices and degree sequence (4,3,3,2,2)?
Corollary 2.6 An undirected graph has an degree. Proof. Let G = (V, E ) be an undirected graph, e = |E |, V1 its set of vertices of odd degree and V2 the set of vertices of even degree. Then, by the Handshaking Theorem,
number of vertices of
2.2
Let G = (V, E ) be a directed graph. Denition 2.7 If (u, v ) E , then u is said to be and v is said to be u is called the and v is called the Example 2.8 vertex of (u, v ) vertex of (u, v )
v2
v3
v 1 v 5
Denition 2.9 The is
v 4
of a vertex u, denoted by
The is
of a vertex u, denoted by
2.3
2. Cycle of length n: V = E=
3. Path of length n: V = E=
2.4
Subgraphs
Example 2.11
c d c d
G'
10
2.5
Bipartite Graphs
Denition 2.14 A simple graph G = (V, E ) is called if V can be partitioned into two sets V1 and V2 such that
Example 2.15
Theorem 2.16 The following statements are equivalent for a simple graph G = (V, E ): 1. G is bipartite 2. The vertices of G can be coloured with colours so that
11
Graph Isomorphism
Example 3.1
Denition 3.2 Let G1 = (V1 , E1 ) and G2 = (V2 , E2 ) be simple graphs. An such that from G1 to G2 is a : V1 V2
if there exists an
Note: Isomorphic graphs are essentially the same, that is, one is obtained from the other by relabelling the vertices. Many graph properties are (i.e. preserved) under isomorphism, e.g.:
To prove that G1 and G2 are isomorphic, we must To prove that G1 and G2 are isomorphic, it suces to
12
13
4
4.1
Note that the terminology of this section diers from the textbook. A conversion glossary is provided below.
3 l k j 8 5 m p e 7 b n o i fg 6 h a 1 2
Denition 4.1 Let G = (V, E ) be an undirected graph (possibly multigraph or pseudograph) with the function f : E {{u, v } : u, v V }. Let n N. A of length is a sequence
A walk is called a A walk is called a pairwise distinct. A walk with A trail with A closed trail with all
if its if its
Terminology conversion table Our term walk trail path Rosens term path simple path none Our term closed walk closed trail cycle Rosens term circuit simple circuit none
14
Example 4.2
l k j 5 m8p e 7 b n o i fg 6 h a 1 2
l k j 5 m8p e 7 b n o i fg 6 h a 1 2
l k j 8 5 m p e 7 b n o i fg 6 h a 1 2
l k j 8 5 m p e 7 b n o i fg 6 h a 1 2
Note: In a simple graph, a walk W = v0 e1 v1 e2 v2 . . . vk1 ek vk can be more simply denoted by its sequence of vertices:
15
Example 4.3 What can you say about vertices u and v in the following graphs if you know that there exists a path from u to v ? 1. a niche overlap graph 2. a friendship graph 3. an airline connection network
4.2
Connected Graphs
if there exists
Denition 4.4 A graph G is called between every pair of vertices in G. Example 4.5
Denition 4.6 Maximal connected subgraphs of G are called Note: Every graph is a Number of connected components in a connected graph: of its
Theorem 4.7 Let G = (V, E ) be a graph and u, v V . In G, there exists a (i.e., a walk from u to v ) if and only if there exists a (i.e., a path from u to v ).
16
Example 5.1 The origins of graph theory the Bridges of K onigsberg In 1736, while stationed in St. Petersburg, the Swiss mathematician Leonhard Euler took interest in the following puzzle. The townsfolk of K onigsberg, Prussia (now Kaliningrad, Russia) take long Sunday walks. They wonder if it is possible to walk around the town, traverse each of the seven bridges of K onigsberg exactly once and return to the starting point. Graph model:
Denition 5.2 An in G containing An in G containing So: does the graph K above contain an
in a graph G is a
in a graph G is a
17
Example 5.3 For each the following graphs, determine whether it has an Euler tour. If not, does it have an open Euler trail?
Conclusion: Theorem 5.4 A Euler tour if and only if graph G (possibly multigraph or pseudograph) has an
First we note that G must be between any pair of vertices of G. Each time a vertex graph are used up, contributing
edges of the is
for all internal vertices of the tour. For , the initial edge of the tour adds to , each visit of .
18 and that
Conversely, suppose G is
2. If T uses all edges of G, then T is the required 3. Otherwise, remove the edges of T from G (as well as any isolated vertices) to obtain a graph G . Note that the degrees of all vertices in G are 4. Since G is Let T be Then T must in fact be 5. Join T and T into Replace T by 6. Repeat Steps 25. Note that since G has this algorithm indeed terminates, producing an Euler tour. , T and G must have
19
Example 5.6 Use the algorithm from the proof of Theorem 5.4 to construct an Euler tour of the graph below.
20
6
6.1
Trees
Trees and Their Properties
is called a
Denition 6.1 A graph (undirected) without A That is, a tree is a is a graph that is forest.
Question 6.2 Can a forest have multiple edges or loops? Example 6.3 Which of the following graphs are trees/forests?
Theorem 6.4 Let G be a graph. Then G is a tree if and only if for any two vertices u, v V (G), there exists in G a Theorem 6.5 Every tree with at least 2 vertices has a vertex of degree (called a ). edges.
21
6.2
Trees as Models
1. Social sciences: family tree V = {u, v } E if and only if 2. Chemistry: molecular structure of saturated hydrocarbons V = E= 3. Social sciences: structure of an organization V = {u, v } E if and only if 4. Biology: evolutionary tree V = {u, v } E if and only if 5. Computer science: directory and le system V = {u, v } E if and only if 6. Computer science: tree-connected networks of parallel processors decision trees (algorithms) search trees prex codes
22
6.3
Rooted Trees
is called a
A rooted tree can be regarded as a directed graph with all edges directed Example 6.8 A rooted tree and its implied orientation.
Example 6.9 Which of the trees in Section 6.2 are rooted trees? Denition 6.10 Terminology for rooted trees. Let T = (V, E ) be a rooted tree with root r and u, v V . If u lies on the unique (v, r)-path, then: u is called an v is called a If u lies on the unique (v, r)-path and u v , then: u is the v is a If u and v have the same parent, then they are called If vertex u has a child, then it is called an has no children, then it is called a The subgraph of T consisting of the vertex u, its descendants, and all incident edges is called the
23
Example 6.11 Use the terms from Denition 6.10 to describe the rooted tree below.
b e j o p q f k
c g l h
d i m n
Denition 6.12 A rooted tree is called an A 2-ary tree is called Example 6.13 For each of the trees below, determine m so that the tree is m-ary. Are any of these trees full m-ary trees? If so, for what m? if every internal vertex has if every internal vertex has
Example 6.15 Let T be a full m-ary tree. If T has n vertices, how many of these are internal vertices? leaves? If T has i internal vertices, what is the number of leaves? all vertices? If T has leaves, what is the number of internal vertices? all vertices? Example 6.16 A chain letter starts when a person sends a letter to 7 others. Each person receiving the letter either sends it to 7 others who have never received the letter, or does not send it to anyone. Suppose 5989 people do not send out the letter before the chain is broken (and no one received more than one letter). How many received the letter? How many people sent out letters?
25
Denition 6.17 Let T be a rooted tree with root r and vertex u. The length of the unique path in T from r to u is called The maximum of any vertex in T is called if every leaf is at level
Example 6.18 Determine the height of each rooted tree below. Which of these trees are balanced?
Theorem 6.19 Let T be an m-ary tree of height h with leaves. Then: If T is a m-ary tree, then
Example 6.20 (a) A full m-ary tree T has 76 leaves and height 3. What are the possible values of m? (b) What if T is also balanced?
Denition 6.21 An of each internal vertex are Let T be an ordered binary tree. Then
The rst child of each internal vertex u is called the The second child of each internal vertex u is called the The subtree of T rooted at the left child of vertex u is called The subtree of T rooted at the right child of vertex u is called Example 6.22 Use the terms dened above to describe the rooted tree below.
a b d h m n e i f j k
c g l