Free Essay

Dijkstra's Algorithm

In: Computers and Technology

Submitted By martina
Words 757
Pages 4
Алгоритам на Дијкстра

Теоријата на графови е посебна гранка во математиката која се занимава со проучување на графовите и нивните својства. За нас информатичарите тоа е една посебно интересна област бидејќи има широка примена во информатиката. Позната е примената на графовите кај описот на моделот на податоците, структурите на податоците, во програмирањето и во компјутерските мрежи. Кај компјутерските мрежи графовите се користат за моделирање и анализирање на мрежниот сообраќај, како и Интернет сообраќајот. Се ова се само некои од примените на графовите.
Графовите се корисни за претставување на многу проблеми од компјутерските науки и во реалниот свет. Апликациите за претставување на графови се движат од прилично едноставни, да дознаеме дали еден јазол е достапен од друг јазол, до екстремно сложени, како наоѓање на патека која поминува низ јазлите и минимизирање на вкупното време. Заеднички, но решлив проблем е наоѓање на едноставна патека. Општо земено, задачата е утврдување на најкратката можна патека од еден почетен јазол, до било кој друг јазол во графот.
Еден од најчестите алгоритми за решавање на овој проблем е алгоритмот на Дијкстра. Осмислен е од страна на познатиот германски математичар и информатичар Edsger W. Dijkstra, кој инаку е познат по многуте алгоритми од областа на математиката и информатиката. Овој алгоритам го решава проблемот за наоѓање на најкратката патека од одреден почетен јазол до било кој друг јазол, каде што нема рабови со негативна тежина и работи на принципот дека најкраткиот можен пат од изворот мора да дојде од една од најкратките можни патеки кои веќе се откриени. Иако негативните тежини некогаш може да бидат и потребни, за многу апликации тие се невозможни, и можноста за негативни тежини може да се игнорира.

1. Опис на алгоритмот

Алгоритмот на Дијкстра работи под претпоставка дека за даден тежински ориентиран граф G = (V, E) за секое ребро (u, v) E важи дека нејзината тежина w(u, v) 0.
Овој алгоритам работи со множество на темиња S до кои е одреден најкраткиот пат од појдовното теме s. Поради тоа за секое теме v S, важи d[v] = (s, v) односно d[v] е бараната тежина на најкраткиот пат. Алгоритмот на Дијкстра ги селектира темињата u V - S така што тие имаат најмал естимиран пат до s, ги вметнува нив во S и ги релаксира сите ребра кои излегуваат од u.

Псевдо код за алгоритмот на Дијкстра:

DIJKSTRA(G,w,s)

1. INITIALIZE-SINGLE-SOURCE (G,s)
2. S ← 
3. Q ← V[G]
4. while Q ≠ 
5. do u ← EXTRACT-MIN(Q)
6. S ← S {u}
7. for sekoe teme v  Adj[u]
8. do RELAX (u,v,w)

Илустрацијата на овој алгоритам за даден граф е прикажана на Слика 1. Појдовното теме е најлевото теме од графот. Во темињата се означени тековните претпоставени најкратки должини на патеките, додека со темна боја се означени ребрата кои се кон моменталните предходници (кои го сочинуваат моменталното стебло на најкратки патеки). Темињата кои припаѓаат на S се означени со темна боја. Темето означено со сива боја е темето кое е одередено како избрано во линија 5 од псевдо кодот. На Слика 1.а е претставена ситуацијата после иницијализацијата, додека останатите слики соодветствуваат со ситуациите после секоја итерација на циклусот од линиите 4 до 8. Слика 1.ѓ го претставува излезот на алгоритмот.

Слика 1. Илустрација на алгоритмот на Дијкстра за граф со повеќе темиња

2. Примери за алгоритмот на Дијкстра

Пример 1.

Слика 1.

Ако е даден графот на Слика 1. ќе ги имаме овие вредности:

Итерација 1:

Итерација 2:

Итерација 3:

Итерација 4:

Дрвото кое се добива по завршувањето на алгоритамот е:

Пример 2.

Пример 3.

Пример 4.

Доколку во графот се јавуваат и рабови со негативни тежини, во тој случај најкратката патека којашто ќе ја пронајдеме со алгоритмот на Дијкстра ќе биде неточна. Во продолжение следува пример за овој случај.

Образложение

Нека е даден графот на сликата. Почетен јазол е јазолот s. Со алгоритмот на Дијкстра, најкратката патека од s до c ќе биде преку директната врска меѓу овие два јазли, и ќе има тежина 3. Точното би било дека најкратката патека од s до c е преку јазолот b, така што има тежина 1.

3. Заклучок

Во оваа семинарска работа е прикажано како се применува теоријата на графови во информатиката. Го разгледавме најпознатиот алгоритам за наоѓање најкратка патека-алгоритмот на Дијкстра. Исто така дадена е и илустрација на алгоритмот низ повеќе примери.

4. Користена литература

1. http://en.wikipedia.org/wiki/Dijkstra's_algorithm 2. http://mendo.mk/wiki/attach/%D0%9F%D0%98%D0%9D%202009/Dijkstra.pdf 3. http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/GraphAlgor/dijkstraAlgor.htm

Similar Documents

Free Essay

98-367 Sec. Fund. Chapter 4 Routing Essay Questions

...1. Describe the process of network routing. Routing is the process of moving packets across a network from one host to another. It is usually performed by dedicated devices called routers. Packets are the fundamental unit of information transport in all modern computer networks, and increasingly in other communications networks as well. They are transmitted over packet switched networks, which are networks on which each message (i.e., data that is transmitted) is cut up into a set of small segments prior to transmission. Each packet is then transmitted individually and can follow the same path or a different path to the common destination. Once all of the packets have arrived at the destination, they are automatically reassembled to recreate the original message. What OSI layer does a router work on? 3 or network. What type of address does a router use? IP address 2. What is a router hop? In computer networking, a hop is one portion of the path between source and destination. Data packets pass through bridges, routers and gateways on the way. Each time packets are passed to the next device, a hop occurs. Which protocol uses router hops? Routing Information Protocol (RIP). What is the maximum number of hops allowed? This limits the number of hops allowed in a path from source to destination. The maximum is 15, and 16 is deemed unreachable. The hop-count limit prevents routing loops from continuing indefinitely. Although, IGRP will route IP, IPX, Decnet and AppleTalk which...

Words: 739 - Pages: 3

Free Essay

A Report to Critically Compare a Number of Routing Protocols; Including Rip V2, Eigrp & Ospf

...Configuration A Report to Critically Compare a Number of Routing Protocols; Including RIP v2, EIGRP & OSPF Paul McDermott CCNA 2 Table of Contents 1.0 Abstract 3 2.0 Introduction 4 3.0 Protocol overview 5 3.1 RIP v2 Overview 5 3.2 EIGRP Overview 6 3.3 OSPF Overview 6 4.0 Protocol Comparison 10 4.1 Topology Overview 10 4.2 Protocol Types 10 4.3 Administration Distance 10 4.4 Protocol Tables 11 4.5 Algorithm 11 4.6 Metric 12 4.7 Periodic Updates 12 4.8 Hierarchical / Scalable 12 4.9 Load Balance 13 4.10 Comparison Table 14 5.0 Conclusion 15 6.0 References 16 Abstract The following report is a critical comparison of three routing protocols; RIPv2, EIGRP and OSPF, detailing the protocol features, as well as their similarities and differences. The report takes an in-depth look at the technical elements and algorithms used in these protocols, such as Bellman Ford, DUAL, and the Dijkstra Algorithm; and how these algorithms are used to calculate the routing metric. The report also discusses the fact that EIGRP is the most desirable protocol to use on Cisco based routers, while OSPF can be used across different router manufacturers. While looking at the technical considerations that are needed in choosing a routing protocol for a desired network the report will also look into the CPU/memory requirements, and how difficult the protocol is to install and maintain on the network;...

Words: 4222 - Pages: 17

Free Essay

Title Paper

...International Journal of Wireless & Mobile Networks (IJWMN) Vol. 4, No. 1, February 2012 Optimization of Energy Consumption for OLSR Routing Protocol in MANET Kirti Aniruddha Adoni1 and Radhika D. Joshi2 1 Modern College of Engineering, Shivaji Nagar, University of Pune, , India akirti2008@gmail.com, k_adoni@rediffmail.com 2 College of Engineering, University of Pune, India rdj.extc@coep.ac.in ABSTRACT Mobile Adhoc Network (MANET) eliminates the complexity associated with an infrastructure networks. Wireless devices are allowed to communicate on the fly for applications. It does not rely on base station to coordinate the flow of the nodes in the network. This paper introduces an algorithm of multipath OLSR (Optimized Link State Routing) for energy optimization of the nodes in the network. It is concluded that this solution improves the number of nodes alive by about 10 to 25% by always choosing energy optimized paths in the network with some increase in normalized routing overheads. KEYWORDS OLSR, multipath, Energy Optimization, Nodes Alive, Overheads 1. INTRODUCTION A Mobile Adhoc NETwork (MANET) is a multi-hop, distributed and self configuration network[1].The communication between two distant nodes is through the number of intermediate nodes which relays the information from one point to another. As nodes can move randomly within the network, routing packets between any pair of nodes become a challenging task. A route that is believed to be optimal...

