The multiple links idea is a bit unusual in the context of what I've read about for graphs but all three methods I've mentioned could be adapted. However, given the additional constraint of per-link information, perhaps the adjacency matrix is not the way to go but you could use this and just have a link information list of boxed items with multiple items for multiple links.
So, assuming a graph like this (where the "V<>" characters are meant to be arrowheads): 0->1->2 |\ | V \ V 3 \__>4 | / V / 5 <__| where the link from 4 to 5 is really 3 links, and the 0 to 1 is 2 links, a vertex array might look like this: VA=. ,&.>(1 1 3 4);2;4;5;(5 5 5);<i. 0 LIva=: ,&.>('rel1';'rel2';'rel0';'rel1');(<'rel0');(<'rel3');(<'rel1');('rel0';'rel2';'rel3');<'' Here the "from" link is implied by the index into VA; LIva is the link information grouped by "from" node; the ",&.>" ensures we have all vectors. The LIva array could also be used with the existing boolean adjacency matrix: the number of links for node "n" would be implied by #>n{LIva . A node;edge representation would be like this: NE=: (0 1 2 3 4 5);<0 1, 0 1,0 3, 0 4,1 2, 2 4, 3 5, 4 5, 4 5,: 4 5 LIne=: 'rel1';'rel2';'rel0';'rel1';'rel0';'rel3';'rel1';'rel0';'rel2';'rel3' So, this shows how the links and relationships line up: }.NE,<>LIne +---+----+ |0 1|rel1| |0 1|rel2| |0 4|rel1| |1 2|rel0| |2 4|rel3| |3 5|rel1| |4 5|rel0| |4 5|rel2| |4 5|rel3| +---+----+ Notice that the VA representation explicitly includes nodes with no children whereas the NE one only implies them. Also, LIne -: ;LIva . On Wed, Mar 21, 2012 at 3:37 PM, Alexander Mikhailov <avm...@yahoo.com> wrote: > ----- > > Date: Wed, 21 Mar 2012 09:25:19 -0400 > From: Raul Miller <rauldmil...@gmail.com> > > The "natural" J data structure here would be two items: > > 1. A list representing data at each node. > 2. A connection matrix. > > [And I saw some other messages in this thread advocating this kind of > approach -- there's good reasons for that.] > > ----- > > How to store link-associated data then? And how to specify that there are 3 > links from node 4 to node 5? ... -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm