[Jprogramming] determine the cycle

Raul Miller rauldmiller at gmail.com
Thu Aug 25 13:36:21 UTC 2016


Oops, I represented the vertices incorrectly ({."1 would only be
valid if the edges were directed).

Here's a fix:

   ~., ((] , -. {~ {. at I.@(-. +./"1 at e. {:@]))^:(<:@#@[) ,:@{.) edges
1 2 3 17 18 19 20 21 22 14 15 16 23 26 25 24 13 12 11 10 9 8 7 6 5 4

This is the same core implementation, but this should show the actual
vertices being traversed in the order they are encountered.

Thanks,

-- 
Raul


On Thu, Aug 25, 2016 at 8:36 AM, 'Jon Hough' via Programming
<programming at jsoftware.com> wrote:
> Raul,
>
> your solution seems to miss out some vertices and duplicates others.
>
>
> --------------------------------------------
> On Thu, 8/25/16, Raul Miller <rauldmiller at gmail.com> wrote:
>
>  Subject: Re: [Jprogramming] determine the cycle
>  To: "Programming forum" <programming at jsoftware.com>
>  Date: Thursday, August 25, 2016, 9:07 PM
>
>  Best I can come up with
>  is
>
>     {."1
>  ((] , -. {~ {. at I.@(-. +./"1 at e. {:@]))^:(<:@#@[) ,:@{.)
>  edges
>  1 3 17 18 18 20 20 21 22 14 15 16 23
>  26 25 13 12 11 11 10 9 7 6 5 4 2
>
>  Change {. at I. to {:@I. if you want things
>  in the other order.
>
>  --
>  Raul
>  ----------------------------------------------------------------------
>  For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list