On 2/24/13, km <[email protected]> wrote:
>     pairs =: [: ,/ [: (2 ,/\ ])"1 (, |:)  NB. Constructs left-right and
> up-down arcs
>     pairs i. 3 3  NB. left-right and up-down arcs

This is a nice trick to create the list of edges.  However, it doesn't
work for a non-square matrix.  For example, (pairs i. 3 4) will
contain the edge (9 0) which shouldn't really be there.

>     CM=: #. e.~ [: i. [ , [  NB. Borrowed from 20. Directed Graphs in
> Dictionary

I find this method of converting the list to the adjacency matrix
strange.  I would instead use the amend verb, like this:

   CM =: (1:`(<"1@[)`]} 0$~,~)~

Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to