Abstract. We construct a readable, compact and efficient implementation of Dijkstra’s shortest path algorithm and Fibonacci heaps using Constraint Handling Rules (CHR), which is increasingly used as a high-level rule-based general-purpose programming lang
Dijkstra’sAlgorithmwithFibonacciHeaps:
AnExecutableDescriptioninCHR
JonSneyers ,TomSchrijvers ,BartDemoen
Dept.ofComputerScience,K.U.Leuven,Belgium
{jon,toms,bmd}@cs.kuleuven.be
Abstract.Weconstructareadable,compactande cientimplementationofDijkstra’sshortestpathalgorithmandFibonacciheapsusingConstraintHandlingRules(CHR),whichisincreasinglyusedasahigh-levelrule-basedgeneral-purposeprogramminglanguage.Wemeasureitsperformanceindi erentCHRsystems,investigatingboththetheoreticalasymp-toticcomplexityandtheconstantfactorsrealizedinpractice.
1Introduction
ConstraintHandlingRules(CHR)[10]isahigh-levelprogramminglanguageextensionbasedonmulti-headedcommitted-choicerules.Originallydesignedforwritingconstraintsolvers,itisin-creasinglyusedasageneral-purposeprogramminglanguage.WeassumethatthereaderisfamiliarwithCHR,referringto[10]foranoverview.Recently,wehaveshown[21]thateveryalgorithmcanbeimplementedinCHRwiththebest-knownasymptotictimeandspacecomplexity.How-ever,itremainsanopenproblemwhetherclassicalalgorithmscanbeimplementedinCHRinanelegantandcompactway.Also,theconstantfactorhiddenbehindthenotionofasymptotictimecomplexitycouldbesohugetobecompletelyparalyzinginpractice.
EarlierworkbySchrijversandFr¨uhwirth[20]resultedinanelegantCHRimplementationoftheclassicalunion- ndalgorithmwhichhastheoptimalasymptotictimecomplexity.Inthispa-per,weconstructareadable,compactande cientCHRprogram(Section3)whichimplementsDijkstra’sshortestpathalgorithmwithFibonacciheaps.Weanalyzeitstheoreticaltimecomplex-ity(Section4)andexperimentallycompareitsperformanceindi erentCHRsystemsagainstalow-levelreferenceimplementationinC(Section5).
Inthispaper,wehopetodemonstratethatCHRcanbeusedas‘executablepseudo-code’forstudyinganddesigningalgorithmswhileconstructingarealprogramwiththedesiredtime(andspace)complexity.WealsoinvestigatetheconstantfactorseparatingCHRfromlow-levellanguages,andproposeamoree cienttypeofconstraintstoresforindexingongroundintegerarguments,improvingtheconstantfactor(forourprogram)by35%ormore.
2Thesingle-sourceshortestpathproblem
Theshortestpathproblem[26]isoneofthemostbasic,andmoststudied,problemsinalgorithmicgraphtheory.Itappearsasasub-probleminmanygraphrelatedalgorithms,suchasnetworkoptimizationalgorithms.GivenaweighteddirectedgraphG=(V,E)andasourcenodes∈V,weareinterestedinthe(shortest)distancesfromstoallothernodesofthegraph.ThisiscalledtheSingle-SourceShortestPath(SSSP)problem.Intherestofthispaperwewillusen=|V|todenotethenumberofnodesandm=|E|todenotethenumberofedges.Weassumetheweightstobenonnegative,butnotnecessarilyinteger.Wealsoassumethatthegraphisconnected,sonisO(m).
ThisworkwaspartlysupportedbyprojectsG.0144.03andG.0160.02fundedbytheResearchFounda-tion-Flanders(F.W.O.-Vlaanderen).ResearchAssistantoftheResearchFoundation-Flanders(F.W.O.-Vlaanderen).
Dijkstra’s algorithm wi... 16页 免费 Dijkstra... Meeting 11 October 4, 2005 Fibonacci Heaps The...cost applied to an initially empty Fibonacci heap...
Dijkstra’s algorithm wi... 10页 免费 Rangan. Relaxed fibonacc... 暂无...[5] invented an implementation of the priority queue called Fibonacci heaps....
Dijkstra’s algorithm wi... 10页 免费 Rangan. Relaxed fibonacc... 暂无...[5] invented an implementation of the priority queue called Fibonacci heaps....
热门文档