1. Trang chủ
  2. » Thể loại khác

Về một thuật toán tìm đường ngắn nhất trong một sơ đồ trọng lượng mở rộng

8 3 0

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

THÔNG TIN TÀI LIỆU

Nội dung

JOURNAL OF SCIENCE OF HNUE Interdisciplmary Science, 2014, Vol 59, No 5, pp 34-41 This paper is available online at http://stdb.hnue.edu.vn AN ALGORITHM FINDING THE SHORTEST PATH D4 AN EXTENDED WEIGHTED GRAPH Pham Thi Hue Xuan Dinh Highschool, Tu Liem Distric, Hanoi Abstract An algorithm finding the shortest path joining two given vertices in an extended graph has been studied in other papei^ [1, 6] In this paper, we show that the algoriUun presented in [6] doesn't work for the extended graphs in [6] We define die oUier extended graph, called an extended weighted graph, such diat a similar algorithm works for it Keywords: Parallel, graph, extended weighted graph, algoridmi, die shortest pafli Introduction In [6], the extended graph is thus defined Definition 1: Given a graph G (V, E) widi a set of vertices V and a set of edges E, where die edges can be directed or undirected, we denote the weight of an edge e e E wifli WE(e) Wifli each vertex v V, let E„ be flie set of edges of vertex v For each vertex v € V and each edge (e, e ') s E„ x E„, e ^ e' weighted wi^ (v, e, e ' ) The graph G = (V, E, w^, wv) is called an extended graph Let P = [u, ei, Ul, e2, U2, , Cft, Uft, Cft+i, v] be die path fhim u to v flirough flie edge «" ' = h +1, and flie vertices Uj, i = 1, , h, define flie lengfli of die padi p, denoted 1(P) A+l h lb>) = '^fiE(ei) + Y^wv(Ui,ei,e,+i) i=l (1) =1 The algoriflim in [6] is as following: - Input Extended graph G(V, E, w „ w„), vertex s e V and set !7 c V - Output l(v) is die lengfli of flie shortest pafli from s to v and die shortest padi (if l(v) < Received April 11,2014 Accepted June 13,2014 Contact Pham Thi Hue, e-mail address: huecntt®gmail.com 34 An algorithm finding the shortest path in an extended weighted graph - Methods The algorithm uses the following symbols: S is a set of vertices that found the shortest path starting from s; T = V-S; l(v) is the length of the shortest path from s to v; VE = {(t>, e)|t; S V{s]k.e e By} U {(s, 0)} is the set of vertices and edges; SE is a set of vertex-edge excluded from VE; TE = VE - SE; L(v, e) is the vertex-edge pair label (v, e) G VE; P(v, e) is the vertex-front edge (v, e) e VE; SU, the set of v in U for which the shortest path starting from s to v is found; TU = U - SU Step (Initialized) Let S = 0; T = V; TU = U; SU = )}S£ = 4,;TE = VE; Set L(v, e) = 00, V (v, e) G VE, L(s, 0): = SetP(v,e) = 0V(v,e)GVE Step2 Calculate m = „i„(L((v, e))l (v, e) G TE) If m = -t-oo, go to Step Or else, if m < +00, choose (Vmi„, e^in) G TE so that L(v„i„, emi„) = m, SetTE = TE- ((v^„,e„„)),SE = SEU ((v„,„,e„j„)),gotostep3 Step - If v„i„ ^ dien set le(v„i„) = e,„,„, S = S U {i;„i„}, l(v„i„) = L(v„,i„, e^n), T = T -( Vrtn) if v„i„ G TUtiienset SU = SU U v„,„, andTU = TU -(v„i„) - If TU = 0, go to step 5, or else go to step Step For any (v, e) G TE adjacent (post-adjacent) (Vmin, Cmin), Set L'(v, e) = L(v^, e„i„) + WE(V„I„,V) + viv(Vmm, e) IF L(v, e) > L'(v, e),flienset L(v, e) = L'(v, e) and P(v, e) = (v„i„, e„,„) Back to step Step (Finding the shortest path) For any vertex t G SU, set l(t) = L(t, le (t)) is the length of the shortest path from stot From t tracing back the front vertex-edge, we receive the shortest path as follows: let (vi, ei) = P(t, le(t)), (vj, cj) = P(vi, Ci), , (vt, e*) = P(V4_i, efc_i), (s, 0) 37 Pham Thi Hue = P(v*,et) It is inferredfliatdie shortest padi is: S to vt to Vk-i to to Vl io t End 2.2 Example Consider die extended weighted graph in Figure The graph has vertices, duected edges and undirected edges The weights of edges WE are represented in die graph in Figure and the weights of the vertices are showed in Table Vertex 1 2 3 4 5 Table Weights of vertices Edge (1,2) (1.3) (3,2) (5,2) (2,3) (4,3) (5,3) (5,4) (6,4) (3,5) (4,5) (6,5) wV Applyingfliealgoriflim tofinddie shortest pafli from one vertex to all vertices The process of implementation offliealgoriflim and die results are shown in Tables and From Table and Table it is inferred that flic shortest paflis from vertex to all vertices as follows: From IK) 2:1 ->2, lengfli 11 From to 3: -> 3, length 10 From to 4: -> -^ 4, lengfli 26 From to 5:1 -»2 -> or -> -> 5, lengfli 22 From to 6:1 -> -» - > o r I - » - > ^ , lengfli 33 38 An algorithm finding the shortest path in an extended weighted graph Table The process of implementing the algorithm at initialized step and the first two loops Sin initialized r •• L VE A_ sr SE S PE h* t L 1,* 2,(1.2) ãằ 11 2,(3,2) " ô « "> " «

Ngày đăng: 08/12/2022, 17:29

w