Here's a restatement of my approach, with three changes: 1. I have removed the code which permits cyclic graphs (extracting only acyclic paths from cyclic graphs).
2. I have added G as a parameter which specifies the graph. 3. I have added some whitespace to prevent the mail archive's anti-spam measures from corrupting the code. G=: ".;._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 ) ST=: {::~&0@[ EN=: {::~&1@[ ROOTPATHS=: ,<,0 extendpath=: ] <@,"1 0 EN #~ ST = {:@] extendpaths=: ] ~.@(,;) extendpath L:0 leafpaths=: #~ ] -. @ e. }:&.> paths_to_leaves=: [: leafpaths extendpaths^:_ Example use: (#, [: ~. #@>) G paths_to_leaves ROOTPATHS 39 9 And here's the raw code: paths_to_leaves f. [: (#~ (] -.@e. }:&.>)) (] ~.@(, ;) (] <@,"1 0 {::~&1@[ #~ {::~&0@[ = {:@])L:0)^:_ FYI, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm