I'm impressed by your solution. Ok, because I'm curious I'll show a 'much' longer one with a power conjunction selector:
T <@((] <@,"1 0 ({::~{:))^:(#@[>{:@]))S:_ 0^:_ <0 Furthermore, counting all paths (paths as meant by R.E. Boss) can be: # result above verb. But a bit faster are the following sentences (working bottom up): indices fold: 0{:: ;(([: < [: +/ ] {::~ ::1:"1 0 {::)`[`]})&.>/ (;/@:i.@#,<)T 39 iterate with 'iterator': 0{:: ;{: (<:@[;<@(([: < [: +/]{::~ ::1:"1 0 {::)`[`]}))&>/^:(#`(<:@#;<))T 39 I'm not a graph expert, so may be there is a clever algorithm (or combinatorial expression) to obtain the same and as a consequence a nice J verb. On 25-04-12 03:38, Thomas Costigliola wrote: > G=. do;._2]0 :0 > 0 1 2 2 3 4 4 5 5 6 7 7 8 9 10 10 11 11 11 12 12 12 > 1 2 3 4 5 6 5 7 8 7 9 10 10 11 12 11 13 14 15 16 15 14 > ) > ]T=.</./G > T (<@((]<@,"1 0 {:@]{::[) ::])S:_ 0^:_)<0 > > > Challenge: find a verb using the same strategy without using :: and is > shorter (or not much longer). > > > On Tue, Apr 24, 2012 at 5:01 PM, R.E. Boss<r.e.b...@planet.nl> wrote: >> No. >> _. >> >> >> R.E. Boss >> >> >>> -----Oorspronkelijk bericht----- >>> Van: programming-boun...@jsoftware.com >>> [mailto:programming-boun...@jsoftware.com] Namens Henry Rich >>> Verzonden: dinsdag 24 april 2012 22:21 >>> Aan: Programming forum >>> Onderwerp: Re: [Jprogramming] all paths in a graph >>> >>> Can the graph contain a cycle? If so, what should be done? >>> >>> Henry Rich >>> >>> On 4/24/2012 11:47 AM, R.E. Boss wrote: >>>> I would like to know other solutions. >>>> And perhaps learn why it took me so long. >>>> >>>> >>>> R.E. Boss >>>> >>>> >>>>> -----Oorspronkelijk bericht----- >>>>> Van: programming-boun...@jsoftware.com >>>>> [mailto:programming-boun...@jsoftware.com] Namens Markus Schmidt-Gröttrup >>>>> Verzonden: dinsdag 24 april 2012 12:59 >>>>> Aan: Programming forum >>>>> Onderwerp: Re: [Jprogramming] all paths in a graph >>>>> >>>>> I have not investigated in finding an expression for all paths. >>>>> What for? Efficient graph algorithms as Dijkstra shortest path >>>>> algorithms avoid the flood of these possibilities. >>>>> >>>>> Could you give an idea, what are you aiming at? (Beside staying young) >>>>> >>>>> Greetings, >>>>> >>>>> Markus >>>>> >>>>> Am 24.04.2012 12:39, schrieb R.E. Boss: >>>>>> Given the directed graph G >>>>>> (see<http://www.jsoftware.com/jwiki/RE%20Boss> >>>>>> http://www.jsoftware.com/jwiki/RE%20Boss) >>> by >>>>> its edges >>>>>> >>>>>> >>>>>> |: G >>>>>> >>>>>> 0 1 2 2 3 4 4 5 5 6 7 7 8 9 10 10 11 11 11 12 12 12 >>>>>> >>>>>> 1 2 3 4 5 6 5 7 8 7 9 10 10 11 12 11 13 14 15 16 15 14 >>>>>> >>>>>> >>>>>> >>>>>> determine all (different) paths from root 0 to the leaves. >>>>>> >>>>>> >>>>>> >>>>>> This took me quite some time(days!). Am I getting old? >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> R.E. Boss >>>>>> >>>>>> >>>>>> >>>>>> ---------------------------------------------------------------------- >>>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>>> >>>>>> >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- Met vriendelijke groet, @@i = Arie Groeneveld ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm