0 ratings 0% found this document useful (0 votes) 57 views 41 pages DSD 5th Unit
The document discusses various concepts related to graph theory, including types of graphs, graph representations, and traversal algorithms such as Breadth-First Search (BFS) and Depth-First Search (DFS). It covers definitions of vertices, edges, paths, cycles, and connected components, as well as methods for finding shortest paths. Additionally, it highlights the importance of directed and undirected graphs and their applications in computer science.
AI-enhanced title and description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save DSD 5th unit For Later Ve) Gueaphx
|
> A Paph G= (VE) twonists of 8 sek of
VerHaus vig Edepes le)
here
VY finite non enepty Bet of verte (v9
ES in se ‘bdgese) ,
”
Ge yey
Eq t- Nad £ Ns
yey *y tw Vv, * Vo,
q aw mE connected b
v ei Voy,
lL L Cm f yap,
Yak Vy"
IM, Yo, Vey M4) 3 vertices.
[Ms v09, War var, Ova, ¥4 9, CVA MD Ce Mg) C209]
bo ee
6 a Vi — Va 4, Ye
“ . 23 M1, Vs
© qi yo ve YS
les 7
toy **
3
v v
+a a?
as
VG M2 YeDey ak RUT Teme
A: nia bs
{Oe at] EBB HB
Nodss > vertices
Eagts > Lundy bho 2 vethees (010 2 nodes,
2) yee?) Graphs
jhe arc Types 5} Birapl. Shay are!
Q) Durected 9) cycle
by unduurctid n) DAG
°) wargnicd HeRR Wy) puget rf
ay Computed 4d) gol} oop
2) subgeaph k) Bi-eonnecti ty
L) eut verux
| = path
|
ly Auiccted graph
| > Aireted edge
SMV (eM)
| (vy, ved4 Ca wd
|
Cvs, va) Fg, 2)
| (v2, OY 2%)b) Unde cled uaph
Undireoted edges
rages ee anced
b woe fwd
(YW) = lv, wy
(v,, vo) = Cv.)
Ova v5) = (vg, va)
, x G wha e
| Ya, W) =) CW, vp y
|e) ) waltg tid quark (vate ne aa
[2a waged FP i: guagh woliick, + em
os song ln A edi
| Mt eiiig9 49 ‘ang od a
valuea) completa graph me
seed
7 ait an undiieeted qpeph ohn veabiees consist %
1D)
nin +N, of edges,
a? Strongly wnnsded qorh
> 24: Socal niw.
5 Ce file ahding
2). sub-qaphs Carpet)
DA Subgraph “Boh aph Gu a Graph Auch that
thu Aak Of yeti & sok of edges of 6 ' are proper
subse of the et of elas ef 4,
@) j
—_¥ Q!
f) path = (amour)
| DA path is aenottd witha. sequence, of
Wei ether ok an edges me vertem
at yeatex.6) @) ‘ Wi, Meu! areabing
}
vy » “e E> no. of
| )—-8 et & ps
9) cycle \ (ret | boop)
Jy A tlosed talk thootigh the raph with
| . , ;
‘yepeated vertion mastty hanng the tame start
\P » eaetty hawng Foe
verter % ending yetesr ,
|
) >) Vv) Ove 2% Vy.
Vo Vy OV, OV
Vy Vp V2 ON
Vyas 03 Vg 25 OY
v
hy V3.2 3 7 V5"
sp acyte yeph: =
@ > edges ane qeere ahould | fomt a
at eyele 5
WEA +
2B Adtected Aeyelic graph
> No wyele. iaetins
Auyelte graph
DTt doen't fom a cycle. ‘
ted hp we eonneeted
1) strongly tanneeted Gop alte
L%
U
A
~ path
> AW nol” peachadk
> Aimed geek) Aeger
we Verte dequs (wv)
2 types oh degree!
a) Indegve
b) outdenres
a) Videgree ~> vedio! the NO- Of edges Thay
, ungide
Weldentty That ventex
¥) outdegue -) yeuten i the tobe north edac,
ne Una,
faa man Rey
[eri] andi
ey May vo |
My Na Ma | NS
4 ie
Va
Va ae
ve | va | Mi a |¥) conneetid qark:
2 an undirected qiaph , ws said ¢ be connected i for
we par of distant vation vj #Y un WEG) tere
wo qsaph fiom vj b wy inh
aL
x
£) Comporunt
> the martmal connected sespoph th
n) Biconnectot
> preenmeled Y
cannot be broken ant
connected ingle age
oph are the qeaphs ‘[ohich
2 dfs connected pices bgr secusecesessesess
©
“4
ye,
3 Fs
E —&
OE
| ©) cut vertex: ‘
| 13 A vertex V ws a undliechd graph & 4 fp
| A ‘ he
| [emery Uk aliseonneets the gap
aut yetea & also called ast elation
| | @. @.1'| 6 ~Os¢
| ie eae @
| 6
Representation h Graph: : .
there one > Upes 8} Crvaphs. They ane:
point
5
3.
|
yy Adjacent Matrix (AM)
| ) Adjacent nat (Ab)
i) Am: . ;
| DA graph tontatning n vetie can be
Seo by a matia with n apws¢ n columns.
Matra formed by sown the eres tocegntad
| ats a wows 4 J™ eolumns oh tre matin between_veattea * the qrerh i...
Frample
1. Given the Ama AL ‘Of he tip Letui qiaph:
. , 9
et re th :
ALEl Cl PEE! | verte,
ol] tli|olo (mae: 5, FD
| Bli jo |nott a4 Arad wpba
| c =D |ne | @. I ads
| Dlofojejo|r|! ot
le | of ofolo| oly te
le | of fo|o| ofo rane
ie 6
"BE
ELE
a [mle io fe [>
|
wiv
=>. [Raketed graph onal ded quaphl| wilgnerd graph]
\aitectein - ie \ )
|
| oe lure .
ae | (ver)
che \ : |
(Mir Vs)
My Ya, N3 io (2,0)
Ya 4 ve 2 (210d .
| tA
% vp | (v1, ¥2) |
| ‘4 V3 3 {iy |
] (24%) ‘
5 —__
¥% 2U3rn) Ve, tay
(¥,,¥3)
(va }va)
\W21 Va)
(vy v3)
(yy, ¥2) (r,¥,
(v5, va) 7D
(4, v3?
—‘ piare
4
bl AL: ian he
DA graph See m veties 4 n edaec can be.
repursanted uring? a a uiked Usk
oeGeary Traversac (AT)
ST k a graph acehnd que sed ‘for a
verter th agraph. mY RAN ’ |
> Te is used to aeelde te ander Pf verbiees uy
iceted un the seach prec.
There ane >-ty pes of Search din GT. They are:
") Breadth first Starch (BES)
|) top ss tars)
\
|. Breadth fiast Search (BFS):
| °>) aby i “o rprretes °*b pare each nooles oF
the _qeaph unto 2 parks.
vated
Nob - vested
> The purpose fh che algon thm wes we eit Alt
Hha_wustn_estile evel oyetes.
DIE usu A ple OS bo Aepreent me
yesttid necles,
DT works duel sy eel
> dnitiatip, BFS stab ak a
qrco rectexechuth Js ak evel_ 0,
air put hr at wads att the verhices al level t
terel 0,19, 3% 418, 6, Fe- ete:
urls o
& Som.
8 A HSE
yee tepad
— > Source - destination
> Find Me Ahoatut path -
a) fiskstras Apert
edi method & tend he eo sete,
2B Are
shortest path problem.
| Buk kuwownh abgodttin “to Jad ee atak pati
ain quark: '
25 Appureable to both
quaphs with wore agate weight nlp.
> aingte - sowie shortest path :
© for a
dined + tuncldreeted
un verte® called the Source th
. wuignted connected graphs ond Svortak path
Jy aut ie other verti es:steps ‘
to renter neortsl ty
le Fund, the Sp fii doer
ue,
noob
9. ‘Then, eptind tte SP dum dou bo (he
Ch js
we
Neartert yeater. ‘a
© procs for tel eth ov vertices
gy. Contfrue
nares? to the Aotvrte.
MAE rapt ag iy
| >, Forws a subir wrty These, Veatt ed, Sie. yes
ealges of the shorted path .
Example : ‘
(D Apk-. Bea, ty, Cas)
alaalauraieh es
Fl -y00)
Sop oe A
LAY (ee
7 a> be >
9.|/b(a,1) | Clb, 399 penta 00302 babe
as bod
Cb, 8) > bE ACO F272, '
ue ; \
ecb bie OCU) FEE
wen Toph bed Els
#(-,a)
—+— Ly SP? eC b,29
3) etb, 2) "| €(b, a) — a
fle, 4) watieapts
#(e4)
gp ab, 2)
ath,2) | a4)
csp Hd)eee
6
no vertea
1 Hay ay
|
val
es ru ee
ae S gbutye 8 21! o7
=3
aba» abbrd= 3 alte
ee => a pee # oe) l41eh
2
&
oc
i
=
L
~
”
~
atta &@
c.3.p frm Aowtse can be qin! but by
kag bstias algosthm
© pid the s.p bebwen node Ate bt wr He
tellowing Figs ty Applydg’ Ary ketal
agent, 1
poradjacent noc -
9, date tost ds tompute por
|
(A) 3N
pr “ey
: wp Rete dst
2 3.P DRDO DEDH
sp ah 9B et 3H
Spa 47b>t-5H
ee
” ~3 MINION SPANNING “TREES.
2 nny Ree oh a qeph & a subgraph Wak
corrtaans AU the vertices 2 uk alo a Wee +:
at qeph ee have mawp pening Ne hee .
taeasn?t frome tgete).
y fon tude stupa gragh we
) eas Bray mucitiple speeeny
bites . \
‘r be b8. ie
Conagtien :
|b To find mininawm Span tee ds an
tna ted graph, we assume that he Ten graph
| ond weighted paph-
Ea mst % an undiuedtd graph & ts a hee jormed
“farm agh ne that convert All the verticw ‘ 4
with minimum total cost -Q eae %
ie wiilate! Homnun
1 prims | ovttiim |
ere een
2. Kruskal 4
|. pam’ Ayrithen
> P, cs nthm .
aaa a art quer alge
PTE EB Used for Fndidg the met [rinime
ie a
Te Tree] +} a geen geaph.
7 fo “pry PA | the given quaph retest be coskghted,
tonmectid 2 unctitedicl.
Ok tn ts
Aimplemenita tion »
1, Randomly choose ony Vertex |
2. The vertex Comnectitig t the oly hating! hast”
twiighted is cauatly selected),
3. Pad all the edges that correct the tree bp
WLU vertices. AM
4. Fd ‘the deat! ae oage meneant Chtes
cages 4 ‘Uneludld ae “4 ges ost vba
5. bh iia) the tae cates avi the dil
thak tdi 3s Lek
eae : yr
6. keep repeating these slaps inti ald thes yertives
are ‘included 4 Met ds obtained
for me Neat “east eoetigit -b(a,3)
C(-) 00)
d(~«)
e (a6)
Fla,s)
sp —» b(a,3)
[Need t Ace shortest
Youu J
Cb, 1)
Ato)
e(a,6)
ost
| £0, 92 an
2 oe
Sp Cbs!) ped
Z ve
be ee| ~
set] Thee Ronaliuing yetious
vertices q
| —+—
Selby jafe.ey
| (a,b)
| Flora) ;
| Spo fear) 4)
jo tsea ats
(4,29
é “MSS SS ep ay ONY: BM
| |
Ey )
| 5) ay | ates) 628
| SP = d(f,5) 3 +
A Ss
©
| udicosb| os hg
+ Cost o Cce MST = add all the weigh
Of the vertey s”
2 B+ 44 pegeist
Bo inekels Aigorith ms ¢~ (kA)
= KA ds used t fend Ke mininurm re
Ke for % Connected tong beted qaph . 7
0 i ;
= The main target ee perm is be Hog
the Subseb e ou es by y wg whith we Can trovene
ee 4 vertex 4 wf gaph.
D It +ollows rey’ a prrach.
bps:
1. FySb, dort alt the edges -fyom lov wget Mh
Now, take the o edge with Lowest wougnt + add i
Ho the 3 tue
Fo is mga seat qe te a
in '
tie y \
Continue to add the edges untel we reach all vectored
ip ws vcated -
Example:
agp .
The weight ¢h the edge ie abore. graph isEPs
| ous gee ebeloww
| PA ty
Le | a8] he qo [ae BC eh
wegne |] 4 ro | By 3 ye oO
Now) xort “ie cage gr sbeldov wo she eae
Ader the weeps
nes qe De‘ with waght a to the MST.
ck Gy wok acto Tie cycle,[ps
a Add , the “age Be ne (8, to Ghe M87, wb ;
ie fs
(ae ty the var
a Now, pick He sigs, amie Y
notidvrering eH aks sm eats «
chps:
hte MOT, te
eden
« Nows saab db.
oat Goats mal tyele » 80 ‘qs
o dn dae
Lyle ‘snout not be for.
5ae
Fe pick the tala AC) with vinight oe
Neasit. e. hy nate BL "eyaley 40 listed at
[eye ahouta not be fore) |
1 den ; a
+ Pid ow edge Ab uit 0H
* Tnebuding me will aio cate the tydls,"60 Asad
185, heal op 5 Pe obtained avr the
Tren wagad graph Oy aig Rata ge
E ie!
ee
Cast op the MST > Edge tonne
AB+ Be + Bc pap
”
. e oly
» Cost of msrp _ o ==