Вы находитесь на странице: 1из 48

Lecture Notes in Introduction to Automata Theory Unit - I Graph Theory

Dr. K.C. Raajasekar

Lecture 1 A Graph G = (V, E) consists of a set of objects V = {v1, v2, . . . . } called vertices, and another set E = {e1, e2, . . . . }, whose elements are called edges, such that each edge ek is identified with an unordered pair (vi, vj) of vertices. Loop: An edge having the same vertex as both its vertices is called a self-loop or simply a loop. Parallel Edges: More than one edge associated with a given pair of vertices is known as Parallel Edges. e1 e2

e
Fig. 1.1 Graph G

e - self loop; e1 and e2 parallel edges

ote: A graph is also called a linear complex, a 1-complex or a one-dimensional complex. A Vertex is also referred to as a node, a junction, a point, 0-cell or a 0 simplex. Other name used for an edge is a branch, a line, an element, 1-cell, an arc and a 1-simplex. Also, in drawing of a graph, the lines drawn need not be straight.

One of the best-known examples in graph theory is the Konigsberg bridge problem. The problem: Two islands, C and D formed by the Pregal River in Konigsberg (Now renamed Kleningrad in West Soviet Russia) were connected to each other and to the banks A and B with seven bridges, as shown in Fig. 1-1. The problem was to start at any of the four land areas of the city, A, B, C, or D, walk over each of the seven bridges exactly once, and return to the starting point (without swimming across the river of course). 1

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Remark: Euler represented this situation by means of a graph. The vertices represent the land areas and the edges represent the bridges. He proved that a solution for this problem does not exist. A

B Knigsberg bridge problem

Fig. 1.2

Graph of Knigsberg bridge problem

Note: In a diagram of a graph, sometimes two edges may seem to intersect at a point that does not represent a vertex. For, example, the edges e and f in Fig. 1.3 have no common point.

Fig. 1.3.

Lecture Notes in Introduction to Automata Theory Finite and Infinite Graphs:

Dr. K.C. Raajasekar

A graph with a finite number of vertices as well as a finite number of edges is called a finite graph. Otherwise, it is an infinite graph. For example, the graph shown in Fig. 1.3, is an example of an infinite graph.

Fig. 1.4 Incidence: When a vertex vi is an end vertex of some edge ej, vi and ej are said to be incident with each other. Adjacent Edges: Two nonparallel edges are said to be adjacent if they are incident on a common vertex. Adjacent Vertices: Two vertices are said to be adjacent if they are incident on a common edge. Degree (Valency): The number of edges incident on a vertex vi, with self-loops counted twice, is called the degree (sometimes Valency), d(vi), of vertex vi. ote: A vertex of degree one is known as a pendant vertex. Problems: 1. Draw all simple graphs on one, two, three and four vertices. 2. Draw graphs of the following chemical compounds: CH4, C2H6, C6H6.

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar Lecture 2

Theorem 1.2.1. If G is a (p,q) graph, then

deg(v) = 2q.
vV ( G )

Proof: Every edge contributes two to degree. Thus, the sum of the degrees of all vertices in G is twice the number of edges in G. Thus,

deg(v) = 2q.
vV ( G )

Theorem 1.2.2. The number of vertices of odd degree in a graph is always even. Proof: Let V1 and V2 be the set of vertices of odd and even degrees in G, respectively. Then,

deg(v) + deg(v) = deg(v)


vV1 ( G ) vV2 ( G )
vV ( G )

is even, by theorem 1.2.1. Since

deg(v)
vV2 ( G )

is even, it follows that

deg(v)
vV1 ( G )

is even. Thus,

|V1| is even. That is, vertices of odd degree in a graph are always even. Isolated Vertex: A vertex having no incident edge is called an isolated vertex. Note: Isolated vertices are vertices with zero degree.

ull Graph: A graph G in which the edge set E is empty, and the vertex set V, non-empty is known as a Null Graph. Problems: 1. Show that Maximum degree of any vertex in a simple graph with n vertices is n-1. 2. Show that the maximum number of edges in a simple graph with n vertices is
n(n 1) . 2

Isomorphic Graphs: Two graphs G and H are said to be isomorphic if there is a one-to-one correspondence between their vertices and between their edges such that the incidence relationship is preserved.

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Fig. 2.1

Two Isomorphic Graphs

Question: Show that the graph shown in fig. 2.1 are isomorphic. Soln. v4 v3 u3

u4

v1 G

v2

u1

u2

Let V(G) = {v1, v2, v3, v4 } V(H) = {u1, u2, u3, u4 } Define the mapping : V(G) V(H)

E(G) = { v1v2, v1v3, v1v4, v2v3, v2v4, v3v4 } E(G) = { u1u2, u1u3, u1u4, u2u3, u2u4, u3u4 }

such that (vi) = ui for i = 1, 2, 3,4. and the mapping : E(G) E(H) such that ( vivj) = ui uj for 1 i j 4. Clearly, the mappings and are both one to one and onto. Moreover, the adjacency is preserved. Thus, G and H are isomorphic. Degree Sequence: The degree sequence of a graph is a non-decreasing sequence of degrees of vertices of G. 5

Lecture Notes in Introduction to Automata Theory Observation: Two isomorphic graphs must have 1. The same number of vertices. 2. The same number of edges. 3. The degree sequence must be same. Question: Show that the graph shown below are not isomorphic.

Dr. K.C. Raajasekar

G Soln. The graph shown by G and H have i) equal number of vertices ii) equal number of edges iii) the degree sequence for G and H are (1,1,1,2,2,3).

