0% found this document useful (0 votes)
8 views

DSA-UNIT3

Uploaded by

prafull barathe
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)
8 views

DSA-UNIT3

Uploaded by

prafull barathe
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/ 8

Unit 3: Ghaph

S trosh ua non-unes dalasucue eohich conaute o vetices


(n hodeo ) connected
dected on undocted-A Gcan be deboeas a
Cndeed et Gv,E) ohew vCG) nepsenta the
set o veLhceo and ECa)aepeenla the set
vabces
etea ohicb ue used to cone ct thee
veses
ype o gaphs Easicalygapho thee typeo
)Diecled aph Ite duscted qaph,the diachian ae'shsn
the etaes. Vetcol can be tiavesed bctw to
Veseo vele 2and vetex3

nducked qraph r Inthe anduected aph,ateo ave not


associated usth tbedetian:

Deigb edaapb The oeigstd gapt bao a value ascociaied


usith eyge
-The vates coeaondirg to the edges as alles

*Fropatue
an wndiected graph otnvase casüb
2 Oninl) numbe o edes thr that gnpt
2

iS' Called complele gaph Focxanple,


2
onthe geno
n:4 e 2 2

Figue sho is acomplete qoaps


)ahera: Asubpaps
(1 that theGogaphs
set o vetces and set
6 ae popà sutset ot
(
Ghash G
ii)
COnecled sphi An undieded qath iu id to be coneced
æn ohichSOMe patb ists n to vees
Thee is no isolated node in the
I-2 couheckedqaph
2 - 4 , 4 8 - , 2-3,|-4
|-2-4,2-4- ,4-3l, 2-4-4
*ath'-A path u a sequente ot nodes that ae tolloed in
ode
to neach soMe teninal nodo OM wihial
nola
Cyele ACycle can bedefned as the path ohich has Aepeded
edaes ecet the þxt and laat edeo
+Indeaee aud otdeano 1 Iodees cfa vete/aodes is tho
numbee o edaeo ini dent o thalt nade.
Nodo 3 ha
hdaye 2e

Sd lso Sely sop i on edae that cowneta to the


Sane node.

aph ADT - delete


)is epty Grapb)iBeo laen;
a) inset veLten (arafph,v): Gapsi )end
9) delete
4) Lnsat edye (Cptu,v) aapb,
be peseutod
S 1hapb ApLNOutation :- Thequaph can a)Atany usig
oulkue glaigß
DAjacorey matix 2) Atjacanoy ist
Uweue adiacony ist u the matix
rma -Each s0o and colum
thee s an ede beho
coeapods to a veatez nche qraph.- theu
settoijotleucnse it's set to o

*Gine eOmple ag e diacad,qaph, uuected gaph saegtsdgas


and dao mti
Aacersy üst -In this AeFLlsentation,a inked lit ucadto

2 A

SAdiaceny rrulta wit In aqaph ech eap io epsated kayt


taso veeto anopoent in tDdeat et
veebscos but chaae tszD
utiist cao be uced Tbenodo tcuue is
Hena adjacong
a Hee mis lbt ield used to Aepset ohethe the ede o visiladorad
)N N N Hee vetices ae 12,3,4 and edaeo aue U.2),

772
N2y
(2,=),(2,4).6,4).Ch4).Thege
rmuliists aue Veee I: N, N Veea 2:NNe

46) hveueadigcaniy list -t is adaanymdti ict in ohich only


ncOng ehqe toa vetea is epAeoeuted Fo. erapte
#Gaph aeatim algorotty ist
Jsiny adycory maa
DDeclad an auay o Msig] siy J Declae Dde studuLs acatg
Lohich jU store the qaph adiacery Ust:
) Erje haO MaMy nees youenut ) Initialgeanauay na Thas
n a aaph aueyul act as Bead node say
3)nla thd edaeo of tha auaph by do *hed io]. The ide os bed ul
be tbe stauting vetex
edgeo. diacted set miJp. .
SOe 3) The ceaie guhn uU aeatthe
fgap is adjacereg ist