Words: 3772 - Pages: 16

Premium Essay

Netw204: Assignment 4, Link-State Routing and Ospf

...NETW204: Assignment 4, Link-state Routing and OSPF (50 points) Fill in the blanks below with either the term defined or the definition for the terms listed. Each answer is worth 2 points each, 25 questions X 2 = 50 total points. Type answers in the appropriate cell; text will automatically wrap. Post your completed assignment to the dropbox. NAME | Jose Antonio Nunez | | Term | Definition | 1 | An OSPF network | Attaches to multiple areas, maintains separatelink-state databases for each area it is connectedto, and routes traffic destined for or arriving fromother areas | 2 | Autonomous System Boundary Router (ASBR) | Is an OSPF router located between OSPF autonomous system networks and non-OSPF networks. | 3 | Backup Designated Router (BDR) | Is a router that becomes the Designated Router if the DR fails. | 4 | Database Description (DBD) | Contains an abbreviated list of the sendingrouter’s link-state database and is used by receiving routers to check against the local link-state database | 5 | Designated Router (DR) | Is an OSPF router that controls the routes of LSA’s or LSU’s. It helps maintain link state updates to other routers in the network. | 6 | DRothers | Is neither a DR, nor a BDR. They are other routers in the OSPF network. | 7 | Flapping link | Is when an advertised route between two nodes alternates back and forth. This creates a link state that cycles between up and down. | 8 | The highest IP address of an active router interface...

Words: 655 - Pages: 3

Free Essay

Operations Research Journal

...Journal of the Eastern Asia Society for Transportation Studies, Vol. 6, pp. 1426 - 1438, 2005 A SHORTEST PATH ALGORITHM FOR REAL ROAD NETWORK BASED ON PATH OVERLAP Yongtaek LIM Assistant Professor Division of Transportation and Logistics System Engineering Yosu National University San 96-1, Dundeok-dong, Yosu city Chunnam, 550-749, KOREA Fax:+82-061-659-3340 E-mail:limyt@yosu.ac.kr Hyunmyung KIM PhD Student Department of Civil Engineering Institute of Transportation Studies University of California, Irvine USA Fax: (949) 824-8385 E-mail: hyunmyuk@uci.edu Abstract : Existing k-shortest path algorithms has some weaknesses such as path similarity among determined paths and network expansion for describing turn prohibitions. Path similarity represents that many of the alternative paths derived from the k-shortest path algorithm are likely to share a lots of links, so they could not represent heterogeneity. The turning restrictions popularly adopted in real road may violate Bellman’s principle of optimality in searching shortest path, so network expansion technique is widely used to avoid such difficulty. But, this method needs additional works to expand the network. This paper proposes a link-based shortest path algorithm to generate dissimilar paths for the travel information in real road network where exists turn prohibitions. The main merit of proposed model is to provide efficient alternative paths under consideration of overlaps among paths to alleviate the path similarity...

Words: 6029 - Pages: 25

Free Essay

Boss

...1 Describe the difference between distance-vector and link-state dynamic routing protocols. Give an example of each.  Distance vector routing is so named because it involves two factors: the distance, or metric, of a destination, and the vector, or direction to take to get there. Routing information is only exchanged between directly connected neighbors. This means a router knows from which neighbor a route was learned, but it does not know where that neighbor learned the route; a router can't see beyond its own neighbors. This aspect of distance vector routing is sometimes referred to as "routing by rumor." Measures like split horizon and poison reverse are employed to avoid routing loops. Link-state routing, in contrast, requires that all routers know about the paths reachable by all other routers in the network. Link-state information is flooded throughout the link-state domain (an area in OSPF or IS-IS) to ensure all routers poses a synchronized copy of the area's link-state database. From this common database, each router constructs its own relative shortest-path tree, with itself as the root, for all known routes. A Comparison: Link State vs. Distance Vector If all routers were running a Distance Vector protocol, the path or 'route' chosen would be from A B directly over the ISDN serial link, even though that link is about 10 times slower than the indirect route from A C D B. [pic] A Link State protocol would choose the A C D B path because it's using a...

Words: 1070 - Pages: 5

Premium Essay

Network 204 Assignment 4

...NETW204: Assignment 4, Link-state Routing and OSPF (50 points) Fill in the blanks below with either the term defined or the definition for the terms listed. Each answer is worth 2 points each, 25 questions X 2 = 50 total points. Type answers in the appropriate cell; text will automatically wrap. Post your completed assignment to the dropbox. NAME | Chad White | | Term | Definition | 1 | ABR | Attaches to multiple areas, maintains separatelink-state databases for each area it is connectedto, and routes traffic destined for or arriving fromother areas | 2 | Autonomous System Boundary Router (ASBR) | Routers that have at least one interface attached to an external internetwork (another autonomous system [AS]), such as a non-OSPF network. ASBRs can import non- OSPF network information to the OSPF network and vice versa; this process is called route redistribution. | 3 | Backup Designated Router (BDR) | Used to provide redundancy in broadcast networks which are utilizing the OSPF | 4 | DBD | Contains an abbreviated list of the sendingrouter’s link-state database and is used by receiving routers to check against the local link-state database | 5 | Designated Router (DR) | A router that informs end nodes of the existence and identity of other routers. | 6 | DRothers | Routers that are not a dr or bdr. they are the routers in the ospf network. | 7 | Flapping link | A link which cycles between up and down. | 8 | Highest active IP | Router ID for an OSPF...

Words: 638 - Pages: 3

Premium Essay

Final Paper

...CMIT 350 WAN and SOHO Skills Implementation Use this document as a guide for formatting and organizing your CMIT 350 Skills Implementation challenge. Title Page Professionalism will be key to your success and advancement in your academic and professional career. Use the title page to identify relevant information such as your name, the course, professor, and submission/completion date. Document Index/Contents Organization will allow your document to be divided into key areas of consideration and allows an overall structure to be placed over the submission. Sample text: I. Site “XXXXXXXX” Challenges and Implementation II. Site “XXXXXXXX” Challenges and Implementation III. Site “XXXXXXXX” Challenges and Implementation IV. Bibliography Site “XXXXXXXXXX” Challenge and Implementation (Provide a section for each site, as suggested in your table of contents.) Site Details and Challenges (Summary) Here, you will simply summarize the site requirements and/or challenges you are attempting to overcome. You will not need to implement solutions or discuss your approach at this point. This information is provided to you and can simply be organized and restated as you understand it. Think of this area as what needs to be corrected. Suggested length would be one or two paragraphs. Sample text: As described in the scenario, the xUMUC site was developed without any VLAN structure, and administrators have found the need to isolate broadcast traffic from a layer-2 perspective. Site...

Words: 663 - Pages: 3

Premium Essay

Pt1420 Final Exam

...Final: Algorithms Spring 2016 I _(your name)____________ did not collaborate with any person on this exam. I understand that doing so will result in a 0 for the Final Exam. • You can use online references, but write answers in your own words! Cite any references used. Answer the question in your own words, no credit will be given for answers copied from any source. • No collaborating with other people; a 0 will be given if any collaboration evidence is found. Ask me for a hint if you are stuck on any particular problem. • I am looking for very specific, detailed, correct, and complete answers. • Most answers found on the Internet (especially Wikipedia) are generic answers for people without a networking background and...

Words: 1249 - Pages: 5

Free Essay

Greedy Algorithm

...GREEDY ALGORITHM A greedy algorithm is a mathematical process that looks for simple, easy-to-implement solutions to complex, multi-step problems by deciding which next step will provide the most obvious benefit. Greedy algorithms are similar to dynamic programming algorithms in that the solutions are both efficient and optimal if the problem exhibits some particular sort of substructure. A greedy algorithm builds a solution by going one step at a time through the feasible solutions, applying a heuristic to determine the best choice. A heuristic applies an insight to solving the problem, such as always choose the largest, smallest, etc. Such algorithms are called greedy because while the optimal solution to each smaller instance will provide an immediate output, the algorithm doesn’t consider the larger problem as a whole. Once a decision has been made, it is never reconsidered. Greedy algorithms work by recursively constructing a set of objects from the smallest possible constituent parts. Recursion is an approach to problem solving in which the solution to a particular problem depends on solutions to smaller instances of the same problem. Advantages of greed algorithm * Always taking the best available choice is usually easy. * It usually requires sorting the choices. * Solutions to smaller instances of the problem can be straightforward and easy to understand. * Repeatedly taking the next available best choice is usually linear work. * But don't...

Words: 387 - Pages: 2

Premium Essay

Pdf. Input Out Files

...something what we call System Analysis and Design programmers do to understand a problem. Many diagrams including "Work Break Down Structure", "Workflow Diagram" and "Class Diagrams" are some of the most common ones are used. Question 2. What is Pseaudocode? Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm. It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading. Pseudocode typically omits details that are not essential for human understanding of the algorithm, such as variable declarations, system-specific code and some subroutines. The programming language is augmented with natural language description details, where convenient, or with compact mathematical notation. The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is an efficient and environment-independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications that are documenting various algorithms, and also in planning of computer program development, for sketching out the structure of the program before the actual coding takes place. Question 3 computer programmers normally perform what 3 steps? 1. Input is received. 2. Some process is performed on the input. 3. Output is produced. Question 4 What does user friendly mean? 2. user friendly"...

Words: 330 - Pages: 2

Free Essay

Initial Sizing of an Airplane

...CONSTRAINT ANALYSIS The two parameters (i) wing loading and (ii) power loading are the most important parameters that affect the airframe design and its performance. Wing loading and power loading are interconnected for a number of design parameters and because of this interconnection it is difficult to use historical data to independently select these values. Hence a different approach needs to be followed. The team decided to use sizing matrix plots to find the optimum value of the two parameters. For calculating the optimum values, the most important design requirements must be decided. The design requirements that have the highest weightage are: (i) (ii) (iii) (iv) Stall speed Take off distance Landing distance Sustained turn All the above design requirements were written in terms of wing loading and power loading. Since in the design requirements parameters are given in the inequality form, hence a region of point is obtained instead of single point of intersection. This region of favorable points is known as design space. On putting values of all parameters and then plotting in matlab, design space is obtained. The code for plotting the sizing matrix plot is given in Appendix A(a). In the design space the optimum design point is obtained by calculating the score of the point based on its weightage. (The weightage of various design parameters is given in Appendix A(b). REGRESSION ANALYSIS A regression analysis was done to find out the statistical relation between...

Words: 582 - Pages: 3

Premium Essay

Cause and Effect of Computer Revolution

...ENC 1101 February 13 2013 Causes and Effects of the Computer/Information Revolution By illustrating the lifestyle of the computer revolution through advancements in human society whether it be medicine, school or businesses, computers paints a vivid image of a world that is interconnected providing further advancement upon our society; only to create a bigger, faster and more efficient world. The 21st century is known as the information and or computer revolution. As Hamming states, "the industrial revolution released man from being a beast of burden; computer revolution will similarly release him from slavery to dull, repetitive routine" (Hamming 4). The revolution began after World War II and to this day continues evolving at a rapid pace enhancements made to it’s speed and size, has led to more and more information being found and processed on a daily basis.  According to Linowes, more information has been produced in the last thirty years than in the previous five thousand. Changes to the lifestyle of the everyday human are quite prevalent. Nowadays, people have access to what seems to be an endless pool of information, whether it is social networks, instant messaging, electronic libraries while businesses use the internet and information technology to operate their organizations. People communicate every day and transfer data every day at an alarming rate. The computer revolution has shaped or current environment into one where the internet is central to todays society...

Words: 1488 - Pages: 6

Free Essay

How to Write a Computer Program

...need to determine how you are going to take your input information and turn it into your output information. An example problem is that you want to determine the price of items before and after tax. Your inputs would be: the price of the item, expressed as ItemPrice; the amount of tax, expressed as TaxRate; and the amount of that item, expressed as ItemQuantity. The output would then be the amount of the item before and after tax has been included, expressed as OriginalPrice and TaxPrice respectively. One way to solve this would be to use the following equations: ItemPrice * ItemQuantity = OriginalPrice and then OriginalPrice * TaxRate + OriginalPrice = TaxPrice. Once the problem has been analyzed, the variables identified, and the algorithm has been determined, it is time to design the program. Designing the program is no more than creating a set of step by step instructions,...

Words: 1031 - Pages: 5

Free Essay

Selection Paper

...Selection Structure Paper Given the following task: Selection Structure Paper, Use the Part 1: Programming Solution Proposal you developed in Week Two and select one section of the proposal that requires a selection structure. Write a 2- to 3-page paper describing the purpose of that structure and write the pseudocode for that structure. Examine any iteration control structure. If the program you described in Week Two does not lend itself well to the inclusion of a selection structure, create a new example of a selection structure. Create a Visual Logic flowchart that parallels this pseudocode. Test the flowchart to make sure that it executes properly and produces correct results. Submit the paper and the Visual Logic file. Format your paper consistent with APA guidelines. The process of selection is a way for the computer to interact with the user and to be able to understand how to make choices based on the user’s point of view or interest. Selection can be understood by computers by transforming such selections into algebraic equations, and from there into binary code which is the language that the computer understands, once the program is written, it will use a compilator, which acts as the translator between computer language and human language. The process of selection allows the user to choose what to do and then it gives options where to choose from, and it gives results which vary depending on the option selected by the user, when using the process of selection...

Words: 554 - Pages: 3