But, each graph has exactly one vertex of degree 3. But in G, the vertex of degree 3 is adjacent to two vertices of degree 1 and exactly one vertex of degree 2, whereas the graph H has a vertex of degree 3 and is adjacent to two vertices of degree 2 and one vertex of degree 1. Thus, the adjacency relation is not preserved. Thus, the graphs G and H are not isomorphic. Subgraph: A graph g is said to be a subgraph of a graph G if all the vertices and all the edges of g are in G, and each edge of g has the same end vertices in g as in G. Proper Subgraph: A subgraph g of G, which is not isomorphic to G is known as a proper subgraph of G.

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Spanning Subgraph: A spanning subgraph of G is a subgraph g with V(g) = V(G). Deletion of a vertex from G: By deletion of a vertex from a graph G, we mean, the deletion of that vertex, and all the edges incident with that vertex. Deletion of an Edge: By deletion of an edge from a graph G, we mean, the deletion of only that edge, and not the end vertices. Addition of an Edge: A graph obtained from G by adding an edge e is denoted by G + e. Note that E(G + e) = E(G) {e}, and V(G + e) = V(G). Vertex Induced Subgraph: Let V1 is a nonempty subset of V. The subgraph of G whose vertex set is V1, and whose edge set is the set of those edges of G that have both ends in V1 is called the subgraph of G induced by V1, and is denoted by G[V1]. Note: G[V \ V1] = G - V1. Edge Induced Subgraph: Let E1 is a nonempty subset of E. The subgraph of G whose vertex set is the set of ends of edges in E1, and whose edge set is E1 is called the subgraph of G induced by E1, and is denoted by G[E1]. Note: G[E \ E1] = G - E1. Edge-Disjoint Subgraphs: Two (or more) subgraphs g1 and g2 of a graph G are said to be edge disjoint if g1 and g2 do not have any edge in common. Vertex-Disjoint Subgraphs: Subgraphs that do not share vertices in common are said to be vertex-disjoint subgraphs.

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

v1

v2

v5 v4 G v3
1

(proper) Subgraph of G

Spanning Subgraph of G

Deletion of v5 from G

Deletion of v2 from G

8 Deletion of edge v4v5 from G

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar Lecture 3

Walk: A Walk is defined as a finite alternating sequence of vertices and edges, beginning and ending with vertices, such that each edge is incident with the vertices preceding and following it. No edge appears more than once in a walk. ote: Standard Graph Theory texts dont put any restriction on the repetition of edges in a walk. In these texts, if the edges are all distinct they call it as a trail. Open Walk: A walk that begins and ends with distinct vertices is known as an Open Walk. Closed Walk: A Walk that begins and ends with the same vertex is known as a closed walk. Path: An open walk in which no vertex appears more than once is called a path. ote: Self-loops are not allowed in a path. Length of a Path: The number of edges in a path is called the length of the path. Observation: Terminal vertices of a path are of degree one and the rest of the vertices (called intermediate vertices) are of degree two. Circuit: A closed walk in which no vertex (except the initial and the final vertex) appears more than once is called a circuit.

ote: A Circuit is also called a cycle, elementary cycle, polygon, and (in electrical engg.) loop.

Connected Graph: A graph G is said to be connected if there is at least one path between every pair of vertices in G. Disconnected Graph: If there doesnt exists a path between at least one pair of vertices in a graph is known as a disconnected graph.

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Components: A maximal connected subgraph of a graph is known as a component.

ote: The number of components of a graph G is denoted by (G). ________________________________________________________________________ Observation: A disconnected graph may have more than 2 components. Note: By a partition of a vertex set V into V1, V2, . . . , Vn, we mean V = V1 V2 . . . Vn, and V1 V2 . . . Vn = .

Theorem 1.3.1. A graph G is disconnected if and only if its vertex set V can be partitioned into two nonempty disjoint subsets V1 and V2 such that there doesnt exists an edge in G whose one end vertex is in subset V1 and the other in subset V2. Proof. Suppose that such a partition exists. Consider two arbitrary vertices a and b of G, such that a V1 and b V2. No path exist between vertices a and b; otherwise there would be at least one edge whose one end vertex would be in V1 and other in V2. Hence, if a partition exists, G is not connected. Conversely, Let G be a disconnected graph. Consider a vertex a in G. Let V1 be the set of all vertices that are joined by paths to a. Since G is disconnected, V1 does not include all vertices of G. The remaining vertices will form a nonempty set V2. No vertex in V1 is joined to any in V2 by an edge. Hence the partition.

10

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Theorem 1.3.2. If a graph (Connected or disconnected) has exactly two vertices of odd degree, there must be a path joining these two vertices. Proof. Let G be a graph with all even vertices except vertices v1 and v2, which are odd. Since the number of vertices of odd degree must be even for every component of G, both the vertices v1 and v2 must belong to the same component of G. Therefore, must exist a path between them.

11

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Lecture 4 Theorem 1.4.1. A simple graph with n vertices and k components can have at most (n-k)(nk+1)/2 edges. Proof. Let the number of vertices in each of the k components of a graph G be n1, n2, . . . . nk. Thus, we have n1 + n2 + . . . . + nk = n, ni 1.
k

(n
i =1

1) = n k

Squaring both sides,


2

k (ni 1) i =1

= (n k)2

(n
i =1

2 i

2ni ) + k + nonnegative cross terms = (n k)2,

because, (ni 1) 0, for all i, Therefore,

n
i =1

2 i

(n k)2 k + 2n = (n - k)2 + (n k) + n = (n-k)(n-k+1) + n

Now the maximum number of edges in the ith component of G (which is a simple connected graph) is ni (ni -1). Therefore, the maximum number of edges in G is
n 1 k 1 k (ni 1)ni = ni2 2 2 i =1 2 i =1

1 n [(n - k)(n k + 1) + n)] 2 2 1 (n-k)(n-k+1). 2

Euler Line: If some closed walk in a graph contains all the edges of a graph, then the walk is

called an Euler line.

12

Lecture Notes in Introduction to Automata Theory


Euler Graph: A graph which has a Euler line is called a Euler Graph.

Dr. K.C. Raajasekar

Theorem 1.4.2. A given connected graph G is an Euler graph if and only if all vertices of G are

of even degree.
Proof. Suppose that G is an Euler graph.

It therefore contains an Euler line. i.e. There exist a closed walk containing all the edges of G. In tracing this walk, we observe that every time the walk meets a vertex v, it goes through two new edges incident on v with one entered v and with the other exited. This is true not only of all intermediate vertices of the walk but also of the terminal vertex, because we exited and entered the same vertex at the beginning and end of the walk, respectively. Thus, if G is an Euler graph, the degree of every vertex is even. Conversely, suppose that G is a non Euler connected graph with at least one edge and no vertices of odd degree. Choose such a graph G with as few edges as possible. Since each vertex of G has degree at least two, G contains a closed walk. Let C be a closed walk of maximum possible length in G. By assumption, C is not an Euler line of G and so G E(C) has some component G1 with (G1) > 0. Since C is itself Euler line, it has no vertices of odd degree; thus the connected graph G1 also has no vertices of odd degree. Since (G1) < (G), it follows from the choice of G that G1 has an Euler line C1. Now, because G is connected, there is a vertex v in V(C) V(C1), and we may assume, without loss of generality, that v is the origin and terminus of both C and C1.

13

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

But then CC1 is a closed trail of G with (CC1) > (C), contradicting the choice of C. Thus, G is an Euler graph.

14

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture 5

Open Euler line: An open walk which includes all edges of a graph without retracing any of its

edges is known as an open Euler line.


Unicursal line: An open Euler line is called Unicursal line. Unicursal Graph: A connected graph that has a Unicursal line is called a Unicursal graph. (See fig. 5.1)

v1

v5

v2 v3 Fig. 5.1. Unicursal graph The Unicursal line: v1v2v3v1v1v5v3v4v5.

v4

Theorem 1.5.1. In a connected graph G with 2k odd vertices, there exist k edge-disjoint

subgraphs such that they together contain all edges of G and that each is a unicursal graph.
Proof. Let the odd vertices of the given graph G be named v1, v2, . . . . . , vk; w1, w2, . . . . . . . ,

wk in any arbitrary order. Add k edges to G between the vertex pairs (v1, w1), (v2, w2), . . . . . . (vk, wk) to form a new graph G1.

15

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Graph G with 8 odd vertices

Graph G1 after adding 4 edges to G

Since every vertex of G1 is of even degree, G1 consists of an Euler line . Now if we remove from the k edges we just added (no two of these edges are incident on the same vertex), will be split into k walks, each of which is a unicursal line; The first removal will leave a single unicursal line; the second removal will split that into two unicursal lines; and each successive removal will split a unicursal line into two unicursal lines, until there are k of them. This completes the proof of the theorem.

16

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Single Unicursal Graph

Two Unicursal graphs

17

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Lecture 6 Operations on Graphs Union of two graphs:

Let G1 = (V1, E1) and G2 = (V2, E2) be two graphs. The union, G1G2 is the new graph whose vertex set is V1 V2 and edge set E1 E2.
Intersection of two graphs:

Let G1 = (V1, E1) and G2 = (V2, E2) be two graphs. The union, G1G2 is the new graph whose vertex set is V1 V2 and edge set E1 E2.
Ring Sum:

The ring sum of two graphs G1 = (V1, E1) and G2 = (V2, E2) is the graph, G1 G2, whose vertex set is V1 V2, and edges that are either in G1 or G2 but not in both. Note: 1. If g is a subgraph of G, then G g = G g. i.e. the graph obtained from G by removing all the edges of g. 2. G g is also known as complement of g with respect to G.
Decomposition: A graph G is said to have been decomposed into two subgraphs g1 and g2, if g1

g2 = G, and g1 g2 = the null graph.


Fusion:

A pair of vertices a, b in a graph are said to be fused (merged or identified) if the two vertices are replaced by a singe new vertex such that every edge that was incident on either a or b or on both is incident on the new vertex.
ote: Fusion of two vertices does not alter the number of edges, but it reduces the number of

vertices by one.

18

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

e a b

e ab

Fusion of vertices a and b


Theorem 1.6.1. A connected graph G is an Euler graph if and only if it can be decomposed into

circuits. Proof. Suppose graph G can be decomposed into circuits; i.e. G is a union of edge-disjoint circuits. Since the degree of every vertex in a circuit is 2, the degree of every vertex in G is even. Hence G is an Euler graph. Conversely, let G be an Euler graph. Consider a vertex v1. There are at least two edges incident at v1. Let one of the edge is between v1 and v2. Since vertex v2 is also of even degree, G must have at least another edge, say between v2 and v3. Proceeding in this fashion, we eventually arrive at a vertex that has previously been traversed, thus forming a circuit . Let us remove from G. All vertices in the remaining graph (not necessarily connected) must also be of even degree. From the remaining graph remove another circuit in exactly the same way as we removed from G. Continue this process until no edges are left. This completes the theorem.

19

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture 7

Arbitrarily Traceable graph from vertex v: An Euler graph is an arbitrarily traceable graph

from a vertex v if we get an Euler line by following any walk from vertex v (without traversal of edges).
Example:

An arbitrarily traceable graph from v.

Euler graph; not arbitrarily traceable.

Arbitrarily traceable graph from all vertices.

20

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

ote: An Euler graph G is arbitrarily traceable from vertex v in G if and only if every circuit in

G contains v.
Hamiltonian Circuit:

A circuit in a connected graph G is a Hamiltonian Circuit if it includes every vertex of G.


ote: As on date, no nontrivial necessary and sufficient condition exists to determine a graph as

Hamiltonian graph.
Hamiltonian Path: A path that traverses all the vertices of a graph is known as Hamiltonian

path.

Observation:

1. The length of a Hamiltonian path (if it exists) in a connected graph on n vertex is n-1. 2. In considering the existence of a Hamiltonian circuit (or path), we need only consider simple graphs. This is because a Hamiltonian circuit (or path) traverses every vertex once. Hence it cannot include a self-loop or a set of parallel edges.

21

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Lecture 8 & 9 Complete Graph: A simple graph in which every pair of vertices is adjacent is known as a

complete graph.
ote: complete graph on n vertices is denoted by Kn.

The following are complete graphs on one, two, three and four vertices respectively:

Observation:

For practical applications, in a simple graph, if at all Hamiltonian circuit exists, we try to find distinct Hamiltonian Circuits. theorem for complete graph:
Theorem 1.9.1. In a complete graph with n vertices there are (n-1)/2 edge-disjoint Hamiltonian

But the determination of the exact number of edge-disjoint

Hamiltonian circuits or paths in a graph in general is an unsolved problem. But, we have a

circuits, if n is an odd number 3.


Proof. A complete graph G on n vertices has n(n-1)/2 edges, and a Hamiltonian circuit in G

consists of n edges. Therefore, the number of edge-disjoint Hamiltonian circuits in G cannot exceed (n-1)/2. That there are (n-1)/2 edge-disjoint Hamiltonian circuits, when n is odd, can be shown as follows: The subgraph (of a complete graph on n vertices) shown in Fig. 1.9.1 is a Hamiltonian circuit. Keeping the vertices fixed on a circle, rotate the polygonal pattern clockwise by 360/(n1), 2 360/(n-1), 3 360/(n-1), . . . . . . . (n-3)/2 360/(n-1) degrees. Observe that each rotation produces a Hamiltonian circuit that has no edge in common with any of the previous ones. Thus, we have (n-3)/2 new Hamiltonian circuits, all edge disjoint from the one in Fig. 22

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

1.9.1, and also edge disjoint among themselves. Thus, we have (n-3)/2 + 1 = (n-1)/2 edgedisjoint Hamiltonian circuits.
5 3 n-2

4 n-3

n-1

Fig. 1.9.1 The edge disjoint Hamiltonian circuits on 9 vertices is shown (as per previous procedure) below:
5 3 7

4 6

Fig. 1.9.2

23

Lecture Notes in Introduction to Automata Theory


Application of Hamiltonian Circuit Seating Problem:

Dr. K.C. Raajasekar

Nine members of a new club meet each day for lunch at a round table. They decide to sit such that every member has different neighbors at each lunch. How many days can this arrangement last? Soln. Representing a member x by a vertex and the possibility of his sitting next to another member y by an edge between x and y, we construct a graph G. Since every member is allowed to sit next to any other member, G is a complete graph of nine vertices nine being the number of people to be seated around the table. Every seating arrangement around the table is a Hamiltonian Circuit. The first day of their meeting they can sit in any other, and it will be a Hamiltonian circuit H1. The second day, if they are to sit such that every member must have different neighbors, we have to find another Hamiltonian circuit H2 in G, with an entirely different set of edges from those in H1; that is, H1 and H2 are edge-disjoint Hamiltonian circuits. From Theorem 1.10.1, the number of edge-disjoint Hamiltonian circuits in G is (9-1)/2 = 4 (See Fig. 1.9.2). Thus, only four such arrangements exist among nine people.
Weighted Graph: A graph in which each edge is associated a real number w(ei), is called a

weighted graph, and w(ei) is known as weight of the edge ei.


Traveling-salesman problem: A salesman is required to visit a number of cities during a trip.

Given the distances between the cities, in what order should he travel so as to visit every city precisely once and return home, with the minimum mileage traveled?
Out line of the solution: Represent the cities by vertices and the roads between them by edges,

we get a graph. In this graph, with every edge ei, associate a real number, (the distance in miles) as w(ei). If each of the cities has a road to every other city, we have a complete weighted graph. This graph has numerous Hamiltonian circuits, and we are to pick the one that has the smallest sum of distances (or weights). The total number of different (not edge disjoint) Hamiltonian circuits in a complete graph of n vertices is (n-1)!/2. Since starting from any vertex we have n-1 edges to choose from the first vertex, n-2 from the second, n-3 from the third and so on. These being independent choices,

24

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

we get (n-1)! possible number of choices. This number is, however, divided by 2, because each Hamiltonian circuit has been counted twice.
ote:

Theoretically, the problem of traveling salesman can always be solved by enumerating all (n1)!/2 Hamiltonian circuits, calculating the distance traveled in each, and then picking the shortest one. However, for a large value of n, the labor involved is too great even for a digital computer.
Remark: No efficient algorithm for problems of arbitrary size has yet been found.

25

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture 10

Tree: A tree is a connected graph without any circuits. ote: Tree is always a simple graph. Since the self-loop or parallel edges form circuits. Theorem 1.10.1. There is one and only one path between every pair of vertices in a tree. Proof: Let T be a tree.

Thus, T is a connected graph, and there exists at least one path between every pair of vertices in T. Now suppose that between two vertices u and v of T there are two distinct paths. The union of these two paths will contain a circuit and T cannot be a tree. Thus, only one path exists between every pair of vertices in T.
Minimally connected graph: A graph is said to be minimally connected if removal of any one

edge from it disconnects the graph.


ote: A minimally connected graph cannot have a circuit. Theorem 1.10.2. If in a graph G there is one and only path between every pair of vertices, G is a

tree.
Proof. The graph G is connected because of the existence a path between every pair of vertices

in G. A circuit in a graph (with two or more vertices) implies that there is at least one pair of vertices u, v such that there are two distinct paths between u and v. Since G has one and only one path between every pair of vertices, G can not have a circuit. Therefore, G is a tree.

26

Lecture Notes in Introduction to Automata Theory


Theorem 1.10.3. A tree with n vertices has n-1 edges. Proof. We prove the theorem by induction on the number of vertices.

Dr. K.C. Raajasekar

For n = 1, obviously the tree drawn on 1 vertex has 0 edges. Thus, the theorem is true for n = 1. Assume the result for n = k ( 1). Now, we prove the result for a tree T on n = k + 1 vertices. Since T is a minimally connected graph, T e disconnects the graph, for any arbitrary edge e. Let T1 and T2 be the connected components of T e. Since T is a tree, Ti ( i = 1,2) is also a tree. Let k1 and k2 be the number of vertices in T1 and T2 respectively. Then the number of edges in these trees will be k1 1 and k2 1. Now, the total number of vertices in T1 T2 is k1 + k2 = k+1, the total number of vertices in T. Also, the number of edges in T1 T2 is (k1 1) + (k2 1), one less than the total number of edges in T. Thus, e(T) = (k1 1) + (k2 1) + 1 = k1 + k2 1 = (k+1) 1 = k. This completes the induction.

27

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture - 11

Theorem 1.11.1. Any connected graph with n vertices and n-1 edges is a tree. Proof. Let G be a connected graph on n vertices, and n-1 edges.

On the contrary, assume that G is not a tree. Then there exist at least one circuit in G. Choose G such that it has minimal number of circuits. Then G ej for some edge ej in the circuit, is a connected, circuit less graph on n vertices and n-2 edges, which is a contradiction. This proves that G is a tree.
Theorem 1.11.2. A graph is a tree if and only if it is minimally connected. Proof. Let G be a minimally connected graph.

Since minimally connected graph cannot have a circuit, it is obviously a tree. Conversely, Assume that G is a tree. We prove that it is minimally connected. Suppose that G is not minimally connected graph. Then G e for some edge e in G is connected. Thus, e is in some circuit of G, which implies that G is not a tree, a contradiction to our hypothesis. This proves the result.
Theorem 1.11.3. A graph G with n vertices, n-1 edges, and no circuits is connected. Proof. Suppose there exists a circuitless graph G with n vertices and n-1 edges which is

disconnected. Thus, G will have two or more circuitless components. With out loss of generality, let G consist of two components g1 and g2. Add an edge e between a vertex v1 in g1 and v2 in g2. 28

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Since there was no path between v1 and v2 in G, addition of e did not create a circuit. Thus, G e is a circuitless, connected graph on n vertices, and n edges, which is not possible. This proves the theorem.
Theorem 1.11.4. In any tree (with two or more vertices), there are at least two pendant vertices. Proof. Let T be a tree on n vertices. Then it has n-1 edges.

Since the sum of the degrees of all the vertices is twice the number of edges,

deg(v) = 2(n-1).
vV ( G )

Also, since T is a connected graph, no vertex is of degree 0. This shows that it is not possible to divide the total degree equally into n-1 vertices. Consequently, we get at least two vertices of degree one.

29

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture - 12

Distance between vertices: In a connected graph G, the distance d(vi, vj) between two of its

vertices vi and vj is the length of the shortest path ( i.e. the number of edges in the shortest path) between them.

v6

v5 v4

v1

v2 Fig. 1.12.1.

v3

In the graph shown above, d(v1, v4) = 2; d(v1, v3) = 2; d(v2, v4) = 1.
Metric: A function f(x,y) satisfying the following three conditions is called a metric.

1. Nonnegativity: f(x,y) 0. 2. Symmetry: f(x,y) = f(y,x). 3. Triangle inequality: f(x,y) f(x,z) + f(z,y) for any z .
Theorem 1.12.1. The distance between vertices of a connected graph is a metric. Proof. Clearly by the definition of distance between two vertices, d(vi, vj) 0.

Also, d(vi, vj) = d(vj, vi). Thus, the first two conditions for metric is satisfied. Also, the distance d(vi, vj) cannot be longer than another path between vi and vj which goes through a specified vertex vk. Thus, d(vi, vj) d(vi, vk) + d(vk, vj). This shows that distance between vertices of a connected graph is a metric.

30

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Eccentricity: The eccentricity E(v) of a vertex v in a graph G is the distance from a vertex

farthest from v in G. That is E(v) = max d(v, vi).


vi G

In the graph shown in Fig. 1.12.1, e(vi) = 2 for all the vertices vi in G.
ote: The eccentricity of a vertex is also known as associated number or separation. Center of G: A vertex with minimum eccentricity in a graph G is called a center of G.
6 6

6
6

6
6

6
6

6 5

T:
6 6 6

5
6

4 5 4

5
6

T1 4 T11 2 Center 0 Fig. 1.12.2. Finding center of a tree. Note: In the figure shown above the center of G consist of the only vertex labeled by 3. In some situation, a tree may have two vertices having the same minimum eccentricity. We call such centers as bicenters. 1 2 3 2 3 4

31

Lecture Notes in Introduction to Automata Theory


Theorem 1.12.2. Every tree has either one or two centers.

Dr. K.C. Raajasekar

Proof. The maximum distance, max d(v, vi) from a given vertex v to any other vertex vi occurs only when vi is a pendant vertex (of a tree). Consider a tree T on more than 2 vertices. Since a Tree must have at least 2 pendant vertices, deletion of pendant vertices in T results again a tree T1 with eccentricities of the remaining vertices reduced by one. Thus, all vertices that T had as centers will still remain centers in T1. If we continue this process, we left with either a vertex (which is the center of T) or an edge (whose end vertices are the two centers of T). This completes the proof. (See Fig. 1.12.2.)
Remark: If a tree T has two centers, the two centers must be adjacent.

32

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture - 13

A sociological Application: Suppose that the communication among a group of n persons in a

society is represented by the graph in Fig. 1.13.1, where the vertices represent the persons and an edge represents the communication link between its two end vertices. Since the graph is connected, all the members can be reached by any member, either directly or through some other members. Also, since the graph is a tree a minimally connected graph, the group cannot lose any of the communication links. The eccentricity of each vertex, e(v), represent how close v is to the farthest member of the group. If closeness of communication were the criterion for leadership, the vertex c should be the leader of the group.
Radius of a tree: The eccentricity of a center in a tree is defined as the radius of the tree. In

other words, it is the minimum eccentricity.


Diameter of a tree: The length of the longest path in a tree is known as its diameter.

In other words, it is the maximum eccentricity.


ote: For the tree T given in Fig. 1.12.2, the radius is 3, and the diameter is 6. It is not necessary

that diameter is twice its radius (in tree).


Rooted Tree: A tree in which one vertex (called the root) is distinguished from all the others is

called a rooted tree.

All rooted trees on 4 vertices (root enclosed in a small triangle)


ote: Usually tree means with out any root. They are sometimes called free trees or non-rooted

trees. 33

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Binary Trees: It is a tree in which there is exactly one vertex of degree two (root), and each of

the remaining vertices is of degree one or three.


Remark: Every binary tree is a rooted tree. Since vertex of degree 2 in a binary tree is distinct

from all other vertices.


Question: Show that the number of vertices in a binary tree is always odd. Solution. In a binary tree, except the root, all the remaining vertices are of degree 1 or 3.

Thus, in a n-vertex binary tree, n-1 vertices are of degree 1 or 3. But, since the number of odd degree vertices must be even in number, n-1 has to be an even number. In other words, n is an odd number.
Question: Show that the number of pendant vertices in a n-vertex binary tree is (n+1)/2. Solution. Let p be the number of pendant vertices in a n-vertex binary tree.

Then, there is exactly one vertex of degree 2, p vertices of degree 1 and (n-(p+1)) vertices of degree 3. Thus, the sum of degrees of all the vertices is
vV

d (v) = 1 2 + p 1 + (n p - 1) 3 = 3n 2p 1

----------- (1)

But, in any tree, number of edges is one less that the number of vertices. Thus, number of edges in an n-vertex binary tree is n-1. Since the sum of the degrees of vertices is twice the number of edges,
vV

d (v) = 2(n-1) -------------------- (2)

From (1) and (2), 2(n-1) = 3n 2p 1. 2p = n + 1 This gives p = (n+1)/2.

34

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Remark: 1. A nonpendant vertex in a binary tree is called an internal vertex.

2. In a binary tree a vertex vi is said to be at level li if vi is at a distance of li from the root. 3. The maximum number of vertices possible in a k-level binary tree is 20 + 21 + 22 + . . . . . . . . . . . + 2k n. 4. The maximum level lmax of any vertex in a binary tree is called the height of the tree. 5. The minimum height of an n-vertex binary tree is min lmax = log2 (n+1) 1 6. The maximum height of an n-vertex binary tree is max lmax = (n - 1)/2.

min lmax = log2 (11+1) 1 = 4

max lmax = (11 - 1)/2 = 5.

Two 11-vertex binary trees

35

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture - 14

Path Length of a tree: The sum of the path lengths from the root to all pendant vertices is

known as the path length of a tree.


ote:

1. The path length of a tree is also known as an external path length. It is directly related to the execution time of an algorithm. 2. A tree with 2 max vertices at level lmax 1 yields the minimum path length for a given n.
Weighted Path Length: If every pendant vertex vj of a binary tree is associated with a positive
l -1

real number wj. Given w1, w2 , w3 . . . . . wm, the problem is to construct a binary tree with m pendant vertices that minimizes wjlj, where lj is the level of pendant vertex vj, and the sum is taken over all the pendant vertices.
Spanning Tree: A tree T is said to be a spanning tree of a connected graph G if T is a subgraph

of G, and T contains all vertices of G.


ote:

1. A spanning tree is also known as skeleton or scaffolding of G. 2. Since spanning trees are the largest (with maximum number of edges) trees among all trees in G, it is also called maximal tree subgraph or maximal tree of G.

Forest: A collection of trees is called a forest. In other words, disconnected acyclic graph is

known as a forest.
Theorem 1.14.1. Every connected graph has at least one spanning tree. Proof. Let G be the connected graph.

If G has no circuit, it is its own spanning tree. If G has a circuit, delete an edge from the circuit. This will still leave the graph connected. If we repeat the same operation till an edge from the last circuit is deleted leave a connected, circuit-free graph that contains all the vertices of G, which is a desired spanning tree of G. 36

Lecture Notes in Introduction to Automata Theory


Branch of a tree: An edge in a spanning tree T is called a branch of T. Chord: An edge of G that is not in a given spanning tree T is called chord. ote:

Dr. K.C. Raajasekar

1. In electrical engineering chord is also referred to as tie or a link.

2. The complement of T, denoted T , is the collection of chords, is called chord set (tie set or cotree) of T.
Theorem 1.14.2. With respect to any of its spanning trees, a connected graph of n vertices and e

edges has n-1 tree branches and e n + 1 chords.


Proof. Let G be a graph on n vertices and e edges.

Let T be a spanning tree of G. Then the number of vertices of T is same as that of G. Since all the edges of T are branches, there are n-1 tree branches available in G (with respect to T). All the remaining edges, i.e. e (n 1) = e n + 1 edges are the chords of G with respect to T. This proves the theorem.
Rank of G: The rank of an n-vertex, k-component graph G is defined as r = n k (i.e. the

number of branches in any spanning tree (or forest) of G).


ullity of G: The nullity of an n-vertex, k-component graph on e edges is defined as = e n +

k (i.e. the number of chords in G).


Remark:

1. rank + nullity = (n k) + ( e n + k) = e, the number of edges in G. 2. The nullity of a graph is also referred as its cyclomatic number or first Betti number.

37

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture - 15

Theorem 1.15.1. A connected graph G is a tree if and only if adding an edge between any two

vertices in G creates exactly one circuit.


Proof. Let G be a tree. Since it is a minimally connected graph, addition of an edge between

any pair of vertices creates a unique circuit. Conversely, Let G be a connected graph with exactly one circuit. Now, removal of any one edge from the circuit, leave the graph to a connected, circuit free graph. Hence, it is a tree. This proves the theorem.
Fundamental Circuit: A circuit formed by addition one chord to a spanning tree is called a

fundamental circuit.

Question: Show that the number of fundamental circuits in n-vertex, k-component graph on e-

edges is e n + k.
Solution. Let G be a graph on n vertices, e-edges, and the number of components k.

Let T be a spanning tree/forest of G. Then the number of branches in T is n k, and addition of one edge from e (n k) chords give rise to one fundamental circuit. Since, there are e (n k) such chords available, we eventually get e n + k fundamental circuits with respect to T.
Question: Describe Elementary tree transformation technique. Solution. Let G be a graph, and T1 be a spanning tree of G. Now, add a chord to the Tree T1.

This forms a fundamental circuit. Removal of any branch of T1 from the fundamental circuit creates a new spanning tree T2. This generation of one spanning tree from another, through addition of a chord and deletion of an appropriate branch is called cyclic interchange or elementary tree transformation.

38

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Distance between two spanning trees: The distance between two spanning trees Ti and Tj of a

graph G is defined as the number of edges of G present in one tree but not in the other. It is denoted by d(Ti, Tj).
Remark: If we denote the number of edges in G by N(G),

N(Ti Tj) = Number of edges present in Ti but not in Tj + Number of edges present in Tj but not in Ti. Thus, N(Ti Tj) = 2 d(Ti, Tj).
Theorem 1.15.2. The distance between the spanning trees of a graph is a metric. Proof.

It is clear from the definition of d(Ti , Tj), which is the minimum number of cyclic

interchanges involved in going from Ti to Tj, the following follows immediately. 1. d(Ti , Tj) 0 and d(Ti , Tj) = 0 if and only if Ti = Tj. 2. d(Ti , Tj) = d(Tj , Ti). 3. d(Ti , Tj) d(Ti , Tk) + d(Tk , Tj). Thus, the distance between the spanning trees is a metric.

39

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar


Lecture - 16

Question: Show that max d(Ti , Tj) min ( , r). Solution. We know that N(Ti Tj) = number of edges present in Ti but not in Tj and also the

number of edges present in Tj but not in Ti Thus, N(Ti Tj) = = 2 d(Ti , Tj). Also, we know that the Max. number of edges present in a n-vertex tree Ti but not in Tj = n - 1 = The rank of G = r. Thus, max d(Ti , Tj) = max N(Ti Tj) r . . . . . . . . . . . . . . . (1) Also, transforming a spanning tree Ti to another Tj requires at most chords. Thus, max d(Ti , Tj) . . . . . . . . . . . . . . . (2) Thus, from (1) and (2), we get, max d(Ti , Tj) min ( , r).
Central Tree:

A spanning tree T0 of a graph G is called a central tree if max d(T0, Ti)


max d(T, Tj) for every tree T of G. j

Tree Graph: The tree graph of a graph G is defined as a graph in which each vertex corresponds

to a spanning tree of G, and each edge corresponds to a cyclic interchange between the spanning tree of G represented by the two end vertices of the edge.
ote: Tree graph of any given finite, connected graph is connected. Weight of a spanning tree T of G is defined as the sum of the weights of all the branches in T. Minimal spanning tree: A spanning tree with the smallest weight in a weighted graph is called

a Shortest-distance spanning tree or minimal spanning tree.

40

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Application: Suppose that we are to connect n cities v1, v2, v3, . . . . . . . , vn through a network of

roads. The cost Cij of building a direct road between vi and vj is given for all pairs of cities where roads can be built. The problem is then to find the least expensive network that connects all n cities together. Thus, the problem of connecting n cities with a least expensive network is the problem of finding a shortest spanning tree in a connected weighted graph of n vertices.
Theorem 1.16.1. A spanning tree T (of a given weighted connected graph G) is a shortest

spanning tree of G if and only if there exists no other spanning tree of G at a distance of one from T whose weight is smaller than that of T.

41

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Lecture - 17

Algorithm for Shortest spanning tree: 1. Kruskals algorithm: Let G be a simple graph on n vertices and m edges. Step 0: Set S = . Step 1: List all the edges of the graph G in order of non decreasing weight. E = (ei1, ei2, ei3 , . . . . . . , eim) Step 2: Select the smallest edge eij from E. Step 3: Set E E \ { eij }. Step 4: If G[S] {eij} does not form a circuit then do the following: S S {eij}, Step 5. Repeat steps 2 to Step 4, till | S | = n - 1. Step 6. G [S] is the required shortest spanning tree.
E

10 9 17 7
F
D

8
11 16

10

12

7
C

9.5

19.5 Fig. 1.17.

42

Lecture Notes in Introduction to Automata Theory For the figure 1.17, we find the shortest spanning tree. Step 0: S = . Step 1: E = (CD, DF, DE, EF, BC, AB, AE, AD, CF, AC, AF, BF)

Dr. K.C. Raajasekar

their weights are (7, 7, 8, 9, 9.5, 10, 10, 11, 12, 16, 17, 19.5) respectively. Step 2.1: The smallest weighted edge is CD. Step 3.1: E = (DF, DE, EF, BC, AB, AE, AD, CF, AC, AF, BF) Step 4.1: G[S] {CD} does not form a circuit. Set S = {CD}. Step 5.1: |S| = 1 = 6-1 is false. Step 2.2: The smallest weighted edge is DF. Step 3.2: E = (DE, EF, BC, AB, AE, AD, CF, AC, AF, BF) Step 4.2: G[S] {DF} does not form a circuit. Set S = S {DF} = {CD, DF}. Step 5.2: |S| = 2 = 6-1 is false. Step 2.3: The smallest weighted edge is DE. Step 3.3: E = (EF, BC, AB, AE, AD, CF, AC, AF, BF) Step 4.3: G[S] {DE} does not form a circuit. S = S {DE} = {CD, DF} {DE} = { CD, DF, DE}. Step 5.3: |S| = 3 = 6-1 is false. Step 2.4: The smallest weighted edge is EF. Step 3.4: E = (BC, AB, AE, AD, CF, AC, AF, BF) Step 4.4: G[S] {EF} forms a circuit. Step 2.5: The smallest weighted edge is BC. Step 3.5: E = (AB, AE, AD, CF, AC, AF, BF) Step 4.5: G[S] {BC} does not form a circuit. S = S {BC} = { CD, DF, DE} {BC} = { CD, DF, DE, BC}. Step 5.5: |S| = 4 = 6-1 is false. 43

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Step 2.6: The smallest weighted edge is AB. Step 3.5: E = (AE, AD, CF, AC, AF, BF) Step 4.5: G[S] {AB} does not form a circuit. S = S {AB} = { CD, DF, DE, BC} {AB} = {CD, DF, DE, BC, AB}. Step 5.5: |S| = 5 = 6-1 is true. Step 6: The minimal spanning tree is G[S]:
E

A 8 10 7
F
D

7
C

9.5

The total cost of the minimal spanning tree is: 7+7+8+9.5+10 = 41.5.

44

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

2. Prims Algorithm: Step 0. Set T = . Step 1. Draw n isolated vertices, and label them as v1, v2, . . . . , vn. Step 2. Tabulate the given weights of edges of G in an n by n table. In that, the diagonal entries are empty, and for nonexistent edges (if there is no direct edge) between cities as very large (). Step 3. Start with vertex v1. Find out the nearest neighbor of v1 (which is obtained by a scan through row 1), say vk. Set T T {v1vk}. Step 4. If |T| < n-1, Scan for vertex (with smallest entry) other than those in G [T] in the rows corresponding to the vertices in G [T] . Step 5. If the smallest entry in step 4 is for the edge vivj then replace T by T {vivj}. Step 6. If |T| = n 1. Stop. G [T] is the required minimal spanning tree. Else, Repeat Step 4 through Step 6. Eg. For the graph shown in figure 1.17, We calculate the minimal spanning tree using Prims Algorithm with the following as the vertices: A = v1; B = v2 ; C = v3; D = v4 ; E = v5 ; and F = v6.

45

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

Step 0: T = . Step 1.
v5

v1

v6
v3

v4

v2

Step 2. v1 v1 v2 v3 v4 v5 v6 10 16 11 10 17 v2 10 9.5 19.5 v3 16 9.5 7 12 v4 11 7 8 7 v5 10 8 9 v6 17 19.5 12 7 9 -

Step 3. The smallest entry in row 1 is for the vertices v2 and for v5. We select any one of them at random. Say v2. Now, T = {v1v2}. Step 4.1: | T | = 1 < 6 1. The smallest weighted vertex in row 1 and row 2 (corresponding to vertices v1 and v2), and is other than v1 and v2 is v3. Step 5.1. The edge v2v3 contributes that minimum weight. T = T {v2v3} = { v1v2, v2v3}. Step 6.1. | T | = 2 6-1. Step 4.2. | T | = 2 < 6 1.

46

Lecture Notes in Introduction to Automata Theory

Dr. K.C. Raajasekar

The smallest weighted vertex in row 1, row 2 and in row 3 (corresponding to vertices v1 v2 and v3), and is other than v1 , v2 and v3 is v4. Step 5.2. The edge v3v4 contributes that minimum weight. T = T {v3v4} = {v1v2, v2v3} {v3v4} = {v1v2, v2v3, v3v4}. Step 6.2. | T | = 3 6-1. Step 4.3. | T | = 3 < 6 1. The smallest weighted vertex in row 1, row 2, row3 and in row 4 (corresponding to vertices v1, v2 , v3 and v4), and is other than v1 , v2 , v3 , and v4 is v6. Step 5.3. The edge v4v6 contributes that minimum weight. T = T {v4v6} = {v1v2, v2v3, v3v4} {v4v6} = {v1v2, v2v3, v3v4 , v4v6}. Step 6.3. | T | = 4 6-1. Step 4.4. | T | = 4 < 6 1. The smallest weighted vertex in row 1, row 2, row3, row 4 and in row 6 (corresponding to vertices v1, v2 , v3 , v4 and v6), and is other than v1 , v2 , v3 , v4 and v6 is v5. Step 5.4. The edge v4v5 contributes that minimum weight. T = T {v4v5} = {v1v2, v2v3, v3v4 , v4v6} {v4v5} = {v1v2, v2v3, v3v4 , v4v6 , v4v5}. Step 6.4. | T | = 5 = 6-1. Step 6: The minimal spanning tree is G[T]:

47

Lecture Notes in Introduction to Automata Theory v5 v1 8 10 v6 7 7 v3 v4 9.5 v2

Dr. K.C. Raajasekar

The total cost of the minimal spanning tree is 41.5.

48

Вам также может понравиться