Mohd Talib Akhtar B.Tech (Lateral Entry) Section-B Iv Semester Discrete Mathematics Assignment ENROLL NO.: 2019-208-007
Mohd Talib Akhtar B.Tech (Lateral Entry) Section-B Iv Semester Discrete Mathematics Assignment ENROLL NO.: 2019-208-007
GRAPH:
A Graph is a non-linear data structure consisting of nodes and edges. The nodes are
sometimes also referred to as vertices and the edges are lines or arcs that connect any two
nodes in the graph. More formally a Graph can be defined as,
A Graph consists of a finite set of vertices(or nodes) and set of Edges which connect a pair of
nodes.
In the above Graph, the set of vertices V = {0,1,2,3,4} and the set of edges E = {01, 12, 23,
34, 04, 14, 13}.
Graphs are used to solve many real-life problems. Graphs are used to represent networks. The
networks may include paths in a city or telephone network or circuit network. Graphs are also
used in social networks like linkedIn, Facebook. For example, in Facebook, each person is
represented with a vertex(or node). Each node is a structure and contains information like
person id, name, gender, locale etc.
Types
Solution: The undirected complete graph of k4 is shown in fig1 and that of k6is shown in
fig2.
Connected Graph & Disconnected Graph
Connected Graph : A graph is called connected if there is a path from any vertex u to
v or vice-versa.
Disconnected Graph : A graph is called disconnected if there is no path between any
two of its vertices.
Example: Consider the graph shown in fig. Determine whether the graphs are
(a)Disconnected Graph
(b)Connected Graph.
Also, write their connected components.
Solution:
(i) The graph is shown in fig is a Disconnected Graph, and its connected components
are
{V1,V2,V3,V4},{V5,V6,V7,V8} and {V9,V10}.
(ii) The graph shown in fig is a Disconnected Graph and its connected components are
{V1,V2},{V3,V4},{V5,V6},{V7,V8},{V9,V10}and {V11,V12}.
Weighted Graph
Weighted Graphs: A graph G=(V, E) is called a weighted graph if each edge of graph
G is assigned a positive number w called the weight of the edge e.
Example: The graph shown in fig is a Weighted Graph.
Tree:
A connected acyclic graph is called a tree. In other words, a connected graph with no cycles
is called a tree.
The edges of a tree are known as branches. Elements of trees are called their nodes. The
nodes without child nodes are called leaf nodes.
A tree with ‘n’ vertices has ‘n-1’ edges. If it has one more edge extra than ‘n-1’, then the
extra edge should obviously has to pair up with two vertices which leads to form a cycle.
Then, it becomes a cyclic graph which is a violation for the tree graph.
Example 1
The graph shown here is a tree because it has no cycles and it is connected. It has four
vertices and three edges, i.e., for ‘n’ vertices ‘n-1’ edges as mentioned in the definition.
Properties of Trees:
Binary Search tree is a binary tree which satisfies the following property −
Example