Professional Documents
Culture Documents
Exposed of Algorithmes in TG
Exposed of Algorithmes in TG
2 Sollin’s Algorithm
Sollin’s algorithm is another greedy algorithm that finds a minimum spanning
tree for a connected weighted graph. The algorithm works by maintaining a
forest of trees, and iteratively adding the lightest edge that connects each tree
to another tree, until all the trees are connected.
Here’s the pseudocode for Sollin’s algorithm:
3 Dijkstra’s Algorithm
Dijkstra’s algorithm is a shortest path algorithm that finds the shortest path
between a source vertex and all other vertices in a weighted graph. The algo-
rithm works by maintaining a priority queue of vertices and their distances from
the source vertex, and iteratively selecting the vertex with the smallest distance
and updating the distances of its neighbors.
Here’s the pseudocode for Dijkstra’s algorithm:
1
Algorithm 3 Dijkstra’s algorithm
1: Initialize a priority queue of vertices, with the source vertex having distance
0 and all other vertices having distance infinity.
2: while the priority queue is not empty do
3: Select the vertex with the smallest distance from the priority queue.
4: for each neighbor of the selected vertex do
5: Calculate the distance from the source vertex to the neighbor through
the selected vertex.
6: if the calculated distance is smaller than the current distance of the
neighbor then
7: Update the distance of the neighbor in the priority queue.
8: end if
9: end for
10: end while