Here's a simpleminded approach:
First, append the path to each of the distances in a
b=:(,&.>(<@#:i.)@$) a
Second, define a minimum function which works on this form
min=: (>&{. { ,:)&.>
Third, define an addition function which works on this form
plus=: (+&{. , ~.@,&}.)&.>
Now you can find the costs with their paths
min/ .plus~^:_ b
Note, also:
(<./ .+~^:_ a) -: {.&> min/ .plus~^:_ b
1
(<0 4){::min/ .plus~^:_ b
7 0 1 2 4
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm