1. Trang chủ
  2. » Công Nghệ Thông Tin

Giải thuật Prim (Jarnik''''''''s (Prim''''''''s) Algorithm)

9 528 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 9
Dung lượng 322,39 KB

Nội dung

The oldest and simplest MST algorithm was discovered by Boruvka in 1926. The Boruvkas algorithm was rediscovered by Choquet in 1938; again by Florek, Lukaziewicz, Perkal, Stienhaus, and Zubrzycki in 1951; and again by Sollin in early 1960s. The next oldest MST algorithm was first described by the Polish mathematician Vojtech Jarnik in a 1929 letter to Boruvka. The algorithm was independently rediscovered by Kruskal in 1956, by Prim in 1957, by Loberman and Weinberger in 1957, and finally by Dijkstra in 1958. This algorithm is (inappropriately) called Prims algorithm, or sometimes (even more inappropriately) called the PrimDijkstra algorithm. The basic idea of the Jarniks algorithm is very simple: find As safe edge and keep it (i.e. add it to the set A).

Jarnik's (Prim's) Algorithm The oldest and simplest MST algorithm was discovered by Boruvka in 1926. The Boruvka's algorithm was rediscovered by Choquet in 1938; again by Florek, Lukaziewicz, Perkal, Stienhaus, and Zubrzycki in 1951; and again by Sollin in early 1960's. The next oldest MST algorithm was first described by the Polish mathematician Vojtech Jarnik in a 1929 letter to Boruvka. The algorithm was independently rediscovered by Kruskal in 1956, by Prim in 1957, by Loberman and Weinberger in 1957, and finally by Dijkstra in 1958. This algorithm is (inappropriately) called Prim's algorithm, or sometimes (even more inappropriately) called 'the Prim/Dijkstra algorithm'. The basic idea of the Jarnik's algorithm is very simple: find A's safe edge and keep it (i.e. add it to the set A). Overall Strategy Like Kruskal's algorithm, Jarnik's algorithm, as described in CLRS, is based on a generic minimum spanning tree algorithm. The main idea of Jarnik's algorithm is similar to that of Dijkstra's algorithm for finding shortest path in a given graph. The Jarnik's algorithm has the property that the edges in the set A always form a single tree. We begin with some vertex v in a given graph G =(V, E), defining the initial set of vertices A. Then, in each iteration, we choose a minimum- weight edge (u, v), connecting a vertex v in the set A to the vertex u outside of set A. Then vertex u is brought in to A. This process is repeated until a spanning tree is formed. Like Kruskal's algorithm, here too, the important fact about MSTs is that we always choose the smallest-weight edge joining a vertex inside set A to the one outside the set A. The implication of this fact is that it adds only edges that are safe for A; therefore when the Jarnik's algorithm terminates, the edges in set A form a minimum spanning tree, MST. Details  The Jarnik's algorithm builds one tree, so A is always a tree.  It starts from an arbitrary "root" r.  At each step, find a light edge crossing cut (V A , V − V A ), where V A = vertices that A is incident on. Add this edge to A. Note that the edges of A are shaded. Now the question is how to find the light edge quickly? Use a priority queue Q:  Each object is a vertex in V − V A .  Key of v is minimum weight of any edge (u, v), where u ∈ V A .  Then the vertex returned by EXTRACT-MIN is v such that there exists u ∈ V A and (u, v) is light edge crossing (V A , V − V A ).  Key of v is ∞ if v is not adjacent to any vertices in V A . The edges of A will form a rooted tree with root r :  Root r is given as an input to the algorithm, but it can be any vertex.  Each vertex knows its parent in the tree by the attribute π[v] = parent of v. Initialize π[v] = NIL if v = r or v has no parent.  As algorithm progresses, A = {(v, π[v]) : v ∈ V − {r} − Q}.  At termination, VA = V ⇒ Q = ∅, so MST is A = {(v, π[v]) : v ∈ V − {r}}. Algorithm Choose a node and build a tree from there selecting at every stage the shortest available edge that can extend the tree to an additional node. JARNIK(V, E, w, r ) Q ← { } for each u in V do key[u] ← ∞ π[u] ← NIL INSERT(Q, u) . algorithm is (inappropriately) called Prim& apos;s algorithm, or sometimes (even more inappropriately) called 'the Prim/ Dijkstra algorithm'. The basic idea of the Jarnik's algorithm. Jarnik's (Prim& apos;s) Algorithm The oldest and simplest MST algorithm was discovered by Boruvka in 1926. The Boruvka's algorithm was rediscovered by Choquet. Strategy Like Kruskal's algorithm, Jarnik's algorithm, as described in CLRS, is based on a generic minimum spanning tree algorithm. The main idea of Jarnik's algorithm is similar to

Ngày đăng: 24/12/2014, 06:00

TỪ KHÓA LIÊN QUAN

w