Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: find all paths of length n in a graph

by Roy Johnson (Monsignor)
on Sep 19, 2007 at 15:26 UTC ( [id://639910]=note: print w/replies, xml ) Need Help??


in reply to Re^4: find all paths of length n in a graph
in thread find all paths of length n in a graph

I wrote this in very much a LISP style, which, if you're not familiar with it, can be pretty hard to follow. The else section constructs the non-trivial solution to the problem
  1. Look at all the nodes adjacent to where we're starting. Weed out any we've already visited.
  2. Call find_path for each of those nodes and gather up the results
  3. Return the list made by prepending this node onto each of those paths

Caution: Contents may have been coded under pressure.
  • Comment on Re^5: find all paths of length n in a graph

Replies are listed 'Best First'.
Re^6: find all paths of length n in a graph
by karden (Novice) on Sep 21, 2007 at 12:12 UTC
    Yeah, much clearer now. Especially after figuring out what "map" does :) Thank you indeed!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-19 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found