[Jprogramming] Graph operations Re: How to represent a graph in J
Alexander Mikhailov
avmich at yahoo.com
Thu Mar 22 05:41:01 HKT 2012
-----
And instead of saying "there are three links from this node to that
node" I would instead say "there is one link from this node to that
node, and it has these three supported options". I think that I would
perform the three operations in parallel on the set of existing states
and then strip out the results which achieved an invalid state.
-----
-----
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.
-----
Thank you, Devon and Raul.
In addition to having multiple links between the same nodes, and having data associated with a link, I also want to find "preceeding" and "following" nodes from a given node in a constant time. So, I don't think array of links would work there.
(Fortunately, my graph is always connected - so, link array does mention all existing nodes, i.e., there are no nodes having no incoming or outgoing links.)
Now, a typical procedure which I do on this graph is "from this node N, find all (directed) sequences of links of length L". "Directed" means that in graph 2->3->4 sequence (2-3-4) is directed, since "beginning" of the arrow always starts where is the "end" of previous arrow in the sequence. Sequence (2-3-2) isn't directed in this sense. Since it's DAG, a node can't happen twice in the same sequence.
Alexander
More information about the Programming
mailing list