0% found this document useful (0 votes)
13 views14 pages

Unit 5

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 14

PARUL UNIVERSITY - FACULTY OF ENGINEERING & TECHNOLOGY

Department of Applied Science & Humanities


3rd Semester B. Tech (CSE, IT)
Discrete Mathematics (203191206)
UNIT-5 GRAPHS and TREES

1). Graphs and their properties


Definition: A graph G = (V ,E) consists of V , a nonempty set of vertices (or nodes) and E, a set of
edges. Each edge has either one or two vertices associated with it, called its endpoints. An edge is said
to connect its endpoints.
For example: A graph with vertex set V={a,b,c,d} and with 4 edges (a,b), (b,d), (b,c), (a,c) is as
follows:

Definition: The set of vertices V of a graph G may be infinite. A graph with an infinite vertex set or an
infinite number of edges is called an infinite graph.
Definition:A graph with a finite vertex set and a finite edge set is called a finite graph.
Definition: A graph in which each edge connects two different vertices and where no two edges
connect the same pair of vertices is called a simple graph.
Definition: Graphs that may have multiple edges connecting the same vertices are called
multigraphs.
Definition: The edges that connect a vertex to itself. Such edges are called loops
Definition: Graphs that may include loops, and possibly multiple edges connecting the same pair of
vertices or a vertex to itself are called pseudo graphs.
Definition: If direction is not assign to edges in a graph then such graph is call undirected graph.
Definition: A directed graph (or digraph) (V ,E) consists of a nonempty set of vertices V and a set of
directed edges (or arcs) E. Each directed edge is associated with an ordered pair of vertices. The
directed edge associated with the ordered pair (u, v) is said to start at u and end at v.
Definition: A directed graph has no loops and has no multiple directed edges, it is called a simple
directed graph.
Definition: Directed graphs that may have multiple directed edges from a vertex to a second
(possibly the same) vertex are used to model the networks.
Definition: A graph with both directed and undirected edges is called a mixed graph.
Definition: Two vertices u and v in an undirected graph G are called adjacent (or neighbors) in G if
u and v are endpoints of an edge e of G. Such an edge e is called incident with the vertices u
and v and e is said to connect u and v.
Definition: The degree of a vertex in an undirected graph is the number of edges incident with it,
except that a loop at a vertex contributes twice to the degree of that vertex. The degree of the
vertex v is denoted by deg(v).
Definition: A vertex of degree zero is called isolated.
Definition: A vertex is pendant if and only if it has degree one.
Question: Determine whether the graph shown has directed or undirected edges, whether it has
multiple edges, and whether it has one or more loops. Use your answers to determine the type of graph
from above Table.

The HandShaking theorem:


Let G(V,E) be a undirected graph with m edges. Then 2m =  deg v
vV
Result: Let G = (V ,E) be a graph with directed edges. Then E =  deg + v =  deg − v
vV vV
Result: An undirected graph has an even number of vertices of odd degree.
Definiton: When (u, v) is an edge of the graph G with directed edges, u is said to be adjacent to v and
v is said to be adjacent from u. The vertex u is called the initial vertex of (u, v), and v is called the
terminal or end vertex of (u, v). The initial vertex and terminal vertex of a loop are the same.
Definition: In a graph with directed edges the in-degree of a vertex v, denoted by deg−(v), is the
number of edges with v as their terminal vertex. The out-degree of v, denoted by deg+(v), is the
number of edges with v as their initial vertex.
Question: Find the number of vertices, the number of edges, and the degree of each vertex in the
given undirected graph. Identify all isolated and pendant vertices. Find the sum of the degrees of the
vertices of following graph and verify that it equals twice the number of edges in the graph.

Question: Determine the number of vertices and edges and find the in-degree and out-degree of each
vertex for the given directed multigraph.
Types of Graphs:
Regular graphs: A simple graph is called regular if every vertex of this graph has the same degree. A
regular graph is called n-regular if every vertex in this graph has degree n.

2-regular 3-regular
Question: For which values of n are the following graphs regular? (i) K n (ii) C n
Complete Graphs: A complete graph on n vertices, denoted by K n , is a simple graph that contains
exactly one edge between each pair of distinct vertices.

Cycles A cycle Cn, n ≥ 3, consists of n vertices v1, v2, . . . , vn and edges {v1, v2),{v2, v3}, . . . , {vn−1, vn}, and {vn,
v1}. The cycles C3 , C 4 , C5 & C 6 are displayed in figure

Wheels We obtain a wheel Wn when we add an additional vertex to a cycle C n , for n ≥ 3,


and connect this new vertex to each of the n vertices in C n , by new edges. The wheels
W3 , W4 ,W5 & W6 are displayed in Figure

n-Cubes: An n-dimensional hypercube, or n-cube, denoted by Qn , is a graph that has vertices


representing the 2n bit strings of length n. Two vertices are adjacent if and only if the bit strings
that they represent differ in exactly one bit position.
Bipartite Graph: A simple graph G is called bipartite if its vertex set V can be partitioned into two
disjoint sets V1 and V2 such that every edge in the graph connects a vertex in V1 and a vertex in V2
(so that no edge in G connects either two vertices in V1 or two vertices in V2 ). When this
condition holds, we call the pair ( V1 , V2 ) a bipartition of the vertex set V of G.
Question: Is C 6 and K 3 a bipartite graph or not?
Complete Bipartite Graphs: A complete bipartite graph Km,n is a graph that has its vertex set
partitioned into two subsets of m and n vertices, respectively with an edge between two vertices if and
only if one vertex is in the first subset and the other vertex is in the second subset. The complete
bipartite graphs K 2,3 , K 3,3 , K 3,5 , and K 2,6 are displayed in Figure

Complementary graph: The complementary graph G of a simple graph G has the same vertices as
G. Two vertices are adjacent in G if and only if they are not adjacent in G.
Question: Describe each of these graphs. (i) K n (ii) C n
Subgraph: A subgraph of a graph G = (V ,E) is a graph H = (W, F), where W ⊆ V and F ⊆ E. A
subgraph H of G is a proper subgraph of G if H = G.
Question: Draw all subgraphs of this graph.

Adjacency Matrix (for undirected graph): Suppose that G = (V ,E) is a simple graph where |V| = n.
The adjacency matrix A (or AG ) of G, with respect to this listing of the vertices, is the n x n zero–
one matrix with 1 as its
(i,j )th entry when v i and v j are adjacent, and 0 as its (i, j )th entry when they are not adjacent. In
other words, if its adjacency matrix is A = [ aij ], then
1, if {vi , v j }is an edge of G
aij = 
0, otherwise
Adjacency Matrix (for directed graph): An adjacency matrix is defined as follows: Let G be a
graph with "n" vertices that are assumed to be ordered from v1 to vn.
The n x n matrix A, in which aij= 1 if there exists a path from vi to vj
aij = 0 otherwise

is called an adjacency matrix.

Question: Use an adjacency matrix to represent the graph shown in Figure

Question: Draw a graph with the adjacency matrix with respect to the ordering of vertices a, b, c, d.

Incidence matrix (for undirected graph): Let G = (V ,E) be an undirected graph. Suppose that
v1 , v 2 ,....., v n are the vertices and e1 , e2 ,....., em are the edges of G. Then the incidence matrix with
respect to this ordering of V and E is the n × m matrix M = [mij ], where
1, when ei is incident with vertex vi
mij = 
0, otherwise
Incidence matrix (for directed graph): The incidence matrix of a directed graph is a n × m
matrix B where n and m are the number of vertices and edges respectively,
such that bi,j = −1 if the edge ej leaves vertex vi,
=1 if it enters vertex vi
= 0 otherwise
Question: Represent the graph shown in the figure with an incidence matrix

Isomorphism
➢ Two graphs have exactly the same form, in the sense that there is a one-to-one correspondence
between their vertex sets that preserves edges, then we say that the two graphs are isomorphic.
➢ The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E 2 ) are isomorphic if there exists a one-to-one
and onto function f from V1 to V2 with the property that a and b are adjacent in G1 if and only
if f (a) and f (b) are adjacent in G1 , for all a and b in V1 . Such a function f is called an
isomorphism. Two simple graphs that are not isomorphic are called non-isomorphic.
Question: Show that the graphs G = (V ,E) and H = (W, F), displayed in Figure are isomorphic.

Question: Show that the following graphs G=(V,E) and H=(W, F) are not isomorphic.

APPLICATIONS OF GRAPH ISOMORPHISMS


➢ Chemists use multigraphs, known as molecular graphs, to model chemical compounds. In these
graphs, vertices represent atoms and edges represent chemical bonds between these atoms.
Two structural isomers, molecules with identical molecular formulas but with atoms bonded
differently, have nonisomorphic molecular graphs. When a potentially new chemical compound
is synthesized, a database of molecular graphs is checked to see whether the molecular graph
of the compound is the same as one already known.
➢ Electronic circuits are modeled using graphs in which vertices represent components and
edges represent connections between them. Modern integrated circuits, known as chips, are
miniaturized(very small unit of same kind) electronic circuits, often with millions of transistors and
connections between them. Because of the complexity of modern chips, automation tools are used to
design them. Graph isomorphism is the basis for the verification that a particular layout of a circuit
produced by an automated tool corresponds to the original schematic of the design. Graph
isomorphism can also be used to determine whether a chip from one vendor includes intellectual
property from a different vendor. This can be done by looking for large isomorphic subgraphs in the
graphs modeling these chips
Definitions: Walk, Path, Circuit and Connectivity:
➢ A Walk in a graph is an alternating finite sequence of vertices and edges such that 1  i  k ,
the edge ei has ends vi −1 and v i i.e. W= v0 e1v1e2 v 2 .......v k −1ek v k .
The vertex v 0 is known as origin of a walk W and v k is called terminus of W.
➢ A trivial walk is one containing no edges.
➢ Given two vertices u and v of a graph G, a u-v walk is called closed or open depending on
whether u = v & u  v .
➢ If the edges e1 , e2 ,...., ek of the walk W= v0 e1v1e2 v 2 .......v k −1ek v k are distinct then W is called
trial. A trail is a walk in which no edge is repeated.
➢ If the vertices v0 , v1 , v 2 ,......., v k −1 , v k of the walk P= v0 e1v1e2 v 2 .......v k −1ek v k are distinct then
W is called Path. A path with n vertices is denoted by Pn . Pn has length n-1.
➢ A nontrivial closed trail in a graph G is called a Cycle or Circuit if its initial and final vertices
are same C= v0 e1v1e2 v 2 .......v k −1ek v0 . In a circuit it is a closed walk in which edges and vertices
are not repeated except initial and final vertices.
Remark: 1) In a path no edge can be repeated either, so every path is a trail, also every path is a walk.
2) A cycle of length k, i.e., with k edges is called a k-cycle. A k-cycle is called odd or even
depending on whether k is odd or even.
3) A 3-cycle is called triangle. Clearly any two cycles of same length are isomorphic.
Definition:
➢ An undirected graph is called connected if there is a path between every pair of distinct
vertices of the graph. An undirected graph that is not connected is called disconnected.
➢ A connected component of a graph G is a connected subgraph of G that is not a proper
subgraph of another connected subgraph of G.
➢ Sometimes the removal from a graph of a vertex and all incident edges produces a subgraph
with more connected components. Such vertices are called cut vertices (or articulation
points).
➢ The removal of a cut vertex from a connected graph produces a subgraph that is not connected.
Analogously, an edge whose removal produces a graph with more connected components than
in the original graph is called a cut edge or bridge.
Question: Find the cut vertices and cut edges in the graph G shown in Figure.

