NAME
Author: Rohan Kachewar
BellmanFord : implements the algorithm for Directed path to find the shortest path from one node to any other on a network.
VERSION
Version 0.01
SYNOPSIS
Quick summary of what the module does
The Module is a Flexible and userfriendly implementation of BellmanFord Alorithm and most important, it works for floating point weights!!!. It reads the graph input from a txt file and outputs the distance and path from source node to all nodes in the graph Then it gives required shortest path to the destination node.
Output as follows:
Total Nodes = and Links =
Welcome to My Bellman algorithm we find solution for source = b and destination = e
<Destination Node> <Distance <infinity is denoted by 122.0>> <Path from source node, denoted as Null>
The required solution:
<Actual Shortest Path>
Input File format
Do not leave empty lines in between in input file.
Format:
nodes <number of nodes>;Links <number of Links>
<node1>,<node2>,<Distance between them (in floating point format)>
once list all nodes separated by comma
path <source node>,<destination node>
Example:
nodes 5;links 8
a,b,50.0
a,d,10.0
b,c,10.0
b,e,75.0
c,b,10.0
c,d,10.0
d,c,10.0
d,a,10.0
a,b,c,d,e
path b,e
path a,d
Usage
use Algorithm::BellmanFord;
$obj = new BellmanFord ('input file path', 'output file path');
$obj->calculate();
example
$obj = new BellmanFord ('C:\input.txt', 'C:\output.txt');
$obj->calculate();
SUBROUTINES/METHODS
calculate : Method will calculate the shortest distance and path and will print to output file.
AUTHOR
Rohan Kachewar, rohank at cpan.org>
BUGS
Please report any bugs or feature requests. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
LICENSE AND COPYRIGHT
Copyright 2011 Rohan Kachewar.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.