From: Claus Spitzer Date: 2004-05-07T01:43:15+09:00 Subject: Re: model for my problem (network simulator) 8< snip > > > Just one little thing (chicken-egg problem): the links should know > about > > > the 2 ending nodes, and nodes must know about in/outgoing links. So > how > > > to easily administrate it? > > > > That's easy in ruby, as ruby is garbage-collected, so it can clean up > > circular references by itself. Thus, you can add a list of both the in > and > > outgoing links to each nodes. > > IMHO the question was rather how to manage those references so that they > are always in sync. That would be the typical problem with bi directional > references in OO languages. Typically you manually have to write code for > that (unless you find a library that does it gracefully) but if done > properly you need to do it only once and can then reuse that code. > > robert > > Probably (and that is _only_ probably, as in "this is how I have seen it implemented in other instances by very smart professors") you'll want do do something along the lines of: * both the nodes and links have a list of what is attached to them. * both are observers and observables * a change in the node notifies the link, and vice-versa Otherwise, if for example only the links initiates the change, then you can make them be the observables and the nodes just the observers. Cheers! -CWS