Solution: The cut vertices of G1 are b, c, and e. The removal of one of these vertices (and its adjacent
edges) disconnects the graph. The cut edges are {a, b} and {c, e}. Removing either one of these edges
disconnects G1.
➢ A directed graph is strongly connected if there is a path from a to b and from b to a whenever
a and b are vertices in the graph.
➢ A directed graph is weakly connected if there is a path between every two vertices in the
underlying undirected graph.
Question: Does each of these lists of vertices form a path in the following graph? Which paths are
simple? Which are circuits? What are the lengths of those that are paths?
a) a, e, b, c, b b) a, e, a, d, b, c, a c) e, b, a, d, b, e d) c, b, d, a, e, c

Question: Determine whether the graphs G and H shown in Figure are isomorphic.

Solution: Both G and H have five vertices and six edges, both have two vertices of degree three and
three vertices of degree two, and both have a simple circuit of length three, a simple circuit of length
four, and a simple circuit of length five. Because all these isomorphic invariants agree, G and H may
be isomorphic.
Question: How many paths of length four are there from a to d in the simple graph G in Figure?
Solution: The adjacency matrix of G (ordering the vertices as a, b, c, d) is

The adjacency matrix of G (ordering the vertices as a, b, c, d) is there are exactly eight paths of length four from a to
d. By inspection of the graph, we see that a, b, a, b, d; a, b, a, c, d; a, b, d, b, d; a, b, d, c, d; a, c, a, b, d; a, c, a, c, d;
a, c, d, b, d; and a, c, d, c, d are the eight paths of length four from a to d.

Eulerian and Hamiltonian Path:


The Swiss mathematician Leonhard Euler solved this problem. His solution, published in 1736, may
be the first use of graph theory. Euler studied this problem using the multigraph obtained when the
four regions are represented by vertices and the bridges by edges. This multigraph is shown in Figure

Seven bridges of koinsberg Multigraph Model of the Town of Königsberg


The problem of traveling across every bridge without crossing any bridge more than once can be
rephrased in terms of this model. The question becomes: Is there a simple circuit in this multigraph
that contains every edge?
Definition: An Euler circuit in a graph G is a simple circuit containing every edge of G. An Euler
path in G is a simple path containing every edge of G.
Theorem: A connected multigraph with at least two vertices has an Euler circuit if and only if each of
its vertices has even degree.
Theorem: A connected multigraph has an Euler path but not an Euler circuit if and only if it has
exactly two vertices of odd degree.
Question: Which graphs shown in Figure have an Euler path?
Definition: A simple path in a graph G that passes through every vertex exactly once is called a
Hamilton path, and a simple circuit in a graph G that passes through every vertex exactly once is
called a Hamilton circuit.
Question: Which of the simple graphs in Figure have a Hamilton circuit or, if not, a Hamilton path?

Remark: 1) DIRAC’S THEOREM If G is a simple graph with n vertices with n ≥ 3 such that the
degree of every vertex in G is at least n/2, then G has a Hamilton circuit.
2) ORE’S THEOREM If G is a simple graph with n vertices with n ≥ 3 such that
deg(u) + deg(v) ≥ n for every pair of nonadjacent vertices u and v in G, then G has a Hamilton circuit.
Definition: Planar Graphs: A graph is called planar if it can be drawn in the plane without any edges
crossing (where a crossing of edges is the intersection of the lines or arcs representing them at a point
other than their common endpoint). Such a drawing is called a planar representation of the graph.
Question: Is K4 (shown in Figure1 with two edges crossing) planar?
Solution: K4 is planar because it can be drawn without crossings, as shown in Figure 2

fig 1 fig 2
Question: Is Q3, shown in Figure, planar?

Definition: A coloring of a simple graph is the assignment of a color to each vertex of the graph so
that no two adjacent vertices are assigned the same color.
Definition: The chromatic number of a graph is the least number of colors needed for a coloring of
this graph. The chromatic number of a graph G is denoted by χ(G). (Here χ is the Greek letter chi.)
Definition: THE FOUR COLOR THEOREM: The chromatic number of a planar graph is no
greater than four.
Question: What are the chromatic numbers of the graphs G and H shown in Figure?

Solution: The chromatic number of G is at least three, because the vertices a, b, and c must
be assigned different colors. To see if G can be colored with three colors, assign red to a, blue
to b, and green to c. Then, d can (and must) be colored red because it is adjacent to b and c.
Furthermore, e can (and must) be colored green because it is adjacent only to vertices colored
red and blue, and f can (and must) be colored blue because it is adjacent only to vertices colored
red and green. Finally, g can (and must) be colored red because it is adjacent only to vertices
colored blue and green. This produces a coloring of G using exactly three colors. Figure 4
displays such a coloring.
The graph H is made up of the graph G with an edge connecting a and g. Any attempt to
color H using three colors must follow the same reasoning as that used to color G, except at the
last stage, when all vertices other than g have been colored. Then, because g is adjacent (in H)
to vertices colored red, blue, and green, a fourth color, say brown, needs to be used. Hence, H
has a chromatic number equal to 4. A coloring of H is shown in Figure

Question: Frequency Assignments Television channels 2 through 13 are assigned to stations in


North America so that no two stations within 150 miles can operate on the same channel. How can the
assignment of channels be modeled by graph coloring?
Solution: Construct a graph by assigning a vertex to each station. Two vertices are connected by
an edge if they are located within 150 miles of each other.An assignment of channels corresponds
to a coloring of the graph, where each color represents a different channel.

Definition: An edge coloring of a graph is an assignment of colors to edges so that edges incident
with a common vertex are assigned different colors. The edge chromatic number of a
graph is the smallest number of colors that can be used in an edge coloring of the graph. The edge
chromatic number of a graph G is denoted by χ’(G).
Question: Find the edge chromatic number of each of the graphs in figure.

Clique: Let G be a graph, Z be a subset of its vertex set. If every pair of vertices in Z are adjacent then
Z is called a clique of G.
Example: The following graph is adjacent because every vertex is connected to every other vertex and
its clique number is 4.

Clique Number: The cardinal number of the largest clique in a graph. G is called the clique number
of G. It is denoted by  (G ) .
Perfect Graphs: A perfect graph is a graph in which the chromatic number of every induced
subgraph equals the size of the largest clique of that subgraph.
For example:

Here chromatic number of the above graph is 3 i.e.  (G ) = 3 and clique number  (G ) =3. Therefore
perfect graph.
Definition: Graphs that have a number assigned to each edge are called weighted graphs.
Example: Use Dijkstra’s algorithm to find the length of a shortest path between the vertices a and z in
the weighted graph displayed in Figure

Solution: The steps used by Dijkstra’s algorithm to find a shortest path between a and z are shown in
Figure 4. At each iteration of the algorithm the vertices of the set Sk are circled. A shortest path from a
to each vertex containing only vertices in Sk is indicated for each iteration. The algorithm terminates
when z is circled.We find that a shortest path from a to z is a, c, b, d, e, z, with length 13.
Tree: A tree is a connected undirected graph with no simple circuits.
➢ A tree is a connected undirected graph with
– No simple circuits
– No multiple edges
– No loops
➢ An undirected graph is a tree if and only if there is a unique simple path between any two
of its vertices
Question: Which graphs are trees?

Answer: G1, G2
Rooted trees: A rooted tree is a tree in which one vertex has been designated as the root and every
edge is directed away from the root.
Definitions: T is a rooted tree. If v is a vertex in T other than the root, the parent of v is the unique
vertex u such that there is a directed edge from u to v (the reader should show that such a vertex is
unique). When u is the parent of v, v is called a child of u. Vertices with the same parent are called
siblings. The ancestors of a vertex other than the root are the vertices in the path from the root to this
vertex, excluding the vertex itself and including the root (that is, its parent, its parent’s parent, and so
on, until the root is reached). The descendants of a vertex v are those vertices that have v as an
ancestor. A vertex of a rooted tree is called a leaf if it has no children. Vertices that have children are
called internal vertices. The root is an internal vertex unless it is the only vertex in the graph, in
which case it is a leaf. If a is a vertex in a tree, the subtree with a as its root is the subgraph of the tree
consisting of a and its descendants and all edges incident to these descendants.

Question: In the rooted tree T (with root a) shown in Figure, find the parent of c, the children of g, the
siblings of h, all ancestors of e, all descendants of b, all internal vertices, and all leaves. What is the
subtree rooted at g?

Rooted Tree T Subtree roooted at g


Solution: The parent of c is b. The children of g are h, i, and j . The siblings of h are i and j . The
ancestors of e are c, b, and a. The descendants of b are c, d, and e. The internal vertices are a, b, c, g,
h, and j . The leaves are d, e, f , i, k, l, and m. The subtree rooted at g is shown in Figure.
Definition: A rooted tree is called an m-ary tree if every internal vertex has no more than m children.
The tree is called a full m-ary tree if every internal vertex has exactly m children. An m-ary tree with
m = 2 is called a binary tree.
Properties of Tree:
1) A tree with n vertices has n − 1 edges.
2) A full m-ary tree with i internal vertices contains n = mi + 1 vertices.
3) A full m-ary tree with
(i ) n vertices has i = (n − 1)/m internal vertices and l = [(m − 1)n + 1]/m leaves,
(ii ) i internal vertices has n = mi + 1 vertices and l = (m − 1)i + 1 leaves,
(iii ) l leaves has n = (ml − 1)/(m − 1) vertices and i = (l − 1)/(m − 1) internal vertices.
4) There are at most mh leaves in an m-ary tree of height h.
Definition: A complete m-ary tree is a full m-ary tree in which every leaf is at the same level.
Definition: The eccentricity of a vertex in an unrooted tree is the length of the longest simple path
beginning at this vertex.A vertex is called a center if no vertex in the tree has smaller eccentricity than
this vertex.
Definition: One way to ensure that no bit string corresponds to more than one sequence of letters is to
encode letters so that the bit string for a letter never occurs as the first part of the bit string for another
letter. Codes with this property are called prefix codes. For instance, the encoding of e as 0, a as 10,
and t as 11 is a prefix code.
For example: The string 10110 is the encoding of ate. To see this, note that the initial 1 does not
represent a character, but 10 does represent a (and could not be the first part of the bit string of another
letter). Then, the next 1 does not represent a character, but 11 does represent t. The final bit, 0,
represents e.
Definition: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing
every vertex of G.
Question: Find a spanning tree of the simple graph G shown in Figure

Solution: The graph G is connected, but it is not a tree because it contains simple circuits. Remove the
edge {a, e}. This eliminates one simple circuit, and the resulting subgraph is still connected and still
contains every vertex of G. Next remove the edge {e, f } to eliminate a second simple circuit. Finally,
remove edge {c, g} to produce a simple graph with no simple circuits. This subgraph is a spanning
tree, because it is a tree that contains every vertex of G.
The sequence of edge removals used to produce the spanning tree is illustrated in Figure

Remark: A simple graph is connected if and only if it has a spanning tree.


Definition: A rooted spanning tree of a directed graph is a rooted tree containing edges of the graph
such that every vertex of the graph is an endpoint of one of the edges in the tree.
Definition: A minimum spanning tree in a connected weighted graph is a spanning tree that has the
smallest possible sum of weights of its edges.
Question: Use Prim’s algorithm to find a minimum spanning tree in the graph shown in Figure
Solution: A minimum spanning tree constructed using Prim’s algorithm is shown in Figure. The
successive edges chosen are displayed.

Question: Use Kruskal’s algorithm to find a minimum spanning tree in the weighted graph shown in
Figure.
Solution: A minimum spanning tree and the choices of edges at each stage of Kruskal’s algorithm are
shown in Figure

You might also like