Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by BrowserUk (Pope)
on Nov 02, 2010 at 15:12 UTC ( #869013=note: print w/replies, xml ) Need Help??


in reply to Re^8: 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

Why?

Because to be useful, you generally have to do something more than just print the path out as a string.

To make it useful, you'd have to either:

  • accumulate all the paths as (say) an array of arrays:

    5 million paths with an average of roughly 20 items per.

  • or turn it into an iterator, so the code using the routines results can operate on the one at a time.

    Which is what I did with mine.

  • or; write all 5 million paths to disk as strings and then read them all back in again.

    In addition to the ovrhead of the IO, you also have to join them and then split them again.

I'd try your routine here,but I can't work out where I supply the start and end?


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.
  • Comment on Re^9: Finding All Paths From a Graph From a Given Source and End Node

Replies are listed 'Best First'.
Re^10: Finding All Paths From a Graph From a Given Source and End Node
by LanX (Cardinal) on Nov 02, 2010 at 15:23 UTC
    I'd try your routine here,but I can't work out where I supply the start and end?

    Globals! See the post before. (there is no point in passing them as long as you don't use any divide and conquer approach)

    or just:

    Of course @path could be global too and the recursion could be liniarized...

    Not talking about nifty short circuit algorithms...

    Cheers Rolf

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-01-24 15:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?