Tuesday, 2 February 2010

Dijkstra algorithm with Delphi

Today I'm going to show you the improved algorithm to find the shortest path using Dijkstra. My older application Thundax Box manager was implementing this algorithm but with several restrictions. Now, with the release of the TestFramework v2.0.0 build 745 you can test this new functionality. I also fixed other bugs, and I would be grateful that if you find any bug, report it to the bug tracker into the Sourceforge. The same for a feature request or a support request. Sometimes it is difficult to find bugs even using TDD. I've checked all my classes but sometimes I skip part of them in order to focus on the part I'm interested in.

Anyway, in this version you would be able to:
  • Draw a graph (n-connections).
  • Connect the nodes and add some weight to the edges.
  • label the nodes.
  • set multiple destinations (Origin and Target/s).
  • calculate the shortest path using Dijkstra.
With all of this, we can do the following:
We can mark the initial node (green) and the final nodes or destination nodes (fuchsia) and then, calculate the shortest path by going to Algorithms -> Apply Dijkstra Algorithm.

Afterwards, we can see:
Remember that we can use all the other very useful implemented utilities in the program, like the graph implementator and the force-based layout to generate and order graphs as fast as we can.

Other useful examples:
In this case, I've played with the new functionality -> Algorithm -> Fill with values. This method will fill the nodes with an ordered number and the edge with the distance between nodes in pixels.

Then the result:
Here you can see a video showing the results of the work done:




If you have time, give it a try!. I'm sure that the application will impress you, and don't hesitate to contact me, by commenting the post or by sending me a message at sourceforge or through my web contact. Enjoy!.

7 comments:

  1. Hi,

    I just wanted to say that I really enjoyed your blog and this post. You make some very informative points. Keep up the great work!

    -
    Delphi development

    ReplyDelete
  2. hello i'm student from indonesia ,i will be glad if you give me a source code to pepehlovechicken@gmail.com

    ReplyDelete
    Replies
    1. Hi Pedagang,

      Look for my google code projects. You'll find the source code there.

      Regards,
      Jordi

      Delete
  3. where is the code,i'm a student and i want to learn

    ReplyDelete
    Replies
    1. Hi,

      Look for my google code projects. You'll find the source code there.

      Regards,
      Jordi

      Delete
  4. I can't find the code on our sourse, please give me a link))))

    ReplyDelete
  5. I am new for delphi and a student.
    can u please provide me the code of this example..
    please

    ReplyDelete