0% found this document useful (0 votes)
171 views5 pages

DSTL Unit 5

Notes

Uploaded by

buinikhil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views5 pages

DSTL Unit 5

Notes

Uploaded by

buinikhil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DSTL UNIT 5

ABHAY KUMAR SINGH


AUTHOR
Graph  Graphs are used for topological sor ng etc.

 A graph is a non-linear data structure consis ng of nodes Terminologies of graph


and edges .It has finite set of ver ces (or nodes) and set of
edges.
 Graph denoted as G(E,V) , where E=edge , V=ver ces Term Description

Types of Graph Vertex individual data element is called vertex(node)

 Undirected Graph Edge It is connec ng link between two nodes


 when all the edges present between any ver ces of the
graph are un-directed or have not defined direc on. Undirected edge It is a bidirec onal edge.
 Directed Graph
 when all the edges present between any ver ces of the Directed Edge It is a unidirec onal edge.
graph are directed or have a defined direc on.
 Weighted Graph Weighted Edge An edge with value (cost) on it.
 each edge of a graph has an associated numerical value,
called a weight. Usually ,the edge weights are non- Degree total number of edges connected to a
nega ve integers. vertex .

Indegree number of incoming edges connected to vertex.

Outdegree total number of outgoing edges connected to


vertex.

 Connected Graph Self-loop an edge that connects a vertex to itself.


 A connected graph is a graph in which there is a path
Adjacency Ver ces are said to be adjacent if edge is
between every pair of ver ces.
connected.
 Simple Graph
 A graph or directed graph which does not have any Representations of graph
selfloop or parallel edges is called a simple graph
 Here are the two most common ways to represent a graph :
 Mul -graph
1. Adjacency Matrix 2.Adjacency List
 A graph which has either a self-loop or parallel edges or
both is called a mul -graph 1.Adjacency Matrix
 An adjacency matrix is a way of represen ng a graph as a
matrix of boolean (0’s and 1’s).
 Let’s assume there are n ver ces in the graph So, create a
2D matrix adjMat[n][n] having dimension n x n.
 If there is an edge from vertex i to j, mark adjMat[i][j] as 1.
 Acyclic graph  If there is no edge from vertex i to j, mark adjMat[i][j] as 0.
 If a graph (digraph) does not have any cycle then it is
called as acyclic graph.
 Cyclic graph
 A graph that has cycles is called a cyclic graph.
 Regular graph
 all graph ver ces should have the same degree.

Applications Graph
2. Adjacency List
Graph theory is used to find shortest path in road or a network.  An array is used to store edges between two ver ces
 Graphs are used to represent networks of communica on.  The size of array is equal to number of ver ces.
 Graphs are used to represent data organiza on.  Each index in array represents a specific vertex in the graph.
 The entry at the index i of the array contains a linked list  Complete bipar te graphs are a special type of bipar te
containing the ver ces that are adjacent to vertex i. graph.
 In a complete bipar te graph, every vertex in one set is
connected to every vertex in the other set.
 Complete bipar te graphs are o en denoted as Km,n,
where m and n represent the number of ver ces in the two
disjoint sets.
 Number of edges=m×n

Planar graph

 A graph is said a planar graph, if it cannot be drawn on a


plane without a crossover between its edges crossing.
 For a graph to be planar 3 – e  6

Complete graph:
A complete graph is an undirected graph where every
vertex is connected to every other vertex by a unique
edge. -
The complete graph of n ver ces is denoted by Kn . Isomorphic graph
Kn has exactly n(n-1)/2 = nC2 edges  Two graphs are isomorphic if and only if they have the same
number of ver ces and edges,
 there exists a one-to-one correspondence between their
ver ces such that the adjacency rela on is preserved.

Bi-partite graph
 Ver ces in a bipar te graph can be divided into two
disjoint sets.
 No two ver ces within the same set are adjacent.
 All edges connect ver ces from different sets.
 Applica ons of bipar te graphs include matching
problems, network flow, social network analysis, and
recommender systems. homomorphism
 homomorphism does not require a one-to-one
correspondence between vertices,
 it does not necessarily preserve all structural properties
of the graphs.
 It only preserves the adjacency relationships between
vertices.

Complete bipartite graphs


Prove that K3 and K4 are planar graphs. Prove that K5 is non- Graph Coloring:
planar.
 It assigns colors to ver ces so that adjacent ver ces have
The complete K3 graph has 3 edges and 3 ver ces. different colors.
For a graph to be planar 3 – e  6  Chroma c Number: The minimum number of colors
3 – e = 3 × 3 – 3 = 9 – 3 = 6  6  K3 is planar graph required to color a graph without adjacent ver ces sharing
the same color.
Similarly complete K4 graph has 4 ver ces and 6 edges.  Applica ons: Used in task scheduling, wireless network
3 – e = 3 × 4 – 6 = 12 – 6 = 6  6  K4 is planar graph frequency assignment, map coloring, and compiler register
alloca on.
The complete K5 graph contains 5 ver ces and 10 edges.  Classifica on: Graph coloring problems can involve vertex,
Now 3 – e = 3 × 5 – 10 = 15 – 10 = 5  6 edge, or total coloring constraints.
Hence K5 is non planar since for a graph to be planar 3v – e  6.

Path
 A path in a graph is a sequence of ver ces connected by
edges. Each vertex in the sequence is adjacent to the next
vertex in the sequence.
 There are no repeated ver ces in the path.
 A path can start and end at any vertex in the graph.
Permutations
Cycle  Permuta ons arrangements of objects in a specific order.
 Permuta ons can be with or without repe on, depending
 Any closed path in a graph where the star ng and ending on whether the same object can be used mul ple mes or
ver ces are the same. not.
 The number of permuta ons of n objects taken r at a me
circuit
is denoted as P(n,r) and calculated as
 circuit refers to a closed path where the star ng and ending  nPr=(n−r)!/n!, where n! represents the factorial of n.
ver ces are the same. Combinations
 It can involve revisi ng ver ces and edges.  Combina ons selec ons of items from a group where the
order doesn't ma er.
Eulerian Path:  Combina ons can be with or without repe on, depending
 Traverses every edge exactly once. on whether the same item can be selected mul ple mes
 May visit ver ces mul ple mes. or not.
 The number of combina ons of n objects taken r at a me is
Eulerian Cycle: denoted as C(n,r) and calculated as !nCr=r!(n−r)!/n!, where
n! represents the factorial of n.
 Traverses every edge exactly once, forming a closed loop.
 If any graph has eularian cycle then it is called eularian Ques on 1: How many different ways can you arrange the
graph le ers in the word "BOOK"?
Hamiltonian Path: Solu on 1: The word "BOOK" has 4 le ers, so the number of
permuta ons is 4!. Therefore, there are 4×3×2×1= 24 different
 Visits every vertex exactly once.
ways to arrange the le ers.
 It's a simple path.
Ques on 2: In how many ways can a commi ee of 3 people be
Hamiltonian Cycle: selected from a group of 7 people?
 Visits every vertex exactly once, forming a closed loop. Solu on 2: This is a combina on problem. The number of ways
 If any graph has Hamiltonian cycle then it is called to choose a commi ee of 3 people from a group of 7 people is
Hamiltonian graph
C(7,3)=7!/3! *(7−3)!

=7×6×5/3×2×1=35

Ques on 3: A password consists of 3 digits. How many different


passwords can be created if repe on is allowed and each digit
can be any number from 0 to 9?
Solu on 3: Since repe on is allowed, each digit has 10 op ons
(0-9). So, the total number of passwords is 103=1000.

Ques on 4: How many different 5-le er words can be formed


using the le ers of the word "APPLE"?

Solu on 4: The word "APPLE" has 5 le ers, but there are two
'P's. So, the number of permuta ons is 5!/2! since the 'P's are
indis nguishable.

This equals 5×4×3×2×1/(2×1)= 60.

Pigeonhole Principle
 The pigeonhole principle is some me useful in coun ng
methods.
 If n pigeons are assigned to m pigeonholes then at least
one pigeonhole contains two or more pigeons (m < n).
 The principle is useful for proving the existence of solu ons,
or bounding the number of solu ons.
 The Pigeonhole Principle is widely applicable in various
areas of mathema cs and computer science, including
combinatorics, number theory, algorithms, and probability.

Quantum 5.33 5.34 5.33

You might also like