IJPRET - CSIT 308

Embed Size (px)

Citation preview

  • 8/20/2019 IJPRET - CSIT 308

    1/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    938 

    INTERNATIONAL JOURNAL OF PURE AND

     APPLIED RESEARCH IN ENGINEERING AND

    TECHNOLOGY A PATH FOR HORIZING YOUR INNOVATIVE WORK

    A STUDY ON SHORTEST PATH ALGORITHM BASED ON DIJKSTRA’S AND BELLMAN

    FORD ALGORITHM

    DIPTEE WARHADE, DR. A. S. ALVIDepartment Of Computer Science and Engineering, Prof. Ram Meghe Institute of Technology and Research, Amravati (India)

    Accepted Date: 05/03/2015; Published Date: 01/05/2015

    Abstract: The shortest path is an important research topic in graph theory. The shortest path

    algorithm in the graph theory includes both the one between the particular node pair and

    the one among all the nodes. Aiming at the shortcomings of traditional algorithm, this paper

    has proposed an optimization method which has mainly improved the nodes selection of the

    shortest path and data storage structure and organization. Through comparison and

    analysis, the improved algorithm has been obtained, which has reduced the storage space,

    improved the operational efficiency and has a better applicability in the shortest path

    calculation.

    Keywords: Bellman Ford, Dijkstra’s Algorithm 

    Corresponding Author: MISS. DIPTEE WARHADE

    Access Online On:

    www.ijpret.com

    How to Cite This Article:

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 PAPER-QR CODE

  • 8/20/2019 IJPRET - CSIT 308

    2/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    939 

    INTRODUCTION

    The shortest path is an important research topic in graph theory. The shortest path algorithm in

    the graph theory includes both the one between the particular node pair and the one among all

    the nodes [1]. The former can be used to rationalize the transportation decision-makinganalysis, that Dijkstra algorithm is a classical algorithm for solving such problems, while the

    latter is for the selection of a reasonable distribution center. A well-known shortest path

    algorithm is Dijkstra's, also called "label algorithm". We need to solve many shortest path

    problems [2].

    For example, in the process of production, to complete production tasks quickly and with

    efficacy, we should find the shortest path to complete each production task; in the process of

    management, to make large gains with minimal cost, we should develop rational plans; in the

    existing transport network, to transport large quantity of goods with minimal costs, we should

    arrange for reasonable transport path. All these questions can be summed up as the “shortest

    path problem” [3]. 

    The Bellman-Ford algorithm uses relaxation to find single source shortest paths on directed

    graphs. And it is also contain negative edges. The algorithm will also detect if there are any

    negative weight cycles (such that there is no solution). If talking about distances on a map,

    there is no any negative distance. The basic structure of bellman-ford algorithm is similar to

    Dijkstra algorithm. It relaxes all the edges, and does this |V| - 1 time, where |V| is the number

    of vertices in the graph [2]. The cost of a path is the sum of edge weights in the path [4].

    I. 

    Literature Review

    A. 

    Description of Algorithm:

    Dijkstra’s algorithm: Identify a shortest distance from the source point to the other target

    nodes, and then use the path length to find the shortest path iteratively, that is, the basic idea

    of Dijkstra algorithm. However, with the development of the computer, the scale of the

    problems is increasing continuously, and meanwhile the use of traditional Dijkstra has

    increased the space and time complexity [1]. Before going into details of the pseudo-code of

    the algorithm it is important to know how the algorithm works. Dijkstra’s algorithm works by

    solving the sub problem k, which compute the shortest path from source to vertices among the

    k closest vertices to the source [5].

  • 8/20/2019 IJPRET - CSIT 308

    3/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    940 

    Dijkstra (G,s)

    For each vertex v in graph G

    {

    D[s] = 0

    D[v] = ∞ 

    }

    Initialize visited vertices S in graph G

    S = null

    Initialize Queue Q as set of all nodes in graph G

    Q = all vertices V

    While Q ≠ ∅ 

    {

    u=mind (Graph G, distance d)

    Visited vertices S = S+u

    for each vertex v in neighbor[u]

    {

    If d[v] > d[u] + w(u,v)

    Then d[v] = d[u] + w (u,v)

    }

    Return d

    }[4]

  • 8/20/2019 IJPRET - CSIT 308

    4/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    941 

    1)  Why It Doesn’t Work for Negative-Weight Edges

    Dijkstra’s algorithm is based on the greedy method. It adds vertices by increasing distance. 

    If a node with a negative incident edge were to be added late to the cloud, it could mess up

    distances for vertices already in the cloud.

    Bellman –Ford algorithm:  It Works even with negative-weight edges must assume directed

    edges (for otherwise we would have negative-weight cycles).Negative edge weights are found

    in various applications of graphs, hence the usefulness of this algorithm. If a graph contains a

    "negative cycle" (i.e. a cycle whose edges sum to a negative value) that is reachable from the

    source, then there is no cheapest path: any path can be made cheaper by one more walk 

    around the negative cycle. In such a case, the Bellman –Ford algorithm can detect negative

    cycles and report their existence.

    Initialize graph

    Bellman-ford (vertices V, edges E, source vertex srv)

    For each v in V

    {

    If v = srvthan d[v] =0

    Else d[v] = infinite

    Cost[v] = null

    }

    Relaxation of edges

    For i form 1 to IVI-1

    {

    For each [u,v] with w in E

    {

    If d[u]+w

  • 8/20/2019 IJPRET - CSIT 308

    5/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    942 

    {

    If d[v]=d[u]+w

    Cost[v] =u

    }

    }

    }[4]

    Checking negative cycle

    For each e(u ,v) with weight winE

    {

    If d[u]+w,d[v]

    {

    Print “graph has negative cycle” 

    }

    }[4]

    II. 

    Comparisons Between Dijkstra's and Bellman Fords Algorithm

    Both of these functions solve the single source shortest path problem. The primary difference in

    the function of the two algorithms is that Dijkstra's algorithm cannont handle negative edge

    weights. Bellman-Ford's algorithm can handle some edges with negative weight. It must be

    remembered, however, that if there is a negative cycle there is no shortest path.

    For Single source shortest paths:

    Dijkstra Algorithm - No negative weight allowed - O(E+Vlg(V))

    Bellman ford Algorithm - Negative weight is allowed. But if a negative cycle is present Bellman

    ford will detect the -ve cycle - O(VE)

    Directed Acyclic Graph - as name suggests it works only for DAG - O(V+E)

  • 8/20/2019 IJPRET - CSIT 308

    6/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    943 

    All pairs shortest paths:

    Dijkstra Algorithm - No negative weight allowed - O(VE + V^2lg(V))

    Bellman ford Algorithm - O(V^2E)

    Matrix chain multiplication method -complexity same as Bellman ford algorithm.

    III. 

    Application of Algorithm

    1)  Application of Bellman Ford’s Algorithm 

      A distributed variant of the Bellman Ford algorithm is used in distance vector

      Routing protocols.

     

    Saving network resource

      Routing Information Protocol (RIP)

      Two metric routing problem

    2)  Application of Dijkstra’s Algorithm

     

    Robot path planning.

      Logistics Distribution Lines.

     

    Link-state routing protocols.

      OSPF(Open Shortest Path First).

     

    IS-IS (Intermediate System to Intermediate System).

    IV.  Disadvantage of Algorithm

    1)  Bellman Ford’s Algorithm 

    The main disadvantage of the Bellman  –Ford algorithm in RIP is that it doesn’t take weightings

    into consideration. Another disadvantage of the Bellman -Ford algorithm is due to the slow

    updates passed from one RIP router to the next. This results in a slow response to changes in

    the network topology, which in turn results in more attempts to use routes that are down,

    which wastes time and network resources.

  • 8/20/2019 IJPRET - CSIT 308

    7/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    944 

    2)  Dijkstra’s Algorithm 

    The major disadvantage of the algorithm is the fact that it does a blind search there by

    consuming a lot of time waste of necessary resources.

    It cannot handle negative edges. This leads to acyclic graphs and most often cannot obtain the

    right shortest path.

    V.  Similarity and Dissimilarity of Dijkstra Algorithm and Bellman Ford Algorithm

    Bellman Ford and Dijkstra both algorithms are used to find the shortest path of a network

    where the value of the shortest path may vary according to the situation of the network. We

    can solve cost and n length problems using this both algorithm. Dijkstra algorithm is faster than

    bellman ford algorithm. Bellman Ford algorithm is not suggested for larger networks. And in

    GIS, there are lots of data so we cannot suggest this algorithm. Bellman ford algorithm work in

    negative weighted graph and also detect negative cycle [4].

    VI. 

    CONCLUSIONS

    In this paper, after studying these two algorithms we concluded that Dijkstra’s algorithm is

    faster and better than Bellman Ford algorithm. Thus, Bellman –Ford is usually used only when

    there are negative edge weights. The small difference in these two algorithms is  that Dijkstra's

    algorithm cannot handle negative edge weights. Bellman-Ford's algorithm can handle some

    edges with negative weight. It must be remembered, however, that if there is a negative cycle

    there is no shortest path.

    REFERENCES

    1. Jinhao Lu and Chi Dong, Research of Shortest Path Algorithm Based on the Data Structure,

    3rd International Conference on Software Engineering and Service Science (ICSESS), 2012 IEEE,

    22-24 June 2012, pp. 108 - 110

    2. 

    Y. Cao, the shortest path algorithm in data structures, Journal of Yibin University, Vol. 6,

    2007, pp.82 -84.

    3. 

    Q. Sun, J. H. Shen, J. Z. Gu, An improved Dijkstra algorithm, [J]. Computer Engineering andApplications, vol. 3, 2002, pp.99-101.

  • 8/20/2019 IJPRET - CSIT 308

    8/8

    Research Article Impact Factor: 4.226 ISSN: 2319-507X

    Diptee Warhade, IJPRET, 2015; Volume 3 (9): 938-945 IJPRET

     Available Online at www.ijpret.com

    945 

    4. 

    Thippeswamy. K, Hanumanthappa. J, and Dr. Manjaiah D. H., A Study on Contrast and

    Comparison between Bellman-Ford algorithm and Dijkstra’s algorithm In: National Conference

    on wireless Networks-09(NCOWN-2010), Dec 2014.

    5. 

    Goyal Abhishek, Mogha Prateek, Luthra Rishabh, and Ms. Sangwan Neeti, Path finding: A* orDijkstra's?, IJITE Vol.02 Issue-01, (January, 2014) ISSN: 2321 –1776, pp. 1 –15