Comments on: Building a Route Planner with Oracle SQL – Finding the quickest route in a graph https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/ Friends of Oracle and Java Sat, 01 Aug 2015 11:10:05 +0000 hourly 1 http://wordpress.org/?v=4.2.3 By: Frank Zhou https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3387 Wed, 12 Dec 2007 21:42:12 +0000 http://technology.amis.nl/blog/?p=1221#comment-3387 Here is a pure SQL solution for finding the shortest path (distance) between the source and destination

http://www.jlcomp.demon.co.uk/faq/shortest_distance.html

Thanks,

Frank

]]>
By: Lucas Jellema https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3386 Sun, 22 Oct 2006 18:45:28 +0000 http://technology.amis.nl/blog/?p=1221#comment-3386 We got a reference to this article on the SQL Server discussion forum: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=800277&SiteID=1. I doubt however this will work in SQL Server.

Lucas

]]>
By: Steffen Mazanek https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3385 Mon, 21 Aug 2006 23:33:00 +0000 http://technology.amis.nl/blog/?p=1221#comment-3385 How does your algorithm scale?

]]>
By: Gracie https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3384 Tue, 20 Jun 2006 23:31:53 +0000 http://technology.amis.nl/blog/?p=1221#comment-3384 Using the above code on a table with each node having distance data for all the other nodes around, the result show that the route could go back to the original node – doesn’t ” nocycle” take acre of that? Here is the a sample of the result
3 +3+3+3 StRita/JCampbl/StRita/SisTheresa 9
3 +3+5+1 StRita/JCampbl/BrockHS/SisTheresa 9
4 +3+3+5+1 StRita/JCampbl/StRita/BrockHS/SisTheresa 12
5 +3+3+6+1+1 StRita/JCampbl/StRita/JrHigh/BrockHS/SisTheresa 14

As you can see, St Rita appears twice in the route. Any suggestions would be a great help. Thanks

]]>
By: Karl https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3383 Mon, 12 Jun 2006 17:52:14 +0000 http://technology.amis.nl/blog/?p=1221#comment-3383 I am very impressed about what via SQL can be done. Even Lucas Example is an easy one it could be an idea for using it in an application. I see always an area of practical use without the demand of Oracle Spatial.
Greetings
Karl

]]>
By: salem https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3382 Wed, 07 Jun 2006 16:00:54 +0000 http://technology.amis.nl/blog/?p=1221#comment-3382 Ever looked at the network data model that is supported by oracle Spatial Option?

]]>
By: Justin Lokitz https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3381 Wed, 07 Jun 2006 06:06:51 +0000 http://technology.amis.nl/blog/?p=1221#comment-3381 The link in the last post for the Oracle10g Spatial Network Model should be: http://www.oracle.com/technology/products/spatial/pdf/10gr2_collateral/spatial_twp_ntwrkdatamod_10gr2_0512.pdf

]]>
By: Justin Lokitz https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3380 Wed, 07 Jun 2006 06:04:31 +0000 http://technology.amis.nl/blog/?p=1221#comment-3380 Lucas…although I think what you’ve done here is quite impressive, Oracle10g already has this functionality (and quite a bit more) and it’s called Oracle Spatial. In fact, Orace10g Spatial has actual multimodal route planning as well as complex network (graph) analysis. Check out http://www.oracle.com/technology/products/spatial/pdf/10gr2_collateral/spatial_twp_ntwrkdatamod_10gr2_0512.pdff for more. Again, your work is pretty fantastic, but you may find that you are in fact trying to reinvent the wheel.

]]>
By: Jeroen van Wilgenburg https://technology.amis.nl/2006/06/06/building-a-route-planner-with-oracle-sql-finding-the-quickest-route-in-a-graph/#comment-3379 Tue, 06 Jun 2006 12:37:49 +0000 http://technology.amis.nl/blog/?p=1221#comment-3379 Really interesting that this is possible with a database. But I think it’s more efficient to write a small program to solve this problem. The problem you described is called the shortest path problem http://en.wikipedia.org/wiki/Shortest_path_problem
The most famous algorithm to solve this problem is developed by Dijkstra.

The graph in the article is too simple to show the benefit of the algorithm, so I created my own to explain the basics of the algorithm:

http://technology.amis.nl/blog/wp-content/images/routeplangraafjeroen2.gif

First we have to pick a random path to start with. It’s not completely random (but if you implement this with a computer it is). Let’s take ABEG (yes, I know ADG is the shortest)
The length of ABEG is 5. This is the shortest path so far. From B we can also branch to H. But 1+5>5, that path is to long, no matter what it does after point H. So we can stop here.

The algorithm also deals with cycles. Take ABEIJ for example. We can loop infinitely in the cycle EIJ, but at a certain moment it’s longer than 5 and we can stop (note that you still need some kind of cycle detection if this is the branch you started with, but a simple maximum length would do the trick because you can guess that the shortest path is not more than 20)

Let’s take the ADG now. ADG is length 3, it’s less than 5 so our new shortest path is 3. When we take the branch AC it’s 3, so we can stop immediately and conclude the shortest path is 3.

But the article still can be very useful for other problems or when you need the lengths of all routes (ie. for routing algorithms of computer networks)

]]>