Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^19: Finding All Paths From a Graph From a Given Source and End Node

by BrowserUk (Pope)
on Jun 04, 2011 at 20:50 UTC ( #908147=note: print w/replies, xml ) Need Help??


in reply to Re^18: Finding All Paths From a Graph From a Given Source and End Node
in thread Finding All Paths From a Graph From a Given Source and End Node

That dataset is an excellent test sample. Thankyou.

BTW. CSV (Comma Seperated Values) data normally actually has commas separating the values :). Using white space to separate values that themselves contain whitespace gave me pause for thought. (I wonder how the thou-shalt-not-parse-csv-yourself brigade would handle that?)

For my purposes, I just ignored the middle column. I tacked the data on the end of my test script and it found and output all possible paths from all possible starting points in 0.04 seconds. Including remembering which starting point generated the longest path, which turned out to be "2,4,4-Trimethyl-1-pentanol":

c:\test>904729-3 >nul Took 0.04846 2,4,4-Trimethyl-1-pentanol ->2,4,4-Trimethylpentanal ->2,4,4-Trimethylpentanoate ->2,4,4-Trimethylpentanoyl-CoA ->2,4,4-Trimethylpent-2-enoyl-CoA ->2,4,4-Trimethyl-3-hydroxypentanoyl-CoA ->2,4,4-Trimethyl-3-oxopentanoyl-CoA ->2,4,4-Trimethyl-3-oxopentanoate ->2,2-Dimethyl-3-pentanone ->1-Hydroxy-4,4-dimethylpentan-3-one ->4,4-Dimethyl-3-oxopentanal 2,4,4-Trimethyl-1-pentanol ->2,4,4-Trimethylpentanal ->2,4,4-Trimethylpentanoate ->2,4,4-Trimethylpentanoyl-CoA ->2,4,4-Trimethylpent-2-enoyl-CoA ->2,4,4-Trimethyl-3-hydroxypentanoyl-CoA ->2,4,4-Trimethyl-3-oxopentanoyl-CoA ->Pivalyl-CoA 2,4,4-Trimethyl-1-pentanol ->2,4,4-Trimethylpentanal ->2,4,4-Trimethylpentanoate ->2,4,4-Trimethylpentanoyl-CoA ->2,4,4-Trimethylpent-2-enoyl-CoA ->2,4,4-Trimethyl-3-hydroxypentanoyl-CoA ->2,4,4-Trimethyl-3-oxopentanoyl-CoA ->Propanoyl-CoA

The script excluding most of the data:


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://908147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2021-04-12 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?