dijkstra

How do you solve the 15-puzzle with A-Star or Dijkstra's Algorithm?

I've read in one of my AI books that popular algorithms (A-Star, Dijkstra) for path-finding in simulation or games is also used to solve the well-known "15-puzzle". Can anyone give me some pointers on how I would reduce the 15-puzzle to a graph of nodes and edges so that I could apply one of these algorithms? If I were to treat each no...

Understanding Dijkstra's Mozart programming style

I came across this article about programming styles, seen by Edsger Dijsktra. To quickly paraphrase, the main difference is Mozart attempted to figure everything out in his head before writing anything, while Beethoven made his decisions as he wrote the notes out on paper, creating many revisions along the way. With Mozart programming, v...

Correct formulation of the A* algorithm

Hello, I'm looking at definitions of the A* path-finding algorithm, and it seems to be defined somewhat differently in different places. The difference is in the action performed when going through the successors of a node, and finding that a successor is on the closed list. One approach (suggested by Wikipedia, and this article) say...

Teaching programming and formal methods

Here's a sort of odd question. I'm in the process of writing a book on learning to program using formal methods, and I'm going to target it toward people with some programming experience. The idea is to teach them to be high-quality programmers. The basic notation is going to be from Dijkstra's Discipline of Programming, along with so...

Fastest Dijkstra algorithm for j2ME

Hi All, Can anybody help me to make j2ME implementation of Dijkstra algorithm faster ? I have two loops, one inside another. Like this while(for each item in Q) { //...do something. //the following loop is to find the minimum for(all un-visited nodes in Q) { //.. do something to get min. } } I have almost...

Dijkstra algorithm for iPhone

Hello all! It is possible to easily use the GPS functionality in the iPhone since sdk 3.0, but it is explicitly forbidden to use Google's Maps. This has two implications, I think: You will have to provide maps yourself You will have to calculate the shortest routes yourself. I know that calculating the shortest route has puzzled ma...

Dijkstra algorithm for 2D array in Java

Hiya guys!! This is my first post, and this is for a school project; I'm running into a huge amount of trouble, and I can't seem to find a understandable solution. a b c d e z a - 2 3 - - - b 2 - - 5 2 - c 3 - - - 5 - d - 5 - - 1 2 e - 2 5 1 - 4 z - - - 2 4 - Thats the two dimensional array. So if you want to find the shortes...

Dijkstra on "Software Engineering"

Edsger Dijkstra, who could be somewhat abrasive at times (he called "Carl Friedrich Gauss, the Prince of Mathematicians but also somewhat of a coward") said in his essay "On the cruelty of really teaching computing science" (EWD1036): A number of these phenomena have been bundled under the name "Software Engineering". As economics is k...

Custom Map With Directions

I want to make a map program that gives directions around a campus (residence halls, football field, etc), and within buildings (to offices, cafeteria, etc). Is there anything existing that would help facilitate that? The alternative seems to be that I would have to create my own map of points and paths around campus and do path-finding...

What are some MUST READ EWDs?

Dijkstra was one of the most prolific computer scientists. He wrote the famous EWDs. It is not feasible to read them all. But I think there are some we all must read. I would love to receive recommendations from the citizens of SO Republic. So, which of them are must read? Thank you. ...

How does Dijkstra's Algorithm and A-Star compare?

I was looking at what the guys in the Mario AI Competition have been doing and some of them have built some pretty neat Mario bots utilizing the A* (A-Star) Pathing Algorithm. (Video of Mario A* Bot In Action) My question is, how does A-Star compare with Dijkstra? Looking over them, they seem similar. Why would someone use one ove...

Optimizing Dijkstra for dense graph?

Is there another way to calculate the shortest path for a near complete graph other than Dijkstra? I have about 8,000 nodes and about 18 million edges. I've gone through the thread "a to b on map" and decided to use Dijkstra. I wrote my script in Perl using the Boost::Graph library. But the result isn't what I expected. It took about 10+...

Shortest path with a fixed number of edges

We were discussing this problem in class, and were unable to come up with a solution I found satisfying. The problem: Find the shortest path through a graph in efficient time, with the additional constraint that the path must contain exactly n nodes. We have a directed, weighted graph. It may, or may not contain a loop. We can easily f...

Are there faster algorithms than Dijkstra?

Given a directed, connected graph with only positive edge weights, are there faster algorithms for finding the shortest path between two vertices, than Dijkstra using a fibonacci heap? Wikipedia says, that Dijkstra is in O(|E| + |V| * log(|V|)) (using a fibonacci heap). I'm not looking for optimizations that, for example, half the exec...

Dijkstra's Bankers Algorithm

Could somebody please provide a step-through approach to solving the following problem using the Banker's Algorithm? How do I determine whether a "safe-state" exists? What is meant when a process can "run to completion"? In this example, I have four processes and 10 instances of the same resource. Resources Allocated | Resour...

Longest circle in graphs

Hi folks, I want to solve the following problem: I have a DAG which contains cities and jobs between them that needs to be done. The jobs are for trucks which can load a definied limit. The more the truck is loaded the better is the tour. Some jobs are for loading something in and some are for loading defined things out. You can always...

Shortest path in a map

I have designed a weighted graph using a normalized adjacency list in mysql. Now I need to find the shortest path between two given nodes. I have tried to use Dijkstra in php but I couldnt manage to implement it (too difficult for me). Another problem I felt was that if I use Dijkstra I would need to consider all the nodes, that may b...

Use Dijkstra's to find a Minimum Spanning Tree?

Dijkstra's is typically used to find the shortest distance between two nodes in a graph. Can it be used to find a minimum spanning tree? If so, how? Edit: This isn't homework, but I am trying to understand a question on an old practice exam. ...

Find shortest combination of words that contain every character from a specified set.

Hey, I got an array (let's call it a1) of words (like "dog", "fish", "run", "programming" anything) that's really huge. I can combine any of the words out of a1 with any other of the words (e.g. you could combine "dog" and "programming" into "dog-programming"), and then again and again, until the strings gets really big. I also got an...

Why this Dijkstra (graph) implementation isn't working ??

I made this implementation for this problem : http://www.spoj.pl/problems/SHOP/ #include<iostream> #include<stdio.h> #include<queue> #include<conio.h> #include<string.h> using namespace std; struct node { int x; int y; int time; }; bool operator <(const node &s,const node &r) { if(s.time>r.time) return true; e...