Best I can come up with is
{."1 ((] , -. {~ {.@I.@(-. +./"1@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 {.@I. to {:@I. if you want things in the other order.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
