We don't bite newbies here... much PerlMonks

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

by choroba (Archbishop)
 on Oct 28, 2010 at 21:06 UTC ( #868151=note: print w/replies, xml ) Need Help??

I tried to benchmark your subs (together with my ones - Update: that turned out to be slower). The short circuiting approach is slower than the previous one.
• Comment on Re^2: Finding All Paths From a Graph From a Given Source and End Node

Replies are listed 'Best First'.
Re^3: Finding All Paths From a Graph From a Given Source and End Node
by Limbic~Region (Chancellor) on Oct 28, 2010 at 21:30 UTC
choroba,
The short circuiting approach is slower than the previous one

I suspect this will heavily depend on the test data which neversaint hasn't supplied. In a nutshell, I am recording path information on the basis that it will pay off down the road. If there is no short circuit possibilities then the overhead of tracking will not be paid for and it becomes slower.

This is why I said I was unhappy with it. I am going to let this sit in my feeble brain for a while and if I can't come up with a better approach I will post a new thread for other monks to weigh in on.

Update: The following is the basically the same algorithm with some optimizations. I would be interested in your test data and/or your benchmark.

Cheers - L~R

Here is my code as it is (your subs removed):
Using your graph and R=>P as the path, the short circuit is the best:
```           Rate   breadth    limbic     depth limbic_sc
breadth   158/s        --      -34%      -42%      -60%
limbic    238/s       51%        --      -13%      -39%
depth     274/s       73%       15%        --      -30%
limbic_sc 392/s      148%       65%       43%        --
choroba,
As I indicated before, certain graphs, order of traversal and endpoints will determine how well the short circuiting approach fairs. I have asked for advice concerning this at Short Circuiting DFS Graph Traversal. My fastest normal solution is below.

Cheers - L~R

Create A New User
Node Status?
node history
Node Type: note [id://868151]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2020-04-06 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
The most amusing oxymoron is:

Results (36 votes). Check out past polls.

Notices?