Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Python
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Python section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2011, 07:21 PM
Registered User
 
Join Date: Mar 2011
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Default Dijkstras Algorithm

Hey,

I am writing a python script that implements Dijkstras Open Shortest Path First Algorithm.

My plan is to read in 2 text files,

network.txt, which is a multi-line file, with node, nearest neighbour and distance metric info:

(this is just the distance metric info, the other details will be added when the file gets read into a list in the script)

0,2,4,1,6,0,0
2,0,0,0,5,0,0
4,0,0,0,0,5,0
1,0,0,0,1,1,0
6,5,0,1,0,5,5
0,0,5,1,5,0,0
0,0,0,0,5,0,0

and route.txt which is a single line file with start and destination information:

(this is only a starting point, as it will get updated within the algorithm)

B>F

once the algorithm has run, i want to produce an output file called spf.txt which contains the shortest path from source to destination.

If anyone could give me some pointers on how to approach this that would be awesome!

cheers

martin
 
Old March 24th, 2011, 02:18 AM
Registered User
 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Martin,

Would you please elaborate on the contents of the file "network.txt"?

You mention "multi-line file, with node, nearest neighbour and distance metric info", but you don't say where the information is coming from other than "the other details will be added when the file gets read into a list in the script".

Where is the information coming from in order to be read into the list? What does the information look like? Is "network.txt" an input file that provides information to the Python script or an output file wherein the script dumps a graph of the network?

Note that the book OSPF and IS-IS: Choosing an IGP for Large-Scale Networks by Jeff Doyle has a good description of Dijkstra's algorithm and the data needed to produce a routing table (pages 50-62). Perhaps this will provide the hints you need.


fracjackmac





Similar Threads
Thread Thread Starter Forum Replies Last Post
apriori algorithm iralala J2EE 4 January 1st, 2014 06:49 PM
Can someone help me with this algorithm please! th kishan4910 VB How-To 18 February 5th, 2008 07:15 AM
algorithm angelboy Other Programming Languages 0 April 14th, 2007 08:56 AM
Typical Algorithm rajanikrishna ASP.NET 1.0 and 1.1 Professional 0 November 20th, 2006 03:05 AM
Algorithm kvanchi General .NET 3 January 20th, 2005 05:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.