Parallel Graph Algorithms - Leiden...
Transcript of Parallel Graph Algorithms - Leiden...
![Page 1: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/1.jpg)
ParallelGraphAlgorithms
![Page 2: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/2.jpg)
BasicDefini6ons• AnundirectedgraphGisapair(V,E),whereVisafinitesetofpointscalledver5cesandEisafinitesetofedges.
• Anedgee∈ Eisanunorderedpair(u,v),whereuandv∈V.
• Inadirectedgraph,theedgeeisanorderedpair(u,v).Anedge(u,v)isincidentfrom/outgoingedgeofvertexuandisincidentto/incomingedgeofvertexv.
• Apathfromavertexvtoavertexuisasequence<v0,v1,v2,…,vk>ofver6ces,wherev0=v,vk=u,and(vi,vi+1)∈ Efori=0,1,…,k-1.
• Thelengthofapathisdefinedasthenumberofedgesinthepath.
![Page 3: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/3.jpg)
Representa6ons(UndirectedGraphs)•
Adjacencymatrixrepresenta6on
Adjacencylistrepresenta6on
![Page 4: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/4.jpg)
Problem1:MinimumSpanningTree
• AspanningtreeofanundirectedgraphGisasub-graphofG,whichisatreecontainingallthever6cesofG.SothespanningtreedoesnotcontainnecessarilyalltheedgesofGbutasubset.
• Inaweightedgraph,theweightofasub-graphisthesumoftheweightsoftheedgesinthesub-graph.
• Aminimumspanningtree(MST)foraweightedundirectedgraphisaspanningtreewithminimumweight.
![Page 5: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/5.jpg)
InaPicture
•
![Page 6: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/6.jpg)
Rela6onshipwithTravelingSalesmanProblem(TSP)
Ø NormallyforTSPcompletegraphsareused(thereisalwaysarouteinbetweentwoci:esnoma;erhowlongittakes)
Ø AnincompletegraphforMSTcanbecompletedbyaddingedgeswithaverylargeweight(notethatthiswillnothaveanyeffectonthesolu6on)
Ø Asolu6onoftheTSPyieldsacyclewithminimalweight.Bydele6nganyedgethiswouldresultinaspanningtree
Ø Soasolu6onofTSPcannothavelessweightthantheweightoftheMST
Ø SotheweightofMSTisalowerboundontheweightofTSP
![Page 7: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/7.jpg)
Sequen6alAlgorithmsforMST• Borůvka’salgorithm(1926),Kruskal’salgorithm(1956)andPrim’salgorithm(1957)
• (Historicalnote)Borůvska’salgorithmwasusedin1926toconstructanefficientelectricitynetworkinMoravia(CzechRepublic)*
• Kruskal’sandPrim’salgorithmarebothbasedontheselec6ngasinglelightestweightedgeineachstepofthealgorithm
*ThealgorithmwasrediscoveredbyChoquetin1938;[4]againbyFlorek,Łukasiewicz,Perkal,Steinhaus,andZubrzycki[5]in1951;andagainbySollin[6]in1965.BecauseSollinwastheonlycomputerscien6stinthislistlivinginanEnglishspeakingcountry,thisalgorithmisfrequentlycalledSollin'salgorithm.
![Page 8: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/8.jpg)
Light-EdgeProperty•
GivenaweightedundirectedgraphG=(V,E),thenforanycutsetS(SCE),theminimalweightededgeinShastobeanedgeoftheMST
AcutsetsScutsthegraphintotwosetsUandV\UsuchthatanypathfromanodexinUtoanodeyinV\UcontainsanedgefromSProof:AssumewehaveacutsetSwhichcontainsanedgee=(x,y)withminimalweight,whichisnotpartoftheMST.ThenthereisapathPinMST,whichconnectsxandyandwhichdoesnotcontaine.So,becausexandyareonoppositesidesofe,nexttoetheremustbeanedgee’inSwithe’onthepathP.NowaddetotheMST=MST’,theneande’arepartofacycleinMST’.Deletee’fromMST’,andweobtainanotherMSTwithalesserweight(w(e)<w(e’)).Contradic6on.
![Page 9: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/9.jpg)
Kruskal’sAlgorithm
AsdecribedbyKruskalin1956:
“Performthefollowingstepasmany6mesaspossible:AmongtheedgesofGnotyetchosen,choosetheshortestedgewhichdoesnotformanyloopswiththoseedgesalreadychosen”
![Page 10: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/10.jpg)
Prim’sAlgorithm•
PRIM_MST(V,E,w,r):GivenV,E,andwweightfunc6on,buildMSTstar6ngfromvertexr
![Page 11: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/11.jpg)
•
![Page 12: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/12.jpg)
Prim'sAlgorithm:ParallelFormula6on
• Thealgorithmworksinnouteritera6ons-itishardtoexecutetheseitera6onsconcurrently.
• Theinnerloopisrela6velyeasytoparallelize.Letpbethenumberofprocesses,andletnbethenumberofver6ces.
• Theadjacencymatrixispar66onedina1-Dblockfashion(columnslices),withdistancevectordpar66onedaccordingly.Seenextslide.
• Ineachstep,eachprocessorselectsthelocallyclosestnode,followedbyaglobalreduc6ontoselectgloballyclosestnode.
• ThisnodeisinsertedintoMST,andthechoiceisbroadcastedtoallprocessors.
• Eachprocessorupdatesitspartofthedvectorlocally.
![Page 13: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/13.jpg)
•
![Page 14: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/14.jpg)
Computa6onalAspects
• ThecosttoselecttheminimumentryisO(n/p+logp).• ThecostofabroadcastisO(logp).• ThecostoflocalupdateofthedvectorisO(n/p).• Theparallel6meperitera6onisO(n/p+logp).• Thetotalparallel6me(nitera6ons)isgivenbyO(n2/p+nlogp).
![Page 15: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/15.jpg)
Borůvka’sAlgorithm(1926)
Whilethereareedgesremaining:(1) selecttheminimumweightedgeoutofeachvertex
andcontracteachconnectedcomponentdefinedbytheseedgesintoavertex;
(2) removeselfedges,andwhenthereareredundantedgeskeeptheminimumweightedge;and
(3) addallselectededgestotheMST.
Notethatthisformula6onisinherentlyparallelwhilecomputerswerenotinventedatthat6me,ormaybebecausecomputerswerenotinventedyet
![Page 16: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/16.jpg)
Example•
12
7
35
64 4
2
54è è
2
3
1
4
6
![Page 17: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/17.jpg)
Example(otherexecu6onorder)•
12
7
35
64 3
2
53
7
6
è è
2
3
1
4
6
TheSame!!!!
![Page 18: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/18.jpg)
NotestoBorůvka’sAlgorithm
• Ateachstepthecontrac6onsofnodesuandvwith(u,v)aminimaledgecanbeexecutedinparallelwiththecontrac6onofnodesxandwwith(x,w)aminimaledge,ifv≠xandu≠w.(Note,u≠xandv≠wautoma6callyholds)
• Soateachstepatleast½|V|ver6cesareeliminatedèatmostlog(n)stepsarerequired
• However,alsotheamountofavailableparallelismisreducedbyanhalfauereachstepèunevenloadbalance
![Page 19: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/19.jpg)
InputDataPar66oning• Recallseparatorsets(nesteddissec6on)forundirectedgraphs,
basedonlevelliza6on(BFS).• ThesetofnodesVisdividedintoPdisjointsubsetsandseparator
sets: V=V1US2UV2US3…SPUVPP=numberofprocessorsand|Vi|aboutequalforalli
• DistributetheedgesEsuchthateachprocessorihas Ei={(u,v)|uεViandvεVi},and Leu_Ei={(u,v)|uεSiandvεVi},and Right_Ei={(u,v)|uεViandvεSi+1}
è FirstphaseeveryprocessorcomputesinparallelanMSTforeachEiè Secondthesepar6alMST’sarekni{edtogetherbysynchronizing
thechoiceofminimumweightedgeofLeu_EiwithRight_Ei+1
![Page 20: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/20.jpg)
Problem2:Single-SourceShortestPaths
• ForaweightedgraphG=(V,E,w,s),thesingle-sourceshortestpathsproblemistofindtheshortestpathsfromavertexs∈Vtoallotherver6cesinV(wistheweigthfunc6onoftheedges).
• Dijkstra'salgorithmissimilartoPrim'salgorithm.Itmaintainsasetofnodesforwhichtheshortestpathsareknown.
• Itgrowsthissetbasedonthenodeclosesttosourceusingoneofthenodesinthecurrentshortestpathset.
![Page 21: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/21.jpg)
Dijkstra'sAlgorithm•
![Page 22: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/22.jpg)
Dijkstra'sAlgorithm:ParallelFormula6on
• Verysimilartotheparallelformula6onofPrim'salgorithmforminimumspanningtrees.
• Theweightedadjacencymatrixispar66onedusingthe1-Dblockmapping(columnslicing).
• Eachprocessselects,locally,thenodeclosesttothesource,followedbyaglobalreduc6ontoselectnextnode.
• Thenodeisbroadcasttoallprocessorsandthel-vectorupdated.
![Page 23: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/23.jpg)
Problem3:All-PairsShortestPaths
• GivenaweightedgraphG(V,E,w),theall-pairsshortestpathsproblemistofindtheshortestpathsbetweenallpairsofver6cesvi,vj∈V.
• Anumberofalgorithmsareknownforsolvingthisproblem:Matrix-Mul6plica6onBasedalgorithm,Dijkstra’salgorithm,Floyd’salgorithm.
![Page 24: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/24.jpg)
Matrix-Mul6plica6onBasedAlgorithm• Considerthemul6plica6onoftheweightedadjacencymatrixwithitself-except,inthiscase,wereplacethemul6plica6onopera6oninmatrixmul6plica6onbyaddi6on,andtheaddi6onopera6onbyminimiza6on.
• No6cethattheproductofweightedadjacencymatrixwithitselfreturnsamatrixthatcontainsshortestpathsoflength2betweenanypairofnodes.
• ItfollowsfromthisargumentthatAncontainsallshortestpaths.
![Page 25: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/25.jpg)
InaPicture•
![Page 26: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/26.jpg)
Computa6onalAspects• For(semi)completegraphsandsequen6alexecu6on:
– Aniscomputedbydoublingpowers-i.e.,asA,A2,A4,A8,andsoon.
– Weneedlogn(dense)matrixmul6plica6ons,eachtaking6meO(n3).
– TheserialcomplexityofthisprocedureisO(n3logn).• For(semi)completegraphsandparallelexecu6on:
– Eachofthelognmatrixmul6plica6onscanbeperformedinparallel.
– Wecanusen3/lognprocessorstocomputeeachmatrix-matrixproductin6melogn.
– Theen6reprocesstakesO(log2n)6me.Notethatforincompletegraphs(leadingtosparsematrices)thiscomplexitydoesnotchangeverymuch,becausesparsexsparsematrixmul6plyveryeasilyleadtofullmatrices.
![Page 27: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/27.jpg)
Dijkstra’sAlgorithmforAll-PairsShortestPaths
Sequen6alExecu6on:– Executeninstancesofthesingle-sourceshortestpathproblem,oneforeachofthensourcever6ces.
– ComplexityisO(n3).ParallelExecu6on:– executeeachofthenshortestpathproblemsonadifferentprocessor(sourcepar66oned),or
– useaparallelformula6onoftheshortestpathproblemtoincreaseconcurrency(sourceparallel)
![Page 28: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/28.jpg)
SourcePar66onedFormula6on
• Usenprocessors,eachprocessorPifindstheshortestpathsfromvertexvitoallotherver6cesbyexecu6ngDijkstra'ssequen6alsingle-sourceshortestpathsalgorithm.
• Itrequiresnointerprocesscommunica6on(providedthattheadjacencymatrixisreplicatedatallprocesses).
• Theparallelrun6meofthisformula6onis:O(n2).O(n2)isthesame6mecomplexityasPrim’salgorithm.
• Whilethealgorithmiscostop6mal,itcanonlyusenprocessors.
![Page 29: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/29.jpg)
SourceParallelFormula6on
Inthiscase,eachoftheshortestpathproblemsisfurtherexecutedinparallel.Wecanthereforeuseupton2processors.
![Page 30: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/30.jpg)
Floyd’sAlgorithm
• Foranypairofver6cesvi,vj∈V,considerallpathsfromvitovjwhoseintermediatever6cesbelongtotheset{v1,v2,…,vk}.Letpi(,kj)(ofweightdi(,kj))betheminimum-weightpathamongthem.
• Ifvertexvkisnotintheshortestpathfromvitovj,thenpi(,kj)isthesameaspi(,kj-1).
• Ifvkisinpi(,kj),thenwecanbreakpi(,kj)intotwopaths– onefromvitovkand– onefromvktovj
Eachofthesepathsusesver6cesfrom{v1,v2,…,vk-1}.
![Page 31: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/31.jpg)
Asaconsequence:
•
Fromtheseobserva6ons,thefollowingrecurrencerela6onfollows:
Thisequa6onmustbecomputedforeachpairofnodesandfork=1,n.TheserialcomplexityisO(n3).
![Page 32: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/32.jpg)
In(pseudo)code•
![Page 33: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/33.jpg)
Floyd'sAlgorithm:ParallelExecu6on
• MatrixD(k)isdividedintopblocksofsize(n/√p)x(n/√p).• Eachprocessorupdatesitspartofthematrixduringeach
itera6on.• Tocomputedl(,kr-1)processorPi,jmustgetdl(,kk-1)forallk≠r,
anddk(,kr-1)forallk≠l.• Ingeneral,duringthekthitera6on,eachofthe√pprocesses
containingpartofthekthrowsendittothe√p-1processesinthesamecolumn.
• Similarly,eachofthe√pprocessescontainingpartofthekthcolumnsendsittothe√p-1processesinthesamerow.
![Page 34: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/34.jpg)
InaPicture
•
![Page 35: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/35.jpg)
InaPicture:con6nued
•
![Page 36: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/36.jpg)
In(pseudo)code•
![Page 37: Parallel Graph Algorithms - Leiden Universityliacs.leidenuniv.nl/~wijshoffhag/PPI2016_2017/Lecture_8.pdf · Basic Defini6ons • An undirected graph G is a pair (V,E), where V is](https://reader033.fdocuments.net/reader033/viewer/2022042622/5f7e5b2d44496f62d654fa75/html5/thumbnails/37.jpg)
Computa6onalAspects
• Duringeachitera6onofthealgorithm,thekthrowandkthcolumnofprocessorsperformaone-to-allbroadcastalongtheirrows/columns.
• Thesizeofthisbroadcastisn/√pelements,taking6meΘ((nlogp)/√p).
• Thesynchroniza6onsteptakes6meΘ(logp).• Thecomputa6on6meisΘ(n2/p).• Thetotalparallelrun6me(nstep)ofthe2-Dblockmappingformula6onofFloyd'salgorithmis