Sei sulla pagina 1di 3

Rafael Nobleza Masallo CS501M

Assignment Desalgo 9-12-17

Prim's algorithm
In computer science, Prim's algorithm is a
greedy algorithm that finds a minimum spanning tree
for a weighted undirected graph. This means it
finds a subset of the edges that forms a tree that
includes every vertex, where the total weight of
all the edges in the tree is minimized. The
algorithm operates by building this tree one vertex
at a time, from an arbitrary starting vertex, at
each step adding the cheapest possible connection
from the tree to another vertex.

The algorithm was developed in 1930 by Czech


mathematician Vojtch Jarnk and later rediscovered
and republished by computer scientists Robert C.
Prim in 1957 and Edsger W. Dijkstra in 1959.
Therefore, it is also sometimes called the DJP
algorithm, Jarnk's algorithm, the PrimJarnk
algorithm, or the PrimDijkstra algorithm.

Other well-known algorithms for this problem


include Kruskal's algorithm and Borvka's
algorithm. These algorithms find the minimum
spanning forest in a possibly disconnected graph;
in contrast, the most basic form of Prim's algorithm only finds
minimum spanning trees in connected graphs. However, running
Prim's algorithm separately for each connected component of the
graph, it can also be used to find the minimum spanning forest.
In terms of their asymptotic time complexity, these three
algorithms are equally fast for sparse graphs, but slower than
other more sophisticated algorithms. However, for graphs that
are sufficiently dense, Prim's algorithm can be made to run in
linear time, meeting or improving the time bounds for other
algorithms.
Rafael Nobleza Masallo CS501M
Assignment Desalgo 9-12-17

Kruskal's algorithm is a minimum-spanning-tree algorithm


which finds an edge of the least possible weight that connects
any two trees in the forest. It is a greedy algorithm in graph
theory as it finds a minimum spanning tree for a connected
weighted graph adding increasing cost arcs at each step. This
means it finds a subset of the edges that forms a tree that
includes every vertex, where the total weight of all the edges
in the tree is minimized. If the graph is not connected, then it
finds a minimum spanning forest (a minimum spanning tree for
each connected component).

This algorithm first appeared in Proceedings of the


American Mathematical Society, pp. 4850 in 1956, and was
written by Joseph Kruskal.

Other algorithms for this problem include Prim's algorithm,


Reverse-delete algorithm, and Borvka's algorithm.
Rafael Nobleza Masallo CS501M
Assignment Desalgo 9-12-17

Dijkstra's algorithm is an algorithm for finding the


shortest paths between nodes in a graph, which may represent,
for example, road networks. It was conceived by computer
scientist Edsger W. Dijkstra in 1956 and published three years
later.

The algorithm exists in many variants; Dijkstra's original


variant found the shortest path between two nodes, but a more
common variant fixes a single node as the "source" node and
finds shortest paths from the source to all other nodes in the
graph, producing a shortest-path tree.

Dijkstra's original algorithm does not use a min-priority


queue and runs in time O ( | V | 2 ) {\displaystyle O(|V|^{2})}
O(|V|^{2}) (where | V | {\displaystyle |V|} |V| is the number of
nodes). The idea of this algorithm is also given in Leyzorek et
al. 1957. The implementation based on a min-priority queue
implemented by a Fibonacci heap and running in O ( | E | + | V |
log | V | ) {\displaystyle O(|E|+|V|\log |V|)} O(|E|+|V|\log
|V|) (where | E | {\displaystyle |E|} |E| is the number of
edges) is due to Fredman & Tarjan 1984. This is asymptotically
the fastest known single-source shortest-path algorithm for
arbitrary directed graphs with unbounded non-negative weights.
However, specialized cases (such as bounded/integer weights,
directed acyclic graphs etc.) can indeed be improved further as
detailed in Specialized variants.

Potrebbero piacerti anche