MuIG-las oel
SOhen all the edts to the deouedaaph àenteed. print the quapt).
* Traveals()Breadt, Fvst sonch i) Deptt krstsauch)
SeplseT STATUS-J (on each node inG. stpkSET STATUS=l toeachnade inG
2:Egueue theshitgnodeA and set a: Pushthe stautingnode Aea the stxce
HSS
satus =2 (uaitrg) aud set ts statuo 2(uaitug)
B:Repet set4ond Suwtl QUAUEisen:Repeat sep4{s untilstactoeupy
4: Deuea node N.Preo it and ceti4:fsp the top node N Procestau~s
STATOS-3(pocesed staAe) s satuo (prcessed )
t%e
SEnque al the neigkoui a thataas) Fushale tthe nebbaus ofN bat
in neady state aud set theiu statis2lao seady state aud set then
G: End statue2
A:,
A:B, D
B. C, F Ce,G,H
aie, E:BF E:BF
FA
F:A
Tirne cauplezity ove)
H>A H: A
(BES) Aautaqe DFS) Atvautaqes
)ttnds hoasEpth betoan
the statg pout aud aut othea than Bfs.
eachabe pot an be esyinplemnated uth
Dsadvautage Disadvaudaes
Daerpally requs DDoEsbt netoaiyand the
than ` S sheleat path to
XAgicabims: Snaviti Applicatn-1)Fainding the pats
)Pats prdig algpathono li) Fo detecsig aples ingaps.
ij) inumn

BES DFS
Breadth-Fist-sech DDepth-Fst-serch
F)BFSpdte sheteat path to )DESpes totte botom asub
ree atthen bacctacs
+te destm
)tuseo queue to bep taack ot9It use Stack to kap teck
tthe nezt locatson to nst: the nezt LoCason to nst
a )BFStaveses aCondig to eDFS taveAsesacaondig to
ree level Aee depth
)uis implarmeued usin FIfo SIt io iropleneted using Ufo
6)ItAEGies bacchacting
No néed of bacthacEig
) You can neatapnto te ) su cantapnto initap
lssps
*arecls stalot/Rluiquo'--t is an alyoiteni meltad
obtainia opnut solution oagiuen probBern .E g ctaiaig
g
Sheet path o SGUe veele to hetsnatmveter wsithin a
-

-Inqrecsy methed,i)e select soe so lutim#tthe ou p Ashain


ii Then echect ohethe the solutn is easible a nat ii)Fom theset e
e easible solutioru,pautsula souim that satiskes naay sat
+he obpctive o the punction
*oasTbe soluhanFo Soling apatiularproblem,teu erisu nipdie
and oe naed to obtain a ubetthat satisfieo Constaita Thenay
Suhet that satisieoteoe conshaint is lle jeaible solut
*Dpbma) soluion-Foma set ot esible solubmspauhiula soutn
that satiste o na satiskea eobechueoapurc,ch a
soutiona alled ina> uba.
Dbecte uncen'tAA gaible olubmtthat eithe mininieo as
Maimigeo a given obecte kunchon sis alled ebectve uneho.
sut miine

*inium spanning thee i- Aspanmig taee s iasubcetot ha


Tihich alU heeeiceo uatee meoent but Ena
not coutain all the edqes
1)Pims Alqorithn In fim's alqorittn
pau uitttbe miimn oeiht s to be chose
)tbe pau
i))ten adiacent to theoe ,dge havi nimumet
vehces,et
Ual! the veca
S selertad ii) ThspDceo uice beonttnues
-hee
cucit
ale CoveLed . iv) The neceAuy Conditia iothat the
shsuld not be joed
QKuskals Aasithrg' In Kuskals alaortbm
i) Each tne edage o minum eight io seleed
)u s not neceay to bave selct adjacowt edae uth
iü)Tbe cçit should not be jomed
Prim's Alqprttrn Kustals Algoitbn
im's algorithm iwsalizeo )Krushals alpaittrminitialige
uth nodo sit edge.
)Nezt rode is auaus selecd ) The ede ith mbmumoeigtt
pom peviony seleeted nodo s seleck independeut prein selkt
eke
must be counoctad

a)Toe cerpleity Tse corplezity io Dleg


SAppayingableelcctical s)Some as om's
nehSnk

*Advontags ofqeody alapthi- DEato deocç be ) an


pefen bele thon otha alaprttr
*Duadvantaae The qready algoith doeortaucays poote
the ptiroal solution
*Tepclsgical Ondeing/soting-This is a dict impleentatin,
o dectase and conquuen mahod. -follousig ae the steps
to be jptloed in ttis dlgoithm
2)Deleta alang
bagven qapb.frd avetey usith no inconing
gapb. avetez
2) Deleta along usthae the edes
inaig adge
utgoing oM
*I thee ae one han 6ne Such vetoshen bneak tbe
Heandny
>) Note the vetice that ae deleted
) Al caheoe neconded veetsceo giue topological soted ust
*Apicatini ottopological soing
the
)Ihstcin scheduling
) Dalaseialigatin.
Diaap- The qapb n uohich all tha ua edao ae diected tte,E
Eis 'called o iaph o diuded
*Floud-uOashal Aaotho- It u used to soue all pas
shoteat path poblern.- Iteoputo the sbatest path benoeen
evey pai %vates ot che given qaph.-s an eaple o
proaning appooa ch *Advantaag, '- Otio etonely sope
Aothgnno vetCOA
tio easy to ioplement
* Time cONpity
io

tori-l ton
jor j= Iton

YetnA

You might also like