Sponsored Content
Top Forums Programming Implementing a shortest path algorithm in C Post 302449595 by pludi on Tuesday 31st of August 2010 03:41:12 AM
Old 08-31-2010
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help for shell script of finding shortest substring from given string by user

please give me proper solution for finding a shortest substring from given string if string itself and first char and last char of that substr are also given by user if S="dpoaoqooroo" and FC="o" and LC="o",then shortest substr is "oo" and rest of the string is "dpoaoqroo" i have code but it is... (1 Reply)
Discussion started by: pankajd
1 Replies

2. UNIX for Dummies Questions & Answers

Shortest way to home dicrectory

hi guys, i am looking for the shortest way to get to home directory using Absolute & Relative paths. Anything except cd or cd/home/user any help would be deeply appreciated. (3 Replies)
Discussion started by: incipientmind
3 Replies

3. Shell Programming and Scripting

shell script for extracting out the shortest substring from the given starting and en

hi all, i need an urgent help for writing a shell script which will extract out and print a substring which is the shortest substring from the given string where first and last character of that substring will be given by the user. for e.g. if str="abcdpqracdpqaserd" now if the user gives 'a'... (18 Replies)
Discussion started by: pankajd
18 Replies

4. Shell Programming and Scripting

To find largest and shortest word in eld

I got a file called Album in that there is list of songs i want to find the Longest and shortest song name in field 2 ie ($2).... Please help me with "awk" (2 Replies)
Discussion started by: Markwaugh
2 Replies

5. Shell Programming and Scripting

longest, shortest, map wrong

Hi Everyone, a.txt cola,colb1111 601030,CEL 6031,CEL 60103,CEL Would like to find the longest field colb1111, and shortest, so the output is 6, 4 my code: #!/usr/bin/perl use strict; use warnings; my %prefix_to_contry = (); my $key; open(FH,'/root/a.txt') or die "$!"; (0 Replies)
Discussion started by: jimmy_y
0 Replies

6. Shell Programming and Scripting

how to find the shortest line which containing a key string?

hi all, suppose a key string: M0271857 and to find all lines containing this key string in a text file which returns multiple lines but i only want the shortest one is there a way to do that? thanks so much! (4 Replies)
Discussion started by: sunnydanniel
4 Replies

7. Shell Programming and Scripting

How to select the shortest path in grep search?

Hi, How can I display only one shortest path (A/B/configure)? $ grep configure file.txt A/B/configure A/B/C/configure A/B/C/D/configure Thank you. (9 Replies)
Discussion started by: hce
9 Replies

8. Shell Programming and Scripting

Shortest path for each query from a csv file

Hi all, I have this file __DATA__ child, Parent, probability, M7, Q, P, M7, M28, E, M28, M6, E, M6, Q, Pl, & several hundred lines..... Legends: P(= Probable) > Pl(=Plausible) > E(=Equivocal). What I want is for each child I want to trace it... (5 Replies)
Discussion started by: rushadrena
5 Replies

9. Homework & Coursework Questions

Need help how to search for shortest line from a file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have to write a program that have to read every standard input then print out the line number and the content of... (10 Replies)
Discussion started by: scopiop
10 Replies

10. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies
Bio::Coordinate::Graph(3pm)				User Contributed Perl Documentation			       Bio::Coordinate::Graph(3pm)

NAME
Bio::Coordinate::Graph - Finds shortest path between nodes in a graph SYNOPSIS
# get a hash of hashes representing the graph. E.g.: my $hash= { '1' => { '2' => 1 }, '2' => { '4' => 1, '3' => 1 }, '3' => undef, '4' => { '5' => 1 }, '5' => undef }; # create the object; my $graph = Bio::Coordinate::Graph->new(-graph => $hash); # find the shortest path between two nodes my $a = 1; my $b = 6; my @path = $graph->shortest_paths($a); print join (", ", @path), " "; DESCRIPTION
This class calculates the shortest path between input and output coordinate systems in a graph that defines the relationships between them. This class is primarely designed to analyze gene-related coordinate systems. See Bio::Coordinate::GeneMapper. Note that this module can not be used to manage graphs. Technically the graph implemented here is known as Directed Acyclic Graph (DAG). DAG is composed of vertices (nodes) and edges (with optional weights) linking them. Nodes of the graph are the coordinate systems in gene mapper. The shortest path is found using the Dijkstra's algorithm. This algorithm is fast and greedy and requires all weights to be positive. All weights in the gene coordinate system graph are currently equal(1) making the graph unweighted. That makes the use of Dijkstra's algorithm an overkill. A simpler and faster breadth-first would be enough. Luckily the difference for small graphs is not significant and the implementation is capable of taking weights into account if needed at some later time. Input format The graph needs to be primed using a hash of hashes where there is a key for each node. The second keys are the names of the downstream neighboring nodes and values are the weights for reaching them. Here is part of the gene coordiante system graph:: $hash = { '6' => undef, '3' => { '6' => 1 }, '2' => { '6' => 1, '4' => 1, '3' => 1 }, '1' => { '2' => 1 }, '4' => { '5' => 1 }, '5' => undef }; Note that the names need to be positive integers. Root should be '1' and directness of the graph is taken advantage of to speed calculations by assuming that downsream nodes always have larger number as name. An alternative (shorter) way of describing input is to use hash of arrays. See Bio::Coordinate::Graph::hash_of_arrays. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing lists Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Heikki Lehvaslaiho Email: heikki-at-bioperl-dot-org APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ Graph structure input methods graph Title : graph Usage : $obj->graph($my_graph) Function: Read/write method for the graph structure Example : Returns : hash of hashes grah structure Args : reference to a hash of hashes hash_of_arrays Title : hash_of_arrays Usage : $obj->hash_of_array(%hasharray) Function: An alternative method to read in the graph structure. Hash arrays are easier to type. This method converts arrays into hashes and assigns equal values "1" to weights. Example : Here is an example of simple structure containing a graph. my $DAG = { 6 => [], 5 => [], 4 => [5], 3 => [6], 2 => [3, 4, 6], 1 => [2] }; Returns : hash of hashes graph structure Args : reference to a hash of arrays Methods for determining the shortest path in the graph shortest_path Title : shortest_path Usage : $obj->shortest_path($a, $b); Function: Method for retrieving the shortest path between nodes. If the start node remains the same, the method is sometimes able to use cached results, otherwise it will recalculate the paths. Example : Returns : array of node names, only the start node name if no path Args : name of the start node : name of the end node dijkstra Title : dijkstra Usage : $graph->dijkstra(1); Function: Implements Dijkstra's algorithm. Returns or sets a list of mappers. The returned path description is always directed down from the root. Called from shortest_path(). Example : Returns : Reference to a hash of hashes representing a linked list which contains shortest path down to all nodes from the start node. E.g.: $res = { '2' => { 'prev' => '1', 'dist' => 1 }, '1' => { 'prev' => undef, 'dist' => 0 }, }; Args : name of the start node perl v5.14.2 2012-03-02 Bio::Coordinate::Graph(3pm)
All times are GMT -4. The time now is 09:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy