9/8/2019 Program Algoritma Dikstra C
Algoritma Dijkstra, (dinamai menurut penemunya, seorang ilmuwan komputer, Edsger Dijkstra), adalah sebuah algoritme rakus (greedy algorithm) yang dipakai dalam memecahkan permasalahan jarak terpendek (shortest path problem) untuk sebuah graf berarah (directed graph) dengan bobot-bobot sisi (edge weights) yang bernilai tak-negatif.
![]()
Dijkstra’s Shortest Path Algorithm is a popular algorithm for finding the shortest path between different nodes in a graph. It was proposed in 1956 by a computer scientist named. Often used in routing, this algorithm is implemented as a subroutine in other graph algorithm.
![]()
In this post, I have included a pseudo code and source code for Dijkstra’s Algorithm in C along with a brief introduction to this algorithm.Dijkstra’s algorithm finds the solution for the single source shortest path problems only when all the edge-weights are non-negative on a weighted, directed graph. Function Dijkstra(Graph, source):distsource:= 0 // Distance from source to sourcefor each vertex v in Graph: // Initializationsif v ≠ sourcedistv:= infinity // Unknown distance function from source to vpreviousv:= undefined // Previous node in optimal path from sourceend ifadd v to Q // All nodes initially in Qend forwhile Q is not empty: // The main loopu:= vertex in Q with min distu // Source node in first caseremove u from Qfor each neighbor v of u: // where v has not yet been removed from Q.alt:= distu + length(u, v)if alt.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |